GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: apply the MySQL comment rules to Dialect.MARIADB by tanjiroK-coder · Pull Request #2891 · JSQLParser/JSqlParser

Conversation

@tanjiroK-coder

@tanjiroK-coder tanjiroK-coder commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

SimpleCharStream.BeginToken applies the MySQL comment rules from #2728 (-- starts a comment only before whitespace or a control character, and /*! ... */ contents are parsed as SQL) only when the dialect is MYSQL. MariaDB's lexer works the same way and also runs its own /*M! ... */ comments, so under Dialect.MARIADB SQL that the server executes was thrown away as a comment:

  1. SELECT 1 /*M! UNION SELECT pw FROM secrets */, SELECT 1 /*! UNION SELECT pw FROM secrets */ and the /*!50000 ... */ form parse as SELECT 1 and TablesNamesFinder finds no table, while MariaDB 13.0.2 returns the rows of secrets.
  2. SELECT a FROM t WHERE a = 1--1 UNION SELECT pw FROM secrets parses as ... WHERE a = 1, while MariaDB reads a = 1 - -1 and runs the UNION.

So a table allowlist or a FeaturesAllowed check run with the MariaDB dialect looks at a different statement from the one the server runs.

The rules now apply to MARIADB too, with MariaDB's own version handling, which I checked against the server: /*M! and /*M!###### are executable, a sixth version digit always belongs to the version (MySQL only takes it before whitespace), and /*!50700 through /*!99999 are skipped while /*M! comments in that range are not. withMySqlServerVersion takes the MariaDB version there (130002 for 13.0.2), and a conditional comment without it still fails instead of being dropped. MYSQL and the other dialects are unchanged. preservesOtherDialectCommentsAndQuotedBodies expected MARIADB to discard /*!90702 +2 */, so it now leaves MARIADB out the way it leaves out MYSQL.

I ran 45 statements on MariaDB 13.0.2 (through mariadb --comments, so the client does not strip them) both as written and as rendered by JSqlParser, and the results match for all of them. The new MySqlCommentTest cases fail before the change and pass after; ./gradlew check and mvn verify pass.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@tanjiroK-coder
fix: apply the MySQL comment rules to Dialect.MARIADB
b991dad
The -- whitespace rule and executable comments were only lexed the
MySQL way under Dialect.MYSQL. MariaDB follows the same rules and also
runs /*M! ... */, so under MARIADB SQL the server executes was dropped
as a comment: SELECT 1 /*M! UNION SELECT pw FROM secrets */ parsed as
SELECT 1. The rules now apply to MARIADB as well, with MariaDB's own
version handling: a sixth digit always belongs to the version, and
/*!50700 through /*!99999 are skipped while /*M! ones are not.

This branch has not been deployed

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

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@tanjiroK-coder
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.