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)

git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10248 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2009-10-30 19:19:48 +00:00
parent c2832affae
commit 5553cfc2ed
2 changed files with 52 additions and 19 deletions

View file

@ -1873,7 +1873,7 @@ class phpbb_db_tools
}
else
{
$statements[] = 'ALTER TABLE ' . $table_name . ' ALTER COLUMN "' . strtoupper($column_name) . '" TYPE ' . ' ' . $column_data['column_type_sql'];
$statements[] = 'ALTER TABLE ' . $table_name . ' ALTER COLUMN "' . strtoupper($column_name) . '" TYPE ' . ' ' . $column_data['column_type_sql_type'];
}
break;

View file

@ -346,12 +346,16 @@ for ($i = 0; $i < sizeof($versions); $i++)
$no_updates = false;
$statements = $db_tools->perform_schema_changes($schema_changes);
// 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);
}
}
}
_write_result($no_updates, $errored, $error_ary);
@ -716,6 +720,9 @@ function database_update_info()
'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,9 +731,6 @@ function database_update_info()
'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(),
@ -1053,10 +1057,21 @@ function change_database_data(&$no_updates, $version)
// 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,6 +1214,18 @@ function change_database_data(&$no_updates, $version)
'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,8 +1233,6 @@ function change_database_data(&$no_updates, $version)
),
);
global $db_tools;
$statements = $db_tools->perform_schema_changes($changes);
foreach ($statements as $sql)
@ -2521,13 +2546,12 @@ class updater_db_tools
FROM user_indexes
WHERE table_name = '" . strtoupper($table_name) . "'
AND generated = 'N'
AND uniqueness = 'UNIQUE'
AND index_name LIKE 'U_%'";
AND uniqueness = 'UNIQUE'";
$col = 'index_name';
break;
case 'sqlite':
$sql = "PRAGMA index_list('" . $table_name . "') WHERE unique = 1;";
$sql = "PRAGMA index_list('" . $table_name . "');";
$col = 'name';
break;
}
@ -2554,7 +2578,15 @@ class updater_db_tools
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,7 +3260,8 @@ class updater_db_tools
}
else
{
$statements[] = 'ALTER TABLE ' . $table_name . ' ALTER COLUMN "' . strtoupper($column_name) . '" TYPE ' . ' ' . $column_data['column_type_sql'];
// 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;