From: Meik S. <acy...@ph...> - 2009-10-30 19:20:33
|
Author: acydburn Date: Fri Oct 30 19:19:48 2009 New Revision: 10248 Log: Several fixes: Fix Bug #53335 Fix wrong unique index fetch for oracle and sqlite Fix alter column definition for firebird (although the query will fail in these circumstances [primary key] because firebird (again) does not support simple things... although... mssql/oracle having the same "problems", but there you are able to do more advanced queries) Modified: branches/phpBB-3_0_0/phpBB/includes/db/db_tools.php branches/phpBB-3_0_0/phpBB/install/database_update.php Modified: branches/phpBB-3_0_0/phpBB/includes/db/db_tools.php ============================================================================== *** branches/phpBB-3_0_0/phpBB/includes/db/db_tools.php (original) --- branches/phpBB-3_0_0/phpBB/includes/db/db_tools.php Fri Oct 30 19:19:48 2009 *************** *** 1873,1879 **** } else { ! $statements[] = 'ALTER TABLE ' . $table_name . ' ALTER COLUMN "' . strtoupper($column_name) . '" TYPE ' . ' ' . $column_data['column_type_sql']; } break; --- 1873,1879 ---- } else { ! $statements[] = 'ALTER TABLE ' . $table_name . ' ALTER COLUMN "' . strtoupper($column_name) . '" TYPE ' . ' ' . $column_data['column_type_sql_type']; } break; Modified: branches/phpBB-3_0_0/phpBB/install/database_update.php ============================================================================== *** branches/phpBB-3_0_0/phpBB/install/database_update.php (original) --- branches/phpBB-3_0_0/phpBB/install/database_update.php Fri Oct 30 19:19:48 2009 *************** *** 346,356 **** $no_updates = false; ! $statements = $db_tools->perform_schema_changes($schema_changes); ! ! foreach ($statements as $sql) { ! _sql($sql, $errored, $error_ary); } } --- 346,360 ---- $no_updates = false; ! // We run one index after the other... to be consistent with schema changes... ! foreach ($schema_changes as $key => $changes) { ! $statements = $db_tools->perform_schema_changes(array($key => $changes)); ! ! foreach ($statements as $sql) ! { ! _sql($sql, $errored, $error_ary); ! } } } *************** *** 716,721 **** --- 720,728 ---- 'session_forum_id' => array('UINT', 0), ), ), + 'drop_keys' => array( + GROUPS_TABLE => array('group_legend'), + ), 'add_index' => array( SESSIONS_TABLE => array( 'session_forum_id' => array('session_forum_id'), *************** *** 724,732 **** 'group_legend_name' => array('group_legend', 'group_name'), ), ), - 'drop_keys' => array( - GROUPS_TABLE => array('group_legend'), - ), ), // No changes from 3.0.1-RC1 to 3.0.1 '3.0.1-RC1' => array(), --- 731,736 ---- *************** *** 1053,1062 **** // Changes from 3.0.3-RC1 to 3.0.3 case '3.0.3-RC1': ! $sql = 'UPDATE ' . LOG_TABLE . " ! SET log_operation = 'LOG_DELETE_TOPIC' ! WHERE log_operation = 'LOG_TOPIC_DELETED'"; ! _sql($sql, $errored, $error_ary); $no_updates = false; break; --- 1057,1077 ---- // Changes from 3.0.3-RC1 to 3.0.3 case '3.0.3-RC1': ! if ($db->sql_layer == 'oracle') ! { ! // log_operation is CLOB - but we can change this later ! $sql = 'UPDATE ' . LOG_TABLE . " ! SET log_operation = 'LOG_DELETE_TOPIC' ! WHERE log_operation LIKE 'LOG_TOPIC_DELETED'"; ! _sql($sql, $errored, $error_ary); ! } ! else ! { ! $sql = 'UPDATE ' . LOG_TABLE . " ! SET log_operation = 'LOG_DELETE_TOPIC' ! WHERE log_operation = 'LOG_TOPIC_DELETED'"; ! _sql($sql, $errored, $error_ary); ! } $no_updates = false; break; *************** *** 1199,1204 **** --- 1214,1231 ---- 'drop_keys' => array( ACL_OPTIONS_TABLE => array('auth_option'), ), + ); + + global $db_tools; + + $statements = $db_tools->perform_schema_changes($changes); + + foreach ($statements as $sql) + { + _sql($sql, $errored, $error_ary); + } + + $changes = array( 'add_unique_index' => array( ACL_OPTIONS_TABLE => array( 'auth_option' => array('auth_option'), *************** *** 1206,1213 **** ), ); - global $db_tools; - $statements = $db_tools->perform_schema_changes($changes); foreach ($statements as $sql) --- 1233,1238 ---- *************** *** 2521,2533 **** FROM user_indexes WHERE table_name = '" . strtoupper($table_name) . "' AND generated = 'N' ! AND uniqueness = 'UNIQUE' ! AND index_name LIKE 'U_%'"; $col = 'index_name'; break; case 'sqlite': ! $sql = "PRAGMA index_list('" . $table_name . "') WHERE unique = 1;"; $col = 'name'; break; } --- 2546,2557 ---- FROM user_indexes WHERE table_name = '" . strtoupper($table_name) . "' AND generated = 'N' ! AND uniqueness = 'UNIQUE'"; $col = 'index_name'; break; case 'sqlite': ! $sql = "PRAGMA index_list('" . $table_name . "');"; $col = 'name'; break; } *************** *** 2554,2560 **** switch ($this->sql_layer) { case 'oracle': ! $row[$col] = substr($row[$col], strlen('U_' . $row['table_owner']) + 1); break; case 'firebird': --- 2578,2592 ---- switch ($this->sql_layer) { case 'oracle': ! // Two cases here... prefixed with U_[table_owner] and not prefixed with table_name ! if (strpos($row[$col], 'U_') === 0) ! { ! $row[$col] = substr($row[$col], strlen('U_' . $row['table_owner']) + 1); ! } ! else if (strpos($row[$col], strtoupper($table_name)) === 0) ! { ! $row[$col] = substr($row[$col], strlen($table_name) + 1); ! } break; case 'firebird': *************** *** 3228,3234 **** } else { ! $statements[] = 'ALTER TABLE ' . $table_name . ' ALTER COLUMN "' . strtoupper($column_name) . '" TYPE ' . ' ' . $column_data['column_type_sql']; } break; --- 3260,3267 ---- } else { ! // TODO: try to change pkey without removing trigger, generator or constraints. ATM this query may fail. ! $statements[] = 'ALTER TABLE ' . $table_name . ' ALTER COLUMN "' . strtoupper($column_name) . '" TYPE ' . ' ' . $column_data['column_type_sql_type']; } break; |