Problem/Motivation

I am trying to update from 8.6.13 to 8.7.

When running the database updates, I am getting the following error:

> [notice] Update started: node_update_8700
> [error] Exception thrown while performing a schema update. SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'NOT NULL' at line 1: ALTER TABLE {node_field_data} CHANGE `uid` `uid` NOT NULL; Array
> (
> )
>
> [error] Update failed: node_update_8700

All the other update hooks ran successfully.

Server version: 10.1.38-MariaDB

Steps to reproduce

Proposed resolution

The proposed resolution was to wait until 8.7.2 was release, see #12.

Remaining tasks

If you are experiencing this problem, add a comment including the database and version you are using.
Determine if this is limited to MariaDB, or perhaps database not supplied with Drupal core.

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

JohannFischmann created an issue. See original summary.

amateescu’s picture

Issue tags: +8.7.0 update

@JohannFischmann, what version of MariaDB are you using?

cilefen’s picture

I thought the same when I saw this.

cilefen’s picture

Title: Unable to update from 8.6.13 to 8.7 » Unable to update from 8.6.13 to 8.7: "SQLSTATE[42000]: Syntax error or access violation"
Priority: Critical » Major
Jadelvalia’s picture

Server version: 10.1.38-MariaDB - Source distribution

jbfelix’s picture

Same error, but for taxonomy terms, it seems to be related to the entity field definition update process who's no more supported by Drupal 8.7.

I get this error when i try to list terms:

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AS expression FROM tfr INNER JOIN tr ON tfr. = tr. AND tr. = 0 INNER JOIN (S' at line 1: SELECT tfr.tid AS tid, MAX(tfr.) AS expression FROM {} tfr INNER JOIN {} tr ON tfr. = tr. AND tr. = 0 INNER JOIN (SELECT t.tid AS tid, t.langcode AS langcode, MAX(t.) AS expression FROM {} t WHERE t. = :db_condition_placeholder_0 GROUP BY t.tid, t.langcode) mr ON tfr. = mr. AND tfr.langcode = mr.langcode GROUP BY tfr.tid; Array ( [:db_condition_placeholder_0] => 1 ) in Drupal\taxonomy\TermStorage->getTermIdsWithPendingRevisions() (line 404 of /home/clients/abfc430b1c3195444/sitename/core/modules/taxonomy/src/TermStorage.php).
Severity

And this error in the status report:

Entity/field definitions
Mismatched entity and/or field definitions
The following changes were detected in the entity type and field definitions.
Taxonomy term
The Taxonomy term entity type needs to be updated.
The Revision ID field needs to be installed.
The Revision create time field needs to be installed.
The Revision user field needs to be installed.
The Revision log message field needs to be installed.
The Default revision field needs to be installed.
The Revision translation affected field needs to be installed.
Custom menu link
The Custom menu link entity type needs to be updated.
The Revision ID field needs to be installed.
The Revision create time field needs to be installed.
The Revision user field needs to be installed.
The Revision log message field needs to be installed.
The Default revision field needs to be installed.
The Revision translation affected field needs to be installed.

How to fix this ?

Thanks

amateescu’s picture

@jbfelix, those errors in the status report mean that you need to run the database updates for 8.7.0, either with Drush or via update.php.

jbfelix’s picture

@amateescu

That's what i did (with drush and update.php), but the entity fields definitions are not updated.
No additional error.

amateescu’s picture

@jbfelix, do you have a database backup that could be restored and then try to run the updates again? The problem seems to be that Drupal thinks it ran all the updates, when in fact it didn't.

amateescu’s picture

Status: Active » Postponed (maintainer needs more info)

@JohannFischmann, I installed MariaDB 10.1.38 locally in a docker container and tried to reproduce your issue, but I couldn't. This is the SQL query generated by the node_update_8700() function:

ALTER TABLE node_field_data CHANGE `uid` `uid` INT unsigned NOT NULL COMMENT 'The ID of the target entity.';

This query is generated by \Drupal\Core\Database\Driver\mysql\Schema::changeField(). Are you using a database driver that's not provided by Drupal core?

jbfelix’s picture

@amateescu

I have a backup and i have already re-tested an update but the errors are still showing.

amateescu’s picture

@jbfelix, then my advice is to wait a few days until 8.7.2 is released, because it will contain quite a few upgrade path fixes..

jbfelix’s picture

@amateescu
OK Thanks

pameeela’s picture

@JohannFischmann @jbfelix Thanks for taking part in this issue. If you'd like to help us make sure the 8.8.0 update is as smooth as possible, please consider signing up for the beta testing program at https://goo.gl/forms/bMBTMRSY3sKEscUJ3

sajiniantony’s picture

Accessing Taxonomy overview page throws error after upgrade to 8.7.1 Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AS expression FROM tfr INNER JOIN tr ON tfr. = tr. AND tr. = 0 INNER JOIN (S' at line 1: SELECT tfr.tid AS tid, MAX(tfr.) AS expression FROM {} tfr INNER JOIN {} tr ON tfr. = tr. AND tr. = 0 INNER JOIN (SELECT t.tid AS tid, t.langcode AS langcode, MAX(t.) AS expression FROM {} t WHERE t. = :db_condition_placeholder_0 GROUP BY t.tid, t.langcode) mr ON tfr. = mr. AND tfr.langcode = mr.langcode GROUP BY tfr.tid; Array ( [:db_condition_placeholder_0] => 1 ) in Drupal\taxonomy\TermStorage->getTermIdsWithPendingRevisions() (line 404 of /opt/web/core/modules/taxonomy/src/TermStorage.php).

Any help is apprceited.

suresh.senthatti’s picture

Do you have any update on this issue

Murz’s picture

I got similar problem with taxonomy terms after some several updates from 8.6.0 to 8.7.x - now I can't open taxonomy vocabulary pages with error:

<em class="placeholder">Drupal\Core\Database\DatabaseExceptionWrapper</em>: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near &#039;) AS expression
FROM
 tfr
INNER JOIN  tr ON tfr. = tr. AND tr. = 0
INNER JOIN (S&#039; at line 1: SELECT tfr.tid AS tid, MAX(tfr.) AS expression
FROM
{} tfr
INNER JOIN {} tr ON tfr. = tr. AND tr. = 0
INNER JOIN (SELECT t.tid AS tid, t.langcode AS langcode, MAX(t.) AS expression
FROM
{} t
WHERE t. = :db_condition_placeholder_0
GROUP BY t.tid, t.langcode) mr ON tfr. = mr. AND tfr.langcode = mr.langcode
GROUP BY tfr.tid; Array
(
    [:db_condition_placeholder_0] =&gt; 1
)
 in <em class="placeholder">Drupal\taxonomy\TermStorage-&gt;getTermIdsWithPendingRevisions()</em> (line <em class="placeholder">404</em> of <em class="placeholder">core/modules/taxonomy/src/TermStorage.php</em>). <pre class="backtrace">Drupal\Core\Database\Statement-&gt;execute(Array, Array) (Line: 631)

All updates are correctly installed but drush entup shows outdated entity schemas. When I try to update entity schema via devel_entity_updates module - I got the error:

In DevelEntityDefinitionUpdateManager.php line 169:
                                                                                         
  The entity schema update for the taxonomy_term entity type requires a data migration.  

Murz’s picture

Manually repeating Taxonomy module update functions via:

drush eval "drupal_set_installed_schema_version('taxonomy', 8503);"
drupal upex

don't help too - they executes normally without erros:

 Switch site into maintenance mode
 Executing required previous updates
 Executing update function "8601" of module "taxonomy"
 Executing update function "8701" of module "taxonomy"
 Operating in maintenance mode off

 // update:entities
 Operating in maintenance mode on
 Starting the entity updates
 Finished the entity updates
 Operating in maintenance mode off
 // cache:rebuild

 Rebuilding cache(s), wait a moment please.

                                                                                                                        
 [OK] Done clearing cache(s).                                                                                           
                                                                                                                        

But the fatal error on taxonomy pages are still here.

effortDee’s picture

I may be having this same issue.

I can't access taxonomy overview pages at all.

mmjvb’s picture

Those having issues with updating to 8.7.0 might try to update to the 8.6.x at the time of release of 8.7.0 first. The updates introduced in 8.6.x releases are meant to be executed with the code of 8.6.x. With 8.7.0 removing functionality, bad practice but it happened, the 8.6.x updates don't do what they were supposed to with 8.6 code when run with 8.7 code.

parashutiki’s picture

8.7.3 same problem. But! On localhost MariaDB 5.5.58 and working fine. But on prod server 5.5.5 - fails.

I tried to run generated query directly on MariaDB 5.5.58
`
ALTER TABLE {versions} CHANGE
`file_version__v1` `file_version__v1` NOT NULL;
`
But it is incorrect.

mmjvb’s picture

@parashutiki Looks like an unrelated issue, suggest to create your own.
The syntax error is because the datatype is missing: CHANGE [old_column] [new_column] [datatype] [ NOT NULL | NULL ]

parashutiki’s picture

@mmjvb sorry for disinformation. it not a problem. not working on both servers.
I have used combined field for ContentType and it is the place where error appears. I tried many approaches, but what i got = for some period of time message for inconsistence of fields is disappear and soon later appear again, so i decided do not fight, because i do not understood where could be a problem and what is the reason of i see this message on Status page.

kappaluppa’s picture

Still experiencing this problem on 8.7.1 and 8.8.0 and 8.8.1

Entity/field definitions
Mismatched entity and/or field definitions
The following changes were detected in the entity type and field definitions.
Content

The node.field_staff_short_description field needs to be updated.

Taxonomy term

The Taxonomy term entity type needs to be updated.
The Revision ID field needs to be installed.
The Revision create time field needs to be installed.
The Revision user field needs to be installed.
The Revision log message field needs to be installed.
The Published field needs to be installed.
The Default revision field needs to be installed.
The Revision translation affected field needs to be installed.

Custom menu link

The Custom menu link entity type needs to be updated.
The Revision ID field needs to be installed.
The Revision create time field needs to be installed.
The Revision user field needs to be installed.
The Revision log message field needs to be installed.
The Default revision field needs to be installed.
The Revision translation affected field needs to be installed.

also

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') AS expression FROM tfr INNER JOIN tr ON tfr. = tr. AND tr. = 0 INNER JOIN (S' at line 1: SELECT tfr.tid AS tid, MAX(tfr.) AS expression FROM {} tfr INNER JOIN {} tr ON tfr. = tr. AND tr. = 0 INNER JOIN (SELECT t.tid AS tid, t.langcode AS langcode, MAX(t.) AS expression FROM {} t WHERE t. = :db_condition_placeholder_0 GROUP BY t.tid, t.langcode) mr ON tfr. = mr. AND tfr.langcode = mr.langcode GROUP BY tfr.tid; Array ( [:db_condition_placeholder_0] => 1 ) in Drupal\taxonomy\TermStorage->getTermIdsWithPendingRevisions() (line 404 of /srv/bindings/21f6285537fa4f6e905fbb0c02565a48/code/core/modules/taxonomy/src/TermStorage.php).

For reference: Drupal 8.7.0 Release notes:

Entity and field system changes

Entity schema operations will now leave backup tables in place for inspection. See the change record on entity update backup data for more details including how to disable this functionality.

Custom menu links and taxonomy terms are now revisionable, which allows them to be used in editorial workflows (similarly to nodes, media, and custom blocks). These changes involve an upgrade path and updates to the respective entity storages. Custom code updating these entities programmatically may need to update to take account revision creation. This may also impact API clients, exported default content, and custom database queries. See the change records for details:
Custom menu links are revisionable
Taxonomy terms are revisionable

Serialized properties of base fields are now automatically unserialized to be consistent with configurable fields. Existing workarounds for this bug might need to be adjusted if they relied on the old behavior of passing a string to those fields. Read the change record about loading serialized field properties.

Have info on what happened, but not how to deal with it:
Support for automatic entity updates has been removed: https://www.drupal.org/node/3034742

Version: 8.7.0 » 8.7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.

Version: 8.7.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Branches prior to 8.8.x are not supported, and Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

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

Adsyy’s picture

Hi, does anyone have an update on this problem ?

effortDee’s picture

Adsymon no, I had to completely rebuild 3 of my sites which had this issue which took me a few weeks to copy all taxonomy terms, content, functionality over to new sites on lastest d8.9.

Adsyy’s picture

@effortDee Okok thanks for your answer. I "resolved" this problem by commenting hook_update() who cause this problem and run drush updb after. I dont think it's a good way but it works for me.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev
quietone’s picture

Issue summary: View changes

Update Issue Summary.

If you have this problem and fixed it, add a comment explaining what you as it might help others.

If you are experiencing this problem, add a comment including the database and version you are using.

Thanks

quietone’s picture

Issue tags: +Bug Smash Initiative

Adding tag

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Wolf_22’s picture

I know I'm late to the game in this but I just thought that I'd throw in my experience when trying to use the 8.x-1.10 Address module. Installing it into my 9.4.3 / PHP 8.0.13 / MariaDB 10.6.5 environment was a breeze, but using the Drupal UI to add an address field into one of my content types resulted in the following error:

There was a problem creating field Home Address: Exception thrown while performing a schema update. SQLSTATE[42000]: Syntax error or access violation: 1118 Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline.: CREATE TABLE "user__field_home_address" ( `bundle` VARCHAR(128) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL DEFAULT '' COMMENT 'The field instance bundle to which this row belongs, used when deleting a field instance', `deleted` TINYINT NOT NULL DEFAULT 0 COMMENT 'A boolean indicating whether this data item has been deleted', `entity_id` INT unsigned NOT NULL COMMENT 'The entity id this data is attached to', `revision_id` INT unsigned NOT NULL COMMENT 'The entity revision id this data is attached to, which for an unversioned entity type is the same as the entity id', `langcode` VARCHAR(32) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL DEFAULT '' COMMENT 'The language code for this data item.', `delta` INT unsigned NOT NULL COMMENT 'The sequence number for this data item, used for multi-value fields', `field_home_address_langcode` VARCHAR(32) NULL DEFAULT NULL, `field_home_address_country_code` VARCHAR(2) NULL DEFAULT NULL, `field_home_address_administrative_area` VARCHAR(255) NULL DEFAULT NULL, `field_home_address_locality` VARCHAR(255) NULL DEFAULT NULL, `field_home_address_dependent_locality` VARCHAR(255) NULL DEFAULT NULL, `field_home_address_postal_code` VARCHAR(255) NULL DEFAULT NULL, `field_home_address_sorting_code` VARCHAR(255) NULL DEFAULT NULL, `field_home_address_address_line1` VARCHAR(255) NULL DEFAULT NULL, `field_home_address_address_line2` VARCHAR(255) NULL DEFAULT NULL, `field_home_address_organization` VARCHAR(255) NULL DEFAULT NULL, `field_home_address_given_name` VARCHAR(255) NULL DEFAULT NULL, `field_home_address_additional_name` VARCHAR(255) NULL DEFAULT NULL, `field_home_address_family_name` VARCHAR(255) NULL DEFAULT NULL, PRIMARY KEY (`entity_id`, `deleted`, `delta`, `langcode`), INDEX `bundle` (`bundle`), INDEX `revision_id` (`revision_id`) ) ENGINE = InnoDB DEFAULT CHARACTER SET utf8mb4 COMMENT 'Data storage for user field field_home_address.'; Array ( )

I've lodged a support request in their issues queue but thought I'd post about this on here as well given the context. For whatever it's worth, I tried this module against a MySQL backend and had no problems at all. I think it's a MariaDB issue with me or else something that might be misconfigured in my MariaDB settings. Just not sure what it might be...

cilefen’s picture

@Wolf_22 The error you posted above, "1118 Row size too large", is different from the one reported in this issue.

cilefen’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)
ash2303’s picture

Attaching files that I have done after upgrading to Drupal 9.4, not sure if this will work for everyone but worth a try.
As usual, take DB backup before running these.

sepa_cleversoft’s picture

I also have the same problem, and I cannot see the taxonomy term overview page. I get this error:

Drupal\Core\Database\DatabaseExceptionWrapper: Exception in Taxonomy[taxonomy]: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM "config_taxonomy_vocabulary" "config_taxonomy_vocabulary" LIMIT 10 OFFSET 0' at line 1: SELECT FROM "config_taxonomy_vocabulary" "config_taxonomy_vocabulary" LIMIT 10 OFFSET 0; Array ( ) in main() (line 19 of index.php).

Does anybody have some workaround or fix for this? Thank you.

piyushc9r36’s picture

"PHP message: Uncaught PHP Exception Drupal\Core\Database\DatabaseExceptionWrapper: "SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ORDER BY LENGTH(redirect_source__query) DESC' at line 1: SELECT rid FROM "redirect" WHERE hash IN () ORDER BY LENGTH(redirect_source__query) DESC; Array
(
)

Anyone please help

jefw’s picture

Related problem: after loading a backup from two days ago (software and DB), emptying the caches, waiting a few minutes, the website worked for about 10 minutes. Then we got this message on several tables (cache..., watchdog). We can repeat this unlimited. We can assume it's not a syntax error.
Apache, drupal 9.5.5, PHP 8.1.17, MYSQL 5.7.40
We are a senior club.
Thanks in advance.

The website encountered an unexpected error. Please try again later.
Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42000]: Syntax error or access violation: 1142 INSERT command denied to user '...............' for table 'watchdog': INSERT INTO "watchdog"

The website encountered an unexpected error. Please try again later.
Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42000]: Syntax error or access violation: 1142 INSERT, UPDATE command denied to user '................' for table 'cache_config': INSERT INTO "cache_config"