diff --git a/src/common/backend/parser/gram.y b/src/common/backend/parser/gram.y index d28252133..d9c2a1bc6 100644 --- a/src/common/backend/parser/gram.y +++ b/src/common/backend/parser/gram.y @@ -28656,7 +28656,15 @@ target_el: a_expr AS ColLabel | a_expr IDENT { $$ = makeNode(ResTarget); - $$->name = $2; + if (u_sess->attr.attr_sql.enable_ignore_case_in_dquotes + && (pg_yyget_extra(yyscanner))->core_yy_extra.ident_quoted) + { + $$->name = pg_strtolower(pstrdup($2)); + } + else + { + $$->name = $2; + } $$->indirection = NIL; $$->val = (Node *)$1; $$->location = @1; diff --git a/src/test/regress/expected/ignore_double_quotes.out b/src/test/regress/expected/ignore_double_quotes.out index 52d0b63f6..99413db23 100644 --- a/src/test/regress/expected/ignore_double_quotes.out +++ b/src/test/regress/expected/ignore_double_quotes.out @@ -79,6 +79,13 @@ select * from "啊啊"; insert into ¥("¥","$") values(1,2); insert into ¥(¥,"$") values(4,3); insert into "啊啊"(",",",") values(1,2); +-- alias +create table t_ignore_case_in_dquotes_use_case0001(col1 int,col2 varchar(10)); +insert into t_ignore_case_in_dquotes_use_case0001 values(1,'one'),(2,'two'),(3,'three'); +select col1 as "AS_COL1",col2 "AS_COL2" from "t_ignore_case_in_dquotes_use_case0001" where "COL2"='two'; +ERROR: column "COL2" does not exist +LINE 1: ...rom "t_ignore_case_in_dquotes_use_case0001" where "COL2"='tw... + ^ -- function create function f1(b int) returns int as $$ @@ -368,6 +375,12 @@ call "P1"(); (1 row) +select col1 as "AS_COL1",col2 "AS_COL2" from "t_ignore_case_in_dquotes_use_case0001" where "COL2"='two'; + as_col1 | as_col2 +---------+--------- + 2 | two +(1 row) + select * from "TeSt"; A | a ---+--- @@ -441,6 +454,7 @@ drop index i1; drop view test_view; drop view "TeSt_view"; drop table test; +drop table t_ignore_case_in_dquotes_use_case0001; drop table "TeSt"; drop table "¥¥"; drop table "$"; diff --git a/src/test/regress/sql/ignore_double_quotes.sql b/src/test/regress/sql/ignore_double_quotes.sql index a150a9575..4eb3bb334 100644 --- a/src/test/regress/sql/ignore_double_quotes.sql +++ b/src/test/regress/sql/ignore_double_quotes.sql @@ -39,6 +39,11 @@ insert into ¥("¥","$") values(1,2); insert into ¥(¥,"$") values(4,3); insert into "啊啊"(",",",") values(1,2); +-- alias +create table t_ignore_case_in_dquotes_use_case0001(col1 int,col2 varchar(10)); +insert into t_ignore_case_in_dquotes_use_case0001 values(1,'one'),(2,'two'),(3,'three'); +select col1 as "AS_COL1",col2 "AS_COL2" from "t_ignore_case_in_dquotes_use_case0001" where "COL2"='two'; + -- function create function f1(b int) returns int as $$ @@ -150,6 +155,7 @@ CREATE SEQUENCE "S1" START 801 CACHE 90;-- error call p1(); select * from test; call "P1"(); +select col1 as "AS_COL1",col2 "AS_COL2" from "t_ignore_case_in_dquotes_use_case0001" where "COL2"='two'; select * from "TeSt"; create table "SCH_ignore_quote_01"."TAB_quote"("A" int); insert into tab_quote (a) values (4); @@ -177,6 +183,7 @@ drop index i1; drop view test_view; drop view "TeSt_view"; drop table test; +drop table t_ignore_case_in_dquotes_use_case0001; drop table "TeSt"; drop table "¥¥"; drop table "$";