mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Fix bugs in the isolation tester flex rules.
Tom Lane pointed out that it was giving a warning: "-s option given but default rule can be matched". That was because there was no rule to handle newline in a quoted string. I made that throw an error. Also, line number tracking was broken, giving incorrect line number on error. Fixed that too.
This commit is contained in:
@ -32,10 +32,9 @@ static void addlitchar(const char c);
|
|||||||
%x qstr
|
%x qstr
|
||||||
|
|
||||||
non_newline [^\n\r]
|
non_newline [^\n\r]
|
||||||
space [ \t\n\r\f]
|
space [ \t\r\f]
|
||||||
|
|
||||||
comment ("#"{non_newline}*)
|
comment ("#"{non_newline}*)
|
||||||
whitespace ({space}+|{comment})
|
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
@ -46,10 +45,10 @@ step { return(STEP); }
|
|||||||
teardown { return(TEARDOWN); }
|
teardown { return(TEARDOWN); }
|
||||||
|
|
||||||
[\n] { yyline++; }
|
[\n] { yyline++; }
|
||||||
{whitespace} {
|
{comment} { /* ignore */ }
|
||||||
/* ignore */
|
{space} { /* ignore */ }
|
||||||
}
|
|
||||||
|
|
||||||
|
/* Quoted strings: "foo" */
|
||||||
\" {
|
\" {
|
||||||
litbufpos = 0;
|
litbufpos = 0;
|
||||||
BEGIN(qstr);
|
BEGIN(qstr);
|
||||||
@ -61,27 +60,36 @@ teardown { return(TEARDOWN); }
|
|||||||
return(string);
|
return(string);
|
||||||
}
|
}
|
||||||
<qstr>. { addlitchar(yytext[0]); }
|
<qstr>. { addlitchar(yytext[0]); }
|
||||||
|
<qstr>\n { yyerror("unexpected newline in quoted string"); }
|
||||||
|
<qstr><<EOF>> { yyerror("unterminated quoted string"); }
|
||||||
|
|
||||||
|
/* SQL blocks: { UPDATE ... } */
|
||||||
"{" {
|
"{" {
|
||||||
|
|
||||||
litbufpos = 0;
|
litbufpos = 0;
|
||||||
BEGIN(sql);
|
BEGIN(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
<sql>"}" {
|
<sql>"}" {
|
||||||
litbuf[litbufpos] = '\0';
|
litbuf[litbufpos] = '\0';
|
||||||
yylval.str = strdup(litbuf);
|
yylval.str = strdup(litbuf);
|
||||||
BEGIN(INITIAL);
|
BEGIN(INITIAL);
|
||||||
return(sqlblock);
|
return(sqlblock);
|
||||||
}
|
}
|
||||||
<sql>[^}] { addlitchar(yytext[0]);}
|
<sql>. {
|
||||||
|
addlitchar(yytext[0]);
|
||||||
|
}
|
||||||
|
<sql>\n {
|
||||||
|
yyline++;
|
||||||
|
addlitchar(yytext[0]);
|
||||||
|
}
|
||||||
|
<sql><<EOF>> {
|
||||||
|
yyerror("unterminated sql block");
|
||||||
|
}
|
||||||
|
|
||||||
. {
|
. {
|
||||||
fprintf(stderr, "syntax error at line %d: unexpected character \"%s\"\n", yyline, yytext);
|
fprintf(stderr, "syntax error at line %d: unexpected character \"%s\"\n", yyline, yytext);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Reference in New Issue
Block a user