diff --git a/lib/Drupal/Core/Database/Driver/pgsql/Connection.php b/lib/Drupal/Core/Database/Driver/pgsql/Connection.php index 9fc1b66d84..b75c1d6562 100644 --- a/lib/Drupal/Core/Database/Driver/pgsql/Connection.php +++ b/lib/Drupal/Core/Database/Driver/pgsql/Connection.php @@ -385,11 +385,11 @@ class Connection extends DatabaseConnection { */ public function getFullQualifiedTableName($table) { $options = $this->getConnectionOptions(); - $prefix = $this->tablePrefix($table); + $info = $this->schema()->getPrefixInfo($table); // The fully qualified table name in PostgreSQL is in the form of - // .., but the schema is handled inside the prefix. - return $options['database'] . '.' . $prefix . $table; + // ..
. + return $options['database'] . '.' . $info['schema'] . '.' . $info['table']; } /** diff --git a/lib/Drupal/Core/Database/Driver/pgsql/Schema.php b/lib/Drupal/Core/Database/Driver/pgsql/Schema.php index 766ebfbf35..ab7afab3d5 100644 --- a/lib/Drupal/Core/Database/Driver/pgsql/Schema.php +++ b/lib/Drupal/Core/Database/Driver/pgsql/Schema.php @@ -770,7 +770,7 @@ EOD; if (!$this->indexExists($table, $name)) { return FALSE; } - + // Add the schema if not using the default one. $index_name = $this->ensureIdentifiersLength($table, $name, 'idx'); if ($this->defaultSchema != 'public') { diff --git a/lib/Drupal/Core/Database/Schema.php b/lib/Drupal/Core/Database/Schema.php index 80a68f6e5a..e336398523 100644 --- a/lib/Drupal/Core/Database/Schema.php +++ b/lib/Drupal/Core/Database/Schema.php @@ -67,16 +67,16 @@ abstract class Schema implements PlaceholderInterface { /** * Get information about the table name and schema from the prefix. * - * @param + * @param string $table * Name of table to look prefix up for. Defaults to 'default' because that's * default key for prefix. - * @param $add_prefix + * @param bool $add_prefix * Boolean that indicates whether the given table name should be prefixed. * - * @return + * @return array * A keyed array with information about the schema, table name and prefix. */ - protected function getPrefixInfo($table = 'default', $add_prefix = TRUE) { + public function getPrefixInfo($table = 'default', $add_prefix = TRUE) { $info = [ 'schema' => $this->defaultSchema, 'prefix' => $this->connection->tablePrefix($table), diff --git a/modules/migrate/src/Plugin/migrate/id_map/Sql.php b/modules/migrate/src/Plugin/migrate/id_map/Sql.php index 6bdd51ebf0..77ccbf659e 100644 --- a/modules/migrate/src/Plugin/migrate/id_map/Sql.php +++ b/modules/migrate/src/Plugin/migrate/id_map/Sql.php @@ -265,7 +265,23 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP * The fully qualified map table name. */ public function getQualifiedMapTableName() { - return $this->getDatabase()->getFullQualifiedTableName($this->mapTableName); + $qualifiedMapTableName = NULL; + $connection = $this->getDatabase(); + + switch ($connection->databaseType()) { + case 'pgsql': + // PostgreSQL doesn't support cross DB merges. So only use schema and + // prefixed table name. + $info = $connection->schema()->getPrefixInfo($this->mapTableName); + $qualifiedMapTableName = $info['schema'] . '.' . $info['table']; + break; + + default: + $qualifiedMapTableName = $connection->getFullQualifiedTableName($this->mapTableName); + break; + } + + return $qualifiedMapTableName; } /**