Issue #2370593 by daffie, nathanweeks, bzrudi71: Database::tableExists optimization for PostgreSQL
parent
6519a0596a
commit
7dad7c77f3
|
@ -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)));
|
||||
|
|
Loading…
Reference in New Issue