Skip to content

Commit a222d52

Browse files
authored
Merge pull request #153606 from spilchen/backport24.1-152910
release-24.1: sql/sem/tree: fix width handling for BIT column default values
2 parents 7007b3c + ba5cac7 commit a222d52

16 files changed

+1525
-2
lines changed

pkg/ccl/schemachangerccl/backup_base_generated_test.go

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/sql/schemachanger/sctest_generated_test.go

Lines changed: 42 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
setup
2+
CREATE TABLE bittab (c1 INT);
3+
----
4+
5+
# Insert is blocked prior to setting the NULL attribute on the column due to a
6+
# temporary constraint.
7+
stage-exec phase=PostCommitPhase stage=4
8+
INSERT INTO bittab(c1) VALUES (1);
9+
----
10+
pq: failed to satisfy CHECK constraint .*
11+
12+
# At this stage, the NULL attribute is now added to the column and temp
13+
# constraint is dropped. We allow the INSERT. A suitable value for the new
14+
# column is selected in tree.NewDefaultDatum.
15+
stage-exec phase=PostCommitPhase stage=5
16+
INSERT INTO bittab(c1) VALUES (1);
17+
----
18+
19+
stage-query phase=PostCommitPhase stage=6
20+
SELECT count(*) FROM bittab
21+
----
22+
1
23+
24+
# Confirm that we can delete the new column value.
25+
stage-exec phase=PostCommitPhase stage=7
26+
DELETE FROM bittab
27+
----
28+
29+
test
30+
ALTER TABLE bittab ADD COLUMN vb VARBIT(25) NOT NULL UNIQUE, ADD COLUMN fb BIT(25) NOT NULL
31+
----

0 commit comments

Comments
 (0)