Issue #2370593 by daffie, nathanweeks, bzrudi71: Database::tableExists optimization for PostgreSQL

8.0.x
webchick 2015-03-13 22:44:43 -07:00
parent 6519a0596a
commit 7dad7c77f3
1 changed files with 9 additions and 0 deletions

View File

@ -420,6 +420,15 @@ class Schema extends DatabaseSchema {
return implode(', ', $return);
}
/**
* {@inheritdoc}
*/
public function tableExists($table) {
$prefixInfo = $this->getPrefixInfo($table, TRUE);
return (bool) $this->connection->query("SELECT 1 FROM pg_tables WHERE schemaname = :schema AND tablename = :table", array(':schema' => $prefixInfo['schema'], ':table' => $prefixInfo['table']))->fetchField();
}
function renameTable($table, $new_name) {
if (!$this->tableExists($table)) {
throw new SchemaObjectDoesNotExistException(t("Cannot rename @table to @table_new: table @table doesn't exist.", array('@table' => $table, '@table_new' => $new_name)));