Index: trunk/phase3/maintenance/postgres/compare_schemas.pl |
— | — | @@ -9,7 +9,7 @@ |
10 | 10 | use Data::Dumper; |
11 | 11 | use Cwd; |
12 | 12 | |
13 | | -check_valid_sql(); |
| 13 | +#check_valid_sql(); |
14 | 14 | |
15 | 15 | my @old = ('../tables.sql'); |
16 | 16 | my $new = 'tables.sql'; |
— | — | @@ -48,7 +48,7 @@ |
49 | 49 | |
50 | 50 | my $typeval = qr{(\(\d+\))?}; |
51 | 51 | |
52 | | -my $typeval2 = qr{ signed| unsigned| binary| NOT NULL| NULL| auto_increment| default ['\-\d\w"]+| REFERENCES .+CASCADE}; |
| 52 | +my $typeval2 = qr{ signed| unsigned| binary| NOT NULL| NULL| PRIMARY KEY| AUTO_INCREMENT| default ['\-\d\w"]+| REFERENCES .+CASCADE}; |
53 | 53 | |
54 | 54 | my $indextype = join '|' => qw(INDEX KEY FULLTEXT), 'PRIMARY KEY', 'UNIQUE INDEX', 'UNIQUE KEY'; |
55 | 55 | $indextype = qr{$indextype}; |
— | — | @@ -96,9 +96,15 @@ |
97 | 97 | chomp; |
98 | 98 | |
99 | 99 | if (/CREATE\s*TABLE/i) { |
100 | | - m{^CREATE TABLE /\*\$wgDBprefix\*/(\w+) \($} |
101 | | - or die qq{Invalid CREATE TABLE at line $. of $oldfile\n}; |
102 | | - $table = $1; |
| 100 | + if (m{^CREATE TABLE /\*_\*/(\w+) \($}) { |
| 101 | + $table = $1; |
| 102 | + } |
| 103 | + elsif (m{^CREATE TABLE /\*\$wgDBprefix\*/(\w+) \($}) { |
| 104 | + $table = $1; |
| 105 | + } |
| 106 | + else { |
| 107 | + die qq{Invalid CREATE TABLE at line $. of $oldfile\n}; |
| 108 | + } |
103 | 109 | $info{$table}{name}=$table; |
104 | 110 | } |
105 | 111 | elsif (m{^\) /\*\$wgDBTableOptions\*/}) { |
— | — | @@ -114,15 +120,15 @@ |
115 | 121 | $info{$table}{type}=$2; |
116 | 122 | $info{$table}{charset}=$3; |
117 | 123 | } |
118 | | - elsif (/^ (\w+) $datatype$typeval$typeval2{0,3},?$/) { |
| 124 | + elsif (/^ (\w+) $datatype$typeval$typeval2{0,4},?$/) { |
119 | 125 | $info{$table}{column}{$1} = $2; |
120 | 126 | my $extra = $3 || ''; |
121 | 127 | $info{$table}{columnfull}{$1} = "$2$extra"; |
122 | 128 | } |
123 | | - elsif (/^ ($indextype)(?: (\w+))? \(([\w, \(\)]+)\),?$/) { |
124 | | - $info{$table}{lc $1.'_name'} = $2 ? $2 : ''; |
125 | | - $info{$table}{lc $1.'pk_target'} = $3; |
| 129 | + elsif (m{^ UNIQUE KEY (\w+) \((.+?)\)}) { |
126 | 130 | } |
| 131 | + elsif (m{^CREATE (?:UNIQUE )?(?:FULLTEXT )?INDEX /\*i\*/(\w+) ON /\*_\*/(\w+) \((.+?)\);}) { |
| 132 | + } |
127 | 133 | else { |
128 | 134 | die "Cannot parse line $. of $oldfile:\n$_\n"; |
129 | 135 | } |
— | — | @@ -301,6 +307,7 @@ |
302 | 308 | |
303 | 309 | ## Simple text-only strings: |
304 | 310 | ar_flags tinyblob TEXT |
| 311 | +ct_params blob TEXT |
305 | 312 | fa_minor_mime varbinary(32) TEXT |
306 | 313 | fa_storage_group varbinary(16) TEXT # Just 'deleted' for now, should stay plain text |
307 | 314 | fa_storage_key varbinary(64) TEXT # sha1 plus text extension |
— | — | @@ -331,6 +338,7 @@ |
332 | 339 | qci_type varbinary(32) TEXT |
333 | 340 | rc_params blob TEXT |
334 | 341 | rlc_to_blob blob TEXT |
| 342 | +ts_tags blob TEXT |
335 | 343 | ug_group varbinary(16) TEXT |
336 | 344 | user_email_token binary(32) TEXT |
337 | 345 | user_ip varbinary(40) TEXT |
— | — | @@ -497,6 +505,8 @@ |
498 | 506 | |
499 | 507 | my $file = shift; |
500 | 508 | open my $fh, '<', $file or die qq{Could not open "$file": $!\n}; |
| 509 | + my $lastline = ''; |
| 510 | + my $inarray = 0; |
501 | 511 | while (<$fh>) { |
502 | 512 | if (/FORCE INDEX/ and $file !~ /Database\w*\.php/) { |
503 | 513 | warn "Found FORCE INDEX string at line $. of $file\n"; |
— | — | @@ -513,6 +523,29 @@ |
514 | 524 | if (/\bGROUP\s+BY\s*\d\b/i and $file !~ /Database\w*\.php/) { |
515 | 525 | warn "Found GROUP BY # at line $. of $file\n"; |
516 | 526 | } |
| 527 | + if (/wfGetDB\s*\(\s+\)/io) { |
| 528 | + warn "wfGETDB is missing parameters at line $. of $file\n"; |
| 529 | + } |
| 530 | + if (/=\s*array\s*\(\s*$/) { |
| 531 | + $inarray = 1; |
| 532 | + next; |
| 533 | + } |
| 534 | + if ($inarray) { |
| 535 | + if (/\s*\);\s*$/) { |
| 536 | + $inarray = 0; |
| 537 | + next; |
| 538 | + } |
| 539 | + next if ! /\w/ or /array\(\s*$/ or /^\s*#/ or m{^\s*//}; |
| 540 | + if (! /,/) { |
| 541 | + my $nextline = <$fh>; |
| 542 | + last if ! defined $nextline; |
| 543 | + if ($nextline =~ /^\s*\)[;,]/) { |
| 544 | + $inarray = 0; |
| 545 | + next; |
| 546 | + } |
| 547 | + #warn "Array is missing a comma? Line $. of $file\n"; |
| 548 | + } |
| 549 | + } |
517 | 550 | } |
518 | 551 | close $fh or die qq{Could not close "$file": $!\n}; |
519 | 552 | return; |