Skip to content

sql: drop schemas when dropping parent database#53126

Merged
craig[bot] merged 1 commit into
cockroachdb:masterfrom
rohany:drop-db-cascade-schema
Aug 25, 2020
Merged

sql: drop schemas when dropping parent database#53126
craig[bot] merged 1 commit into
cockroachdb:masterfrom
rohany:drop-db-cascade-schema

Conversation

@rohany

@rohany rohany commented Aug 20, 2020

Copy link
Copy Markdown
Contributor

Fixes #52362.

This commit updates DROP DATABASE CASCADE to also clean up any child
user defined schemas.

Release note: None

@rohany rohany requested a review from a team August 20, 2020 15:12
@rohany rohany requested a review from a team as a code owner August 20, 2020 15:12
@rohany rohany requested review from pbardea and removed request for a team and pbardea August 20, 2020 15:12
@cockroach-teamcity

Copy link
Copy Markdown
Member

This change is Reviewable

@rohany rohany force-pushed the drop-db-cascade-schema branch from 50c1b69 to 1d0b7cd Compare August 20, 2020 15:56
@rohany rohany requested review from ajwerner and thoszhang August 20, 2020 16:00
@rohany rohany force-pushed the drop-db-cascade-schema branch 5 times, most recently from 41e6415 to 639711c Compare August 24, 2020 14:46
@rohany

rohany commented Aug 24, 2020

Copy link
Copy Markdown
Contributor Author

This is ready for a review!

Fixes cockroachdb#52362.

This commit updates `DROP DATABASE CASCADE` to also clean up any child
user defined schemas.

Release note: None
@rohany rohany force-pushed the drop-db-cascade-schema branch from 639711c to 3551c83 Compare August 24, 2020 20:39

@thoszhang thoszhang left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reviewed 5 of 5 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner)

@rohany

rohany commented Aug 24, 2020

Copy link
Copy Markdown
Contributor Author

bors r*

@rohany

rohany commented Aug 24, 2020

Copy link
Copy Markdown
Contributor Author

bors r+

@craig

craig Bot commented Aug 24, 2020

Copy link
Copy Markdown
Contributor

Build failed (retrying...):

craig Bot pushed a commit that referenced this pull request Aug 24, 2020
53067: opt: add INSERT ON CONFLICT WHERE syntax for selecting arbiter indexes r=mgartner a=mgartner

This commit adds support for selecting unique partial indexes as
"arbiters" for `INSERT ON CONFLICT` statements. An arbiter index is a
unique index that is used to detect conflicts in which to perform the
`ON CONFLICT` action on.

Unique partial indexes can only be used as arbiters if the arbiter
predicate in the `ON CONFLICT` statement implies the partial index's
predicate.

To avoid parsing the same partial index predicates multiple times, this
commit also adds a `parsedIndexExprs` cache to `mutationBuilder`,
similar to the cache it has for default and computed column expressions.

Finally, this commit also makes the parsing of `ON CONFLICT DO UPDATE`
more strict. It now requires a list of conflict columns. This matches
Postgres behavior.

From https://www.postgresql.org/docs/12/sql-insert.html:

> For ON CONFLICT DO UPDATE, a conflict_target must be provided.

In Postgres, the `conflict_target` can be a list of columns or a
constraint name. Cockroach currently only supports a list of column
names as a conflict target, so the list of column names preceeding
`DO UPDATE` is now required by the parser.

Release note (sql change): An `INSERT ... ON CONFLICT DO UPDATE`
statement without a list of column names after `ON CONFLICT` now results
in a SQL syntax error with the error code 42601. Previously it errored
with the message "there is no unqiue or exlcusion constraint matching
the ON CONFLICT specification" and the error code 42P10.


53126: sql: drop schemas when dropping parent database r=rohany a=rohany

Fixes #52362.

This commit updates `DROP DATABASE CASCADE` to also clean up any child
user defined schemas.

Release note: None

Co-authored-by: Marcus Gartner <marcus@cockroachlabs.com>
Co-authored-by: Rohan Yadav <rohany@alumni.cmu.edu>
@craig

craig Bot commented Aug 25, 2020

Copy link
Copy Markdown
Contributor

Build failed (retrying...):

@rohany

rohany commented Aug 25, 2020

Copy link
Copy Markdown
Contributor Author

bors r-

@craig

craig Bot commented Aug 25, 2020

Copy link
Copy Markdown
Contributor

Canceled.

@rohany

rohany commented Aug 25, 2020

Copy link
Copy Markdown
Contributor Author

bors r+

@craig

craig Bot commented Aug 25, 2020

Copy link
Copy Markdown
Contributor

Build succeeded:

@craig craig Bot merged commit 40382d7 into cockroachdb:master Aug 25, 2020
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: dropping a database needs to drop its child schemas

3 participants