diff --git a/src/common/backend/parser/parse_expr.cpp b/src/common/backend/parser/parse_expr.cpp index 722db712d..849b07fb3 100644 --- a/src/common/backend/parser/parse_expr.cpp +++ b/src/common/backend/parser/parse_expr.cpp @@ -3186,7 +3186,7 @@ static Node* transformSequenceFuncCall(ParseState* pstate, Node* field1, Node* f if (field1 != NULL) { StringInfoData buf; initStringInfo(&buf); - appendStringInfo(&buf, "%s.%s", strVal(field1), strVal(field2)); + appendStringInfo(&buf, "\"%s\".\"%s\"", strVal(field1), strVal(field2)); arg = makeString(buf.data); } else { arg = (Value*)field2; diff --git a/src/test/regress/expected/single_node_sequence.out b/src/test/regress/expected/single_node_sequence.out index 94ab62332..152eda5e8 100644 --- a/src/test/regress/expected/single_node_sequence.out +++ b/src/test/regress/expected/single_node_sequence.out @@ -429,3 +429,33 @@ DROP USER seq_user; DROP SEQUENCE seq; drop sequence "QUOTATION_SEQ"; drop sequence no_quotation_seq; +-- uppercase sequence name +-- public schema +create table "T1" (c1 int, c2 int); +create sequence "SEQ1" increment by 1 maxvalue 9223372036854775807 start with 3 cache 20; +NOTICE: Not advised to use MAXVALUE or MINVALUE together with CACHE. +DETAIL: If CACHE is defined, some sequence values may be wasted, causing available sequence numbers to be less than expected. +insert into "T1" values(128, "SEQ1".nextval); +select * from "T1"; + c1 | c2 +-----+---- + 128 | 3 +(1 row) + +drop sequence "SEQ1"; +drop table "T1"; +-- new schema +create schema if not exists "NEW_SCHEMA"; +create table "NEW_SCHEMA"."T1" (c1 int, c2 int); +create sequence "NEW_SCHEMA"."SEQ1" increment by 1 maxvalue 9223372036854775807 start with 3 cache 20; +NOTICE: Not advised to use MAXVALUE or MINVALUE together with CACHE. +DETAIL: If CACHE is defined, some sequence values may be wasted, causing available sequence numbers to be less than expected. +insert into "NEW_SCHEMA"."T1" values (128, "NEW_SCHEMA"."SEQ1".nextval); +select * from "NEW_SCHEMA"."T1"; + c1 | c2 +-----+---- + 128 | 3 +(1 row) + +drop sequence "NEW_SCHEMA"."SEQ1"; +drop table "NEW_SCHEMA"."T1"; diff --git a/src/test/regress/sql/single_node_sequence.sql b/src/test/regress/sql/single_node_sequence.sql index 0c70040bd..12b315523 100644 --- a/src/test/regress/sql/single_node_sequence.sql +++ b/src/test/regress/sql/single_node_sequence.sql @@ -192,3 +192,21 @@ DROP USER seq_user; DROP SEQUENCE seq; drop sequence "QUOTATION_SEQ"; drop sequence no_quotation_seq; + +-- uppercase sequence name +-- public schema +create table "T1" (c1 int, c2 int); +create sequence "SEQ1" increment by 1 maxvalue 9223372036854775807 start with 3 cache 20; +insert into "T1" values(128, "SEQ1".nextval); +select * from "T1"; +drop sequence "SEQ1"; +drop table "T1"; + +-- new schema +create schema if not exists "NEW_SCHEMA"; +create table "NEW_SCHEMA"."T1" (c1 int, c2 int); +create sequence "NEW_SCHEMA"."SEQ1" increment by 1 maxvalue 9223372036854775807 start with 3 cache 20; +insert into "NEW_SCHEMA"."T1" values (128, "NEW_SCHEMA"."SEQ1".nextval); +select * from "NEW_SCHEMA"."T1"; +drop sequence "NEW_SCHEMA"."SEQ1"; +drop table "NEW_SCHEMA"."T1";