-
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
schemachanger: implement ADD CONSTRAINT ... FOREIGN KEY
#93068
Merged
Xiang-Gu
merged 6 commits into
cockroachdb:master
from
Xiang-Gu:implement-add-constraint-foreign-key
Jan 12, 2023
+2,007
−548
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9f64db7
catenumpb: Moved some enums into a new low-dependency package
Xiang-Gu 9a8de1e
backfill: Add logic for foreign key validation
Xiang-Gu e14fe03
opgen: adding support for the adding/dropping path of ForeignKey element
Xiang-Gu 0e57b6a
scbuildstmt: Implement `ADD FOREIGN KEY` in the builder
Xiang-Gu d8d13ce
rewrite: Rewrite FK in mutations during restore
Xiang-Gu d05c969
schemachanger: Enable `ADD FOREIGN KEY` by default and add tests
Xiang-Gu 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright 2022 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
// This file should contain only EMUN definitions for concepts that | ||
// are internal and not visible to the SQL layer. | ||
// It uses proto3 so other packages can import those enum definitions | ||
// when needed. | ||
syntax = "proto3"; | ||
package cockroach.sql.catalog.catpb; | ||
option go_package = "catpb"; | ||
|
||
import "gogoproto/gogo.proto"; | ||
|
||
// SystemColumnKind is an enum representing the different kind of system | ||
// columns that can be synthesized by the execution engine. | ||
enum SystemColumnKind { | ||
// Default value, unused. | ||
NONE = 0; | ||
// A system column containing the value of the MVCC timestamp associated | ||
// with the kv's corresponding to the row. | ||
MVCCTIMESTAMP = 1; | ||
// A system column containing the OID of the table that the row came from. | ||
TABLEOID = 2; | ||
} | ||
|
||
// InvertedIndexColumnKind is the kind of the inverted index on a column. The | ||
// reason this needs to be stored is that we need to be able to check that the | ||
// "opclass" passed into an inverted index declaration (for example, | ||
// gin_trgm_ops) is compatible with the datatype of a particular column | ||
// (gin_tgrm_ops is only valid on text). A future reason is that it's possible | ||
// to desire having more than one type of inverted index on a particular | ||
// datatype - for example, you might want to create a "stemming" inverted index | ||
// on text. And without this extra kind, it wouldn't be possible to distinguish | ||
// a text inverted index that uses trigrams, vs a text inverted index that uses | ||
// stemming. | ||
enum InvertedIndexColumnKind { | ||
// DEFAULT is the default kind of inverted index column. JSON, Array, and | ||
// geo inverted indexes all are DEFAULT, though prior to 22.2 they had no | ||
// kind at all. | ||
DEFAULT = 0; | ||
// TRIGRAM is the trigram kind of inverted index column. It's only valid on | ||
// text columns. | ||
TRIGRAM = 1; | ||
} |
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.
very minor nit: is it possible to
switch constraint.(type)
here instead? I'm not actually sure, in any case these if-elses feel kinda clunky.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.
FYI you can
case catalog.CheckConstraint:
etc but this is fine too of course.