Bug #119672 [ERROR] [MY-013235] [Server] Error in parsing Event while upgrading MySQL version if Event was created in ANSI sql_mode
Submitted: 13 Jan 14:54 Modified: 14 Jan 9:35
Reporter: Vitali Vinahradski (OCA) Email Updates:
Status: Open Impact on me:
None 
Category:MySQL Server: Stored Routines Severity:S3 (Non-critical)
Version:all versions > 8.0 OS:Any
Assigned to: CPU Architecture:Any
Tags: Upgrade failed

[13 Jan 14:54] Vitali Vinahradski
Description:
During the upgrade process from any MySQL server > 8.0 (5.7 upgrade have separate code path which is unaffected by this bug), stored events that use ANSI quotes (double quotes ") fail to parse, resulting in the error `[MY-013235] [Server] Error in parsing Event` and server shutdown. This issue occurs when sql_mode includes ANSI_QUOTES at the event level. The upgrade process appears to ignore the preserved sql_mode of the event during the parsing check, causing valid ANSI SQL syntax to be flagged as invalid.

How to repeat:
1. Start MySQL server of any version greater that 8.0, e.g. 8.0.44

2. Run the following:
mysql> SET GLOBAL sql_mode = 'ANSI';
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE DATABASE testdb;
Query OK, 1 row affected (0.00 sec)

mysql> USE testdb;
Database changed

mysql> CREATE TABLE IF NOT EXISTS "test_table" (
    "id" INT AUTO_INCREMENT PRIMARY KEY,
    "name" VARCHAR(100) NOT NULL,
    "created_at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB;

Query OK, 0 rows affected (0.0159 sec)

mysql> INSERT INTO "test_table" ("name") VALUES ('Test Record 1'), ('Test Record 2');
Query OK, 2 rows affected (0.01 sec)

mysql> DELIMITER $$

mysql> CREATE EVENT IF NOT EXISTS "test_event_ansi_quotes"
ON SCHEDULE EVERY 1 MINUTE
DO
BEGIN
    INSERT INTO "test_table" ("name") 
    VALUES (CONCAT('Event triggered at ', NOW()));
END$$

Query OK, 0 rows affected (0.01 sec)

mysql> DELIMITER ;

mysql> SHOW CREATE EVENT "test_event_ansi_quotes";
+------------------------+--------------------------------------------------------------------------------+-----------+--------------------
-------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------
--------------------------+----------------------+----------------------+--------------------+
| Event                  | sql_mode                                                                       | time_zone | Create Event

                          | character_set_client | collation_connection | Database Collation |
+------------------------+--------------------------------------------------------------------------------+-----------+--------------------
-------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------
--------------------------+----------------------+----------------------+--------------------+
| test_event_ansi_quotes | REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ONLY_FULL_GROUP_BY,ANSI | SYSTEM    | CREATE DEFINER="roo
t"@"%" EVENT "test_event_ansi_quotes" ON SCHEDULE EVERY 1 MINUTE STARTS '2026-01-13 14:22:24' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
    -- Use double quotes for table and column names (valid in ANSI mode)
    INSERT INTO "test_table" ("name")
    VALUES (CONCAT('Event triggered at ', NOW()));
END | utf8mb4              | utf8mb4_0900_ai_ci   | utf8mb4_0900_ai_ci |
+------------------------+--------------------------------------------------------------------------------+-----------+--------------------
-------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------
--------------------------+----------------------+----------------------+--------------------+
1 row in set (0.0009 sec)

3. Upgrade MySQL to any allowed version, e.g. 8.4.7

4. Observe error logs
[mysql-8.4.7]  | 2026-01-13T14:23:58.060139Z 1 [ERROR] [MY-013235] [Server] Error in parsing Event 'testdb'.'test_event_ansi_quotes' during upgrade. 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 '"test_table" ("name")      VALUES (CONCAT('Event triggered at ', NOW())); END' at line 3
[mysql-8.4.7]  | 2026-01-13T14:23:58.061794Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
[mysql-8.4.7]  | 2026-01-13T14:23:58.061816Z 0 [ERROR] [MY-010119] [Server] Aborting
[mysql-8.4.7]  | 2026-01-13T14:23:59.534809Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.4.7)  MySQL Community Server - GPL.
[mysql-8.4.7]  | 2026-01-13T14:23:59.534830Z 0 [System] [MY-015016] [Server] MySQL Server - end.

5. Which is a bug

I've created github repository with docker-compose file and bash scripts to reproduce this issue automatically: https://github.com/VitaliVinahradski/mysql-event-upgrade-bug-reproduction

Suggested fix:
Existing workaround: drop event before upgrade and recreate using standard (backticks) MySQL syntax.

Suggested fix is to modify check_events code in sql/dd/impl/upgrade/server.cc to respect Event's sql_mode
[13 Jan 14:56] Vitali Vinahradski
a patch against 8.4.7 tag which I tested manually

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: 001-fix_ansi_event_upgrade.patch (application/octet-stream, text), 717 bytes.

[13 Jan 15:50] Daniƫl van Eeden
Does the https://dev.mysql.com/doc/mysql-shell/9.5/en/mysql-shell-utilities-upgrade.html detect this issue?
[14 Jan 9:35] Vitali Vinahradski
No, the mysqlsh upgrade checker output you provided did NOT find the ANSI quotes bug.
```
% mysqlsh -- util checkForServerUpgrade root:rootpassword@127.0.0.1:3306 --target-version=8.4.7
...
3) MySQL syntax check for routine-like objects (syntax) No issues found
...
```