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:
José Luis Gordo Romero 2007-10-18 04:29:16 +00:00
parent 015180cd06
commit 3081b0a05a
2 changed files with 35 additions and 27 deletions

View File

@ -197,12 +197,14 @@ end;
$trigname = $this->trigPrefix.$seqname;
}
if (strlen($seqname) > 30) {
$seqname = $this->seqPrefix.uniqid('');
} // end if
if (strlen($trigname) > 30) {
$trigname = $this->trigPrefix.uniqid('');
} // end if
if (strlen($seqname) > 30)
{
$seqname = "s".substr(hash('md5', $seqname),0,29);
}
if (strlen($trigname) > 30)
{
$trigname = "t".substr(hash('md5', $trigname),0,29);
}
if (isset($tableoptions['REPLACE'])) $sql[] = "DROP SEQUENCE $seqname";
$seqCache = '';

View File

@ -867,27 +867,27 @@
function _index_name($sTableName,$aColumnNames)
{
// 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)
{
static $existing_indexes=array();
if (!isset($existing_indexes[$sTableName]) && method_exists($this->adodb,'MetaIndexes'))
{
$existing_indexes[$sTableName] = $this->adodb->MetaIndexes($sTableName);
}
$i = 0;
$firstCol = is_array($aColumnNames) ? $aColumnNames[0] : $aColumnNames;
do
{
++$i;
$name = $firstCol . ($i > 1 ? '_'.$i : '');
}
while (isset($existing_indexes[$sTableName][$name]) || isset($existing_indexes[strtoupper($sTableName)][strtoupper($name)]));
$existing_indexes[$sTableName][$name] = True; // mark it as existing now
return $name;
}
// if (isset($this->max_index_length[$this->sType]) && $this->max_index_length[$this->sType] <= 32)
// {
// static $existing_indexes=array();
//
// if (!isset($existing_indexes[$sTableName]) && method_exists($this->adodb,'MetaIndexes'))
// {
// $existing_indexes[$sTableName] = $this->adodb->MetaIndexes($sTableName);
// }
// $i = 0;
// $firstCol = is_array($aColumnNames) ? $aColumnNames[0] : $aColumnNames;
// do
// {
// ++$i;
// $name = $firstCol . ($i > 1 ? '_'.$i : '');
// }
// while (isset($existing_indexes[$sTableName][$name]) || isset($existing_indexes[strtoupper($sTableName)][strtoupper($name)]));
//
// $existing_indexes[$sTableName][$name] = True; // mark it as existing now
//
// return $name;
// }
// This code creates longer index-names incl. the table-names and the used columns
$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
@ -904,6 +904,12 @@
$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;
}