Index: trunk/phase3/maintenance/postgres/archives/patch-ipb_address_unique.sql |
— | — | @@ -0,0 +1,2 @@ |
| 2 | +DROP INDEX IF EXISTS ipb_address; |
| 3 | +CREATE UNIQUE INDEX ipb_address_unique ON ipblocks (ipb_address,ipb_user,ipb_auto,ipb_anon_only); |
Property changes on: trunk/phase3/maintenance/postgres/archives/patch-ipb_address_unique.sql |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 4 | + native |
Index: trunk/phase3/maintenance/postgres/tables.sql |
— | — | @@ -241,9 +241,8 @@ |
242 | 242 | ipb_range_end TEXT, |
243 | 243 | ipb_deleted SMALLINT NOT NULL DEFAULT 0, |
244 | 244 | ipb_block_email SMALLINT NOT NULL DEFAULT 0 |
245 | | - |
246 | 245 | ); |
247 | | -CREATE INDEX ipb_address ON ipblocks (ipb_address); |
| 246 | +CREATE UNIQUE INDEX ipb_address_unique ON ipblocks (ipb_address,ipb_user,ipb_auto,ipb_anon_only); |
248 | 247 | CREATE INDEX ipb_user ON ipblocks (ipb_user); |
249 | 248 | CREATE INDEX ipb_range ON ipblocks (ipb_range_start,ipb_range_end); |
250 | 249 | |
— | — | @@ -352,7 +351,7 @@ |
353 | 352 | rc_params TEXT |
354 | 353 | ); |
355 | 354 | CREATE INDEX rc_timestamp ON recentchanges (rc_timestamp); |
356 | | -CREATE INDEX rc_timestamp ON recentchanges (rc_timestamp) WHERE rc_bot = '0'; |
| 355 | +CREATE INDEX rc_timestamp_bot ON recentchanges (rc_timestamp) WHERE rc_bot = '0'; |
357 | 356 | CREATE INDEX rc_namespace_title ON recentchanges (rc_namespace, rc_title); |
358 | 357 | CREATE INDEX rc_cur_id ON recentchanges (rc_cur_id); |
359 | 358 | CREATE INDEX new_name_timestamp ON recentchanges (rc_new, rc_namespace, rc_timestamp); |
Index: trunk/phase3/maintenance/updaters.inc |
— | — | @@ -1686,7 +1686,7 @@ |
1687 | 1687 | $wgDatabase->query("CREATE UNIQUE INDEX pagelink_unique ON pagelinks (pl_from,pl_namespace,pl_title)"); |
1688 | 1688 | } |
1689 | 1689 | else |
1690 | | - echo "... index \"pagelink_unique_index\" aready exists\n"; |
| 1690 | + echo "... index \"pagelink_unique_index\" already exists\n"; |
1691 | 1691 | |
1692 | 1692 | if (pg_fkey_deltype("revision_rev_user_fkey") == 'r') { |
1693 | 1693 | echo "... constraint \"revision_rev_user_fkey\" is ON DELETE RESTRICT\n"; |
— | — | @@ -1696,6 +1696,14 @@ |
1697 | 1697 | dbsource(archive('patch-revision_rev_user_fkey.sql')); |
1698 | 1698 | } |
1699 | 1699 | |
| 1700 | + # Fix ipb_address index |
| 1701 | + if (pg_index_exists('ipblocks', 'ipb_address_unique' )) { |
| 1702 | + echo "... have ipb_address_unique\n"; |
| 1703 | + } else { |
| 1704 | + echo "Adding ipb_address_unique index\n"; |
| 1705 | + dbsource(archive('patch-ipb_address_unique.sql')); |
| 1706 | + } |
| 1707 | + |
1700 | 1708 | global $wgExtNewTables, $wgExtPGNewFields, $wgExtNewIndexes; |
1701 | 1709 | # Add missing extension tables |
1702 | 1710 | foreach ( $wgExtNewTables as $nt ) { |
Index: trunk/phase3/includes/db/DatabasePostgres.php |
— | — | @@ -72,6 +72,7 @@ |
73 | 73 | var $mInsertId = NULL; |
74 | 74 | var $mLastResult = NULL; |
75 | 75 | var $numeric_version = NULL; |
| 76 | + var $mAffectedRows = NULL; |
76 | 77 | |
77 | 78 | function DatabasePostgres($server = false, $user = false, $password = false, $dbName = false, |
78 | 79 | $failFunction = false, $flags = 0 ) |
— | — | @@ -546,9 +547,11 @@ |
547 | 548 | |
548 | 549 | function doQuery( $sql ) { |
549 | 550 | if (function_exists('mb_convert_encoding')) { |
550 | | - return $this->mLastResult=pg_query( $this->mConn , mb_convert_encoding($sql,'UTF-8') ); |
| 551 | + $sql = mb_convert_encoding($sql,'UTF-8'); |
551 | 552 | } |
552 | | - return $this->mLastResult=pg_query( $this->mConn , $sql); |
| 553 | + $this->mLastResult = pg_query( $this->mConn, $sql); |
| 554 | + $this->mAffectedRows = NULL; // use pg_affected_rows(mLastResult) |
| 555 | + return $this->mLastResult; |
553 | 556 | } |
554 | 557 | |
555 | 558 | function queryIgnore( $sql, $fname = '' ) { |
— | — | @@ -641,9 +644,12 @@ |
642 | 645 | } |
643 | 646 | |
644 | 647 | function affectedRows() { |
645 | | - if( !isset( $this->mLastResult ) or ! $this->mLastResult ) |
| 648 | + if ( !is_null( $this->mAffectedRows ) ) { |
| 649 | + // Forced result for simulated queries |
| 650 | + return $this->mAffectedRows; |
| 651 | + } |
| 652 | + if( empty( $this->mLastResult ) ) |
646 | 653 | return 0; |
647 | | - |
648 | 654 | return pg_affected_rows( $this->mLastResult ); |
649 | 655 | } |
650 | 656 | |
— | — | @@ -809,7 +815,6 @@ |
810 | 816 | |
811 | 817 | $sql .= '(' . $this->makeList( $args ) . ')'; |
812 | 818 | $res = (bool)$this->query( $sql, $fname, $ignore ); |
813 | | - |
814 | 819 | if ( $ignore ) { |
815 | 820 | $bar = pg_last_error(); |
816 | 821 | if ($bar != false) { |
— | — | @@ -821,13 +826,15 @@ |
822 | 827 | } |
823 | 828 | } |
824 | 829 | } |
825 | | - |
826 | 830 | if ( $ignore ) { |
827 | 831 | $olde = error_reporting( $olde ); |
828 | 832 | if ($didbegin) { |
829 | 833 | $this->commit(); |
830 | 834 | } |
831 | 835 | |
| 836 | + // Set the affected row count for the whole operation |
| 837 | + $this->mAffectedRows = $numrowsinserted; |
| 838 | + |
832 | 839 | // IGNORE always returns true |
833 | 840 | return true; |
834 | 841 | } |