Index: class.ux_t3lib_sqlparser.php =================================================================== --- class.ux_t3lib_sqlparser.php (revision 26756) +++ class.ux_t3lib_sqlparser.php (working copy) @@ -535,7 +535,8 @@ $indexKeys = array_merge($indexKeys, $GLOBALS['TYPO3_DB']->handlerInstance[$GLOBALS['TYPO3_DB']->handler_getFromTableList($components['TABLE'])]->DataDictionary->CreateIndexSQL($n, $components['TABLE'], $field, array('UNIQUE'))); } } else { - $indexKeys = array_merge($indexKeys, $GLOBALS['TYPO3_DB']->handlerInstance[$GLOBALS['TYPO3_DB']->handler_getFromTableList($components['TABLE'])]->DataDictionary->CreateIndexSQL($components['TABLE'] . '_' . $kN, $components['TABLE'], $kCfg)); + $indexName = $GLOBALS['TYPO3_DB']->automap_indexName($components['TABLE'], $components['TABLE'] . '_' . $kN); + $indexKeys = array_merge($indexKeys, $GLOBALS['TYPO3_DB']->handlerInstance[$GLOBALS['TYPO3_DB']->handler_getFromTableList($components['TABLE'])]->DataDictionary->CreateIndexSQL($indexName, $components['TABLE'], $kCfg)); } } } Index: class.ux_t3lib_db.php =================================================================== --- class.ux_t3lib_db.php (revision 26756) +++ class.ux_t3lib_db.php (working copy) @@ -2637,6 +2637,30 @@ } } + /** + * Automatically re-mapping index name if needed. + * + * @param string $table Table name + * @param string $indexName initial index name + * @return string Either $indexName or an automatically remapped string to be compatible with the underlying DBMS + */ + public function automap_indexName($table, $indexName) { + $handlerCfg = $this->handlerCfg[$this->handler_getFromTableList($table)]; + switch ((string)$handlerCfg['type']) { + case 'native': + return $indexName; + case 'adodb': + switch ((string)$handlerCfg['config']['driver']) { + case 'oci8': + // Oracle only support up to 30-character identifier + if (strlen($indexName) > 30) { + return substr(md5($indexName), 0, 30); + } + break; + } + } + return $indexName; + } @@ -2653,6 +2677,7 @@ + /************************************** * * Debugging Index: tests/db_oracle_testcase.php =================================================================== --- tests/db_oracle_testcase.php (revision 26757) +++ tests/db_oracle_testcase.php (working copy) @@ -390,5 +390,45 @@ $expected .= ' AND "pages"."deleted" = 0 AND 1 = 1 ORDER BY "cpg_categories"."pos"'; $this->assertEquals($expected, $query); } + + /** + * @test + * @see http://bugs.typo3.org/view.php?id=3751 + */ + public function longIndexesAreAutomaticallyRemapped() { + $parseString = ' + CREATE TABLE tx_realurl_uniqalias ( + uid int(11) NOT NULL auto_increment, + tstamp int(11) DEFAULT \'0\' NOT NULL, + tablename varchar(60) DEFAULT \'\' NOT NULL, + field_alias varchar(255) DEFAULT \'\' NOT NULL, + field_id varchar(60) DEFAULT \'\' NOT NULL, + value_alias varchar(255) DEFAULT \'\' NOT NULL, + value_id int(11) DEFAULT \'0\' NOT NULL, + lang int(11) DEFAULT \'0\' NOT NULL, + expire int(11) DEFAULT \'0\' NOT NULL, + + PRIMARY KEY (uid), + KEY tablename (tablename), + KEY bk_realurl01 (field_alias,field_id,value_id,lang,expire), + KEY bk_realurl02 (tablename,field_alias,field_id,value_alias(220),expire) + ); + '; + + $components = $GLOBALS['TYPO3_DB']->SQLparser->_callRef('parseCREATETABLE', $parseString); + $sqlCommands = $GLOBALS['TYPO3_DB']->SQLparser->_call('compileCREATETABLE', $components); + $this->assertEquals( + 'CREATE INDEX "tx_realurl_uniqalias_tablename" ON "tx_realurl_uniqalias" ("tablename")', + $this->cleanSql($sqlCommands[1]) + ); + $this->assertEquals( + 'CREATE INDEX "' . substr(md5('tx_realurl_uniqalias_bk_realurl01'), 0, 30) . '" ON "tx_realurl_uniqalias" ("field_alias", "field_id", "value_id", "lang", "expire")', + $this->cleanSql($sqlCommands[2]) + ); + $this->assertEquals( + 'CREATE INDEX "' . substr(md5('tx_realurl_uniqalias_bk_realurl02'), 0, 30) . '" ON "tx_realurl_uniqalias" ("tablename", "field_alias", "field_id", "value_alias", "expire")', + $this->cleanSql($sqlCommands[3]) + ); + } } ?> \ No newline at end of file