Index: includes/database/database.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/database/database.inc,v retrieving revision 1.50 diff -u -p -r1.50 database.inc --- includes/database/database.inc 25 Jan 2009 12:19:31 -0000 1.50 +++ includes/database/database.inc 2 Mar 2009 04:03:44 -0000 @@ -319,6 +319,13 @@ abstract class DatabaseConnection extend */ protected $schema = NULL; + /** + * Quote type to escape table names and indexes. + * + * @var string + */ + protected $quote = '"'; + function __construct($dsn, $username, $password, $driver_options = array()) { // Because the other methods don't seem to work right. $driver_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION; @@ -397,7 +404,7 @@ abstract class DatabaseConnection extend * Queries sent to Drupal should wrap all table names in curly brackets. This * function searches for this syntax and adds Drupal's table prefix to all * tables, allowing Drupal to coexist with other systems in the same database - * and/or schema if necessary. + * if necessary. * * @param $sql * A string containing a partial or entire SQL query. @@ -412,19 +419,19 @@ abstract class DatabaseConnection extend $tmp = $db_prefix; unset($tmp['default']); foreach ($tmp as $key => $val) { - $sql = strtr($sql, array('{' . $key . '}' => $val . $key)); + $sql = strtr($sql, array('{' . $key . '}' => $this->quote . $val . $key . $this->quote)); } - return strtr($sql, array('{' => $db_prefix['default'] , '}' => '')); + return strtr($sql, array('{' => $this->quote . $db_prefix['default'] , '}' => $this->quote)); } else { foreach ($db_prefix as $key => $val) { - $sql = strtr($sql, array('{' . $key . '}' => $val . $key)); + $sql = strtr($sql, array('{' . $key . '}' => $this->quote . $val . $key . $this->quote)); } - return strtr($sql, array('{' => '' , '}' => '')); + return strtr($sql, array('{' => $this->quote, '}' => $this->quote)); } } else { - return strtr($sql, array('{' => $db_prefix , '}' => '')); + return strtr($sql, array('{' => $this->quote . $db_prefix , '}' => $this->quote)); } } Index: includes/database/mysql/database.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/database/mysql/database.inc,v retrieving revision 1.16 diff -u -p -r1.16 database.inc --- includes/database/mysql/database.inc 26 Jan 2009 14:08:40 -0000 1.16 +++ includes/database/mysql/database.inc 2 Mar 2009 04:03:44 -0000 @@ -13,6 +13,8 @@ class DatabaseConnection_mysql extends DatabaseConnection { + protected $quote = '`'; + public function __construct(array $connection_options = array()) { // This driver defaults to non transaction support. $this->transactionSupport = !empty($connection_option['transactions']); Index: includes/database/pgsql/schema.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/database/pgsql/schema.inc,v retrieving revision 1.8 diff -u -p -r1.8 schema.inc --- includes/database/pgsql/schema.inc 24 Feb 2009 16:34:46 -0000 1.8 +++ includes/database/pgsql/schema.inc 2 Mar 2009 04:03:44 -0000 @@ -90,7 +90,7 @@ class DatabaseSchema_pgsql extends Datab } if (isset($table['unique keys']) && is_array($table['unique keys'])) { foreach ($table['unique keys'] as $key_name => $key) { - $sql_keys[] = 'CONSTRAINT {' . $name . '}_' . $key_name . '_key UNIQUE (' . implode(', ', $key) . ')'; + $sql_keys[] = 'CONSTRAINT {' . $name . '_' . $key_name . '_key} UNIQUE (' . implode(', ', $key) . ')'; } } @@ -398,7 +398,7 @@ class DatabaseSchema_pgsql extends Datab * The table to be altered. */ public function dropPrimaryKey(&$ret, $table) { - $ret[] = update_sql('ALTER TABLE {' . $table . '} DROP CONSTRAINT {' . $table . '}_pkey'); + $ret[] = update_sql('ALTER TABLE {' . $table . '} DROP CONSTRAINT {' . $table . '_pkey}'); } /** @@ -547,7 +547,7 @@ class DatabaseSchema_pgsql extends Datab } protected function _createIndexSql($table, $name, $fields) { - $query = 'CREATE INDEX {' . $table . '}_' . $name . '_idx ON {' . $table . '} ('; + $query = 'CREATE INDEX {' . $table . '_' . $name . '_idx} ON {' . $table . '} ('; $query .= $this->_createKeySql($fields) . ')'; return $query; } Index: includes/database/sqlite/schema.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/database/sqlite/schema.inc,v retrieving revision 1.2 diff -u -p -r1.2 schema.inc --- includes/database/sqlite/schema.inc 23 Nov 2008 21:01:03 -0000 1.2 +++ includes/database/sqlite/schema.inc 2 Mar 2009 04:03:44 -0000 @@ -51,7 +51,7 @@ class DatabaseSchema_sqlite extends Data } if (!empty($schema['indexes'])) { foreach ($schema['indexes'] as $index => $fields) { - $sql[] = 'CREATE INDEX {' . $tablename . '}_' . $index . ' ON {' . $tablename . '} (' . $this->createKeySql($fields) . "); \n"; + $sql[] = 'CREATE INDEX {' . $tablename . '_' . $index . '} ON {' . $tablename . '} (' . $this->createKeySql($fields) . "); \n"; } } return $sql;