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: include all schemas into schema.sql in the bundle #91245

Merged
merged 1 commit into from
Nov 4, 2022

Conversation

yuzefovich
Copy link
Member

@yuzefovich yuzefovich commented Nov 3, 2022

This commit makes it so that all schemas are added into the schema.sql file of the statement bundle using SHOW CREATE ALL SCHEMAS; statement (the only exception is the public schema that always exists in CRDB clusters). This will make it more likely that debug statement-bundle recreate succeeds on the bundles.

Fixes: #91099.

Epic: CRDB-14510

Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@yuzefovich yuzefovich marked this pull request as ready for review November 3, 2022 22:38
@yuzefovich yuzefovich requested review from michae2, cucaroach and a team November 3, 2022 22:38
Copy link
Collaborator

@DrewKimball DrewKimball left a comment

Choose a reason for hiding this comment

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

:lgtm:

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

Copy link
Collaborator

@michae2 michae2 left a comment

Choose a reason for hiding this comment

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

Thank you for doing this!

Reviewed all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @cucaroach and @yuzefovich)


pkg/sql/explain_bundle.go line 494 at r1 (raw file):

	rows, err := c.ie.QueryBufferedEx(
		c.ctx,
		"stmtEnvCollector",

Could we use a more descriptive name? Maybe something about the current statement bundle?


pkg/sql/explain_bundle.go line 738 at r1 (raw file):

	}
	for _, r := range createAllSchemas {
		if strings.HasPrefix(r, "CREATE SCHEMA "+catconstants.PublicSchemaName) {

Will this work if someone has a schema starting with "public", like CREATE SCHEMA publicfoo?

This commit makes it so that all schemas are added into the `schema.sql`
file of the statement bundle using `SHOW CREATE ALL SCHEMAS;` statement
(the only exception is the public schema that always exists in CRDB
clusters). This will make it more likely that `debug statement-bundle
recreate` succeeds on the bundles.

Epic: None

Release note: None
Copy link
Member Author

@yuzefovich yuzefovich 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 (and 1 stale) (waiting on @cucaroach and @michae2)


pkg/sql/explain_bundle.go line 494 at r1 (raw file):

Previously, michae2 (Michael Erickson) wrote…

Could we use a more descriptive name? Maybe something about the current statement bundle?

It doesn't seem that important (it would only show up as a log tag), and I'd also like it to keep it for consistency with query() method. I guess places that use query() method can also be invoked during EXPLAIN (OPT, ENV) and that's why the opName is not very descriptive there, but the schemas are only used for the bundle.


pkg/sql/explain_bundle.go line 738 at r1 (raw file):

Previously, michae2 (Michael Erickson) wrote…

Will this work if someone has a schema starting with "public", like CREATE SCHEMA publicfoo?

Good point, made it an exact comparison.

Copy link
Collaborator

@michae2 michae2 left a comment

Choose a reason for hiding this comment

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

:lgtm: Nice!

Reviewed all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (and 1 stale) (waiting on @cucaroach)


pkg/sql/explain_bundle.go line 494 at r1 (raw file):

Previously, yuzefovich (Yahor Yuzefovich) wrote…

It doesn't seem that important (it would only show up as a log tag), and I'd also like it to keep it for consistency with query() method. I guess places that use query() method can also be invoked during EXPLAIN (OPT, ENV) and that's why the opName is not very descriptive there, but the schemas are only used for the bundle.

I see. That's fine, thanks for checking it out!

@yuzefovich
Copy link
Member Author

TFTRs!

bors r+

@craig craig bot merged commit c57b340 into cockroachdb:master Nov 4, 2022
@craig
Copy link
Contributor

craig bot commented Nov 4, 2022

Build succeeded:

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: fix statement bundle recreate with non-default schema
4 participants