1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-02-24 12:03:21 +01:00

remove log_time index (was not used at all)

At the same time the database updater now supports checking for existing indexes. The db tools will not have this in 3.0.6 (the db tools have a function to retrieve all indexes) and i need to test the updater on all DBMS today...

git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10183 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2009-09-24 08:53:17 +00:00
parent c1b898890b
commit 54c22ae52a
2 changed files with 126 additions and 6 deletions

View File

@ -212,7 +212,6 @@
<li>[Fix] Correctly display underlined links placed in last line in viewtopic. (Bug #14811 - Patch by primehalo)</li>
<li>[Change] submit_post() now accepts force_approved_state key passed to $data to indicate new posts being approved (true) or unapproved (false).</li>
<li>[Change] Change the data format of the default file ACM to be more secure from tampering and have better performance.</li>
<li>[Change] Add index on log_time to the log table to prevent slowdown on boards with many log entries. (Bug #44665 - Patch by bantu)</li>
<li>[Change] Template engine now permits to a limited extent variable includes.</li>
<li>[Change] Quote BBCode no longer requires the f_reply permission. (Bug #16079)</li>
<li>[Change] Banning/unbanning users now generates an entry in their user notes (Bug #21825 - Patch by nickvergessen)</li>

View File

@ -8,7 +8,7 @@
*
*/
$updates_to_version = '3.0.6-RC1';
$updates_to_version = '3.0.6-RC2';
// Enter any version to update from to test updates. The version within the db will not be updated.
$debug_from_version = false;
@ -868,9 +868,6 @@ function database_update_info()
),
),
'add_index' => array(
LOG_TABLE => array(
'log_time' => array('log_time'),
),
REPORTS_TABLE => array(
'post_id' => array('post_id'),
'pm_id' => array('pm_id'),
@ -880,6 +877,12 @@ function database_update_info()
),
),
),
// Changes from 3.0.6-RC1 to 3.0.6-RC2
'3.0.6-RC1' => array(
'drop_keys' => array(
LOG_TABLE => array('log_time'),
),
),
);
}
@ -1506,6 +1509,16 @@ function change_database_data(&$no_updates, $version)
$no_updates = false;
break;
// Changes from 3.0.6-RC1 to 3.0.6-RC2
case '3.0.6-RC1':
// We check if there is an index for log_time within the logs table
// If so, we remove it
break;
}
}
@ -1902,7 +1915,8 @@ class updater_db_tools
{
if ($column_exists)
{
$sqlite_data[$table]['change_columns'][] = $result;
continue;
// $sqlite_data[$table]['change_columns'][] = $result;
}
else
{
@ -1924,6 +1938,11 @@ class updater_db_tools
{
foreach ($indexes as $index_name)
{
if (!$this->sql_index_exists($table, $index_name))
{
continue;
}
$result = $this->sql_index_drop($table, $index_name);
if ($this->return_statements)
@ -1984,6 +2003,11 @@ class updater_db_tools
{
foreach ($index_array as $index_name => $column)
{
if ($this->sql_index_exists($table, $index_name))
{
continue;
}
$result = $this->sql_create_unique_index($table, $index_name, $column);
if ($this->return_statements)
@ -2001,6 +2025,11 @@ class updater_db_tools
{
foreach ($index_array as $index_name => $column)
{
if ($this->sql_index_exists($table, $index_name))
{
continue;
}
$result = $this->sql_create_index($table, $index_name, $column);
if ($this->return_statements)
@ -2308,6 +2337,98 @@ class updater_db_tools
}
}
/**
* Check if a specified index exists in table
*
* @param string $table_name Table to check the index at
* @param string $index_name The index name to check
*
* @return bool True if index exists, else false
*/
function sql_index_exists($table_name, $index_name)
{
if ($this->sql_layer == 'mssql')
{
$sql = "EXEC sp_statistics '$table_name'";
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
if ($row['TYPE'] == 3)
{
if (strtolower($row['INDEX_NAME']) == strtolower($index_name))
{
$this->db->sql_freeresult($result);
return true;
}
}
}
$this->db->sql_freeresult($result);
return false;
}
switch ($this->sql_layer)
{
case 'firebird':
$sql = "SELECT LOWER(RDB\$INDEX_NAME) as index_name
FROM RDB\$INDICES
WHERE RDB\$RELATION_NAME = " . strtoupper($table_name) . "
AND RDB\$UNIQUE_FLAG IS NULL
AND RDB\$FOREIGN_KEY IS NULL";
$col = 'index_name';
break;
case 'postgres':
$sql = "SELECT ic.relname as index_name
FROM pg_class bc, pg_class ic, pg_index i
WHERE (bc.oid = i.indrelid)
AND (ic.oid = i.indexrelid)
AND (bc.relname = '" . $table_name . "')
AND (i.indisunique != 't')
AND (i.indisprimary != 't')";
$col = 'index_name';
break;
case 'mysql_40':
case 'mysql_41':
$sql = 'SHOW KEYS
FROM ' . $table_name;
$col = 'Key_name';
break;
case 'oracle':
$sql = "SELECT index_name
FROM user_indexes
WHERE table_name = '" . $table_name . "'
AND generated = 'N'";
break;
case 'sqlite':
$sql = "PRAGMA index_info('" . $table_name . "');";
$col = 'name';
break;
}
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
if (($this->sql_layer == 'mysql_40' || $this->sql_layer == 'mysql_41') && !$row['Non_unique'])
{
continue;
}
if (strtolower($row[$col]) == strtolower($index_name))
{
$this->db->sql_freeresult($result);
return true;
}
}
$this->db->sql_freeresult($result);
return false;
}
/**
* Private method for performing sql statements (either execute them or return them)
* @access private