From 907d977ac22bc921cd746075422672aab6ee6a75 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Wed, 25 Oct 2006 07:26:59 +0000 Subject: [PATCH] * Added 'redirect' table - contains unique targets of redirects --- maintenance/archives/patch-redirect.sql | 28 +++++++++++++++++++++++++ maintenance/mysql5/tables.sql | 16 ++++++++++++++ maintenance/tables.sql | 19 +++++++++++++++++ maintenance/updaters.inc | 1 + 4 files changed, 64 insertions(+) create mode 100644 maintenance/archives/patch-redirect.sql diff --git a/maintenance/archives/patch-redirect.sql b/maintenance/archives/patch-redirect.sql new file mode 100644 index 0000000000..d377f1b1e2 --- /dev/null +++ b/maintenance/archives/patch-redirect.sql @@ -0,0 +1,28 @@ +-- +-- Create the new redirect table. +-- For each redirect, this table contains exactly one row defining its target +-- +CREATE TABLE /*$wgDBprefix*/redirect ( + -- Key to the page_id of the redirect page + rd_from int(8) unsigned NOT NULL default '0', + + -- Key to page_namespace/page_title of the target page. + -- The target page may or may not exist, and due to renames + -- and deletions may refer to different page records as time + -- goes by. + rd_namespace int NOT NULL default '0', + rd_title varchar(255) binary NOT NULL default '', + + PRIMARY KEY rd_from (rd_from), + KEY rd_ns_title (rd_namespace,rd_title,rd_from) +) TYPE=InnoDB; + +-- Import existing redirects +-- Using ignore because some of the redirect pages contain more than one link +INSERT IGNORE + INTO /*$wgDBprefix*/redirect (rd_from,rd_namespace,rd_title) + SELECT pl_from,pl_namespace,pl_title + FROM /*$wgDBprefix*/pagelinks, /*$wgDBprefix*/page + WHERE pl_from=page_id AND page_is_redirect=1; + + diff --git a/maintenance/mysql5/tables.sql b/maintenance/mysql5/tables.sql index 9682ecd21e..f25988e388 100644 --- a/maintenance/mysql5/tables.sql +++ b/maintenance/mysql5/tables.sql @@ -1024,3 +1024,19 @@ CREATE TABLE /*$wgDBprefix*/querycache_info ( UNIQUE KEY ( qci_type ) ) TYPE=InnoDB; + +-- For each redirect, this table contains exactly one row defining its target +CREATE TABLE /*$wgDBprefix*/redirect ( + -- Key to the page_id of the redirect page + rd_from int(8) unsigned NOT NULL default '0', + + -- Key to page_namespace/page_title of the target page. + -- The target page may or may not exist, and due to renames + -- and deletions may refer to different page records as time + -- goes by. + rd_namespace int NOT NULL default '0', + rd_title varchar(255) binary NOT NULL default '', + + PRIMARY KEY rd_from (rd_from), + KEY rd_ns_title (rd_namespace,rd_title,rd_from) +) TYPE=InnoDB, DEFAULT CHARSET=utf8; diff --git a/maintenance/tables.sql b/maintenance/tables.sql index 9b2955d3e0..1c7905b7f0 100644 --- a/maintenance/tables.sql +++ b/maintenance/tables.sql @@ -1016,4 +1016,23 @@ CREATE TABLE /*$wgDBprefix*/querycache_info ( ) TYPE=InnoDB; +-- +-- Create the new redirect table. +-- For each redirect, this table contains exactly one row defining its target +-- +CREATE TABLE /*$wgDBprefix*/redirect ( + -- Key to the page_id of the redirect page + rd_from int(8) unsigned NOT NULL default '0', + + -- Key to page_namespace/page_title of the target page. + -- The target page may or may not exist, and due to renames + -- and deletions may refer to different page records as time + -- goes by. + rd_namespace int NOT NULL default '0', + rd_title varchar(255) binary NOT NULL default '', + + PRIMARY KEY rd_from (rd_from), + KEY rd_ns_title (rd_namespace,rd_title,rd_from) +) TYPE=InnoDB; + -- vim: sw=2 sts=2 et diff --git a/maintenance/updaters.inc b/maintenance/updaters.inc index a63307b984..6985a44936 100644 --- a/maintenance/updaters.inc +++ b/maintenance/updaters.inc @@ -30,6 +30,7 @@ $wgNewTables = array( array( 'langlinks', 'patch-langlinks.sql' ), array( 'querycache_info', 'patch-querycacheinfo.sql' ), array( 'filearchive', 'patch-filearchive.sql' ), + array( 'redirect', 'patch-redirect.sql' ), ); $wgNewFields = array( -- 2.20.1