修复sequence大小写忽略问题

This commit is contained in:
梅程
2024-07-22 13:19:00 +08:00
parent f3b82066f6
commit f27f8a7bc3
3 changed files with 49 additions and 1 deletions

View File

@ -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;

View File

@ -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";

View File

@ -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";