mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-10-01 12:41:20 +02:00
Fix psql lexer to avoid use of backtracking.
Per previous experimentation, backtracking slows down lexing performance significantly (by about a third). It's usually pretty easy to avoid, just need to have rules that accept an incomplete construct and do whatever the lexer would have done otherwise. The backtracking was introduced by the patch that added quoted variable substitution. Back-patch to 9.0 where that was added.
This commit is contained in:
parent
2e95f1f002
commit
77ce50a403
@ -723,6 +723,23 @@ other .
|
|||||||
escape_variable(true);
|
escape_variable(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These rules just avoid the need for scanner backup if one of the
|
||||||
|
* two rules above fails to match completely.
|
||||||
|
*/
|
||||||
|
|
||||||
|
:'[A-Za-z0-9_]* {
|
||||||
|
/* Throw back everything but the colon */
|
||||||
|
yyless(1);
|
||||||
|
ECHO;
|
||||||
|
}
|
||||||
|
|
||||||
|
:\"[A-Za-z0-9_]* {
|
||||||
|
/* Throw back everything but the colon */
|
||||||
|
yyless(1);
|
||||||
|
ECHO;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Back to backend-compatible rules.
|
* Back to backend-compatible rules.
|
||||||
*/
|
*/
|
||||||
@ -913,7 +930,7 @@ other .
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:[A-Za-z0-9_]* {
|
:[A-Za-z0-9_]+ {
|
||||||
/* Possible psql variable substitution */
|
/* Possible psql variable substitution */
|
||||||
if (option_type == OT_VERBATIM)
|
if (option_type == OT_VERBATIM)
|
||||||
ECHO;
|
ECHO;
|
||||||
@ -960,6 +977,20 @@ other .
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:'[A-Za-z0-9_]* {
|
||||||
|
/* Throw back everything but the colon */
|
||||||
|
yyless(1);
|
||||||
|
ECHO;
|
||||||
|
BEGIN(xslashdefaultarg);
|
||||||
|
}
|
||||||
|
|
||||||
|
:\"[A-Za-z0-9_]* {
|
||||||
|
/* Throw back everything but the colon */
|
||||||
|
yyless(1);
|
||||||
|
ECHO;
|
||||||
|
BEGIN(xslashdefaultarg);
|
||||||
|
}
|
||||||
|
|
||||||
"|" {
|
"|" {
|
||||||
ECHO;
|
ECHO;
|
||||||
if (option_type == OT_FILEPIPE)
|
if (option_type == OT_FILEPIPE)
|
||||||
|
Loading…
Reference in New Issue
Block a user