allow to limit size of index by appending it in brackets after the column name, eg. "column(32)", which is already supported by ADOdb, by was broken by our fix to always quote names, to allow column names which are reserved words, eg. "timestamp" in phpfreechat

This commit is contained in:
Ralf Becker 2010-09-15 13:27:26 +00:00
parent 1e79225a29
commit 1e9695dbc9
2 changed files with 15 additions and 3 deletions

View File

@ -238,10 +238,20 @@ class ADODB_DataDict {
return $quote . $matches[1] . $quote;
}
// if name contains special characters, quote it
/*$regex = ($allowBrackets) ? $this->nameRegexBrackets : $this->nameRegex;
// if brackets are allowed, quote only the rest,
// to allow to limit indexes on colums, eg "column(32)"
if ($allowBrackets && preg_match('/^(.*) *(\(\d+\))$/',$name,$matches)) {
return $quote . $matches[1] . $quote . ' '. $matches[2];
}
return $quote . $name . $quote;
// not used stock ADOdb code, which only quotes names with special chars,
// which does not help with column names using reserved words, eg. "timestamp" in phpfreechat
if ( !preg_match('/^[' . $regex . ']+$/', $name) )*/ {
// if name contains special characters, quote it
$regex = ($allowBrackets) ? $this->nameRegexBrackets : $this->nameRegex;
if ( !preg_match('/^[' . $regex . ']+$/', $name) ) {
return $quote . $name . $quote;
}

View File

@ -918,6 +918,8 @@ class schema_proc
$aColumnNames = str_replace($remove,'',$aColumnNames);
$name = $sTableName.'_'.(is_array($aColumnNames) ? implode('_',$aColumnNames) : $aColumnNames);
// remove length limits from column names
$name = preg_replace('/ *\(\d+\)/','',$name);
// 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 ||