Skip to content

dialect(mysql): version checks and fixes, tested on MySQL in Docker - #98

Merged
stbischof merged 1 commit into
eclipse-daanse:mainfrom
dbulahov:main231126_3
Nov 23, 2026
Merged

stbischof merged 1 commit into
eclipse-daanse:mainfrom
dbulahov:main231126_3

Conversation

@dbulahov

Copy link
Copy Markdown
Contributor

What does this PR do?

The dialect wrote SQL that MySQL refused or that lost data. Each case is now run against the server, on the versions around its boundary:

  • PERCENTILE_DISC/CONT: none on any version; MySQL has no such functions and refused WITHIN GROUP with a syntax error
  • regular expressions in SQL from 8.0, whose REGEXP is ICU's; 5.7's Henry Spencer REGEXP refused (?-i), \A and \z, and the expression is matched in Java there
  • upsert without update columns: ON DUPLICATE KEY UPDATE key = key, insert-or-ignore as UpsertSpec says, not a plain INSERT that failed with "Duplicate entry"
  • upsert with update columns: the row alias from 8.0.19, INSERT ... AS new_row ... UPDATE col = new_row.col, instead of VALUES(col), which 8.0.20 deprecates with warning 1287; VALUES(col) before; a dialect without a version writes the alias
  • GROUP_CONCAT: the separator a string literal of its own, a quote or a backslash in it no longer ends it; NULLS FIRST/LAST, which MySQL has not, as an order of col IS NULL before the column; a list longer than group_concat_max_len is cut, as the Javadoc now says
  • triggers: WHEN, which MySQL has not, as an IF around the body; no FOR EACH STATEMENT, which MySQL has not either and a row trigger cannot stand in for: UnsupportedOperationException
  • RENAME INDEX from 5.7; before, renameIndex gives null
  • a column renamed before 8.0 with CHANGE keeps its AUTO_INCREMENT and its COMMENT; a generated column is not renamed

Tested as they were: users from 5.7.8, roles from 8.0, recursive CTEs from 8.0, descending index columns from 8.0, the order by an alias from 5.7.

The Docker tests are in the container package and run with -Dintegration.docker=true on MySQL 5.6, 5.7, 8.0, 8.4 and 9. Their server has a my.cnf of its own: Testcontainers' default sets

The dialect wrote SQL that MySQL refused or that lost data. Each case
is now run against the server, on the versions around its boundary:

- PERCENTILE_DISC/CONT: none on any version; MySQL has no such
  functions and refused WITHIN GROUP with a syntax error
- regular expressions in SQL from 8.0, whose REGEXP is ICU's; 5.7's
  Henry Spencer REGEXP refused (?-i), \A and \z, and the expression is
  matched in Java there
- upsert without update columns: ON DUPLICATE KEY UPDATE key = key,
  insert-or-ignore as UpsertSpec says, not a plain INSERT that failed
  with "Duplicate entry"
- upsert with update columns: the row alias from 8.0.19, INSERT ...
  AS new_row ... UPDATE col = new_row.col, instead of VALUES(col),
  which 8.0.20 deprecates with warning 1287; VALUES(col) before; a
  dialect without a version writes the alias
- GROUP_CONCAT: the separator a string literal of its own, a quote or
  a backslash in it no longer ends it; NULLS FIRST/LAST, which MySQL
  has not, as an order of col IS NULL before the column; a list longer
  than group_concat_max_len is cut, as the Javadoc now says
- triggers: WHEN, which MySQL has not, as an IF around the body; no
  FOR EACH STATEMENT, which MySQL has not either and a row trigger
  cannot stand in for: UnsupportedOperationException
- RENAME INDEX from 5.7; before, renameIndex gives null
- a column renamed before 8.0 with CHANGE keeps its AUTO_INCREMENT and
  its COMMENT; a generated column is not renamed

Tested as they were: users from 5.7.8, roles from 8.0, recursive CTEs
from 8.0, descending index columns from 8.0, the order by an alias
from 5.7.

The Docker tests are in the container package and run with
-Dintegration.docker=true on MySQL 5.6, 5.7, 8.0, 8.4 and 9. Their
server has a my.cnf of its own: Testcontainers' default sets

Signed-off-by: <bulahovdenis@gmail.com>
@stbischof
stbischof merged commit 687aa11 into eclipse-daanse:main Nov 23, 2026
29 checks passed
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