Skip to content
Snippets Groups Projects
Commit da2cb445 authored by Drew Webber's avatar Drew Webber
Browse files

Issue #2370593 by poker10, daffie, joseph.olstad, nathanweeks,...

Issue #2370593 by poker10, daffie, joseph.olstad, nathanweeks, Sivaji_Ganesh_Jojodae, bzrudi71, webchick, mcdruid, Fabianx: Database::tableExists optimization for PostgreSQL
parent 0d75dbbc
Branches
Tags
1 merge request!7330Issue #3306390 by poker10, catch, Fabianx, pwolanin, rvtraveller: [D7]...
......@@ -414,6 +414,17 @@ protected function _createKeySql($fields) {
return implode(', ', $return);
}
/**
* {@inheritdoc}
*/
public function tableExists($table) {
// In PostgreSQL "unquoted names are always folded to lower case."
// @see DatabaseSchema_pgsql::buildTableNameCondition().
$prefixInfo = $this->getPrefixInfo(strtolower($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 DatabaseSchemaObjectDoesNotExistException(t("Cannot rename @table to @table_new: table @table doesn't exist.", array('@table' => $table, '@table_new' => $new_name)));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment