Merge "Add short-circuit to DatabasePostgres::schemaExists()"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 27 Oct 2016 05:43:38 +0000 (05:43 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 27 Oct 2016 05:43:38 +0000 (05:43 +0000)
includes/libs/rdbms/database/DatabasePostgres.php

index 7acd8dc..b72557a 100644 (file)
@@ -1175,8 +1175,12 @@ SQL;
         * @return bool
         */
        function schemaExists( $schema ) {
-               $exists = $this->selectField( '"pg_catalog"."pg_namespace"', 1,
-                       [ 'nspname' => $schema ], __METHOD__ );
+               if ( !strlen( $schema ) ) {
+                       return false; // short-circuit
+               }
+
+               $exists = $this->selectField(
+                       '"pg_catalog"."pg_namespace"', 1, [ 'nspname' => $schema ], __METHOD__ );
 
                return (bool)$exists;
        }