-
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.
Browse files
Browse the repository at this point in the history
111403: sql: add new check relation to help build insert fast path uniqueness checks r=msirek a=msirek sql: add new check relation to help build insert fast path uniqueness checks This creates a `FastPathUniqueChecks` list as a child of `InsertExpr`, similar to `UniqueChecks`, but consisting of relational expressions which can be used to build a fast path uniqueness check using a particular index. Each item in the `FastPathUniqueChecks` list is a `FastPathUniqueChecksItem` whose `Check` expression, if the unique constraint is provisionally eligible to use a fast path uniqueness check, is a filtered scan from the target table of an `INSERT INTO ... VALUES` statement. It is only built if the VALUES clause has a single row. The filter equates each of the unique constraint key columns with its corresponding value from the VALUES clause. The values may either be a `ValuesExpr` or a `WithScanExpr` whose source is a `ValuesExpr`. During exploration, GenerateConstrainedScans will find all valid constrained index scans which are equivalent to the original filtered Scan. The built relations are not executed or displayed in the EXPLAIN, but will be analyzed in a later commit to specify the index and index key values to use for insert fast path uniqueness checks. FastPathUniqueChecksItemPrivate is added with elements which are designed to communicate details of how to build a fast path uniqueness check to the execbuilder. Epic: CRDB-26290 Informs: #58047 Release note: None ---- memo: optbuild unit tests for fast path unique check exprs This commit adds the `ExprFmtHideFastPathChecks` flag, which hides fast path check expressions from the output of expression formatting. It is used in all places except TestBuilder. Also, unit tests for `buildFiltersForFastPathCheck` are added. Epic: CRDB-26290 Informs: #58047 Release note: None ---- xform: opt test for insert fast path checks This commit adds an `insert` transformation rules test which displays optimized fast path checks which are built in the optbuilder and later explored and optimized. This test is modified in a later commit to test for rule firing. Epic: CRDB-26290 Informs: #58047 Release note: None 111443: ccl: regionless restores with rbr table(s) fail fast, add version gate r=msbutler a=annrpom ### ccl: regionless restores with regional by row table(s) fail fast Previously, backing up an MR cluster/db/table that had a regional by row table did not work out-of-the-box (users could not write to said table without performing some operations to ensure hidden column added by regional by row enablement, `crdb_region`, and zone config behaved according to the target RESTORE cluster. This was inadequate because we allowed users to perform a RESTORE where some tables were not "available" right away. This patch addresses this by making sure we "fail fast" if users do decide to attempt a RESTORE where the BACKUP object has a regional by row table. Also: tests. A small amount of tests were fixed to separate the behavior of restoring a database vs a table (just dropping a table after we performed a db restore to test table restore is not a properly isolated test of behavior). Mixed-version tests were added as well. Epic: none Informs: #111348 Part of: https://cockroachlabs.atlassian.net/browse/CRDB-29129 Release note (sql change): Users are not able to perform a `remove_regions` RESTORE if the object being restored contains a regional by row table. --- ### ccl: add 23.2 version gate to regionless restore This patch adds a >= 23.2 version gate to the `remove_regions` RESTORE option, in addition to a mixed-version test to ensure that RESTORE fails fast if it is on a cluster version < 23.2. Epic: none Fixes: #111348 Part of: https://cockroachlabs.atlassian.net/browse/CRDB-29129 Release note: none 111758: server: reduce a flake under race r=stevendanna a=knz Informs #111742. Will be superseded by #111753, but this one needs to be backported (the flake is on the release branch). Epic: CRDB-28893 Release note: None 111761: sql: add select for update in udf tests r=rharding6373 a=rharding6373 This PR exercises simple SELECT FOR UPDATE patterns in UDFs, and also tests UDFs in transactions that are committed or rolled back. Epic: CRDB-25388 Informs: #87289 Release note: None Co-authored-by: Mark Sirek <[email protected]> Co-authored-by: Annie Pompa <[email protected]> Co-authored-by: Raphael 'kena' Poss <[email protected]> Co-authored-by: rharding6373 <[email protected]>
- Loading branch information
Showing
37 changed files
with
3,019 additions
and
1,060 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
59 changes: 59 additions & 0 deletions
59
pkg/ccl/backupccl/testdata/backup-restore/restore-regionless-mixed-version
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,59 @@ | ||
new-cluster name=s1 beforeVersion=23_2_Start disable-tenant localities=us-east-1,us-west-1,eu-central-1 | ||
---- | ||
|
||
exec-sql | ||
CREATE DATABASE d PRIMARY REGION "us-east-1" REGIONS "us-west-1", "eu-central-1"; | ||
CREATE TABLE d.t (x INT); | ||
INSERT INTO d.t VALUES (1), (2), (3); | ||
---- | ||
|
||
query-sql | ||
SELECT region FROM [SHOW REGIONS FROM DATABASE d] ORDER BY 1; | ||
---- | ||
eu-central-1 | ||
us-east-1 | ||
us-west-1 | ||
|
||
query-sql | ||
SHOW DATABASES; | ||
---- | ||
d root us-east-1 {eu-central-1,us-east-1,us-west-1} zone | ||
data root <nil> <nil> {} <nil> | ||
defaultdb root <nil> <nil> {} <nil> | ||
postgres root <nil> <nil> {} <nil> | ||
system node <nil> <nil> {} <nil> | ||
|
||
# backup a cluster | ||
exec-sql | ||
BACKUP INTO 'nodelocal://1/cluster_backup/'; | ||
---- | ||
|
||
new-cluster name=s2 beforeVersion=23_2_Start share-io-dir=s1 disable-tenant | ||
---- | ||
|
||
# restore fails when cluster is in mixed version state while upgrading to 23.2 | ||
exec-sql | ||
RESTORE FROM LATEST IN 'nodelocal://1/cluster_backup/' WITH remove_regions; | ||
---- | ||
pq: to set the remove_regions option, cluster version must be >= 1000023.1-26 | ||
|
||
# upgrade cluster | ||
upgrade-cluster version=23_2 | ||
---- | ||
|
||
exec-sql | ||
RESTORE DATABASE d FROM LATEST IN 'nodelocal://1/cluster_backup/' WITH remove_regions; | ||
---- | ||
|
||
exec-sql | ||
INSERT INTO d.t VALUES (4), (5); | ||
---- | ||
|
||
query-sql | ||
SELECT * FROM d.t | ||
---- | ||
1 | ||
2 | ||
3 | ||
4 | ||
5 |
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.