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: parse followed by format is not idempotent for EXPLAIN ANALYZE (PLAN) #51473

Closed
rohany opened this issue Jul 15, 2020 · 5 comments · Fixed by #51477
Closed

sql: parse followed by format is not idempotent for EXPLAIN ANALYZE (PLAN) #51473

rohany opened this issue Jul 15, 2020 · 5 comments · Fixed by #51477
Assignees
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.

Comments

@rohany
Copy link
Contributor

rohany commented Jul 15, 2020

found by the RSG tests:

Parse followed by Format is not idempotent: "EXPLAIN ANALYZE ( PLAN ) ALTER SEQUENCE HOUR RENAME TO FAMILY . LEAST . GREATEST" -> "EXPLAIN ANALYZE ALTER SEQUENCE hour RENAME TO "family".least.greatest" != "EXPLAIN ANALYZE (DISTSQL) ALTER SEQUENCE hour RENAME TO "family".least.greatest"

@rohany rohany added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Jul 15, 2020
@rohany rohany mentioned this issue Jul 15, 2020
25 tasks
@RaduBerinde
Copy link
Member

EXPLAIN ANALYZE (PLAN) is invalid and should error out.

@RaduBerinde
Copy link
Member

@rohany can you clarify exactly what RSG is doing? Is it actually using the tree code directly to Parse and Format?

@rohany
Copy link
Contributor Author

rohany commented Jul 15, 2020

Yeah, it looks like it is generating a statement, parsing it, then dumping it with tree.AsStringWithFlags and ensuring the result is the same.

@RaduBerinde
Copy link
Member

I think that won't work in general, various statements have multiple forms that get normalized. My guess is that it's generating a statement, parsing it, dumping it, then parsing it again, then dumping it again, and cross-checking the two dumps.

@rohany
Copy link
Contributor Author

rohany commented Jul 15, 2020

The relevant code is in pkg/sql/tests/rsg_test.go:55

@RaduBerinde RaduBerinde changed the title sql: parse followed by format is not idempotent sql: parse followed by format is not idempotent for EXPLAIN ANALYZE (PLAN) Jul 15, 2020
craig bot pushed a commit that referenced this issue Jul 15, 2020
51477: sql: be more strict with validating EXPLAIN r=RaduBerinde a=RaduBerinde

#### sql: be more strict with validating EXPLAIN

Verify during paring that we are not specifying an invalid mode for
`EXPLAIN ANALYZE`.

Fixes #51473.

Release note: None

Co-authored-by: Radu Berinde <[email protected]>
@craig craig bot closed this as completed in 9cec1ec Jul 15, 2020
RaduBerinde added a commit to RaduBerinde/cockroach that referenced this issue Jul 28, 2020
Verify during paring that we are not specifying an invalid mode for
`EXPLAIN ANALYZE`.

Fixes cockroachdb#51473.

Release note: None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants