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: TestRandomSyntaxGeneration fixes #98821

Merged
merged 2 commits into from
Mar 21, 2023
Merged

Conversation

cucaroach
Copy link
Contributor

@cucaroach cucaroach commented Mar 16, 2023

sql: fix some TestRandomSyntaxGeneration bugs

The RSG works by calling format on the AST's it generates so its good
at finding Format bugs.

Fix a missing separator in ShowBackupOptions. Example:

SHOW BACKUP 'family' IN ('string', 'placeholder', 'placeholder', 'placeholder', 'string', 'placeholder', 'string', 'placeholder') WITH incremental_location = 'nullif', privilegesdebug_dump_metadata_sst

Fix bad construction in ShowTenant. Example:

SHOW TENANT [B'10010'] WITH REPLICATION STATUS WITH CAPABILITIES

Epic: none
Release note: None

copy: fix copy grammar to match PG

Previously COPY would allow a wide range of syntax in the COPY
TO substatement. Now like PG we limit it to a few things.

PG grammar is:

PreparableStmt:
                        SelectStmt
                        | InsertStmt
                        | UpdateStmt
                        | DeleteStmt
                        | MergeStmt

And now we do something similar. This prevents the wheels from coming
off when RSG generates EXPLAIN's in the substatement for instance.

Release note: none
Epic: none

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@cucaroach cucaroach changed the title rsg fixes sql: TestRandomSyntaxGeneration fixes Mar 16, 2023
@cucaroach cucaroach requested review from a team and michae2 March 16, 2023 22:50
@cucaroach cucaroach marked this pull request as ready for review March 16, 2023 22:50
@cucaroach cucaroach requested a review from a team March 16, 2023 22:50
@cucaroach cucaroach requested a review from a team as a code owner March 16, 2023 22:50
Copy link
Collaborator

@mgartner mgartner left a comment

Choose a reason for hiding this comment

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

Looks like the last commit is causing issues. I think it's finding other bugs and possibly the 30s timeout is not graceful so that tests always fail. Feel free to back that commit out and follow it up later if you want to merge the first two commits.

Reviewed 2 of 2 files at r1, 1 of 1 files at r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @cucaroach and @michae2)


-- commits line 32 at r2:
Can you add a parser test like this?


-- commits line 38 at r2:
Can you also add a parser test like this?

Copy link
Contributor Author

@cucaroach cucaroach left a comment

Choose a reason for hiding this comment

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

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


-- commits line 32 at r2:

Previously, mgartner (Marcus Gartner) wrote…

Can you add a parser test like this?

A test that shows the parser fails to parse this? Not sure I see the point, but I do agree a regression test would be nice, I'll look for a place to put a format regression test.

@cucaroach
Copy link
Contributor Author

I removed the CI bit, I'll put that on ice until all the bugs are fixed.

Copy link
Contributor Author

@cucaroach cucaroach left a comment

Choose a reason for hiding this comment

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

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


-- commits line 32 at r2:

Previously, cucaroach (Tommy Reilly) wrote…

A test that shows the parser fails to parse this? Not sure I see the point, but I do agree a regression test would be nice, I'll look for a place to put a format regression test.

Nevermind, I didn't realize the parse tests ARE hitting the Format path, tests for these two cases added.

@cucaroach
Copy link
Contributor Author

bors r+
Merging first two fixes, will revisit CI change.

@craig
Copy link
Contributor

craig bot commented Mar 19, 2023

👎 Rejected by too few approved reviews

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!

@rafiss
Copy link
Collaborator

rafiss commented Mar 20, 2023

oh, still needs a ./dev gen bazel maybe

The RSG works by calling format on the AST's it generates so its good
at finding Format bugs.

Fix a missing separator in ShowBackupOptions.  Example:

```
SHOW BACKUP 'family' IN ('string', 'placeholder', 'placeholder', 'placeholder', 'string', 'placeholder', 'string', 'placeholder') WITH incremental_location = 'nullif', privilegesdebug_dump_metadata_sst
```

Fix bad construction in ShowTenant.  Example:

```
SHOW TENANT [B'10010'] WITH REPLICATION STATUS WITH CAPABILITIES
```

Epic: none
Release note: None
@cucaroach cucaroach requested a review from a team as a code owner March 20, 2023 17:31
@cucaroach
Copy link
Contributor Author

Yeah, I tried gen bazel and gen bnf and no dice. Oh wait I had some cruft preventing gen from working completely. Should be fixed now. I also rebased to pick up #98977 and now my 30s CI test seems to be working. I also ran a 5m one to be sure. I'll wait to merge until CI is green.

@cucaroach
Copy link
Contributor Author

Okay well stress on the rsg_tests found a bunch of issues so that's not ready for prime time.

Previously COPY would allow a wide range of syntax in the COPY
TO substatement.  Now like PG we limit it to a few things.

PG grammar is:
```
PreparableStmt:
			SelectStmt
			| InsertStmt
			| UpdateStmt
			| DeleteStmt
			| MergeStmt
```

And now we do something similar. This prevents the wheels from coming
off when RSG generates EXPLAIN's in the substatement for instance.

Release note: none
Epic: none
@cucaroach
Copy link
Contributor Author

bors r+

@craig
Copy link
Contributor

craig bot commented Mar 21, 2023

Build succeeded:

@craig craig bot merged commit eab416d into cockroachdb:master Mar 21, 2023
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.

4 participants