summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2011-08-25 14:33:08 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2011-08-25 14:33:25 -0400
commitbe93200c76911047dcb94ddb696441ecdef9a3cb (patch)
tree74d893ec5101caebed548adbed8854201acfc3ea /src
parentde632180ed51b8a6ff275a5f81198521e8b30e12 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/bin/psql/psqlscan.l33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/bin/psql/psqlscan.l b/src/bin/psql/psqlscan.l
index dfc6648e569..1d4e7f11e99 100644
--- a/src/bin/psql/psqlscan.l
+++ b/src/bin/psql/psqlscan.l
@@ -723,6 +723,23 @@ other .
}
/*
+ * 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.
*/
@@ -912,7 +929,7 @@ other .
}
}
-:[A-Za-z0-9_]* {
+:[A-Za-z0-9_]+ {
/* Possible psql variable substitution */
if (option_type == OT_VERBATIM)
ECHO;
@@ -959,6 +976,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;
if (option_type == OT_FILEPIPE)