Skip to content
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

sql: fix behavior of SERIAL columns on mixed-case tables #40965

Merged
merged 1 commit into from
Sep 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/serial
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,26 @@ SELECT count(DISTINCT a), count(DISTINCT b), count(DISTINCT c) FROM serial
----
4 3 4

statement ok
CREATE TABLE "serial_MixedCase" (
a SERIAL PRIMARY KEY,
b INT DEFAULT 7,
c SERIAL,
UNIQUE INDEX (c)
)

query TT
SHOW CREATE TABLE "serial_MixedCase"
----
"serial_MixedCase" CREATE TABLE "serial_MixedCase" (
a INT8 NOT NULL DEFAULT nextval('"serial_MixedCase_a_seq"':::STRING),
b INT8 NULL DEFAULT 7:::INT8,
c INT8 NOT NULL DEFAULT nextval('"serial_MixedCase_c_seq"':::STRING),
CONSTRAINT "primary" PRIMARY KEY (a ASC),
UNIQUE INDEX "serial_MixedCase_c_key" (c ASC),
FAMILY "primary" (a, b, c)
)

statement error multiple default values specified for column "a" of table "s1"
CREATE TABLE s1 (a SERIAL DEFAULT 7)

Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/serial.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (p *planner) processSerialInColumnDef(

defaultExpr := &tree.FuncExpr{
Func: tree.WrapFunction("nextval"),
Exprs: tree.Exprs{tree.NewStrVal(seqName.Table())},
Exprs: tree.Exprs{tree.NewStrVal(seqName.String())},
}

seqType := ""
Expand Down