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

release-22.2: sql: fix formatting of import, backup and alter tenant #107185

Conversation

chengxiong-ruan
Copy link
Contributor

@chengxiong-ruan chengxiong-ruan commented Jul 19, 2023

Fixes: #95618

This commit is trying to fix 2 things found in the TestRandomSyntaxGeneration failures:

  1. TenenatID expr in ALTER TENANT and SHOW ... FOR TENANT should be formatted as being wrapped with parenthesises. This was fixed in 23.1. The idea is copied
    from there.
  2. IMPORT/BACKUP options are formatted without being wrapped with OPTIONS (). This sometimes got confused with other WITH SOME_KEYWORD = xxx syntax, for example WITH BUCkET_COUNT = 123.

Release note: None
Release justification: test fixes

@chengxiong-ruan chengxiong-ruan requested review from a team as code owners July 19, 2023 17:55
@blathers-crl
Copy link

blathers-crl bot commented Jul 19, 2023

Thanks for opening a backport.

Please check the backport criteria before merging:

  • Patches should only be created for serious issues or test-only changes.
  • Patches should not break backwards-compatibility.
  • Patches should change as little code as possible.
  • Patches should not change on-disk formats or node communication protocols.
  • Patches should not add new functionality.
  • Patches must not add, edit, or otherwise modify cluster versions; or add version gates.
If some of the basic criteria cannot be satisfied, ensure that the exceptional criteria are satisfied within.
  • There is a high priority need for the functionality that cannot wait until the next release and is difficult to address in another way.
  • The new functionality is additive-only and only runs for clusters which have specifically “opted in” to it (e.g. by a cluster setting).
  • New code is protected by a conditional check that is trivial to verify and ensures that it only runs for opt-in clusters.
  • The PM and TL on the team that owns the changed code have signed off that the change obeys the above rules.

Add a brief release justification to the body of your PR to justify this backport.

Some other things to consider:

  • What did we do to ensure that a user that doesn’t know & care about this backport, has no idea that it happened?
  • Will this work in a cluster of mixed patch versions? Did we test that?
  • If a user upgrades a patch version, uses this feature, and then downgrades, what happens?

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@chengxiong-ruan chengxiong-ruan force-pushed the 20230719-fix-rand-syntax branch from 191ecb4 to d7824b8 Compare July 19, 2023 20:34
@rafiss
Copy link
Collaborator

rafiss commented Jul 20, 2023

Seems like we may need this on master (and probably 23.1 also): #99185 (comment)

@chengxiong-ruan chengxiong-ruan force-pushed the 20230719-fix-rand-syntax branch from d7824b8 to 37223d2 Compare July 24, 2023 18:14
@chengxiong-ruan chengxiong-ruan requested a review from a team July 24, 2023 18:14
@chengxiong-ruan chengxiong-ruan requested review from a team as code owners July 24, 2023 18:14
@chengxiong-ruan chengxiong-ruan requested review from nkodali, DrewKimball and adityamaru and removed request for a team, nkodali, adityamaru and DrewKimball July 24, 2023 18:14
Fixes: cockroachdb#95618

This commit is trying to fix 2 things found in the TestRandomSyntaxGeneration
failures:
1. TenenatID expr in `ALTER TENANT` and `SHOW ... FOR TENANT` should
be formatted as being wrapped with parenthesises. This was fixed in
23.1. The idea is copied
from there.
2. IMPORT/BACKUP options are formatted without being wrapped with
`OPTIONS ()`.  This sometimes got confused with other
`WITH SOME_KEYWORD = xxx` syntax, for example `WITH BUCkET_COUNT = 123`.

Release note: None
Release justification: test fixes
@chengxiong-ruan chengxiong-ruan force-pushed the 20230719-fix-rand-syntax branch from 37223d2 to 9e4bdc6 Compare July 24, 2023 19:03
@chengxiong-ruan
Copy link
Contributor Author

Seems like we may need this on master (and probably 23.1 also): #99185 (comment)

@rafiss yes, I'll apply some of the changes in this PR 23.1 and master as well.

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.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @chengxiong-ruan)


pkg/sql/sem/tree/tenant_settings.go line 90 at r1 (raw file):

// all the d_expr expression *types*. We can only do so for a few
// types for which we know that *all possible objects* of that type
// are well-delimited, such as Subquery, NumVal or Placeholder.

very nice explanation!

maybe the multi-tenant team should be aware? it seems that ALTER TENANT and SHOW CLUSTER SETTINGS FOR TENANT are the only statements affected by this problem?


pkg/sql/sem/tree/tenant_settings.go line 109 at r1 (raw file):

	ctx.WriteString(" FOR TENANT ")
	_, canOmitParentheses := node.TenantID.(alreadyDelimitedAsSyntacticDExpr)
	if !canOmitParentheses {

just want to understand better: what is the problem if we always add the parenthesis here?

Copy link
Contributor Author

@chengxiong-ruan chengxiong-ruan 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 @knz and @rafiss)


pkg/sql/sem/tree/tenant_settings.go line 90 at r1 (raw file):

Previously, rafiss (Rafi Shamim) wrote…

very nice explanation!

maybe the multi-tenant team should be aware? it seems that ALTER TENANT and SHOW CLUSTER SETTINGS FOR TENANT are the only statements affected by this problem?

hehe, I stole this from master. Huge credits to @knz who added that. But yes.


pkg/sql/sem/tree/tenant_settings.go line 109 at r1 (raw file):

Previously, rafiss (Rafi Shamim) wrote…

just want to understand better: what is the problem if we always add the parenthesis here?

good question, I think it's fine, but just looking weird in some cases, for example (NULL)...

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.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @chengxiong-ruan and @knz)


pkg/sql/sem/tree/tenant_settings.go line 109 at r1 (raw file):

Previously, chengxiong-ruan (Chengxiong Ruan) wrote…

good question, I think it's fine, but just looking weird in some cases, for example (NULL)...

ah OK, if the team already decided on fixing it this way on master then i suppose we should do that here too instead of always adding parentheses.

chengxiong-ruan added a commit to chengxiong-ruan/cockroach that referenced this pull request Jul 28, 2023
Informs: cockroachdb#99183

Similar to cockroachdb#107185, this commit wraps option formatting of
import, backup and restore statement with `()`. Also wrap
replcation expression with `()` in `create tenant from replication`
statements.

Release note: None
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.

3 participants