mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 17:02:03 +02:00
Added support for getSequenceFromDB() to PG.
Merged from MOODLE_17_STABLE
This commit is contained in:
parent
879caa5172
commit
d5eff6795e
@ -446,6 +446,29 @@ class XMLDBpostgres7 extends XMLDBgenerator {
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given one XMLDBTable returns one string with the sequence of the table
|
||||
* in the table (fetched from DB)
|
||||
* The sequence name for Postgres has one standard name convention:
|
||||
* tablename_fieldname_seq
|
||||
* so we just calculate it and confirm it's present in pg_class
|
||||
* If no sequence is found, returns false
|
||||
*/
|
||||
function getSequenceFromDB($xmldb_table) {
|
||||
|
||||
$tablename = $this->getTableName($xmldb_table);
|
||||
$sequencename = $tablename . '_id_seq';
|
||||
|
||||
if (!get_record_sql("SELECT *
|
||||
FROM pg_class
|
||||
WHERE relname = '{$sequencename}'
|
||||
AND relkind = 'S'")) {
|
||||
$sequencename = false;
|
||||
}
|
||||
|
||||
return $sequencename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of reserved words (lowercase) for this DB
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user