Skip to content

sqlparser: accept boolean expressions in generated columns - #503

Closed
sciyoshi wants to merge 1 commit into
dolthub:mainfrom
sciyoshi:fix/generated-boolean-expression
Closed

sciyoshi wants to merge 1 commit into
dolthub:mainfrom
sciyoshi:fix/generated-boolean-expression

Conversation

@sciyoshi

@sciyoshi sciyoshi commented Nov 4, 2026

Copy link
Copy Markdown

Generated columns such as small BOOL GENERATED ALWAYS AS (value < 8) VIRTUAL currently fail to parse unless the comparison has an extra pair of parentheses. Accept the full expression production in both generated-column syntaxes while preserving their outer ParenExpr, so existing DDL formatting and doubly parenthesized expressions keep working.

Fixes dolthub/dolt#12343.

Regression coverage exercises comparisons, IS NULL, BETWEEN, combined AND/OR/NOT, and arithmetic across abbreviated/full syntax, omitted/VIRTUAL/STORED persistence, single/double parentheses, and CREATE/ALTER ADD/ALTER MODIFY. It checks the generated-expression AST and column-definition format/reparse stability. The new test has 72 failing boolean cases against the original parser and passes with this change.

Validation:

  • GOWORK=off go test ./go/vt/sqlparser passes with Vitess's own declared dependencies.
  • Regenerated sql.go using the repository Makefile commands; a second generation is byte-identical. Both original and changed grammars report zero shift/reduce and zero reduce/reduce conflicts.
  • Built Dolt from current main using an external Go workspace with this Vitess and unchanged current GMS main; verified resolved module directories. GMS go test ./enginetest -run '^TestGeneratedColumns$' -count=1 passes.
  • The built Dolt passes CLI checks for all 12 syntax/persistence/parentheses variants: inputs 3/8/NULL, update recomputation, fresh-process schema reopening, SHOW CREATE TABLE recreation, ALTER ADD/MODIFY predicates, and rejection of missing columns and explicit generated-column values.
  • Broader GOWORK=off go test ./... did not pass: MySQL server tests require an unavailable mysqld/VT_MYSQL_ROOT; the MySQL package was interrupted while stalled in TestTLSServer. All other test packages passed.

This is a standalone parser change with no module version changes or local overrides. Downstream dependency adoption is separate.

@fulghum

fulghum commented Nov 6, 2026

Copy link
Copy Markdown

Closing this PR and pulling in the contributor's change through #506 since maintainers weren't able to resolve the conflict directly in this PR.

@fulghum fulghum closed this Nov 6, 2026

@fulghum fulghum left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

These changes look good, but there's a conflict that I'm unable to resolve in this PR. I've created #506 with this same commit, from the latest main and I'll get that merged in.

In the future, if you can enable the Allow edits from maintainers settings, it makes it a little bit easier for us to resolve conflicts or make small changes and get the original PR merged in.

@sciyoshi

sciyoshi commented Nov 6, 2026

Copy link
Copy Markdown
Author

Thanks @fulghum, I've enabled maintainer edits for the other PRs I have open and will make sure to do so going forward.

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.

Boolean generated column expression requires an extra pair of parentheses

3 participants