PostgreSQL: Support table prefixes
authorJeff <jeff.janes@gmail.com>
Thu, 29 May 2014 06:28:04 +0000 (23:28 -0700)
committerJeff Janes <jeff.janes@gmail.com>
Thu, 29 May 2014 22:11:33 +0000 (15:11 -0700)
PostgreSQL is usually not used with table name prefixes,
and some of the PostgreSQL-specific code took the
shortcut of not dealing with prefixes.  However, the PHPUnit
tests do force a prefix to be used, exposing this limitation.

Make PostgreSQL code add the prefix to table names being used
in FOR UPDATE OF clause.

This fixes 13 of the 17 PostgreSQL unit tests errors against
git HEAD:

EditPageTest::testAutoMerge with data set #1 ('Elmo', 'one
EditPageTest::testAutoMerge with data set #2 ('Elmo', 'Intro
EditPageTest::testAutoMerge with data set #3 ('Adam', 'one
EditPageTest::testAutoMerge with data set #4 ('Adam', 'one
EditPageTest::testAutoMerge with data set #5 ('Adam', 'Intro
EditPageTest::testAutoMerge with data set #6 ('Berta', 'one
EditPageTest::testAutoMerge with data set #7 ('Berta', 'one
EditPageTest::testAutoMerge with data set #8 ('Berta', 'Intro
WikiPageTest::testDoEdit
WikiPageTest::testDoEditContent
WikiPageTest::testDoRollback
WikiPageTest::testDoRollbackFailureSameContent
WikiPageTest::testExists

The change also applies to 1.22.6 and fixes several unit tests
errors there.

Change-Id: I054690f49e250cadd2dc2a6d9e20dea879d896b6

includes/db/DatabasePostgres.php

index 131b758..1cbd1e2 100644 (file)
@@ -1565,7 +1565,8 @@ SQL;
                //}
 
                if ( isset( $options['FOR UPDATE'] ) ) {
-                       $postLimitTail .= ' FOR UPDATE OF ' . implode( ', ', $options['FOR UPDATE'] );
+                       $postLimitTail .= ' FOR UPDATE OF ' .
+                               implode( ', ', array_map( array( &$this, 'tableName' ), $options['FOR UPDATE'] ) );
                } elseif ( isset( $noKeyOptions['FOR UPDATE'] ) ) {
                        $postLimitTail .= ' FOR UPDATE';
                }