Skip to content

MDEV-41606 Support line comments in optimizer hints - #5935

Open
chaitanya-bhardwaj wants to merge 1 commit into
MariaDB:mainfrom
chaitanya-bhardwaj:mdev-41606-hint-comments
Open

chaitanya-bhardwaj wants to merge 1 commit into
MariaDB:mainfrom
chaitanya-bhardwaj:mdev-41606-hint-comments

Conversation

@chaitanya-bhardwaj

@chaitanya-bhardwaj chaitanya-bhardwaj commented Oct 20, 2026 •

Copy link
Copy Markdown

A -- comment inside an optimizer hint used to trigger a syntax warning and cause MariaDB to ignore the hint block. You can now add a note or comment out one hint while the others still work. MDEV-41606

Comments can go between hint tokens, including just before a comma. They start with two dashes followed by whitespace or a control byte and end at a newline or the end of the hint. Dashes inside quoted names keep their meaning, and malformed prefixes such as -x or a bare -- still warn.

All 15 optimizer-hint tests passed on a Linux debug build. The new test also passed in prepared-statement, cursor and view modes. It checks which hints take effect and catches both a missing second-dash check and a missing control-byte check.

I submit this contribution under the BSD-new license.

@CLAassistant

CLAassistant commented Oct 20, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@gkodinov gkodinov added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Oct 21, 2026
@gkodinov gkodinov self-assigned this Oct 21, 2026

@gkodinov gkodinov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! This is a preliminary review.

It's a good first iteration, but it needs more work IMHO. I have drafted some suggestions to improve the diff below.

Please also add a more detailed description either in the jira and a summary of it into the commit message. This should contribute to better documentation.

This should cover:

  • what was the state before (a.k.a. what was wrong)
  • what new functionality is added
    • what is supposed to work
    • what is supposed to not work
    • what is missing (if anything)
  • how was the feature tested

Comment thread sql/opt_hints_parser.cc Resolved
Comment thread sql/opt_hints_parser.cc Resolved
Comment thread mysql-test/main/opt_hints_comments.test Resolved
Comment thread mysql-test/main/opt_hints_comments.test Resolved

@gkodinov gkodinov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Please stand by for the final review.

@gkodinov
gkodinov requested a review from spetrunia October 22, 2026 08:40
@gkodinov gkodinov assigned spetrunia and unassigned gkodinov Oct 22, 2026
@chaitanya-bhardwaj

Copy link
Copy Markdown
Author

Hi @spetrunia, the latest commit now passes all the checks, including the Windows one.

There have also been test and runner changes since Georgi’s approval.

Could you take a look when you have time? thanks.

@DaveGosselin-MariaDB DaveGosselin-MariaDB left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are the vector changes included in this PR? I think that they should be reviewed and delivered separately.

Please squash the commits related to MDEV-41606 together into one commit (don't squash unrelated changes into the commit).

Comment thread sql/opt_hints_parser.cc Resolved
Comment thread sql/opt_hints_parser.cc Resolved
Comment thread sql/opt_hints_parser.cc Resolved
Comment thread sql/opt_hints_parser.cc Resolved
A line comment inside an optimizer hint used to trigger a syntax
warning and cause MariaDB to ignore the hint block. Allow comments
between hint tokens so users can explain or comment out individual
hints.

Skip comments that start with two dashes followed by whitespace or
a control byte inside the hint. Resume scanning at the next newline
or at the end of the hint. Quoted names keep their literal dashes.
Empty hint blocks and malformed prefixes still warn. The hint syntax
still rejects split tokens, # comments and nested block comments.

Test the Jira example, comments around punctuation and numbers, and
warning line numbers. The test checks that -x still warns and that a
hint after a control-byte comment still takes effect.
All 15 optimizer-hint tests passed on a Linux debug build. The new
test also passed in prepared-statement, cursor and view modes.

Assisted-by: Codex:gpt-6-astra
@chaitanya-bhardwaj

Copy link
Copy Markdown
Author

thanks dave for the review
took the unrelated commits out and folded into one commit.
tokenizer now uses a plain loop
the new cases check that -x sttill warns and that the hint on rhe next line still works after a comment introduced by -- and a control byte
the regression failed as expected when i removed either check

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

Labels

External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements.

Development

Successfully merging this pull request may close these issues.

5 participants