diff --git a/INSTALL.pgsql.txt b/INSTALL.pgsql.txt index a01cfbd..59382f9 100644 --- a/INSTALL.pgsql.txt +++ b/INSTALL.pgsql.txt @@ -42,18 +42,3 @@ Note that the database must be created with UTF-8 (Unicode) encoding. Do this for as many schemas as you need. See default.settings.php for how to set which tables use which schemas. -3. CREATE A SCHEMA OR SCHEMAS (Optional advanced) - - Drupal will run across different schemas within your database if you so wish. - By default, Drupal runs inside the 'public' schema but you can use $db_prefix - inside settings.php to define a schema for Drupal to inside of or specify tables - that are shared inside of a separate schema. Drupal will not create schemas for - you, infact the user that Drupal runs as should not be allowed to. You'll need - execute the SQL below as a superuser (such as a postgres user) and replace - 'drupaluser' with the username that Drupal uses to connect to PostgreSQL with - and replace schema_name with a schema name you wish to use such as 'shared': - - CREATE SCHEMA schema_name AUTHORIZATION drupaluser; - - Do this for as many schemas as you need. See default.settings.php for how to - set which tables use which schemas. diff --git a/includes/database/database.inc b/includes/database/database.inc index b0a0bb3..5358dab 100644 --- a/includes/database/database.inc +++ b/includes/database/database.inc @@ -429,7 +429,8 @@ abstract class DatabaseConnection extends PDO { /** * Find the prefix for a table. * - * This is not used in prefixTables due to performance reasons. + * This is function is for when you want to know the prefix of a table. This + * is not used in prefixTables due to performance reasons. */ public function tablePrefix($table = 'default') { global $db_prefix; @@ -446,7 +447,7 @@ abstract class DatabaseConnection extends PDO { } /** - * * Prepare a query string and return the prepared statement. + * Prepare a query string and return the prepared statement. * * This method caches prepared statements, reusing them when * possible. It also prefixes tables names enclosed in curly-braces. @@ -2502,4 +2503,4 @@ function _db_check_install_needed() { include_once DRUPAL_ROOT . '/includes/install.inc'; install_goto('install.php'); } -} \ No newline at end of file +} diff --git a/includes/database/pgsql/schema.inc b/includes/database/pgsql/schema.inc index b08135b..950e5e7 100644 --- a/includes/database/pgsql/schema.inc +++ b/includes/database/pgsql/schema.inc @@ -280,7 +280,7 @@ class DatabaseSchema_pgsql extends DatabaseSchema { // the query will fail. So we must figure this out here instead of wrapping // the new column in curly braces. $prefixInfo = $this->getPrefixInfo($new_name); - $this->connection->query('ALTER TABLE {' . $table . '} RENAME TO {' . $prefixInfo['table'] . '}'); + $this->connection->query('ALTER TABLE {' . $table . '} RENAME TO ' . $prefixInfo['table']); } public function dropTable($table) { diff --git a/includes/database/schema.inc b/includes/database/schema.inc index 9cf6dd6..72f92a8 100644 --- a/includes/database/schema.inc +++ b/includes/database/schema.inc @@ -188,8 +188,14 @@ abstract class DatabaseSchema implements QueryPlaceholderInterface { 'schema' => $this->defaultSchema, 'prefix' => $this->connection->tablePrefix($table), ); + // If the prefix contains a period in it, then that means the prefix also + // contains a schema reference in which case we will change the schema key + // to the value before the period in the prefix. Everything after the dot with + // be prefixed onto the front of the table. if (($pos = strpos($info['prefix'], '.')) !== FALSE) { + // Grab everything before the period. $info['schema'] = substr($info['prefix'], 0, $pos); + // Grab everything after (++$pos increments $pos before it is used in substr). $info['table'] = substr($info['prefix'], ++$pos) . $table; } else { diff --git a/includes/database/sqlite/schema.inc b/includes/database/sqlite/schema.inc index 2af5a4e..f1e9ba9 100644 --- a/includes/database/sqlite/schema.inc +++ b/includes/database/sqlite/schema.inc @@ -233,10 +233,10 @@ class DatabaseSchema_sqlite extends DatabaseSchema { // SQLite doesn't allow you to rename tables outside of the current // database. So the syntax '...RENAME TO database.table' would fail. // So we must determine the full table name here rather than surrounding - // the table with curly bracesi incase the db_prefix contains a reference + // the table with curly braces incase the db_prefix contains a reference // to a database outside of our existsing database. $info = $this->getPrefixInfo($new_name); - $this->connection->query('ALTER TABLE {' . $table . '} RENAME TO {' . $info['table'] . '}'); + $this->connection->query('ALTER TABLE {' . $table . '} RENAME TO ' . $info['table']); } /**