aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Wiedler <igor@wiedler.ch>2010-09-02 19:38:34 +0200
committerIgor Wiedler <igor@wiedler.ch>2010-09-03 22:26:06 +0200
commitbb191a1d696994c1d27bbd0457457cf538dff7ee (patch)
treeb4ba3d2eede278bfde284b5887912b131786e46e
parentebb4a50d9ba539ea98d6af6f29adc1f25eadc4b0 (diff)
downloadforums-bb191a1d696994c1d27bbd0457457cf538dff7ee.tar
forums-bb191a1d696994c1d27bbd0457457cf538dff7ee.tar.gz
forums-bb191a1d696994c1d27bbd0457457cf538dff7ee.tar.bz2
forums-bb191a1d696994c1d27bbd0457457cf538dff7ee.tar.xz
forums-bb191a1d696994c1d27bbd0457457cf538dff7ee.zip
[ticket/8944] Add index length to CREATE INDEX for MySQL4 in database_update
Fixes following SQL error when updating the database to 3.0.6. BLOB column 'post_username' used in key specification without a key length PHPBB3-8944
-rw-r--r--phpBB/install/database_update.php20
1 files changed, 18 insertions, 2 deletions
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php
index fec09f89db..019469b061 100644
--- a/phpBB/install/database_update.php
+++ b/phpBB/install/database_update.php
@@ -880,7 +880,7 @@ function database_update_info()
'pm_id' => array('pm_id'),
),
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
* add_primary_keys: adding primary keys
* 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:
* {TABLE NAME} => array(
@@ -3520,6 +3520,12 @@ class updater_db_tools
{
$statements = array();
+ // remove index length unless MySQL4
+ if ('mysql_40' != $this->sql_layer)
+ {
+ $column = preg_replace('#:.*$#', '', $column);
+ }
+
switch ($this->sql_layer)
{
case 'firebird':
@@ -3530,6 +3536,16 @@ class updater_db_tools
break;
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':
$statements[] = 'CREATE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')';
break;