修复set 赋值反单引号``问题

This commit is contained in:
qianxue21
2022-11-25 16:48:22 +08:00
parent cd1244c51f
commit d3caf0fe23
3 changed files with 27 additions and 1 deletions

View File

@ -886,6 +886,21 @@ other .
char *slashstar = strstr(yytext, "/*");
char *dashdash = strstr(yytext, "--");
if (u_sess->attr.attr_sql.sql_compatibility == B_FORMAT && u_sess->attr.attr_common.enable_set_variable_b_format)
{
if(nchars > 3 && yytext[0] == '@' && yytext[1] == '`' && yytext[nchars-1] == '`')
{
char *subtext = strstr(yytext + 2, "`");
if(strlen(subtext) == 1)
{
SET_YYLLOC();
yylval->str = pstrdup(yytext + 1);
yyextra->is_hint_str = false;
return SET_USER_IDENT;
}
}
}
if (slashstar && dashdash)
{
/* if both appear, take the first one */

View File

@ -92,6 +92,9 @@ select @v1, @1a_b.2$3, @a_b.2$3, @_ab.2$3, @.ab_2$3, @$ab.2_3,
@"v1", @"1a_b.2$3", @"a_b.2$3", @"_ab.2$3", @".ab_2$3", @"$ab.2_3",
@`v1`, @`1a_b.2$3`, @`a_b.2$3`, @`_ab.2$3`, @`.ab_2$3`, @`$ab.2_3`;
select @`gdas()^&?<>cs`, @"gdas()^&?<>cs", @'gdas()^&?<>cs';
set @`!`:= 2;
set @`~~!` := 3;
select @`!`,@`~~!`;
-- error
select @gdas()^&?<>cs;
@ -546,4 +549,4 @@ drop database if exists test_set;
\! @abs_bindir@/gs_guc reload -Z datanode -D @abs_srcdir@/tmp_check/datanode1 -c "enable_set_variable_b_format=off" >/dev/null 2>&1
\! sleep 1
show enable_set_variable_b_format;
show enable_set_variable_b_format;

View File

@ -171,6 +171,14 @@ select @`gdas()^&?<>cs`, @"gdas()^&?<>cs", @'gdas()^&?<>cs';
7 | 7 | 7
(1 row)
set @`!`:= 2;
set @`~~!` := 3;
select @`!`,@`~~!`;
@! | @~~!
----+------
2 | 3
(1 row)
-- error
select @gdas()^&?<>cs;
ERROR: syntax error at or near "("