-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
33681: opt: Project merged Upsert columns r=andy-kimball a=andy-kimball Currently, the Upsert operator's insert and update columns are separately created and maintained. For example: CREATE TABLE abc (a INT PRIMARY KEY, b INT) INSERT INTO abc VALUES (1) ON CONFLICT (a) DO UPDATE SET b=5 Here are the projected columns: SELECT a AS fetch_a, b AS fetch_b, 1 AS ins_a, NULL AS ins_b, 5 AS upd_b FROM ... This commit constructs CASE statements that merge the insert and update columns, like this: SELECT a AS fetch_a, b AS fetch_b, CASE WHEN fetch_a IS NULL THEN 1 ELSE fetch_a END AS ups_a, CASE WHEN fetch_a IS NULL THEN NULL::INT ELSE 5 END AS ups_b FROM ... The advantages to making this change are: 1. This sets us up to implement check constraints, since they will now be able to operate on the combined columns. 2. This often avoids evaluating the update expression when an insert needs to occur for a given row. 3. This simplifies the property derivation, making Upsert act just like Update, Insert, and Delete. It's now possible to cleanly map each mutation output column to a single input column. Co-authored-by: Andrew Kimball <andyk@cockroachlabs.com>
- Loading branch information
Showing
30 changed files
with
1,804 additions
and
980 deletions.
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
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
Oops, something went wrong.