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

tree: fix formatting of SHOW BACKUP WITH OPTIONS #110580

Merged
merged 1 commit into from
Sep 15, 2023

Conversation

rafiss
Copy link
Collaborator

@rafiss rafiss commented Sep 13, 2023

This avoids an ambiguity when formatting the statement.

fixes #110411
Release note: None

@rafiss rafiss added backport-22.2.x backport-23.1.x Flags PRs that need to be backported to 23.1 labels Sep 13, 2023
@rafiss rafiss requested a review from annrpom September 13, 2023 16:36
@rafiss rafiss requested a review from a team as a code owner September 13, 2023 16:36
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@annrpom annrpom left a comment

Choose a reason for hiding this comment

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

lgtm mod a dev gen

@rafiss rafiss force-pushed the fix-show-backup-options-format branch from 8680c66 to 903211d Compare September 13, 2023 21:50
@dt
Copy link
Member

dt commented Sep 13, 2023

can you add a testcase that doesn't round-trip in the normalized form before this change but does after?

The example in 110411 of SHOW BACKUP 'placeholder' WITH bucket_count wouldn't round-trip with or without this change, since bucket_count isn't in valid in the show_backup_options rule.

@rafiss
Copy link
Collaborator Author

rafiss commented Sep 14, 2023

Ah i see the issue now. The test failed on the 22.2 branch: #110411 (comment). But on that branch, SHOW BACKUP is using opt_with_options in its syntax rules rather than specifying the valid options in the syntax, like how more recent branches do. So I think this might be a more correct fix, but I'm not sure if this breaks a few other things: #110622 Maybe there is a backport from 23.1 that achieves this?

@dt
Copy link
Member

dt commented Sep 14, 2023

I think #110622 shouldn't break too much; none of the SHOW BACKUP options take non-string RHS values, so I don't think there is anything that worked with the 22.2 string/string map that would break if it is switched to a typed rules.

@rafiss
Copy link
Collaborator Author

rafiss commented Sep 14, 2023

closing in favor of #110622

@rafiss rafiss closed this Sep 14, 2023
@rafiss rafiss deleted the fix-show-backup-options-format branch September 14, 2023 19:58
@rafiss rafiss restored the fix-show-backup-options-format branch September 14, 2023 20:54
@rafiss
Copy link
Collaborator Author

rafiss commented Sep 14, 2023

actually, here is a test case that does not round trip (parse, format, parse) on all branches currently:

SHOW BACKUP CONNECTION 'bar' WITH OPTIONS (TIME = '1h')

It is because of this parser lookahead logic:

case WITH:
switch nextToken.id {
case TIME, ORDINALITY, BUCKET_COUNT:
lval.id = WITH_LA
}

For the same reason, the following statement cannot even be parsed in the first place.

SHOW BACKUP CONNECTION 'bar' WITH TIME = '1h'

I think we should go with this PR.

@rafiss rafiss reopened this Sep 14, 2023
@rafiss rafiss force-pushed the fix-show-backup-options-format branch from 903211d to d83436d Compare September 14, 2023 20:59
@rafiss rafiss requested a review from dt September 14, 2023 20:59
@dt
Copy link
Member

dt commented Sep 14, 2023

That parameter doesn't need to be named TIME. We can use a different token for the duration to run the test.

@dt
Copy link
Member

dt commented Sep 14, 2023

I don't really care all that much about the canonicalization of this SHOW here, since users don't see it, but I'm looking to remove the other WITH OPTIONS () canonicalizations in BACKUP and RESTORE statements, like the one that were added in #107892, since those are user-visible, and caused our job descriptions to no longer match our docs or examples / what the user ran and will be looking for, potentially via regex, in the set of jobs.

So I'm not going to oppose merging this but I also think we could just change TIME to another parameter here to avoid the with-la special case instead of wrapping the whole sub-clause.

@rafiss
Copy link
Collaborator Author

rafiss commented Sep 14, 2023

That parameter doesn't need to be named TIME. We can use a different token for the duration to run the test.

I will leave that up to you. It seems like it would be a backwards incompatible syntax change (not just a change in the outputs returned by SHOW). If it's OK to do under our API stability contracts for SHOW, I will let DR drive that effort.

I gave the backport of e6f47a0 a shot, but there were too many conflicts for me to be able to do it myself.

If you don't have any opposition to merging this PR I will go ahead with it.

but I'm looking to remove the other WITH OPTIONS () canonicalizations in BACKUP and RESTORE statements, like the one that were added in #107892, since those are user-visible, and caused our job descriptions to no longer match our docs or examples / what the user ran and will be looking for, potentially via regex, in the set of jobs.

Ack. It doesn't seem like a major priority to me, but you'd know better about this area.

This avoids an ambiguity when formatting the statement.

Release note: None
@rafiss rafiss force-pushed the fix-show-backup-options-format branch from d83436d to e1fbdfe Compare September 14, 2023 21:13
@dt
Copy link
Member

dt commented Sep 14, 2023

If you don't have any opposition to merging this PR I will go ahead with it.

Works for me.

@rafiss
Copy link
Collaborator Author

rafiss commented Sep 15, 2023

bors r+

@craig
Copy link
Contributor

craig bot commented Sep 15, 2023

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Sep 15, 2023

Build succeeded:

@craig craig bot merged commit 28552c8 into cockroachdb:master Sep 15, 2023
8 checks passed
@blathers-crl
Copy link

blathers-crl bot commented Sep 15, 2023

Encountered an error creating backports. Some common things that can go wrong:

  1. The backport branch might have already existed.
  2. There was a merge conflict.
  3. The backport branch contained merge commits.

You might need to create your backport manually using the backport tool.


error creating merge commit from e1fbdfe to blathers/backport-release-22.2-110580: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 22.2.x failed. See errors above.


error creating merge commit from e1fbdfe to blathers/backport-release-23.1-110580: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 23.1.x failed. See errors above.


🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-23.1.x Flags PRs that need to be backported to 23.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sql/tests: TestRandomSyntaxGeneration failed
4 participants