summaryrefslogtreecommitdiff
path: root/includes/database/mysql/schema.inc
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-01-08 09:52:12 +0000
committerDries Buytaert <dries@buytaert.net>2009-01-08 09:52:12 +0000
commit9af9e3de8851ee43ef77c90205bd1cfe9af15358 (patch)
tree734abca89eba6c0e30a20cdd461b9b56d3b676b7 /includes/database/mysql/schema.inc
parenta7b4bdef1d053bfd00342b5250b98153c7a6be5e (diff)
downloadbrdo-9af9e3de8851ee43ef77c90205bd1cfe9af15358.tar.gz
brdo-9af9e3de8851ee43ef77c90205bd1cfe9af15358.tar.bz2
- Patch #342503 by Josh Waihi, Damien Tournoud et al: schema function findTables fails on PostgreSQL.
Diffstat (limited to 'includes/database/mysql/schema.inc')
-rw-r--r--includes/database/mysql/schema.inc27
1 files changed, 21 insertions, 6 deletions
diff --git a/includes/database/mysql/schema.inc b/includes/database/mysql/schema.inc
index 3e19f05d0..b12aa525a 100644
--- a/includes/database/mysql/schema.inc
+++ b/includes/database/mysql/schema.inc
@@ -14,14 +14,29 @@
class DatabaseSchema_mysql extends DatabaseSchema {
- public function tableExists($table) {
- return (bool) $this->connection->query("SHOW TABLES LIKE '{" . $table . "}'", array(), array())->fetchField();
- }
+ /**
+ * Build a condition to match a table name against a standard information_schema.
+ *
+ * MySQL uses databases like schemas rather than catalogs so when we build
+ * a condition to query the information_schema.tables, we set the default
+ * database as the schema unless specified otherwise, and exclude table_catalog
+ * from the condition criteria.
+ */
+ protected function buildTableNameCondition($table_name, $operator = '=') {
+ $info = Database::getConnectionInfo();
- public function columnExists($table, $column) {
- return (bool) $this->connection->query("SHOW COLUMNS FROM {" . $this->connection->escapeTable($table) . "} LIKE '" . $this->connection->escapeTable($column) . "'", array(), array())->fetchField();
- }
+ if (strpos($table_name, '.')) {
+ list($schema, $table_name) = explode('.', $table_name);
+ }
+ else {
+ $schema = $info['default']['database'];
+ }
+ $condition = db_and()
+ ->condition('table_schema', $schema)
+ ->condition('table_name', $table_name, $operator);
+ return $condition;
+ }
/**
* Generate SQL to create a new table from a Drupal schema definition.