Add short-circuit to DatabasePostgres::schemaExists()
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 26 Oct 2016 23:07:12 +0000 (16:07 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Wed, 26 Oct 2016 23:07:12 +0000 (16:07 -0700)
Change-Id: I5221f7d937be1e87689df5a21fd64e244dbd4c2a

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;
        }