mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
Merge branch 'ticket/evil3/8944' into develop-olympus
* ticket/evil3/8944: [ticket/8944] Patch db_tools to support index length for MySQL4 [ticket/8944] Add index length to CREATE INDEX for MySQL4 in database_update
This commit is contained in:
commit
1b3b79b694
2 changed files with 35 additions and 3 deletions
|
@ -611,7 +611,7 @@ class phpbb_db_tools
|
||||||
* drop_columns: Removing/Dropping columns
|
* drop_columns: Removing/Dropping columns
|
||||||
* add_primary_keys: adding primary keys
|
* add_primary_keys: adding primary keys
|
||||||
* add_unique_index: adding an unique index
|
* add_unique_index: adding an unique index
|
||||||
* add_index: adding an index
|
* add_index: adding an index (can be column:index_size if you need to provide size)
|
||||||
*
|
*
|
||||||
* The values are in this format:
|
* The values are in this format:
|
||||||
* {TABLE NAME} => array(
|
* {TABLE NAME} => array(
|
||||||
|
@ -1804,6 +1804,12 @@ class phpbb_db_tools
|
||||||
{
|
{
|
||||||
$statements = array();
|
$statements = array();
|
||||||
|
|
||||||
|
// remove index length unless MySQL4
|
||||||
|
if ('mysql_40' != $this->sql_layer)
|
||||||
|
{
|
||||||
|
$column = preg_replace('#:.*$#', '', $column);
|
||||||
|
}
|
||||||
|
|
||||||
switch ($this->sql_layer)
|
switch ($this->sql_layer)
|
||||||
{
|
{
|
||||||
case 'firebird':
|
case 'firebird':
|
||||||
|
@ -1814,6 +1820,16 @@ class phpbb_db_tools
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'mysql_40':
|
case 'mysql_40':
|
||||||
|
// add index size to definition as required by MySQL4
|
||||||
|
foreach ($column as $i => $col)
|
||||||
|
{
|
||||||
|
if (false !== strpos($col, ':'))
|
||||||
|
{
|
||||||
|
list($col, $index_size) = explode(':', $col);
|
||||||
|
$column[$i] = "$col($index_size)";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// no break
|
||||||
case 'mysql_41':
|
case 'mysql_41':
|
||||||
$statements[] = 'CREATE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')';
|
$statements[] = 'CREATE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')';
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -880,7 +880,7 @@ function database_update_info()
|
||||||
'pm_id' => array('pm_id'),
|
'pm_id' => array('pm_id'),
|
||||||
),
|
),
|
||||||
POSTS_TABLE => array(
|
POSTS_TABLE => array(
|
||||||
'post_username' => array('post_username'),
|
'post_username' => array('post_username:255'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -2141,7 +2141,7 @@ class updater_db_tools
|
||||||
* drop_columns: Removing/Dropping columns
|
* drop_columns: Removing/Dropping columns
|
||||||
* add_primary_keys: adding primary keys
|
* add_primary_keys: adding primary keys
|
||||||
* add_unique_index: adding an unique index
|
* add_unique_index: adding an unique index
|
||||||
* add_index: adding an index
|
* add_index: adding an index (can be column:index_size if you need to provide size)
|
||||||
*
|
*
|
||||||
* The values are in this format:
|
* The values are in this format:
|
||||||
* {TABLE NAME} => array(
|
* {TABLE NAME} => array(
|
||||||
|
@ -3520,6 +3520,12 @@ class updater_db_tools
|
||||||
{
|
{
|
||||||
$statements = array();
|
$statements = array();
|
||||||
|
|
||||||
|
// remove index length unless MySQL4
|
||||||
|
if ('mysql_40' != $this->sql_layer)
|
||||||
|
{
|
||||||
|
$column = preg_replace('#:.*$#', '', $column);
|
||||||
|
}
|
||||||
|
|
||||||
switch ($this->sql_layer)
|
switch ($this->sql_layer)
|
||||||
{
|
{
|
||||||
case 'firebird':
|
case 'firebird':
|
||||||
|
@ -3530,6 +3536,16 @@ class updater_db_tools
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'mysql_40':
|
case 'mysql_40':
|
||||||
|
// add index size to definition as required by MySQL4
|
||||||
|
foreach ($column as $i => $col)
|
||||||
|
{
|
||||||
|
if (false !== strpos($col, ':'))
|
||||||
|
{
|
||||||
|
list($col, $index_size) = explode(':', $col);
|
||||||
|
$column[$i] = "$col($index_size)";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// no break
|
||||||
case 'mysql_41':
|
case 'mysql_41':
|
||||||
$statements[] = 'CREATE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')';
|
$statements[] = 'CREATE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')';
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Reference in a new issue