From 72e90545454c0e014318fa3c81658e035aac58c1 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 10 Jun 2009 13:00:47 +0200 Subject: applying patch to version 1.15.0 --- maintenance/postgres/archives/patch-change_tag.sql | 28 +++++++++++ maintenance/postgres/compare_schemas.pl | 54 ++++++++++++++++++---- maintenance/postgres/tables.sql | 36 +++++++++++++-- 3 files changed, 104 insertions(+), 14 deletions(-) create mode 100644 maintenance/postgres/archives/patch-change_tag.sql (limited to 'maintenance/postgres') diff --git a/maintenance/postgres/archives/patch-change_tag.sql b/maintenance/postgres/archives/patch-change_tag.sql new file mode 100644 index 00000000..1f52c474 --- /dev/null +++ b/maintenance/postgres/archives/patch-change_tag.sql @@ -0,0 +1,28 @@ + +CREATE TABLE change_tag ( + ct_rc_id INTEGER NULL, + ct_log_id INTEGER NULL, + ct_rev_id INTEGER NULL, + ct_tag TEXT NOT NULL, + ct_params TEXT NULL +); +CREATE UNIQUE INDEX change_tag_rc_tag ON change_tag(ct_rc_id,ct_tag); +CREATE UNIQUE INDEX change_tag_log_tag ON change_tag(ct_log_id,ct_tag); +CREATE UNIQUE INDEX change_tag_rev_tag ON change_tag(ct_rev_id,ct_tag); +CREATE INDEX change_tag_tag_id ON change_tag(ct_tag,ct_rc_id,ct_rev_id,ct_log_id); + + +CREATE TABLE tag_summary ( + ts_rc_id INTEGER NULL, + ts_log_id INTEGER NULL, + ts_rev_id INTEGER NULL, + ts_tags TEXT NOT NULL +); +CREATE UNIQUE INDEX tag_summary_rc_id ON tag_summary(ts_rc_id); +CREATE UNIQUE INDEX tag_summary_log_id ON tag_summary(ts_log_id); +CREATE UNIQUE INDEX tag_summary_rev_id ON tag_summary(ts_rev_id); + + +CREATE TABLE valid_tag ( + vt_tag TEXT NOT NULL PRIMARY KEY +); diff --git a/maintenance/postgres/compare_schemas.pl b/maintenance/postgres/compare_schemas.pl index 144663df..850244ba 100644 --- a/maintenance/postgres/compare_schemas.pl +++ b/maintenance/postgres/compare_schemas.pl @@ -9,7 +9,7 @@ use warnings; use Data::Dumper; use Cwd; -check_valid_sql(); +#check_valid_sql(); my @old = ('../tables.sql'); my $new = 'tables.sql'; @@ -48,7 +48,7 @@ $datatype = qr{($datatype)}; my $typeval = qr{(\(\d+\))?}; -my $typeval2 = qr{ signed| unsigned| binary| NOT NULL| NULL| auto_increment| default ['\-\d\w"]+| REFERENCES .+CASCADE}; +my $typeval2 = qr{ signed| unsigned| binary| NOT NULL| NULL| PRIMARY KEY| AUTO_INCREMENT| default ['\-\d\w"]+| REFERENCES .+CASCADE}; my $indextype = join '|' => qw(INDEX KEY FULLTEXT), 'PRIMARY KEY', 'UNIQUE INDEX', 'UNIQUE KEY'; $indextype = qr{$indextype}; @@ -96,9 +96,15 @@ sub parse_sql { chomp; if (/CREATE\s*TABLE/i) { - m{^CREATE TABLE /\*\$wgDBprefix\*/(\w+) \($} - or die qq{Invalid CREATE TABLE at line $. of $oldfile\n}; - $table = $1; + if (m{^CREATE TABLE /\*_\*/(\w+) \($}) { + $table = $1; + } + elsif (m{^CREATE TABLE /\*\$wgDBprefix\*/(\w+) \($}) { + $table = $1; + } + else { + die qq{Invalid CREATE TABLE at line $. of $oldfile\n}; + } $info{$table}{name}=$table; } elsif (m{^\) /\*\$wgDBTableOptions\*/}) { @@ -114,14 +120,14 @@ sub parse_sql { $info{$table}{type}=$2; $info{$table}{charset}=$3; } - elsif (/^ (\w+) $datatype$typeval$typeval2{0,3},?$/) { + elsif (/^ (\w+) $datatype$typeval$typeval2{0,4},?$/) { $info{$table}{column}{$1} = $2; my $extra = $3 || ''; $info{$table}{columnfull}{$1} = "$2$extra"; } - elsif (/^ ($indextype)(?: (\w+))? \(([\w, \(\)]+)\),?$/) { - $info{$table}{lc $1.'_name'} = $2 ? $2 : ''; - $info{$table}{lc $1.'pk_target'} = $3; + elsif (m{^ UNIQUE KEY (\w+) \((.+?)\)}) { + } + elsif (m{^CREATE (?:UNIQUE )?(?:FULLTEXT )?INDEX /\*i\*/(\w+) ON /\*_\*/(\w+) \((.+?)\);}) { } else { die "Cannot parse line $. of $oldfile:\n$_\n"; @@ -152,15 +158,18 @@ while (<$pfh>) { close $pfh or die qq{Could not close "$parsefile": $!\n}; my $OK_NOT_IN_PTABLE = ' +change_tag filearchive logging profiling querycache_info searchindex +tag_summary trackbacks transcache user_newtalk updatelog +valid_tag '; ## Make sure all tables in main tables.sql are accounted for in the parsertest. @@ -301,6 +310,7 @@ rc_log_type varbinary(255) TEXT ## Simple text-only strings: ar_flags tinyblob TEXT +ct_params blob TEXT fa_minor_mime varbinary(32) TEXT fa_storage_group varbinary(16) TEXT # Just 'deleted' for now, should stay plain text fa_storage_key varbinary(64) TEXT # sha1 plus text extension @@ -331,6 +341,7 @@ qcc_type varbinary(32) TEXT qci_type varbinary(32) TEXT rc_params blob TEXT rlc_to_blob blob TEXT +ts_tags blob TEXT ug_group varbinary(16) TEXT user_email_token binary(32) TEXT user_ip varbinary(40) TEXT @@ -497,6 +508,8 @@ sub find_problems { my $file = shift; open my $fh, '<', $file or die qq{Could not open "$file": $!\n}; + my $lastline = ''; + my $inarray = 0; while (<$fh>) { if (/FORCE INDEX/ and $file !~ /Database\w*\.php/) { warn "Found FORCE INDEX string at line $. of $file\n"; @@ -513,6 +526,29 @@ sub find_problems { if (/\bGROUP\s+BY\s*\d\b/i and $file !~ /Database\w*\.php/) { warn "Found GROUP BY # at line $. of $file\n"; } + if (/wfGetDB\s*\(\s+\)/io) { + warn "wfGETDB is missing parameters at line $. of $file\n"; + } + if (/=\s*array\s*\(\s*$/) { + $inarray = 1; + next; + } + if ($inarray) { + if (/\s*\);\s*$/) { + $inarray = 0; + next; + } + next if ! /\w/ or /array\(\s*$/ or /^\s*#/ or m{^\s*//}; + if (! /,/) { + my $nextline = <$fh>; + last if ! defined $nextline; + if ($nextline =~ /^\s*\)[;,]/) { + $inarray = 0; + next; + } + #warn "Array is missing a comma? Line $. of $file\n"; + } + } } close $fh or die qq{Could not close "$file": $!\n}; return; diff --git a/maintenance/postgres/tables.sql b/maintenance/postgres/tables.sql index 93cee862..e8d5eb77 100644 --- a/maintenance/postgres/tables.sql +++ b/maintenance/postgres/tables.sql @@ -276,15 +276,15 @@ CREATE TABLE oldimage ( oi_size INTEGER NOT NULL, oi_width INTEGER NOT NULL, oi_height INTEGER NOT NULL, - oi_bits SMALLINT NOT NULL, + oi_bits SMALLINT NULL, oi_description TEXT, oi_user INTEGER NULL REFERENCES mwuser(user_id) ON DELETE SET NULL, oi_user_text TEXT NOT NULL, - oi_timestamp TIMESTAMPTZ NOT NULL, + oi_timestamp TIMESTAMPTZ NULL, oi_metadata BYTEA NOT NULL DEFAULT '', oi_media_type TEXT NULL, - oi_major_mime TEXT NOT NULL DEFAULT 'unknown', - oi_minor_mime TEXT NOT NULL DEFAULT 'unknown', + oi_major_mime TEXT NULL DEFAULT 'unknown', + oi_minor_mime TEXT NULL DEFAULT 'unknown', oi_deleted SMALLINT NOT NULL DEFAULT 0, oi_sha1 TEXT NOT NULL DEFAULT '' ); @@ -554,6 +554,32 @@ CREATE TABLE category ( CREATE UNIQUE INDEX category_title ON category(cat_title); CREATE INDEX category_pages ON category(cat_pages); +CREATE TABLE change_tag ( + ct_rc_id INTEGER NULL, + ct_log_id INTEGER NULL, + ct_rev_id INTEGER NULL, + ct_tag TEXT NOT NULL, + ct_params TEXT NULL +); +CREATE UNIQUE INDEX change_tag_rc_tag ON change_tag(ct_rc_id,ct_tag); +CREATE UNIQUE INDEX change_tag_log_tag ON change_tag(ct_log_id,ct_tag); +CREATE UNIQUE INDEX change_tag_rev_tag ON change_tag(ct_rev_id,ct_tag); +CREATE INDEX change_tag_tag_id ON change_tag(ct_tag,ct_rc_id,ct_rev_id,ct_log_id); + +CREATE TABLE tag_summary ( + ts_rc_id INTEGER NULL, + ts_log_id INTEGER NULL, + ts_rev_id INTEGER NULL, + ts_tags TEXT NOT NULL +); +CREATE UNIQUE INDEX tag_summary_rc_id ON tag_summary(ts_rc_id); +CREATE UNIQUE INDEX tag_summary_log_id ON tag_summary(ts_log_id); +CREATE UNIQUE INDEX tag_summary_rev_id ON tag_summary(ts_rev_id); + +CREATE TABLE valid_tag ( + vt_tag TEXT NOT NULL PRIMARY KEY +); + CREATE TABLE mediawiki_version ( type TEXT NOT NULL, mw_version TEXT NOT NULL, @@ -573,5 +599,5 @@ CREATE TABLE mediawiki_version ( ); INSERT INTO mediawiki_version (type,mw_version,sql_version,sql_date) - VALUES ('Creation','??','$LastChangedRevision: 41967 $','$LastChangedDate: 2008-10-11 07:08:10 -0500 (Sat, 11 Oct 2008) $'); + VALUES ('Creation','??','$LastChangedRevision: 48615 $','$LastChangedDate: 2009-03-19 20:15:41 -0500 (Thu, 19 Mar 2009) $'); -- cgit v1.2.3-54-g00ecf