diff --git a/phpgwapi/inc/adodb/adodb-datadict.inc.php b/phpgwapi/inc/adodb/adodb-datadict.inc.php index 898071c397..78f19acb80 100644 --- a/phpgwapi/inc/adodb/adodb-datadict.inc.php +++ b/phpgwapi/inc/adodb/adodb-datadict.inc.php @@ -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; } diff --git a/phpgwapi/inc/class.schema_proc.inc.php b/phpgwapi/inc/class.schema_proc.inc.php index d5ec9ae0fe..5c5320c969 100644 --- a/phpgwapi/inc/class.schema_proc.inc.php +++ b/phpgwapi/inc/class.schema_proc.inc.php @@ -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 ||