X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2Fpostgres%2Fcompare_schemas.pl;h=53aeb147fc9e4ebc8e0906cae2e029382c082848;hb=95e5d904f60e7f5efa92fd83416dcd8fcd5cfaca;hp=850244ba34c503073757ad79b2f5af82586523fc;hpb=cdb4377e8ca598557571b816cd7cecac9c8a0e90;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/postgres/compare_schemas.pl b/maintenance/postgres/compare_schemas.pl index 850244ba34..53aeb147fc 100644 --- a/maintenance/postgres/compare_schemas.pl +++ b/maintenance/postgres/compare_schemas.pl @@ -38,12 +38,12 @@ while () { my $datatype = join '|' => qw( bool -tinyint int bigint real float +tinyint smallint int bigint real float tinytext mediumtext text char varchar varbinary binary timestamp datetime tinyblob mediumblob blob ); -$datatype .= q{|ENUM\([\"\w, ]+\)}; +$datatype .= q{|ENUM\([\"\w\', ]+\)}; $datatype = qr{($datatype)}; my $typeval = qr{(\(\d+\))?}; @@ -129,6 +129,8 @@ sub parse_sql { } elsif (m{^CREATE (?:UNIQUE )?(?:FULLTEXT )?INDEX /\*i\*/(\w+) ON /\*_\*/(\w+) \((.+?)\);}) { } + elsif (m{^\s*PRIMARY KEY \([\w,]+\)}) { + } else { die "Cannot parse line $. of $oldfile:\n$_\n"; } @@ -140,50 +142,6 @@ sub parse_sql { } ## end of parse_sql -## Read in the parser test information -my $parsefile = '../parserTests.inc'; -open my $pfh, '<', $parsefile or die qq{Could not open "$parsefile": $!\n}; -my $stat = 0; -my %ptable; -while (<$pfh>) { - if (!$stat) { - if (/function listTables/) { - $stat = 1; - } - next; - } - $ptable{$1}=2 while m{'(\w+)'}g; - last if /\);/; -} -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. -for my $table (sort keys %{$old{'../tables.sql'}}) { - $ptable{$table}++; - next if $ptable{$table} > 2; - next if $OK_NOT_IN_PTABLE =~ /\b$table\b/; - print qq{Table "$table" is in the schema, but not used inside of parserTest.inc\n}; -} -## Any that are used in ptables but no longer exist in the schema? -for my $table (sort grep { $ptable{$_} == 2 } keys %ptable) { - print qq{Table "$table" ($ptable{$table}) used in parserTest.inc, but not found in schema\n}; -} - for my $oldfile (@old) { ## Begin non-standard indent @@ -200,16 +158,17 @@ for my $table (sort keys %{$old{$oldfile}}) { } } -my $dtype = join '|' => qw( +my $dtypelist = join '|' => qw( SMALLINT INTEGER BIGINT NUMERIC SERIAL TEXT CHAR VARCHAR BYTEA TIMESTAMPTZ CIDR ); -$dtype = qr{($dtype)}; +my $dtype = qr{($dtypelist)}; my %new; my ($infunction,$inview,$inrule,$lastcomma) = (0,0,0,0); +my %custom_type; seek $newfh, 0, 0; while (<$newfh>) { next if /^\s*\-\-/ or /^\s*$/; @@ -221,6 +180,15 @@ while (<$newfh>) { next if /^CREATE TRIGGER/ or /^ FOR EACH ROW/; next if /^INSERT INTO/ or /^ VALUES \(/; next if /^ALTER TABLE/; + next if /^DROP SEQUENCE/; + next if /^DROP FUNCTION/; + + if (/^CREATE TYPE (\w+)/) { + die "Type $1 declared more than once!\n" if $custom_type{$1}++; + $dtype = qr{($dtypelist|$1)}; + next; + } + chomp; if (/^\$mw\$;?$/) { @@ -258,6 +226,9 @@ while (<$newfh>) { } $lastcomma = $3 ? 1 : 0; } + elsif (m{^\s*PRIMARY KEY \([\w,]+\)}) { + $lastcomma = 0; + } else { die "Cannot parse line $. of $new:\n$_\n"; } @@ -268,6 +239,7 @@ my $COLMAP = q{ ## INTS: tinyint SMALLINT int INTEGER SERIAL +smallint SMALLINT bigint BIGINT real NUMERIC float NUMERIC @@ -302,7 +274,8 @@ ar_comment tinyblob TEXT fa_description tinyblob TEXT img_description tinyblob TEXT ipb_reason tinyblob TEXT -log_action varbinary(10) TEXT +log_action varbinary(32) TEXT +log_type varbinary(32) TEXT oi_description tinyblob TEXT rev_comment tinyblob TEXT rc_log_action varbinary(255) TEXT @@ -310,21 +283,39 @@ rc_log_type varbinary(255) TEXT ## Simple text-only strings: ar_flags tinyblob TEXT +cf_name varbinary(255) TEXT +cf_value blob TEXT +ar_sha1 varbinary(32) TEXT +cl_collation varbinary(32) TEXT +cl_sortkey varbinary(230) TEXT ct_params blob TEXT -fa_minor_mime varbinary(32) TEXT +fa_minor_mime varbinary(100) 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 ipb_address tinyblob TEXT # IP address or username ipb_range_end tinyblob TEXT # hexadecimal ipb_range_start tinyblob TEXT # hexadecimal -img_minor_mime varbinary(32) TEXT +img_minor_mime varbinary(100) TEXT +lc_lang varbinary(32) TEXT +lc_value varbinary(32) TEXT img_sha1 varbinary(32) TEXT +iw_wikiid varchar(64) TEXT job_cmd varbinary(60) TEXT # Should we limit to 60 as well? keyname varbinary(255) TEXT # No tablename prefix (objectcache) ll_lang varbinary(20) TEXT # Language code +lc_value mediumblob TEXT log_params blob TEXT # LF separated list of args log_type varbinary(10) TEXT -oi_minor_mime varbinary(32) TEXT +ls_field varbinary(32) TEXT +md_deps mediumblob TEXT # JSON +md_module varbinary(255) TEXT +md_skin varbinary(32) TEXT +mr_blob mediumblob TEXT # JSON +mr_lang varbinary(32) TEXT +mr_resource varbinary(255) TEXT +mrl_message varbinary(255) TEXT +mrl_resource varbinary(255) TEXT +oi_minor_mime varbinary(100) TEXT oi_sha1 varbinary(32) TEXT old_flags tinyblob TEXT old_text mediumblob TEXT @@ -340,19 +331,29 @@ qc_type varbinary(32) TEXT qcc_type varbinary(32) TEXT qci_type varbinary(32) TEXT rc_params blob TEXT +rev_sha1 varbinary(32) TEXT rlc_to_blob blob TEXT ts_tags blob TEXT -ug_group varbinary(16) TEXT +ufg_group varbinary(32) TEXT +ug_group varbinary(32) TEXT +ul_value blob TEXT +up_property varbinary(255) TEXT +up_value blob TEXT +us_sha1 varchar(31) TEXT +us_source_type varchar(50) TEXT +us_status varchar(50) TEXT user_email_token binary(32) TEXT user_ip varbinary(40) TEXT user_newpassword tinyblob TEXT user_options blob TEXT user_password tinyblob TEXT user_token binary(32) TEXT +iwl_prefix varbinary(20) TEXT ## Text URLs: el_index blob TEXT el_to blob TEXT +iw_api blob TEXT iw_url blob TEXT tb_url blob TEXT tc_url varbinary(255) TEXT @@ -453,6 +454,9 @@ for my $t (sort keys %{$old{$oldfile}}) { next if exists $colmapok{$c}{$old}{$new}; $old =~ s/ENUM.*/ENUM/; + + next if $old eq 'ENUM' and $new eq 'media_type'; + if (! exists $colmap{$old}{$new}) { print "Column types for $t.$c do not match: $old does not map to $new\n"; } @@ -561,5 +565,4 @@ __DATA__ OLD: searchindex ## We use tsearch2 directly on the page table instead RENAME: user mwuser ## Reserved word causing lots of problems RENAME: text pagecontent ## Reserved word -NEW: mediawiki_version ## Just us, for now XFILE: ../archives/patch-profiling.sql