Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: fix index visibility parsing for small values #109697

Merged

Conversation

mgartner
Copy link
Collaborator

This commit updates the parser and AST to keep track of whether or not
an index VISIBILITY float was provided in a CREATE TABLE,
CREATE INDEX, or ALTER INDEX statement. This allows the statements
to be round-tripped correctly with very low float values that would be
rounded to zero and change the VISIBILITY clause into NOT VISIBLE.

Fixes #108083

Release note: None

@mgartner mgartner requested a review from rafiss August 29, 2023 19:56
@mgartner mgartner requested review from a team as code owners August 29, 2023 19:56
@mgartner mgartner requested review from herkolategan, smg260 and msirek and removed request for a team August 29, 2023 19:56
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@@ -1059,7 +1060,7 @@ func (og *operationGenerator) createIndex(ctx context.Context, tx pgx.Tx) (*opSt
Unique: og.randIntn(4) == 0, // 25% UNIQUE
Inverted: og.randIntn(10) == 0, // 10% INVERTED
IfNotExists: og.randIntn(2) == 0, // 50% IF NOT EXISTS
Invisibility: 1 - visibility, // 5% NOT VISIBLE
Invisibility: visibility, // 5% NOT VISIBLE
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: i think this should still be 1 - visibility

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch. Fixed this above.

@msirek msirek removed their request for review August 29, 2023 20:56
@mgartner mgartner force-pushed the 108083-fix-index-invisibility-parsing branch 2 times, most recently from 70ee664 to 5bb41ae Compare August 29, 2023 22:03
This commit updates the parser and AST to keep track of whether or not
an index `VISIBILITY` float was provided in a `CREATE TABLE`,
`CREATE INDEX`, or `ALTER INDEX` statement. This allows the statements
to be round-tripped correctly with very low float values that would be
rounded to zero and change the `VISIBILITY` clause into `NOT VISIBLE`.

Fixes cockroachdb#108083

Release note: None
@mgartner mgartner force-pushed the 108083-fix-index-invisibility-parsing branch from 5bb41ae to 67f9e00 Compare August 30, 2023 14:13
Copy link
Collaborator

@rafiss rafiss left a comment

Choose a reason for hiding this comment

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

nice fix!

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @herkolategan and @smg260)

@mgartner
Copy link
Collaborator Author

TFTR!

bors r+

@craig
Copy link
Contributor

craig bot commented Aug 30, 2023

Build succeeded:

@craig craig bot merged commit 6a51bf4 into cockroachdb:master Aug 30, 2023
@mgartner mgartner deleted the 108083-fix-index-invisibility-parsing branch August 30, 2023 19:03
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.

sql/tests: TestRandomSyntaxGeneration failed [index visibility precision]
3 participants