Skip to content

vtgate: Reject unqualified * after comma in SELECT list#19475

Open
arthurschreiber wants to merge 2 commits intomainfrom
fix/parser-reject-unqualified-star
Open

vtgate: Reject unqualified * after comma in SELECT list#19475
arthurschreiber wants to merge 2 commits intomainfrom
fix/parser-reject-unqualified-star

Conversation

@arthurschreiber
Copy link
Member

@arthurschreiber arthurschreiber commented Feb 25, 2026

Description

MySQL only allows unqualified * as the first expression in a SELECT list. After a comma, only qualified table.* is permitted (e.g. SELECT a, t.* FROM t is fine, but SELECT a, * FROM t is a syntax error). The Vitess parser accepted * in any position, diverging from MySQL behavior.

This adds a check in the select_expression_list grammar rule to reject unqualified * when it appears after a comma.

MySQL behavior reference:

Query MySQL Result
SELECT * FROM t OK
SELECT *, a FROM t OK
SELECT a, t.* FROM t OK
SELECT t.*, t.* FROM t OK
SELECT a, * FROM t ERROR 1064
SELECT *, * FROM t ERROR 1064

Note

This means that some queries that worked in Vitess previously might fail after this change.

This is only relevant for queries targeting tables in sharded keyspaces due to the automatic expansion of unqualified * expressions.

Queries against unsharded keyspaces would have failed even before this fix once they reached MySQL.

Related Issue(s)

N/A

Checklist

  • "Backport to:" labels have been added if this change should be back-ported to release branches
  • If this change is to be back-ported to previous releases, a justification is included in the PR description
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on CI?
  • Documentation was added or is not required

Deployment Notes

N/A

AI Disclosure

Most of this PR was written by Claude Code.

@github-actions github-actions bot added this to the v24.0.0 milestone Feb 25, 2026
@vitess-bot vitess-bot bot added NeedsWebsiteDocsUpdate What it says NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsIssue A linked issue is missing for this Pull Request NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels Feb 25, 2026
@vitess-bot
Copy link
Contributor

vitess-bot bot commented Feb 25, 2026

Review Checklist

Hello reviewers! 👋 Please follow this checklist when reviewing this Pull Request.

General

  • Ensure that the Pull Request has a descriptive title.
  • Ensure there is a link to an issue (except for internal cleanup and flaky test fixes), new features should have an RFC that documents use cases and test cases.

Tests

  • Bug fixes should have at least one unit or end-to-end test, enhancement and new features should have a sufficient number of tests.

Documentation

  • Apply the release notes (needs details) label if users need to know about this change.
  • New features should be documented.
  • There should be some code comments as to why things are implemented the way they are.
  • There should be a comment at the top of each new or modified test to explain what the test does.

New flags

  • Is this flag really necessary?
  • Flag names must be clear and intuitive, use dashes (-), and have a clear help text.

If a workflow is added or modified:

  • Each item in Jobs should be named in order to mark it as required.
  • If the workflow needs to be marked as required, the maintainer team must be notified.

Backward compatibility

  • Protobuf changes should be wire-compatible.
  • Changes to _vt tables and RPCs need to be backward compatible.
  • RPC changes should be compatible with vitess-operator
  • If a flag is removed, then it should also be removed from vitess-operator and arewefastyet, if used there.
  • vtctl command output order should be stable and awk-able.

@arthurschreiber arthurschreiber changed the title Reject unqualified * after comma in SELECT list (MySQL compat) vtgate: Reject unqualified * after comma in SELECT list Feb 25, 2026
@promptless
Copy link
Contributor

promptless bot commented Feb 25, 2026

📝 Documentation updates detected!

New suggestion: Document SELECT expression syntax rules for * wildcard


Tip: Tag @Promptless in GitHub PR comments to guide documentation changes during code review 🐙

@arthurschreiber arthurschreiber added Backport to: release-22.0 Needs to be backport to release-22.0 Backport to: release-23.0 Needs to be backport to release-23.0 and removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says NeedsIssue A linked issue is missing for this Pull Request NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels Feb 25, 2026
@arthurschreiber
Copy link
Member Author

I dismissed Promptless' documentation suggestion, because I don't think we need to document behavior where Vitess and MySQL match (because that should be the "default" behavior).

MySQL only allows unqualified `*` as the first expression in a SELECT
list. After a comma, only qualified `table.*` is permitted. Add a check
in the `select_expression_list` grammar rule to reject unqualified `*`
when it appears after a comma, matching MySQL behavior.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Arthur Schreiber <arthur@planetscale.com>
@arthurschreiber arthurschreiber force-pushed the fix/parser-reject-unqualified-star branch from 0b45ea6 to 36f409c Compare February 25, 2026 10:25
Update two plan test cases that used unqualified `*` after a comma,
which is now rejected at parse time.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Arthur Schreiber <arthur@planetscale.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backport to: release-22.0 Needs to be backport to release-22.0 Backport to: release-23.0 Needs to be backport to release-23.0 Component: Query Serving Type: Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant