开启双引号开关时把别名转化为小写

This commit is contained in:
leiziwei
2024-03-06 17:51:35 +08:00
parent cdae0a6ce5
commit 7b292d41ce
3 changed files with 30 additions and 1 deletions

View File

@ -28622,7 +28622,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;

View File

@ -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 $$
@ -264,6 +271,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
---+---
@ -336,6 +349,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 "$";

View File

@ -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 $$
@ -114,6 +119,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);
@ -140,6 +146,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 "$";