-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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-20.1: combined fixes for ownership related bugs #51629
Merged
arulajmani
merged 5 commits into
cockroachdb:release-20.1
from
arulajmani:backport20.1-50665-50720-50744-50744-50949-51253
Jul 24, 2020
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
24fa3d6
sql: remove sequence ownership dependency when dropping sequences
arulajmani f1e7327
sql: fix bug causing sequenceIDs to be duplicated on column descriptors
arulajmani 24e9d84
sql: fix drop database - sequence ownership bug
arulajmani 3fd4ec3
backupccl: handle sequence ownership remapping logic for restore
arulajmani 996de21
sql: allow drops on tables/sequences that have invalid ownership states
arulajmani File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1071,3 +1071,149 @@ DROP TABLE b; | |
|
||
statement ok | ||
DROP TABLE a; | ||
subtest regression_50649 | ||
|
||
statement ok | ||
CREATE TABLE t_50649(a INT PRIMARY KEY) | ||
|
||
statement ok | ||
CREATE SEQUENCE seq_50649 OWNED BY t_50649.a | ||
|
||
statement ok | ||
DROP SEQUENCE seq_50649 | ||
|
||
statement ok | ||
DROP TABLE t_50649 | ||
|
||
subtest regression_50712 | ||
|
||
statement ok | ||
CREATE DATABASE db_50712 | ||
|
||
statement ok | ||
CREATE TABLE db_50712.t_50712(a INT PRIMARY KEY) | ||
|
||
statement ok | ||
CREATE SEQUENCE db_50712.seq_50712 OWNED BY db_50712.t_50712.a | ||
|
||
statement ok | ||
DROP DATABASE db_50712 CASCADE | ||
|
||
# Same test like above, except the table is lexicographically less than the | ||
# sequence, which results in drop database dropping the table before the | ||
# sequence. | ||
statement ok | ||
CREATE DATABASE db_50712 | ||
|
||
statement ok | ||
CREATE TABLE db_50712.a_50712(a INT PRIMARY KEY) | ||
|
||
statement ok | ||
CREATE SEQUENCE db_50712.seq_50712 OWNED BY db_50712.a_50712.a | ||
|
||
statement ok | ||
DROP DATABASE db_50712 CASCADE | ||
|
||
# Same test like above, except the db is switched as the current db | ||
statement ok | ||
CREATE DATABASE db_50712 | ||
|
||
statement ok | ||
SET DATABASE = db_50712 | ||
|
||
statement ok | ||
CREATE TABLE a_50712(a INT PRIMARY KEY) | ||
|
||
statement ok | ||
CREATE SEQUENCE seq_50712 OWNED BY a_50712.a | ||
|
||
statement ok | ||
DROP DATABASE db_50712 | ||
|
||
statement ok | ||
SET DATABASE = test | ||
|
||
# Tests db drop. | ||
# Sequence: outside db. | ||
# Owner: inside db. | ||
# The sequence should be automatically dropped. | ||
statement ok | ||
CREATE DATABASE db_50712 | ||
|
||
statement ok | ||
CREATE TABLE db_50712.t_50712(a INT PRIMARY KEY) | ||
|
||
statement ok | ||
CREATE SEQUENCE seq_50712 OWNED BY db_50712.t_50712.a | ||
|
||
statement ok | ||
DROP DATABASE db_50712 CASCADE | ||
|
||
statement error pq: relation "seq_50712" does not exist | ||
SELECT * FROM seq_50712 | ||
|
||
# Tests db drop. | ||
# Sequence: inside db | ||
# Owner: outside db | ||
# It should be possible to drop the table later. | ||
statement ok | ||
CREATE DATABASE db_50712 | ||
|
||
statement ok | ||
CREATE TABLE t_50712(a INT PRIMARY KEY) | ||
|
||
statement ok | ||
CREATE SEQUENCE db_50712.seq_50712 OWNED BY t_50712.a | ||
|
||
statement ok | ||
DROP DATABASE db_50712 CASCADE | ||
|
||
statement ok | ||
DROP TABLE t_50712 | ||
<<<<<<< HEAD | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Ideally you'd remove this line in this commit rather than a later commit in the PR. |
||
|
||
# previously, changing ownership of a sequence between columns of the same table | ||
# was causing the sequenceID to appear in multiple column's ownedSequences list. | ||
# This makes it impossible to drop the affected columns/table once the sequence | ||
# has been dropped. This tests for these scenarios and ensures the table/columns | ||
# remain drop-able. | ||
subtest regression_50711 | ||
|
||
statement ok | ||
CREATE TABLE t_50711(a int, b int) | ||
|
||
statement ok | ||
CREATE SEQUENCE seq_50711 owned by t_50711.a | ||
|
||
statement ok | ||
ALTER SEQUENCE seq_50711 owned by t_50711.b | ||
|
||
statement ok | ||
ALTER SEQUENCE seq_50711 owned by t_50711.a | ||
|
||
statement ok | ||
DROP SEQUENCE seq_50711 | ||
|
||
statement ok | ||
DROP TABLE t_50711 | ||
|
||
statement ok | ||
CREATE TABLE t_50711(a int, b int) | ||
|
||
statement ok | ||
CREATE SEQUENCE seq_50711 owned by t_50711.a | ||
|
||
statement ok | ||
ALTER SEQUENCE seq_50711 owned by t_50711.b | ||
|
||
statement ok | ||
ALTER SEQUENCE seq_50711 owned by t_50711.a | ||
|
||
statement ok | ||
DROP SEQUENCE seq_50711 | ||
|
||
statement ok | ||
ALTER TABLE t_50711 DROP COLUMN a | ||
|
||
statement ok | ||
ALTER TABLE t_50711 DROP COLUMN b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Kind of confusing how tests from a different commit ended up in this one, but I don't know if it's worth the trouble to fix.