From: Brion Vibber Date: Mon, 2 May 2005 10:15:02 +0000 (+0000) Subject: * (bug 719) Increase namespace fields from tinyint to regular int X-Git-Tag: 1.5.0alpha1~20 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/ajouter.php?a=commitdiff_plain;h=480419b3a9524ad13ccd4b100952869720cd8c01;p=lhc%2Fweb%2Fwiklou.git * (bug 719) Increase namespace fields from tinyint to regular int This keeps custom namespaces from bumping the 8-bit ceiling so quickly. --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 2aff684107..7ca31c6571 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1095,8 +1095,8 @@ $wgFeedDiffCutoff = 32768; * no longer be accessible. If you rename it, then you can access them through * the new namespace name. * - * Custom namespaces should start at 100 and stop at 255 (hard limit set by - * database). + * Custom namespaces should start at 100 to avoid conflicting with standard + * namespaces, and should always follow the even/odd main/talk pattern. */ #$wgExtraNamespaces = # array(100 => "Hilfe", diff --git a/maintenance/archives/patch-logging.sql b/maintenance/archives/patch-logging.sql index 88c8bdfc89..79bb53b52d 100644 --- a/maintenance/archives/patch-logging.sql +++ b/maintenance/archives/patch-logging.sql @@ -16,7 +16,7 @@ CREATE TABLE /*$wgDBprefix*/logging ( -- Key to the page affected. Where a user is the target, -- this will point to the user page. - log_namespace tinyint unsigned NOT NULL default 0, + log_namespace int NOT NULL default 0, log_title varchar(255) binary NOT NULL default '', -- Freeform text. Interpreted as edit history comments. diff --git a/maintenance/archives/patch-querycache.sql b/maintenance/archives/patch-querycache.sql index 329b590287..7df9129e93 100644 --- a/maintenance/archives/patch-querycache.sql +++ b/maintenance/archives/patch-querycache.sql @@ -8,7 +8,7 @@ CREATE TABLE /*$wgDBprefix*/querycache ( qc_value int(5) unsigned NOT NULL default '0', -- Target namespace+title - qc_namespace tinyint(2) unsigned NOT NULL default '0', + qc_namespace int NOT NULL default '0', qc_title char(255) binary NOT NULL default '', KEY (qc_type,qc_value) diff --git a/maintenance/tables.sql b/maintenance/tables.sql index 5a612353eb..cc25ed387c 100644 --- a/maintenance/tables.sql +++ b/maintenance/tables.sql @@ -149,7 +149,7 @@ CREATE TABLE /*$wgDBprefix*/page ( -- A page name is broken into a namespace and a title. -- The namespace keys are UI-language-independent constants, -- defined in Namespace.php. - page_namespace tinyint NOT NULL, + page_namespace int NOT NULL, -- The rest of the title, as text. -- Spaces are transformed into underscores in title storage. @@ -286,7 +286,7 @@ CREATE TABLE /*$wgDBprefix*/text ( -- fields, with several caveats. -- CREATE TABLE /*$wgDBprefix*/archive ( - ar_namespace tinyint(2) unsigned NOT NULL default '0', + ar_namespace int NOT NULL default '0', ar_title varchar(255) binary NOT NULL default '', -- Newly deleted pages will not store text in this table, @@ -600,7 +600,7 @@ CREATE TABLE /*$wgDBprefix*/recentchanges ( rc_user_text varchar(255) binary NOT NULL default '', -- When pages are renamed, their RC entries do _not_ change. - rc_namespace tinyint(3) NOT NULL default '0', + rc_namespace int NOT NULL default '0', rc_title varchar(255) binary NOT NULL default '', -- as in revision... @@ -656,7 +656,7 @@ CREATE TABLE /*$wgDBprefix*/watchlist ( -- Key to page_namespace/page_title -- Note that users may watch patches which do not exist yet, -- or existed in the past but have been deleted. - wl_namespace tinyint(2) unsigned NOT NULL default '0', + wl_namespace int NOT NULL default '0', wl_title varchar(255) binary NOT NULL default '', -- Timestamp when user was last sent a notification e-mail; @@ -750,7 +750,7 @@ CREATE TABLE /*$wgDBprefix*/querycache ( qc_value int(5) unsigned NOT NULL default '0', -- Target namespace+title - qc_namespace tinyint(2) unsigned NOT NULL default '0', + qc_namespace int NOT NULL default '0', qc_title char(255) binary NOT NULL default '', KEY (qc_type,qc_value) @@ -796,7 +796,7 @@ CREATE TABLE /*$wgDBprefix*/logging ( -- Key to the page affected. Where a user is the target, -- this will point to the user page. - log_namespace tinyint unsigned NOT NULL default 0, + log_namespace int NOT NULL default 0, log_title varchar(255) binary NOT NULL default '', -- Freeform text. Interpreted as edit history comments. diff --git a/maintenance/updaters.inc b/maintenance/updaters.inc index 11206382d1..01c6a68bb0 100644 --- a/maintenance/updaters.inc +++ b/maintenance/updaters.inc @@ -344,7 +344,7 @@ function do_schema_restructuring() { echo "......Creating tables.\n"; $wgDatabase->query("CREATE TABLE $page ( page_id int(8) unsigned NOT NULL auto_increment, - page_namespace tinyint NOT NULL, + page_namespace int NOT NULL, page_title varchar(255) binary NOT NULL, page_restrictions tinyblob NOT NULL default '', page_counter bigint(20) unsigned NOT NULL default '0', @@ -437,6 +437,41 @@ function do_text_id() { } } +function do_namespace_size() { + $tables = array( + 'page' => 'page', + 'archive' => 'ar', + 'recentchanges' => 'rc', + 'watchlist' => 'wl', + 'querycache' => 'qc', + 'logging' => 'log', + ); + foreach( $tables as $table => $prefix ) { + do_namespace_size_on( $table, $prefix ); + flush(); + } +} + +function do_namespace_size_on( $table, $prefix ) { + global $wgDatabase; + $field = $prefix . '_namespace'; + + $tablename = $wgDatabase->tableName( $table ); + $result = $wgDatabase->query( "SHOW COLUMNS FROM $tablename LIKE '$field'" ); + $info = $wgDatabase->fetchObject( $result ); + $wgDatabase->freeResult( $result ); + + if( substr( $info->Type, 0, 3 ) == 'int' ) { + echo "...$field is already a full int ($info->Type).\n"; + } else { + echo "Promoting $field from $info->Type to int... "; + + $sql = "ALTER TABLE $tablename MODIFY $field int NOT NULL"; + $wgDatabase->query( $sql ); + + echo "ok\n"; + } +} function do_all_updates() { global $wgNewTables, $wgNewFields; @@ -470,6 +505,7 @@ function do_all_updates() { do_schema_restructuring(); flush(); do_inverse_timestamp(); flush(); do_text_id(); flush(); + do_namespace_size(); flush(); initialiseMessages(); flush(); }