Skip to content

Commit d771ace

Browse files
committed
sql: handle mixed-case for pg_get_serial_sequence
Release note (bug fix): The pg_get_serial_sequence builtin function can now handle mixed-case names correctly.
1 parent b4dfdc0 commit d771ace

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

pkg/sql/logictest/testdata/logic_test/serial

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,18 @@ create table serial_2 ("capITALS" SERIAL)
245245
query T
246246
SELECT pg_get_serial_sequence('serial_2', 'capITALS')
247247
----
248-
public.serial_2_capITALS_seq
248+
public."serial_2_capITALS_seq"
249+
250+
statement ok
251+
create schema "schema-hyphen"
252+
253+
statement ok
254+
create table "schema-hyphen"."Serial_3" ("capITALS" SERIAL)
255+
256+
query T
257+
SELECT pg_get_serial_sequence('"schema-hyphen"."Serial_3"', 'capITALS')
258+
----
259+
"schema-hyphen"."Serial_3_capITALS_seq"
249260

250261
statement ok
251262
INSERT INTO serial (a, b) VALUES (0, 2), (DEFAULT, DEFAULT), (DEFAULT, 3)

pkg/sql/sem/builtins/pg_builtins.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ var pgBuiltins = map[string]builtinDefinition{
832832
return tree.DNull, nil
833833
}
834834
res.ExplicitCatalog = false
835-
return tree.NewDString(fmt.Sprintf(`%s.%s`, res.Schema(), res.Object())), nil
835+
return tree.NewDString(fmt.Sprintf(`%s.%s`, res.SchemaName.String(), res.ObjectName.String())), nil
836836
},
837837
Info: "Returns the name of the sequence used by the given column_name in the table table_name.",
838838
Volatility: volatility.Stable,

0 commit comments

Comments
 (0)