From: Greg Sabino Mullane Date: Sun, 10 Feb 2008 16:50:38 +0000 (+0000) Subject: Fixes for 8.3 compatibility, addresses bug 12784. X-Git-Tag: 1.31.0-rc.0~49527 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=33272a8204616bbc22f16335707da6e9c5383797;p=lhc%2Fweb%2Fwiklou.git Fixes for 8.3 compatibility, addresses bug 12784. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index f02d6feaf3..22f5280220 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -378,6 +378,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Fixing message cache updates for MediaWiki messages moves * (bug 12815) Signature timestamps were always in UTC, even if the timezone code in parentheses after them claimed otherwise +* (bug 12732) Fix installer and searching to handle built-in tsearch2 for Postgres. +* (bug 12784) Change "bool" types to smallint to handle Postgres 8.3 strictness. == Parser changes in 1.12 == diff --git a/maintenance/postgres/tables.sql b/maintenance/postgres/tables.sql index 4adceb18a0..97ff17d508 100644 --- a/maintenance/postgres/tables.sql +++ b/maintenance/postgres/tables.sql @@ -5,7 +5,7 @@ -- For information about each table, please see the notes in maintenance/tables.sql -- Please make sure all dollar-quoting uses $mw$ at the start of the line -- We can't use SERIAL everywhere: the sequence names are hard-coded into the PHP --- TODO: Change CHAR to BOOL (still needed as CHAR due to some PHP code) +-- TODO: Change CHAR/SMALLINT to BOOL (still needed as CHAR due to some PHP code) BEGIN; SET client_min_messages = 'ERROR'; @@ -55,8 +55,8 @@ CREATE TABLE page ( page_title TEXT NOT NULL, page_restrictions TEXT, page_counter BIGINT NOT NULL DEFAULT 0, - page_is_redirect CHAR NOT NULL DEFAULT 0, - page_is_new CHAR NOT NULL DEFAULT 0, + page_is_redirect SMALLINT NOT NULL DEFAULT 0, + page_is_new SMALLINT NOT NULL DEFAULT 0, page_random NUMERIC(15,14) NOT NULL DEFAULT RANDOM(), page_touched TIMESTAMPTZ, page_latest INTEGER NOT NULL, -- FK? @@ -89,9 +89,9 @@ CREATE TABLE revision ( rev_text_id INTEGER NULL, -- FK rev_comment TEXT, rev_user INTEGER NOT NULL REFERENCES mwuser(user_id) ON DELETE RESTRICT, - rev_user_text TEXT NOT NULL, - rev_timestamp TIMESTAMPTZ NOT NULL, - rev_minor_edit CHAR NOT NULL DEFAULT '0', + rev_user_text TEXT NOT NULL, + rev_timestamp TIMESTAMPTZ NOT NULL, + rev_minor_edit SMALLINT NOT NULL DEFAULT 0, rev_deleted SMALLINT NOT NULL DEFAULT 0, rev_len INTEGER NULL, rev_parent_id INTEGER NULL @@ -133,7 +133,7 @@ CREATE TABLE archive ( ar_user INTEGER NULL REFERENCES mwuser(user_id) ON DELETE SET NULL, ar_user_text TEXT NOT NULL, ar_timestamp TIMESTAMPTZ NOT NULL, - ar_minor_edit CHAR NOT NULL DEFAULT '0', + ar_minor_edit SMALLINT NOT NULL DEFAULT 0, ar_flags TEXT, ar_rev_id INTEGER, ar_text_id INTEGER, @@ -222,15 +222,15 @@ CREATE TABLE ipblocks ( ipb_by INTEGER NOT NULL REFERENCES mwuser(user_id) ON DELETE CASCADE, ipb_reason TEXT NOT NULL, ipb_timestamp TIMESTAMPTZ NOT NULL, - ipb_auto CHAR NOT NULL DEFAULT '0', - ipb_anon_only CHAR NOT NULL DEFAULT '0', - ipb_create_account CHAR NOT NULL DEFAULT '1', - ipb_enable_autoblock CHAR NOT NULL DEFAULT '1', + ipb_auto SMALLINT NOT NULL DEFAULT 0, + ipb_anon_only SMALLINT NOT NULL DEFAULT 0, + ipb_create_account SMALLINT NOT NULL DEFAULT 1, + ipb_enable_autoblock SMALLINT NOT NULL DEFAULT 1, ipb_expiry TIMESTAMPTZ NOT NULL, ipb_range_start TEXT, ipb_range_end TEXT, ipb_deleted SMALLINT NOT NULL DEFAULT 0, - ipb_block_email CHAR NOT NULL DEFAULT '0' + ipb_block_email SMALLINT NOT NULL DEFAULT 0 ); CREATE INDEX ipb_address ON ipblocks (ipb_address); @@ -321,16 +321,16 @@ CREATE TABLE recentchanges ( rc_namespace SMALLINT NOT NULL, rc_title TEXT NOT NULL, rc_comment TEXT, - rc_minor CHAR NOT NULL DEFAULT '0', - rc_bot CHAR NOT NULL DEFAULT '0', - rc_new CHAR NOT NULL DEFAULT '0', + rc_minor SMALLINT NOT NULL DEFAULT 0, + rc_bot SMALLINT NOT NULL DEFAULT 0, + rc_new SMALLINT NOT NULL DEFAULT 0, rc_cur_id INTEGER NULL REFERENCES page(page_id) ON DELETE SET NULL, rc_this_oldid INTEGER NOT NULL, rc_last_oldid INTEGER NOT NULL, - rc_type CHAR NOT NULL DEFAULT '0', + rc_type SMALLINT NOT NULL DEFAULT 0, rc_moved_to_ns SMALLINT, rc_moved_to_title TEXT, - rc_patrolled CHAR NOT NULL DEFAULT '0', + rc_patrolled SMALLINT NOT NULL DEFAULT 0, rc_ip CIDR, rc_old_len INTEGER, rc_new_len INTEGER, @@ -366,10 +366,10 @@ CREATE TABLE math ( CREATE TABLE interwiki ( - iw_prefix TEXT NOT NULL UNIQUE, - iw_url TEXT NOT NULL, - iw_local CHAR NOT NULL, - iw_trans CHAR NOT NULL DEFAULT '0' + iw_prefix TEXT NOT NULL UNIQUE, + iw_url TEXT NOT NULL, + iw_local SMALLINT NOT NULL, + iw_trans SMALLINT NOT NULL DEFAULT 0 ); @@ -493,7 +493,7 @@ CREATE TRIGGER ts2_page_text BEFORE INSERT OR UPDATE ON pagecontent CREATE INDEX ts2_page_title ON page USING gin(titlevector); CREATE INDEX ts2_page_text ON pagecontent USING gin(textvector); -CREATE FUNCTION add_interwiki (TEXT,INT,CHAR) RETURNS INT LANGUAGE SQL AS +CREATE FUNCTION add_interwiki (TEXT,INT,SMALLINT) RETURNS INT LANGUAGE SQL AS $mw$ INSERT INTO interwiki (iw_prefix, iw_url, iw_local) VALUES ($1,$2,$3); SELECT 1; diff --git a/maintenance/updaters.inc b/maintenance/updaters.inc index 11877bbfc9..7687d8b15f 100644 --- a/maintenance/updaters.inc +++ b/maintenance/updaters.inc @@ -1364,9 +1364,10 @@ function do_postgres_updates() { ); - # table, column, desired type, USING clause if needed + # table, column, desired type, USING clause if needed (with new default if needed) $typechanges = array( array("archive", "ar_deleted", "smallint", ""), + array("archive", "ar_minor_edit", "smallint", "ar_minor_edit::smallint DEFAULT 0"), array("filearchive", "fa_deleted", "smallint", ""), array("filearchive", "fa_height", "integer", ""), array("filearchive", "fa_metadata", "bytea", "decode(fa_metadata,'escape')"), @@ -1378,6 +1379,13 @@ function do_postgres_updates() { array("image", "img_size", "integer", ""), array("image", "img_width", "integer", ""), array("image", "img_height", "integer", ""), + array("interwiki", "iw_local", "smallint", "iw_local::smallint DEFAULT 0"), + array("interwiki", "iw_trans", "smallint", "iw_trans::smallint DEFAULT 0"), + array("ipblocks", "ipb_auto", "smallint", "ipb_auto::smallint DEFAULT 0"), + array("ipblocks", "ipb_anon_only", "smallint", "ipb_anon_only::smallint DEFAULT 0"), + array("ipblocks", "ipb_create_account", "smallint", "ipb_create_account::smallint DEFAULT 1"), + array("ipblocks", "ipb_enable_autoblock", "smallint", "ipb_enable_autoblock::smallint DEFAULT 1"), + array("ipblocks", "ipb_block_email", "smallint", "ipb_block_email::smallint DEFAULT 0"), array("ipblocks", "ipb_address", "text", "ipb_address::text"), array("ipblocks", "ipb_deleted", "smallint", ""), array("math", "math_inputhash", "bytea", "decode(math_inputhash,'escape')"), @@ -1388,9 +1396,17 @@ function do_postgres_updates() { array("oldimage", "oi_height", "integer", ""), array("oldimage", "oi_size", "integer", ""), array("oldimage", "oi_width", "integer", ""), + array("page", "page_is_redirect","smallint", "page_is_redirect::smallint DEFAULT 0"), + array("page", "page_is_new", "smallint", "page_is_new::smallint DEFAULT 0"), array("querycache", "qc_value", "integer", ""), array("querycachetwo","qcc_value", "integer", ""), + array("recentchanges","rc_bot", "smallint", "rc_bot::smallint DEFAULT 0"), array("recentchanges","rc_deleted", "smallint", ""), + array("recentchanges","rc_minor", "smallint", "rc_minor::smallint DEFAULT 0"), + array("recentchanges","rc_new", "smallint", "rc_new::smallint DEFAULT 0"), + array("recentchanges","rc_type", "smallint", "rc_type::smallint DEFAULT 0"), + array("recentchanges","rc_patrolled", "smallint", "rc_patrolled::smallint DEFAULT 0"), + array("revision", "rev_minor_edit", "smallint", "rev_minor_edit::smallint DEFAULT 0"), array("templatelinks","tl_namespace", "smallint", "tl_namespace::smallint"), array("user_newtalk", "user_ip", "text", "host(user_ip)"), ); @@ -1465,6 +1481,12 @@ function do_postgres_updates() { echo "Changing column type of \"$tc[0].$tc[1]\" from \"{$fi->type()}\" to \"$tc[2]\"\n"; $sql = "ALTER TABLE $tc[0] ALTER $tc[1] TYPE $tc[2]"; if (strlen($tc[3])) { + $default = array(); + if (preg_match( '/DEFAULT (.+)/', $tc[3], $default)) { + $sqldef = "ALTER TABLE $tc[0] ALTER $tc[1] SET DEFAULT $default[1]"; + $wgDatabase->query($sqldef); + $tc[3] = preg_replace( '/\s*DEFAULT .+/', '', $tc[3]); + } $sql .= " USING $tc[3]"; } $sql .= ";\nCOMMIT;\n";