forked from extern/egroupware
ORA - Fixed schema creation (indexes, triggers and secuences):
Indexes: The solution of put the index name of the first columnt dont't work because duplicates, create instead a hash of the large name (PHP 5 >= 5.1.2, PECL hash:1.1-1.5) with an fixed char at beginning (Oracle objects names can't start with a number) Secuences & triggers: create a a hash of the large name.
This commit is contained in:
parent
015180cd06
commit
3081b0a05a
@ -197,12 +197,14 @@ end;
|
|||||||
$trigname = $this->trigPrefix.$seqname;
|
$trigname = $this->trigPrefix.$seqname;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen($seqname) > 30) {
|
if (strlen($seqname) > 30)
|
||||||
$seqname = $this->seqPrefix.uniqid('');
|
{
|
||||||
} // end if
|
$seqname = "s".substr(hash('md5', $seqname),0,29);
|
||||||
if (strlen($trigname) > 30) {
|
}
|
||||||
$trigname = $this->trigPrefix.uniqid('');
|
if (strlen($trigname) > 30)
|
||||||
} // end if
|
{
|
||||||
|
$trigname = "t".substr(hash('md5', $trigname),0,29);
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($tableoptions['REPLACE'])) $sql[] = "DROP SEQUENCE $seqname";
|
if (isset($tableoptions['REPLACE'])) $sql[] = "DROP SEQUENCE $seqname";
|
||||||
$seqCache = '';
|
$seqCache = '';
|
||||||
|
@ -867,27 +867,27 @@
|
|||||||
function _index_name($sTableName,$aColumnNames)
|
function _index_name($sTableName,$aColumnNames)
|
||||||
{
|
{
|
||||||
// this code creates extrem short index-names, eg. for MaxDB
|
// this code creates extrem short index-names, eg. for MaxDB
|
||||||
if (isset($this->max_index_length[$this->sType]) && $this->max_index_length[$this->sType] <= 32)
|
// if (isset($this->max_index_length[$this->sType]) && $this->max_index_length[$this->sType] <= 32)
|
||||||
{
|
// {
|
||||||
static $existing_indexes=array();
|
// static $existing_indexes=array();
|
||||||
|
//
|
||||||
if (!isset($existing_indexes[$sTableName]) && method_exists($this->adodb,'MetaIndexes'))
|
// if (!isset($existing_indexes[$sTableName]) && method_exists($this->adodb,'MetaIndexes'))
|
||||||
{
|
// {
|
||||||
$existing_indexes[$sTableName] = $this->adodb->MetaIndexes($sTableName);
|
// $existing_indexes[$sTableName] = $this->adodb->MetaIndexes($sTableName);
|
||||||
}
|
// }
|
||||||
$i = 0;
|
// $i = 0;
|
||||||
$firstCol = is_array($aColumnNames) ? $aColumnNames[0] : $aColumnNames;
|
// $firstCol = is_array($aColumnNames) ? $aColumnNames[0] : $aColumnNames;
|
||||||
do
|
// do
|
||||||
{
|
// {
|
||||||
++$i;
|
// ++$i;
|
||||||
$name = $firstCol . ($i > 1 ? '_'.$i : '');
|
// $name = $firstCol . ($i > 1 ? '_'.$i : '');
|
||||||
}
|
// }
|
||||||
while (isset($existing_indexes[$sTableName][$name]) || isset($existing_indexes[strtoupper($sTableName)][strtoupper($name)]));
|
// while (isset($existing_indexes[$sTableName][$name]) || isset($existing_indexes[strtoupper($sTableName)][strtoupper($name)]));
|
||||||
|
//
|
||||||
$existing_indexes[$sTableName][$name] = True; // mark it as existing now
|
// $existing_indexes[$sTableName][$name] = True; // mark it as existing now
|
||||||
|
//
|
||||||
return $name;
|
// return $name;
|
||||||
}
|
// }
|
||||||
// This code creates longer index-names incl. the table-names and the used columns
|
// This code creates longer index-names incl. the table-names and the used columns
|
||||||
$table = str_replace(array('phpgw_','egw_'),'',$sTableName);
|
$table = str_replace(array('phpgw_','egw_'),'',$sTableName);
|
||||||
// if the table-name or a part of it is repeated in the column-name, remove it there
|
// if the table-name or a part of it is repeated in the column-name, remove it there
|
||||||
@ -903,6 +903,12 @@
|
|||||||
$aColumnNames = str_replace($remove,'',$aColumnNames);
|
$aColumnNames = str_replace($remove,'',$aColumnNames);
|
||||||
|
|
||||||
$name = $sTableName.'_'.(is_array($aColumnNames) ? implode('_',$aColumnNames) : $aColumnNames);
|
$name = $sTableName.'_'.(is_array($aColumnNames) ? implode('_',$aColumnNames) : $aColumnNames);
|
||||||
|
|
||||||
|
// this code creates a fixed short index-names (30 chars) from the long and unique name, eg. for MaxDB or Oracle
|
||||||
|
if (isset($this->max_index_length[$this->sType]) && $this->max_index_length[$this->sType] <= 32 && strlen($name) > 30)
|
||||||
|
{
|
||||||
|
$name = "i".substr(hash ('md5', $name),0,29);
|
||||||
|
}
|
||||||
|
|
||||||
return $name;
|
return $name;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user