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

x0r1x created an issue. See original summary.

x0r1x’s picture

Issue tags: +PostgreSQL, +schema, +insert, +update

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

RoSk0’s picture

RoSk0’s picture

Status: Active » Closed (duplicate)