Commit 7dad7c77 authored by webchick's avatar webchick

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

parent 6519a059
......@@ -420,6 +420,15 @@ protected function createPrimaryKeySql($fields) {
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)));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment