-
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.
sql: set zone configs before backfill on ALTER TABLE LOCALITY/PRIMARY…
… KEY Ensure that the zone configurations are correctly set before the backfill runs, so data is backfilled to the correct location upfront for REGIONAL BY ROW tables. Note this bug also exists on existing ALTER PRIMARY KEY statements. Release justification: bug fixes and low-risk updates to new functionality Release note (bug fix): Fix bug where zone configurations on indexes were not copied before the backfill of an ALTER PRIMARY KEY. They used to be copied afterwards instead.
- Loading branch information
Showing
7 changed files
with
430 additions
and
82 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright 2021 The Cockroach Authors. | ||
// | ||
// Licensed as a CockroachDB Enterprise file under the Cockroach Community | ||
// License (the "License"); you may not use this file except in compliance with | ||
// the License. You may obtain a copy of the License at | ||
// | ||
// https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt | ||
|
||
package partitionccl | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/sql/sqltestutils" | ||
"github.com/cockroachdb/cockroach/pkg/util/leaktest" | ||
"github.com/cockroachdb/cockroach/pkg/util/log" | ||
) | ||
|
||
func TestAlterPrimaryKeyCorrectZoneConfigBeforeBackfill(t *testing.T) { | ||
defer leaktest.AfterTest(t)() | ||
defer log.Scope(t).Close(t) | ||
|
||
testCases := []sqltestutils.AlterPrimaryKeyCorrectZoneConfigTestCase{ | ||
{ | ||
Desc: "ALTER PRIMARY KEY", | ||
SetupQuery: `CREATE TABLE t.test (k INT NOT NULL, v INT NOT NULL, INDEX v_idx (v)); | ||
ALTER INDEX t.test@v_idx CONFIGURE ZONE USING gc.ttlseconds = 888 | ||
`, | ||
AlterQuery: `ALTER TABLE t.test ALTER PRIMARY KEY USING COLUMNS (v)`, | ||
ExpectedIntermediateZoneConfigs: []sqltestutils.AlterPrimaryKeyCorrectZoneConfigIntermediateZoneConfig{ | ||
{ | ||
ShowConfigStatement: `SHOW ZONE CONFIGURATION FOR INDEX t.test@v_idx_rewrite_for_primary_key_change`, | ||
ExpectedTarget: `INDEX t.public.test@v_idx_rewrite_for_primary_key_change`, | ||
ExpectedSQL: `ALTER INDEX t.public.test@v_idx_rewrite_for_primary_key_change CONFIGURE ZONE USING | ||
range_min_bytes = 134217728, | ||
range_max_bytes = 536870912, | ||
gc.ttlseconds = 888, | ||
num_replicas = 1, | ||
constraints = '[]', | ||
lease_preferences = '[]'`, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
sqltestutils.AlterPrimaryKeyCorrectZoneConfigTest( | ||
t, | ||
`CREATE DATABASE t`, | ||
testCases, | ||
) | ||
} |
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.