mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
Cache names for improved speed in long iterations requesting
the same name thousands of times. Prepare Oracle Sequnces for the insert_record function.
This commit is contained in:
parent
c7a872cbcf
commit
b8851b80eb
@ -390,10 +390,16 @@ class XMLDBgenerator {
|
||||
$name = '';
|
||||
|
||||
/// Implement one basic cache to avoid object name duplication
|
||||
/// and to speed up repeated queries for the same objects
|
||||
if (!isset($used_names)) {
|
||||
static $used_names = array();
|
||||
}
|
||||
|
||||
/// If this exact object has been requested, return it
|
||||
if (array_key_exists($tablename.'-'.$fields.'-'.$suffix, $used_names)) {
|
||||
return $used_names[$tablename.'-'.$fields.'-'.$suffix];
|
||||
}
|
||||
|
||||
/// Use standard naming. See http://docs.moodle.org/en/XMLDB_key_and_index_naming
|
||||
$tablearr = explode ('_', $tablename);
|
||||
foreach ($tablearr as $table) {
|
||||
@ -434,7 +440,7 @@ class XMLDBgenerator {
|
||||
}
|
||||
|
||||
/// Add the name to the cache
|
||||
$used_names[] = $namewithsuffix;
|
||||
$used_names[$tablename.'-'.$fields.'-'.$suffix] = $namewithsuffix;
|
||||
|
||||
/// Quote it if necessary (reserved words)
|
||||
$namewithsuffix = $this->getEncQuoted($namewithsuffix);
|
||||
|
@ -138,7 +138,9 @@ class XMLDBoci8po extends XMLDBgenerator {
|
||||
$trigger.= "\nON " . $this->getEncQuoted($this->prefix . $xmldb_table->getName());
|
||||
$trigger.= "\n FOR EACH ROW";
|
||||
$trigger.= "\nBEGIN";
|
||||
$trigger.= "\n SELECT " . $sequence_name . '.nextval INTO :new.' . $this->getEncQuoted($xmldb_field->getName()) . " FROM dual;";
|
||||
$trigger.= "\n IF :old." . $this->getEncQuoted($xmldb_field->getName()) . ' IS NOT NULL THEN';
|
||||
$trigger.= "\n SELECT " . $sequence_name . '.nextval INTO :new.' . $this->getEncQuoted($xmldb_field->getName()) . " FROM dual;";
|
||||
$trigger.= "\n END IF;";
|
||||
$trigger.= "\nEND;";
|
||||
return array($sequence, $trigger);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user