re-added to postgres fixes not (yet) contributed to JohnLim:

- updates to work around postgres error while upgrading a phpGW 0.9.14 install
- postgres fix (error in converting varchar to int if >= 100)
This commit is contained in:
Ralf Becker 2005-09-26 10:28:28 +00:00
parent 4e5cb1786e
commit 93e3241b70

View File

@ -134,10 +134,11 @@ class ADODB2_postgres extends ADODB_DataDict {
if (($not_null = preg_match('/NOT NULL/i',$v))) { if (($not_null = preg_match('/NOT NULL/i',$v))) {
$v = preg_replace('/NOT NULL/i','',$v); $v = preg_replace('/NOT NULL/i','',$v);
} }
if (preg_match('/^([^ ]+) .*(DEFAULT [^ ]+)/',$v,$matches)) { if (preg_match('/^([^ ]+) .*DEFAULT ([^ ]+)/',$v,$matches)) {
list(,$colname,$default) = $matches; list(,$colname,$default) = $matches;
$sql[] = $alter . str_replace($default,'',$v); $sql[] = $alter . str_replace('DEFAULT '.$default,'',$v);
$sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' SET ' . $default; $sql[] = 'UPDATE '.$tabname.' SET '.$colname.'='.$default;
$sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' SET DEFAULT ' . $default;
} else { } else {
$sql[] = $alter . $v; $sql[] = $alter . $v;
} }
@ -214,7 +215,7 @@ class ADODB2_postgres extends ADODB_DataDict {
// we need to explicit convert varchar to a number to be able to do an AlterColumn of a char column to a nummeric one // we need to explicit convert varchar to a number to be able to do an AlterColumn of a char column to a nummeric one
if (preg_match('/'.$fld->name.' (I|I2|I4|I8|N|F)/i',$tableflds,$matches) && if (preg_match('/'.$fld->name.' (I|I2|I4|I8|N|F)/i',$tableflds,$matches) &&
in_array($fld->type,array('varchar','char','text','bytea'))) { in_array($fld->type,array('varchar','char','text','bytea'))) {
$copyflds[] = "to_number($fld->name,'S99D99')"; $copyflds[] = "to_number($fld->name,'S9999999999999D99')";
} else { } else {
$copyflds[] = $fld->name; $copyflds[] = $fld->name;
} }