Changeset 1075

Show
Ignore:
Timestamp:
10/27/07 18:38:38 (11 months ago)
Author:
Neal
Message:

Added the unique index online_user_id_ident_idx to the online table for PostgreSQL and SQLite (MySQL has had this index already). The index ensures that a user can not have multiple rows with the same ident.
Changed instances of $db_prefix to $db->prefix in extras/db_update.php.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/punbb-1.3-dev/extras/db_update.php

    r1072 r1075  
    339339        case 'start': 
    340340                // Add the extensions table if it doesn't already exist 
    341                 if (!$db->table_exists($db_prefix.'extensions')) 
     341                if (!$db->table_exists($db->prefix.'extensions')) 
    342342                { 
    343343                        switch ($db_type) 
     
    345345                                case 'mysql': 
    346346                                case 'mysqli': 
    347                                         $sql = 'CREATE TABLE '.$db_prefix."extensions ( 
     347                                        $sql = 'CREATE TABLE '.$db->prefix."extensions ( 
    348348                                                        id VARCHAR(50) NOT NULL DEFAULT '', 
    349349                                                        title VARCHAR(255) NOT NULL DEFAULT '', 
     
    357357 
    358358                                case 'pgsql': 
    359                                         $sql = 'CREATE TABLE '.$db_prefix."extensions ( 
     359                                        $sql = 'CREATE TABLE '.$db->prefix."extensions ( 
    360360                                                        id VARCHAR(50) NOT NULL DEFAULT '', 
    361361                                                        title VARCHAR(255) NOT NULL DEFAULT '', 
     
    369369 
    370370                                case 'sqlite': 
    371                                         $sql = 'CREATE TABLE '.$db_prefix."extensions ( 
     371                                        $sql = 'CREATE TABLE '.$db->prefix."extensions ( 
    372372                                                        id VARCHAR(50) NOT NULL DEFAULT '', 
    373373                                                        title VARCHAR(255) NOT NULL DEFAULT '', 
     
    385385 
    386386                // Add the extension_hooks table if it doesn't already exist 
    387                 if (!$db->table_exists($db_prefix.'extension_hooks')) 
     387                if (!$db->table_exists($db->prefix.'extension_hooks')) 
    388388                { 
    389389                        switch ($db_type) 
     
    391391                                case 'mysql': 
    392392                                case 'mysqli': 
    393                                         $sql = 'CREATE TABLE '.$db_prefix."extension_hooks ( 
     393                                        $sql = 'CREATE TABLE '.$db->prefix."extension_hooks ( 
    394394                                                        id VARCHAR(50) NOT NULL DEFAULT '', 
    395395                                                        extension_id VARCHAR(50) NOT NULL DEFAULT '', 
     
    401401 
    402402                                case 'pgsql': 
    403                                         $sql = 'CREATE TABLE '.$db_prefix."extension_hooks ( 
     403                                        $sql = 'CREATE TABLE '.$db->prefix."extension_hooks ( 
    404404                                                        id VARCHAR(50) NOT NULL DEFAULT '', 
    405405                                                        extension_id VARCHAR(50) NOT NULL DEFAULT '', 
     
    411411 
    412412                                case 'sqlite': 
    413                                         $sql = 'CREATE TABLE '.$db_prefix."extension_hooks ( 
     413                                        $sql = 'CREATE TABLE '.$db->prefix."extension_hooks ( 
    414414                                                        id VARCHAR(50) NOT NULL DEFAULT '', 
    415415                                                        extension_id VARCHAR(50) NOT NULL DEFAULT '', 
     
    523523 
    524524                // We need to add a unique index to avoid users having multiple rows in the online table 
    525                 if (($db_type == 'mysql' || $db_type == 'mysqli') && !$db->index_exists($db->prefix.'online', $db->prefix.'online_user_id_ident_idx')) 
     525                if (!$db->index_exists($db->prefix.'online', $db->prefix.'online_user_id_ident_idx')) 
    526526                { 
    527527                        $db->query('DELETE FROM '.$db->prefix.'online') or error(__FILE__, __LINE__); 
    528                         $db->query('ALTER TABLE '.$db->prefix.'online ADD UNIQUE INDEX '.$db->prefix.'online_user_id_ident_idx (user_id, ident)') or error(__FILE__, __LINE__); 
     528 
     529                        switch ($db_type) 
     530                        { 
     531                                case 'mysql': 
     532                                case 'mysqli': 
     533                                        $db->query('ALTER TABLE '.$db->prefix.'online ADD UNIQUE INDEX '.$db->prefix.'online_user_id_ident_idx (user_id, ident)') or error(__FILE__, __LINE__); 
     534                                        break; 
     535 
     536                                default: 
     537                                        $db->query('CREATE UNIQUE INDEX '.$db->prefix.'online_user_id_ident_idx ON '.$db->prefix.'online(user_id, ident)') or error(__FILE__, __LINE__); 
     538                                        break; 
     539                        } 
    529540                } 
    530541 
    531542                // Get rid of the old search tables for mysql/mysqli 
    532                 if (($db_type == 'mysql' || $db_type == 'mysqli') && $db->table_exists($db_prefix.'search_cache') && $db->table_exists($db_prefix.'search_matches') && $db->table_exists($db_prefix.'search_words')) 
     543                if (($db_type == 'mysql' || $db_type == 'mysqli') && $db->table_exists($db->prefix.'search_cache') && $db->table_exists($db->prefix.'search_matches') && $db->table_exists($db->prefix.'search_words')) 
    533544                        $db->query('DROP TABLE '.$db->prefix.'search_cache, '.$db->prefix.'search_matches, '.$db->prefix.'search_words') or error(__FILE__, __LINE__); 
    534545 
    535546                // Add fulltext indexes for mysql/mysqli 
    536547                if (($db_type == 'mysql' || $db_type == 'mysqli') && !$db->index_exists($db->prefix.'posts', $db->prefix.'posts_message_idx')) 
    537                         $db->query('ALTER TABLE '.$db_prefix.'posts ADD FULLTEXT '.$db_prefix.'posts_message_idx(message)') or error(__FILE__, __LINE__); 
     548                        $db->query('ALTER TABLE '.$db->prefix.'posts ADD FULLTEXT '.$db->prefix.'posts_message_idx(message)') or error(__FILE__, __LINE__); 
    538549                if (($db_type == 'mysql' || $db_type == 'mysqli') && !$db->index_exists($db->prefix.'topics', $db->prefix.'topics_subject_idx')) 
    539                         $db->query('ALTER TABLE '.$db_prefix.'topics ADD FULLTEXT '.$db_prefix.'topics_subject_idx(subject)') or error(__FILE__, __LINE__); 
     550                        $db->query('ALTER TABLE '.$db->prefix.'topics ADD FULLTEXT '.$db->prefix.'topics_subject_idx(subject)') or error(__FILE__, __LINE__); 
    540551 
    541552                // Add an index on last_post in the topics table 
     
    546557                                case 'mysql': 
    547558                                case 'mysqli': 
    548                                         $db->query('ALTER TABLE '.$db_prefix.'topics ADD INDEX '.$db_prefix.'topics_last_post_idx(last_post)') or error(__FILE__, __LINE__); 
     559                                        $db->query('ALTER TABLE '.$db->prefix.'topics ADD INDEX '.$db->prefix.'topics_last_post_idx(last_post)') or error(__FILE__, __LINE__); 
    549560                                        break; 
    550561 
    551562                                default: 
    552                                         $db->query('CREATE INDEX '.$db_prefix.'topics_last_post_idx ON '.$db_prefix.'topics(last_post)') or error(__FILE__, __LINE__); 
     563                                        $db->query('CREATE INDEX '.$db->prefix.'topics_last_post_idx ON '.$db->prefix.'topics(last_post)') or error(__FILE__, __LINE__); 
    553564                                        break; 
    554565                        } 
  • branches/punbb-1.3-dev/upload/install.php

    r1069 r1075  
    13391339 
    13401340                default: 
     1341                        $queries[] = 'CREATE UNIQUE INDEX '.$db_prefix.'online_user_id_ident_idx ON '.$db_prefix.'online(user_id,ident)'; 
    13411342                        $queries[] = 'CREATE INDEX '.$db_prefix.'online_user_id_idx ON '.$db_prefix.'online(user_id)'; 
    13421343                        $queries[] = 'CREATE INDEX '.$db_prefix.'posts_topic_id_idx ON '.$db_prefix.'posts(topic_id)';