diff --git a/includes/database/database.inc b/includes/database/database.inc index e08f907..81a84d3 100644 --- a/includes/database/database.inc +++ b/includes/database/database.inc @@ -2099,6 +2099,13 @@ class DatabaseStatementBase extends PDOStatement implements DatabaseStatementInt $this->setFetchMode($options['fetch']); } } + // Allow individual queries to temporarily override the letter-casing of + // column names. Typically used by schema queries. + // This attribute is not supported on PDOStatement. + if (isset($options['case'])) { + $original_case = $this->dbh->getAttribute(PDO::ATTR_CASE); + $this->dbh->setAttribute(PDO::ATTR_CASE, $options['case']); + } $logger = $this->dbh->getLogger(); if (!empty($logger)) { @@ -2112,6 +2119,11 @@ class DatabaseStatementBase extends PDOStatement implements DatabaseStatementInt $logger->log($this, $args, $query_end - $query_start); } + // Revert letter-casing. + if (isset($options['case'])) { + $this->dbh->setAttribute(PDO::ATTR_CASE, $original_case); + } + return $return; } diff --git a/includes/database/mysql/database.inc b/includes/database/mysql/database.inc index 157cbfa..a497dab 100644 --- a/includes/database/mysql/database.inc +++ b/includes/database/mysql/database.inc @@ -42,8 +42,6 @@ class DatabaseConnection_mysql extends DatabaseConnection { PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => TRUE, // Because MySQL's prepared statements skip the query cache, because it's dumb. PDO::ATTR_EMULATE_PREPARES => TRUE, - // Force column names to lower case. - PDO::ATTR_CASE => PDO::CASE_LOWER, )); // Force MySQL to use the UTF-8 character set. Also set the collation, if a diff --git a/includes/database/mysql/schema.inc b/includes/database/mysql/schema.inc index 4e88fa1..53be523 100644 --- a/includes/database/mysql/schema.inc +++ b/includes/database/mysql/schema.inc @@ -380,7 +380,12 @@ class DatabaseSchema_mysql extends DatabaseSchema { public function indexExists($table, $name) { // Returns one row for each column in the index. Result is string or FALSE. // Details at http://dev.mysql.com/doc/refman/5.0/en/show-index.html - $row = $this->connection->query('SHOW INDEX FROM {' . $table . "} WHERE key_name = '$name'")->fetchAssoc(); + $row = $this->connection->query('SHOW INDEX FROM {' . $table . '} WHERE key_name = :name', array( + ':name' => $name, + ), array( + // Force column names to lower case. + 'case' => PDO::CASE_LOWER + ))->fetchAssoc(); return isset($row['key_name']); } diff --git a/includes/database/pgsql/database.inc b/includes/database/pgsql/database.inc index 98b954f..f673143 100644 --- a/includes/database/pgsql/database.inc +++ b/includes/database/pgsql/database.inc @@ -57,8 +57,6 @@ class DatabaseConnection_pgsql extends DatabaseConnection { PDO::ATTR_EMULATE_PREPARES => TRUE, // Convert numeric values to strings when fetching. PDO::ATTR_STRINGIFY_FETCHES => TRUE, - // Force column names to lower case. - PDO::ATTR_CASE => PDO::CASE_LOWER, )); // Force PostgreSQL to use the UTF-8 character set by default. diff --git a/includes/database/sqlite/database.inc b/includes/database/sqlite/database.inc index 0fc0b55..ff56d7f 100644 --- a/includes/database/sqlite/database.inc +++ b/includes/database/sqlite/database.inc @@ -64,8 +64,6 @@ class DatabaseConnection_sqlite extends DatabaseConnection { $this->connectionOptions = $connection_options; parent::__construct('sqlite:' . $connection_options['database'], '', '', array( - // Force column names to lower case. - PDO::ATTR_CASE => PDO::CASE_LOWER, // Convert numeric values to strings when fetching. PDO::ATTR_STRINGIFY_FETCHES => TRUE, ));