dont try oids for new postgres versions

This commit is contained in:
Ralf Becker 2008-05-30 07:08:19 +00:00
parent b2378bb7a8
commit e2b84e8c32
2 changed files with 279 additions and 260 deletions

View File

@ -152,11 +152,17 @@ WHERE relkind in ('r','v') AND (c.relname='%s' or c.relname = lower('%s'))
Using a OID as a unique identifier is not generally wise.
Unless you are very careful, you might end up with a tuple having
a different OID if a database must be reloaded. */
function _insertid($table,$column)
function _insertid($table,$column,$try_oid=true)
{
if ($try_oid)
{
if (!is_resource($this->_resultid) || get_resource_type($this->_resultid) !== 'pgsql result') return false;
$oid = pg_getlastoid($this->_resultid);
}
else
{
$oid = false;
}
if ($oid === false && $table && $column) // table might not use oid's, default for 8.1+
{
// try the standard sequence name first, due to table renames etc. this might not be the correct one

View File

@ -121,6 +121,19 @@ function MetaForeignKeys($table, $owner=false, $upper=false)
} else return true;
}
// use pg_escape_string if available
function qstr($s,$magic_quotes=false)
{
if (!$magic_quotes && function_exists('pg_escape_string')) {
return "'".pg_escape_string($s)."'";
}
return parent::qstr($s,$magic_quotes);
}
function _insertid($table,$column)
{
return parent::_insertid($table,$column,false); // dont try oid
}
}
/*--------------------------------------------------------------------------------------