Skip to content

Bug#120948 Add removedLegacyHashingFunctions upgrade check for MySQL 9.7#30

Open
akshatnehra wants to merge 1 commit into
mysql:9.7from
akshatnehra:Bug#120948
Open

Bug#120948 Add removedLegacyHashingFunctions upgrade check for MySQL 9.7#30
akshatnehra wants to merge 1 commit into
mysql:9.7from
akshatnehra:Bug#120948

Conversation

@akshatnehra

@akshatnehra akshatnehra commented Jul 17, 2026

Copy link
Copy Markdown

Description


The MySQL Shell upgrade checker (util.checkForServerUpgrade()) does not detect usage of MD5(), SHA1(), or SHA() functions in database objects when upgrading from 8.4 to 9.6+. These functions were removed from the server binary in MySQL 9.6.0 and moved to component_classic_hashing.

The existing removedFunctions check is registered at version 8.0.11, so its version condition (8.0.11 > 8.4.x) evaluates to false and the check is skipped entirely for 8.4+ source versions. This leaves a gap: if a generated column within any table uses these functions and MySQL server is upgraded to 9.6.0 or later, the table stops working. The server does not re-validate stored generated column expressions during upgrade, and component_classic_hashing cannot help since loadable functions are disallowed in generated column expressions (ERROR 3763). The only recovery path is restoring from a pre-upgrade backup.

How to recreate the issue


  1. Set up a MySQL 8.4 server.
  2. Create a table with a STORED generated column using MD5:
    CREATE TABLE t (id INT PRIMARY KEY, val VARCHAR(255),
      h VARCHAR(32) GENERATED ALWAYS AS (MD5(val)) STORED);
    INSERT INTO t VALUES (1, 'hello', DEFAULT);
  3. Run util.checkForServerUpgrade() targeting 9.7.0:
    mysqlsh root@localhost --util check-for-server-upgrade --target-version=9.7.0
    
  4. Observe that no error or warning is reported for the generated column.
  5. Upgrade to MySQL 9.7.0.
  6. Attempt any operation on the table:
    SELECT * FROM t;
    -- ERROR 3763 (HY000): Expression of generated column 'h' contains a disallowed function: md5.

The table is now permanently inaccessible and SELECT, INSERT, ALTER TABLE DROP COLUMN, SHOW CREATE TABLE, and TRUNCATE all fail with ERROR 3763.

Fix


This patch adds a new removedLegacyHashingFunctions upgrade check that scans 8 object types for usage of the removed functions: views, stored routines, triggers, events, generated columns (STORED and VIRTUAL), CHECK constraints, DEFAULT expressions, and functional indexes.

Severity is split based on recoverability:

  • ERROR for generated columns, functional indexes, CHECK constraints, and DEFAULT expressions as these either permanently brick the table or block the upgrade, and cannot be resolved by installing the component.
  • WARNING for views, routines, triggers, and events as these can be resolved after upgrade by installing component_classic_hashing, or rewritten before upgrading.

The check is registered at version 9.6.0 so it fires for upgrades from 8.4+ to 9.6+

Testing


  • Tested against Docker MySQL 8.4.10 with all 10 object types: 5 errors, 5 warnings as expected.
  • Verified actual upgrade behavior on MySQL 9.7:
    • Generated columns (STORED/VIRTUAL): ERROR 3763, even with component installed that confirms ERROR severity.
    • Functional indexes, CHECK constraints, DEFAULT expressions: server rejects creation that confirms ERROR severity.
    • Views, routines, triggers, events: work correctly after INSTALL COMPONENT 'file://component_classic_hashing' that confirms WARNING severity.

References



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

…9.6+

MD5(), SHA1(), and SHA() were removed from the server binary in MySQL
9.6.0 and moved to component_classic_hashing. Generated columns using
these functions become permanently inaccessible after upgrade since
loadable functions are disallowed in generated column expressions.

This check scans views, routines, triggers, events, generated columns,
CHECK constraints, DEFAULT expressions, and functional indexes for
usage of these removed functions.

Severity is split based on recoverability:
- ERROR for generated columns, functional indexes, CHECK constraints,
  and DEFAULT expressions (blocks upgrade or bricks the table)
- WARNING for views, routines, triggers, and events (recoverable
  post-upgrade by installing component_classic_hashing)

The check is registered at version 9.6.0 so it fires for upgrades
from 8.4+ to 9.6+.

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 your contribution. Please confirm this code is submitted under the terms of the OCA (Oracle's Contribution Agreement) you have previously signed by cutting and pasting the following text as a comment:
"I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it."
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