Merge "PostgreSQL: Fix text search on moved pages"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 20 Jul 2015 23:03:58 +0000 (23:03 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 20 Jul 2015 23:03:58 +0000 (23:03 +0000)
includes/installer/PostgresUpdater.php
includes/search/SearchPostgres.php
maintenance/postgres/archives/patch-textsearch_bug66650.sql [new file with mode: 0644]
maintenance/postgres/update-keys.sql

index 6ac5436..4410271 100644 (file)
@@ -407,6 +407,8 @@ class PostgresUpdater extends DatabaseUpdater {
                        array( 'addPgField', 'mwuser', 'user_password_expires', 'TIMESTAMPTZ NULL' ),
                        array( 'changeFieldPurgeTable', 'l10n_cache', 'lc_value', 'bytea',
                                "replace(lc_value,'\','\\\\')::bytea" ),
+                       // 1.23.9
+                       array( 'rebuildTextSearch'),
 
                        // 1.24
                        array( 'addPgField', 'page_props', 'pp_sortkey', 'float NULL' ),
@@ -947,4 +949,12 @@ END;
                        $this->applyPatch( 'patch-tsearch2funcs.sql', false, "Rewriting tsearch2 triggers" );
                }
        }
+
+       protected function rebuildTextSearch() {
+               if ( $this->updateRowExists( 'patch-textsearch_bug66650.sql' ) ) {
+                       $this->output( "...bug 66650 already fixed or not applicable.\n" );
+                       return true;
+               };
+               $this->applyPatch( 'patch-textsearch_bug66650.sql', false, "Rebuilding text search for bug 66650" );
+       }
 }
index bda10b0..71e3b63 100644 (file)
@@ -186,7 +186,7 @@ class SearchPostgres extends SearchDatabase {
        function update( $pageid, $title, $text ) {
                ## We don't want to index older revisions
                $sql = "UPDATE pagecontent SET textvector = NULL WHERE textvector IS NOT NULL and old_id IN " .
-                               "(SELECT rev_text_id FROM revision WHERE rev_page = " . intval( $pageid ) .
+                               "(SELECT DISTINCT rev_text_id FROM revision WHERE rev_page = " . intval( $pageid ) .
                                " ORDER BY rev_text_id DESC OFFSET 1)";
                $this->db->query( $sql );
                return true;
diff --git a/maintenance/postgres/archives/patch-textsearch_bug66650.sql b/maintenance/postgres/archives/patch-textsearch_bug66650.sql
new file mode 100644 (file)
index 0000000..e4f5681
--- /dev/null
@@ -0,0 +1,5 @@
+UPDATE /*_*/pagecontent SET textvector=to_tsvector(old_text)
+WHERE textvector IS NULL AND old_id IN 
+(SELECT  max(rev_text_id) FROM revision GROUP BY rev_page);
+
+INSERT INTO /*_*/updatelog(ul_key) VALUES ('patch-textsearch_bug66650.sql');
index 7761d0c..b858551 100644 (file)
@@ -27,3 +27,8 @@ INSERT INTO /*_*/updatelog (ul_key, ul_value)
        VALUES( 'user_former_groups-ufg_group-patch-ufg_group-length-increase-255.sql', null );
 INSERT INTO /*_*/updatelog (ul_key, ul_value)
        VALUES( 'user_properties-up_property-patch-up_property.sql', null );
+
+-- PostgreSQL-specific patches.
+
+INSERT INTO /*_*/updatelog (ul_key, ul_value)
+       VALUES( 'patch-textsearch_bug66650.sql', null );