In database PostgreSQL 9.5.5 I have schema "dlu" and table "worksheets", after Drupal update 8.2.7->8.3.0 I got error, when inserting or updating "dlu.worksheets" table with '\Drupal::database()->update('dlu.worksheets')' and '\Drupal::database()->insert('dlu.worksheets')' functions.
Message Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42602]: Invalid name: 7 ERROR: invalid name syntax LINE 6: AND pg_attribute.attrelid = '.dlu.worksheets'::regclass ^: SELECT pg_attribute.attname AS column_name, format_type(pg_attribute.atttypid, pg_attribute.atttypmod) AS data_type, pg_get_expr(pg_attrdef.adbin, pg_attribute.attrelid) AS column_default FROM pg_attribute LEFT JOIN pg_attrdef ON pg_attrdef.adrelid = pg_attribute.attrelid AND pg_attrdef.adnum = pg_attribute.attnum WHERE pg_attribute.attnum > 0 AND NOT pg_attribute.attisdropped AND pg_attribute.attrelid = :key::regclass AND (format_type(pg_attribute.atttypid, pg_attribute.atttypmod) = 'bytea' OR pg_attrdef.adsrc LIKE 'nextval%'); Array ( [:key] => .dlu.worksheets ) in Drupal\dlu\Form\addForm->submitForm() (line 173 of /var/www/qbit/modules/dlu/src/Form/addForm.php).
PostgreSQL ERROR message (problem with dot before "dlu" schema name):
2017-04-08 21:36:52 EEST qbit ERROR: invalid name syntax at character 409
2017-04-08 21:36:52 EEST qbit STATEMENT: SELECT pg_attribute.attname AS column_name, format_type(pg_attribute.atttypid, pg_attribute.atttypmod) AS data_type, pg_get_expr(pg_attrdef.adbin, pg_attribute.attrelid) AS column_default
FROM pg_attribute
LEFT JOIN pg_attrdef ON pg_attrdef.adrelid = pg_attribute.attrelid AND pg_attrdef.adnum = pg_attribute.attnum
WHERE pg_attribute.attnum > 0
AND NOT pg_attribute.attisdropped
AND pg_attribute.attrelid = '.dlu.worksheets'::regclass
AND (format_type(pg_attribute.atttypid, pg_attribute.atttypmod) = 'bytea'
OR pg_attrdef.adsrc::text LIKE 'nextval%')
Problem temporary solved with comment out last 3 lines bellow (core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php)
public function queryTableInformation($table) {
// Generate a key to reference this table's information on.
$key = $this->connection->prefixTables('{' . $table . '}');
// Take into account that temporary tables are stored in a different schema.
// \Drupal\Core\Database\Connection::generateTemporaryTableName() sets the
// 'db_temporary_' prefix to all temporary tables.
if (strpos($key, '.') === FALSE && strpos($table, 'db_temporary_') === FALSE) {
$key = 'public.' . $key;
}
// else {
// $key = $this->getTempNamespaceName() . '.' . $key;
// }
Comments
Comment #2
x0r1x CreditAttribution: x0r1x commentedComment #4
RoSk0Comment #5
RoSk0Closing as a duplicate of #1060476: Multiple issues when PostgreSQL is used with non-public schema.