Problem/Motivation
When updating to Drupal 9.3 an error occurs when the MySQL system variable "sql_require_primary_key" is set to ON
, leaving the database in an undesired state (hence the reason I've set priority to "Critical").
The error is triggered by user_update_9301
:
[error] SQLSTATE[HY000]: General error: 3750 Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Add a primary key to the table or unset this variable to avoid this message. Note that tables without a primary key can cause performance problems in row-based replication, so please consult your DBA before changing this setting.: ALTER TABLE "users" DROP PRIMARY KEY;
> [error] Update failed: user_update_9301
[error] Update aborted by: user_update_9301
[error] Finished performing updates.
Some managed database services require this to avoid replication issues.
Steps to reproduce
The error occurs when applying updates to the database. Trying to update a Drupal website to 9.3
with the MySQL system variable "sql_require_primary_key" set to ON
triggers the error.
Proposed resolution
In user_update_9301
: dropping the old primary key and adding the new one needs to happen in one statement.
Remaining tasks
Patch needs review.
Data model changes
No changes to the model are required, only the way schema changes are executed in user_update_9301
needs to be altered.
Release notes snippet
Fixed an issue where an error is triggered executing update user_update_9301
when updating to Drupal 9.3 on a MySQL database with the system variable "sql_require_primary_key" set to "ON".