Now MySQL looks for existing index names. MDL-9256
Merged from MOODLE_18_STABLE
This commit is contained in:
@@ -925,7 +925,7 @@ class XMLDBgenerator {
|
||||
}
|
||||
|
||||
/// If the calculated name is in the cache, or if we detect it by introspecting the DB let's modify if
|
||||
if (in_array($namewithsuffix, $used_names) || $this->isNameInUse($namewithsuffix, $suffix)) {
|
||||
if (in_array($namewithsuffix, $used_names) || $this->isNameInUse($namewithsuffix, $suffix, $tablename)) {
|
||||
$counter = 2;
|
||||
/// If have free space, we add 2
|
||||
if (strlen($namewithsuffix) < $this->names_max_length) {
|
||||
@@ -939,7 +939,7 @@ class XMLDBgenerator {
|
||||
$newnamewithsuffix = $newnamewithsuffix . '_' . $suffix;
|
||||
}
|
||||
/// Now iterate until not used name is found, incrementing the counter
|
||||
while (in_array($newnamewithsuffix, $used_names) || $this->isNameInUse($newnamewithsuffix, $suffix)) {
|
||||
while (in_array($newnamewithsuffix, $used_names) || $this->isNameInUse($newnamewithsuffix, $suffix, $tablename)) {
|
||||
$counter++;
|
||||
$newname = substr($name, 0, strlen($newname)-1) . $counter;
|
||||
$newnamewithsuffix = $newname;
|
||||
@@ -1080,10 +1080,11 @@ class XMLDBgenerator {
|
||||
/**
|
||||
* Given one object name and it's type (pk, uk, fk, ck, ix, uix, seq, trg)
|
||||
* return if such name is currently in use (true) or no (false)
|
||||
* (MySQL requires the whole XMLDBTable object to be specified, so we add it always)
|
||||
* (invoked from getNameForObject()
|
||||
* Only some DB have this implemented
|
||||
*/
|
||||
function isNameInUse($object_name, $type) {
|
||||
function isNameInUse($object_name, $type, $table_name) {
|
||||
return false; //For generators not implementing introspecion,
|
||||
//we always return with the name being free to be used
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user