Skip to content

Add 8.4 and 9.x reserved keywords to the upgrade check - #41

Open
y2kwak wants to merge 1 commit into
mysql:masterfrom
y2kwak:reserved-keywords-8.4-9.x
Open

Add 8.4 and 9.x reserved keywords to the upgrade check#41
y2kwak wants to merge 1 commit into
mysql:masterfrom
y2kwak:reserved-keywords-8.4-9.x

Conversation

@y2kwak

@y2kwak y2kwak commented Aug 26, 2026

Copy link
Copy Markdown

Description

The upgrade checker's reserved-keywords check reports database objects whose names collide with words that become reserved in the target server version (get_reserved_keywords_check in modules/util/upgrade_checker/upgrade_check_creators.cc). It builds an IN (...) list of keywords via an add_keywords(version, words) helper that includes a set of words only when the upgrade crosses that version, and the check is registered against the same crossing versions (register_reserved in modules/util/upgrade_checker/upgrade_check_registry.cc).

Both the keyword list and the registration stopped at 8.0.31. This caused two problems for upgrades to 8.4 and the 9.x series:

  1. Missing keywords. Words that became reserved after 8.0.31 — QUALIFY, TABLESAMPLE (8.4.0), LIBRARY (9.2.0) and EXTERNAL (9.4.0) — were never added, so objects named after them were not reported.
  2. Check never ran. Because the check was registered only for the 8.0.11–8.0.31 crossings, it was not even scheduled when the source server was already past 8.0.31. The common 8.0 → 8.4 upgrade skipped the check entirely.

As a result, the objects upgrade fine, but referencing their names unquoted afterward fails on the target (the word is now reserved), and util.checkForServerUpgrade() flagged nothing - so there was no prompt to add backticks or rename before upgrading.

Fix

Add the words reserved since 8.0.31 and register the check for their crossings:

  • MANUAL, PARALLEL — reserved in 8.4.0 but became nonreserved again in 8.4.11
  • QUALIFY, TABLESAMPLE — reserved in 8.4.0
  • LIBRARY — reserved in 9.2.0
  • EXTERNAL — reserved in 9.4.0

To express the MANUAL/PARALLEL window, add_keywords gains an optional upper-bound version; those words are contributed only for targets below 8.4.11. register_reserved is extended with 8.4.0, 9.2.0 and 9.4.0 so the check is scheduled for those upgrade paths (including 8.0 → 8.4, which previously skipped it). Words that were already reserved on the source server are not re-reported.

USE sbtest;

CREATE TABLE MANUAL(id INT);
CREATE TABLE PARALLEL(id INT);
CREATE TABLE QUALIFY(id INT);
CREATE TABLE TABLESAMPLE(id INT);

mysql> show tables;
+------------------+
| Tables_in_sbtest |
+------------------+
| MANUAL           |
| PARALLEL         |
| QUALIFY          |
| TABLESAMPLE      |
+------------------+
4 rows in set (0.00 sec)
{
    "serverAddress": "localhost:33071",
    "serverVersion": "8.0.45 - MySQL Community Server - GPL",
    "targetVersion": "8.4.8",
    "errorCount": 0,
    "warningCount": 4,
    "noticeCount": 0,
    "summary": "No fatal errors were found that would prevent an upgrade, but some potential issues were detected. Please ensure that the reported issues are not significant before upgrading.",
    "checksPerformed": [
        {
            "id": "reservedKeywords",
            "title": "Usage of db objects with names conflicting with new reserved keywords",
            "status": "OK",
            "description": "Warning: The following objects have names that conflict with new reserved keywords. Ensure queries sent by your applications use `quotes` when referring to them or they will result in errors.",
            "documentationLink": "https://dev.mysql.com/doc/refman/en/keywords.html",
            "detectedProblems": [
                {
                    "level": "Warning",
                    "dbObject": "sbtest.MANUAL",
                    "description": "Table name",
                    "dbObjectType": "Table"
                },
                {
                    "level": "Warning",
                    "dbObject": "sbtest.PARALLEL",
                    "description": "Table name",
                    "dbObjectType": "Table"
                },
                {
                    "level": "Warning",
                    "dbObject": "sbtest.QUALIFY",
                    "description": "Table name",
                    "dbObjectType": "Table"
                },
                {
                    "level": "Warning",
                    "dbObject": "sbtest.TABLESAMPLE",
                    "description": "Table name",
                    "dbObjectType": "Table"
                }
            ],
            "solutions": []
        }
    ],
    "manualChecks": []
}

{
    "serverAddress": "localhost:33071",
    "serverVersion": "8.0.45 - MySQL Community Server - GPL",
    "targetVersion": "8.4.11",
    "errorCount": 0,
    "warningCount": 2,
    "noticeCount": 0,
    "summary": "No fatal errors were found that would prevent an upgrade, but some potential issues were detected. Please ensure that the reported issues are not significant before upgrading.",
    "checksPerformed": [
        {
            "id": "reservedKeywords",
            "title": "Usage of db objects with names conflicting with new reserved keywords",
            "status": "OK",
            "description": "Warning: The following objects have names that conflict with new reserved keywords. Ensure queries sent by your applications use `quotes` when referring to them or they will result in errors.",
            "documentationLink": "https://dev.mysql.com/doc/refman/en/keywords.html",
            "detectedProblems": [
                {
                    "level": "Warning",
                    "dbObject": "sbtest.QUALIFY",
                    "description": "Table name",
                    "dbObjectType": "Table"
                },
                {
                    "level": "Warning",
                    "dbObject": "sbtest.TABLESAMPLE",
                    "description": "Table name",
                    "dbObjectType": "Table"
                }
            ],
            "solutions": []
        }
    ],
    "manualChecks": []
}

Release Notes

Fixed an upgrade-checker issue where objects (schemas, tables, columns, routines, views, triggers, events) whose names match keywords that became reserved in MySQL 8.4 or 9.x — QUALIFY, TABLESAMPLE, LIBRARY, EXTERNAL — were not reported during util.checkForServerUpgrade(). For upgrades from a source newer than 8.0.31 (for example 8.0 to 8.4), the reserved-keywords check was not run at all; it now runs and reports such names so they can be quoted before the upgrade.

Testing

New/updated cases:

  • unittest/modules/util/upgrade_checker/upgrade_check_creators_t.cc - asserts the generated keyword list per source/target pair: 8.0→8.4.8 includes QUALIFY/TABLESAMPLE/MANUAL/PARALLEL; 8.0→8.4.11 drops MANUAL/PARALLEL (the un-reserved boundary) while keeping QUALIFY/TABLESAMPLE; 8.4.0→9.2.0 adds only LIBRARY; 8.4.0→9.4.0 adds LIBRARY and EXTERNAL; 9.2.0→9.4.0 adds only EXTERNAL (source already reserves LIBRARY).
  • unittest/modules/util/upgrade_checker/upgrade_check_registry_t.cc  - extended to assert the check is available for the 8.4.0, 9.2.0 and 9.4.0 crossings and unavailable for ranges that cross none (e.g. 8.4.0→8.4.11), correcting the prior assertion that treated 8.0.31→ as unavailable.

Copyright

This contribution is under the OCA signed by Amazon and covering submissions to the MySQL project.

The reserved keywords check only knew about words reserved up to 8.0.31,
and wasn't registered for any later version, so it missed newer keywords
and didn't run at all for upgrades starting past 8.0.31 (e.g. 8.0 to 8.4).

Add the words reserved since then -- QUALIFY and TABLESAMPLE (8.4.0),
LIBRARY (9.2.0) and EXTERNAL (9.4.0) -- and register the check for those
crossings. MANUAL and PARALLEL were reserved in 8.4.0 but nonreserved again
in 8.4.11, so add_keywords gains an optional upper-bound version to report
them only below 8.4.11.

Adds unit tests for the generated keyword list (including the 8.4.11
boundary) and the new registry crossings.

This contribution is under the OCA signed by Amazon and covering
submissions to the MySQL project.
@mysql-oca-bot

Copy link
Copy Markdown

Hi, thank you for submitting this pull request. In order to consider your code we need you to sign the Oracle Contribution Agreement (OCA). Please review the details and follow the instructions at https://oca.opensource.oracle.com/
Please make sure to include your MySQL bug system user (email) in the returned form.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants