Fix have not set yyloc when using @var.

This commit is contained in:
totaj
2023-02-06 15:48:45 +08:00
parent 7ac947b7c3
commit 3435e4fc9b
4 changed files with 55 additions and 11 deletions

View File

@ -1170,8 +1170,8 @@ other .
}
{setUserIdentifier} {
SET_YYLLOC();
if (u_sess->attr.attr_sql.sql_compatibility == B_FORMAT && u_sess->attr.attr_common.enable_set_variable_b_format) {
SET_YYLLOC();
yylval->str = pstrdup(yytext + 1);
yyextra->is_hint_str = false;
return SET_USER_IDENT;

View File

@ -2,9 +2,29 @@
set @v1 := 1;
select @v1;
-- error
create or replace function tri_func1() returns trigger as
$$
declare
begin
set @num = @num + NEW.a;
return NEW;
end
$$ LANGUAGE PLPGSQL;
\! @abs_bindir@/gs_guc reload -Z datanode -D @abs_srcdir@/tmp_check/datanode1 -c "enable_set_variable_b_format=on" >/dev/null 2>&1
\! sleep 1
-- error
create or replace function tri_func1() returns trigger as
$$
declare
begin
set @num = @num + NEW.a;
return NEW;
end
$$ LANGUAGE PLPGSQL;
-- error
set @v1 := 1;
select @v1;

View File

@ -1,15 +1,15 @@
-- error
select 10 into @aa;
ERROR: syntax error at or near "into @"
ERROR: syntax error at or near "@"
LINE 1: select 10 into @aa;
^
^
\! @abs_bindir@/gs_guc reload -Z datanode -D @abs_srcdir@/tmp_check/datanode1 -c "enable_set_variable_b_format=on" >/dev/null 2>&1
\! sleep 1
-- error
select 10 into @aa;
ERROR: syntax error at or near "into @"
ERROR: syntax error at or near "@"
LINE 1: select 10 into @aa;
^
^
create database test dbcompatibility 'b';
\c test
show enable_set_variable_b_format;

View File

@ -1,19 +1,43 @@
-- error
set @v1 := 1;
ERROR: syntax error at or near "set @"
ERROR: syntax error at or near "@"
LINE 1: set @v1 := 1;
^
^
select @v1;
ERROR: column "v1" does not exist
LINE 1: select @v1;
^
-- error
create or replace function tri_func1() returns trigger as
$$
declare
begin
set @num = @num + NEW.a;
return NEW;
end
$$ LANGUAGE PLPGSQL;
ERROR: syntax error at or near "@"
LINE 5: set @num = @num + NEW.a;
^
\! @abs_bindir@/gs_guc reload -Z datanode -D @abs_srcdir@/tmp_check/datanode1 -c "enable_set_variable_b_format=on" >/dev/null 2>&1
\! sleep 1
-- error
create or replace function tri_func1() returns trigger as
$$
declare
begin
set @num = @num + NEW.a;
return NEW;
end
$$ LANGUAGE PLPGSQL;
ERROR: syntax error at or near "@"
LINE 5: set @num = @num + NEW.a;
^
-- error
set @v1 := 1;
ERROR: syntax error at or near "set @"
ERROR: syntax error at or near "@"
LINE 1: set @v1 := 1;
^
^
select @v1;
ERROR: column "v1" does not exist
LINE 1: select @v1;
@ -1185,9 +1209,9 @@ show enable_set_variable_b_format;
set enable_set_variable_b_format = off;
set @v1 := 1, @v2 := 2, @v3 := @v4 := 3;
ERROR: syntax error at or near "set @"
ERROR: syntax error at or near "@"
LINE 1: set @v1 := 1, @v2 := 2, @v3 := @v4 := 3;
^
^
\c test_set
show enable_set_variable_b_format;
enable_set_variable_b_format