-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
backupccl: add support for SHOW BACKUP WITH SCHEMAS #39323
Conversation
bors try |
🔒 Permission denied Existing reviewers: click here to make pbardea a reviewer |
bors try |
tryBuild succeeded |
2a2edc5
to
d0eb304
Compare
2190d17
to
ad31f02
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM on the backup parts and tests.
I'd defer to @knz the the change in resolver.go
since that's his area.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 10 of 10 files at r1.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @pbardea)
pkg/sql/parser/sql.y, line 3303 at r2 (raw file):
} } | SHOW BACKUP WITH SCHEMAS string_or_placeholder
-
why not
show backup schemas
and why iswith
important -
the thing is not showing schemas, it's showing CREATE statements. Maybe
show backup ddl
is the better phrasing. -
I am sad that these are becoming separate things. What if I want to see both the files and the
create
statements? Maybe these things should be options that can be combined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 7 of 10 files at r1.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @rolandcrosby)
pkg/sql/parser/sql.y, line 3303 at r2 (raw file):
Previously, knz (kena) wrote…
why not
show backup schemas
and why iswith
importantthe thing is not showing schemas, it's showing CREATE statements. Maybe
show backup ddl
is the better phrasing.I am sad that these are becoming separate things. What if I want to see both the files and the
create
statements? Maybe these things should be options that can be combined.
re: 3, I think I prefer this direction as-is: files
and ranges
are pretty much only debugging options and there is almost no reason for an end-user to run them, and particularly little reason they'd want to combine them with other options. For such an edge case, I'm fine with asking you to just run it again with the other option (in particularly since they return different rows -- i.e. one per table or one per range or one per file).
re: 2: I have a slight preference for SCHEMAS
this over DDLS
since the later I think is somewhat more obscure, but I'll let @rolandcrosby chime in.
But on the points regarding the naming I welcome @rolandcrosby's input as well.
|
Should this also omit views referencing tables that are not in the backup? |
I think printing the views is actually one of the big motivating reasons for this change: it lets you recreate a view by hand that RESTORE won't touch due to missing one of the referenced tables. |
That makes sense. There's no way to do the same for FKs because the backups don't have the names of the referenced table/columns, right? |
@lucy-zhang Yes, when getting the CREATE statement for the view it can use |
Yup, the view issue that @pbardea identified is indeed part of what spurred us to prioritize this work. A customer was unable to restore the entirety of a backup because it contained a view referencing a non-backed-up table, and we realized that there wasn't a good way to retrieve the view definition. Re: @knz's syntax questions, I don't particularly care if we include |
No further comments 👍 |
ad31f02
to
b9c81d1
Compare
Add the ability to show the create statement for the tables, views or sequences that are stored within a backup. Tables with references to foreign keys will only display foreign key constraints if the table to which the constraint relates to is also in the backup. Closes cockroachdb#38517. Release note (enterprise change): Add support for displaying creation statements of relations stored in a backup.
b9c81d1
to
06ad5eb
Compare
Looks like the general consensus is that the
|
bors r+ |
39323: backupccl: add support for SHOW BACKUP WITH SCHEMAS r=pbardea a=pbardea Add the ability to show the create statement for the tables, views or sequences that are stored within a backup. Tables with references to foreign keys will only display foreign key constraints if the table to which the constraint relates to is also in the backup. Closes #38517. The SQL syntax chose was `SHOW BACKUP WITH SCHEMAS`. The changes for this were minimal since they were all already keywords. Note that `WITH SCHEMAS` cannot be used along with the `RANGES` and `FILES` descriptor. Release note (enterprise change): Add support for displaying creation statements of relations stored in a backup. Co-authored-by: Paul Bardea <pbardea@gmail.com>
Build succeeded |
nice work @pbardea |
Add the ability to show the create statement for the tables, views
or sequences that are stored within a backup. Tables with references to
foreign keys will only display foreign key constraints if the table to
which the constraint relates to is also in the backup.
Closes #38517.
The SQL syntax chose was
SHOW BACKUP WITH SCHEMAS
. Thechanges for this were minimal since they were all already keywords.
Note that
WITH SCHEMAS
cannot be used along with theRANGES
and
FILES
descriptor.Release note (enterprise change): Add support for displaying creation
statements of relations stored in a backup.