Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbe93200

Browse files
committed
Fix psql lexer to avoid use of backtracking.
Per previous experimentation, backtracking slows down lexing performancesignificantly (by about a third). It's usually pretty easy to avoid, justneed to have rules that accept an incomplete construct and do whatever thelexer would have done otherwise.The backtracking was introduced by the patch that added quoted variablesubstitution. Back-patch to 9.0 where that was added.
1 parentde63218 commitbe93200

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

‎src/bin/psql/psqlscan.l

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,23 @@ other.
722722
escape_variable(true);
723723
}
724724
725+
/*
726+
* These rules just avoid the need for scanner backup if one of the
727+
* two rules above fails to match completely.
728+
*/
729+
730+
:'[A-Za-z0-9_]*{
731+
/* Throw back everything but the colon */
732+
yyless(1);
733+
ECHO;
734+
}
735+
736+
:\"[A-Za-z0-9_]*{
737+
/* Throw back everything but the colon */
738+
yyless(1);
739+
ECHO;
740+
}
741+
725742
/*
726743
* Back to backend-compatible rules.
727744
*/
@@ -912,7 +929,7 @@ other.
912929
}
913930
}
914931

915-
:[A-Za-z0-9_]*{
932+
:[A-Za-z0-9_]+{
916933
/* Possible psql variable substitution */
917934
if (option_type == OT_VERBATIM)
918935
ECHO;
@@ -959,6 +976,20 @@ other.
959976
}
960977
}
961978
979+
:'[A-Za-z0-9_]*{
980+
/* Throw back everything but the colon */
981+
yyless(1);
982+
ECHO;
983+
BEGIN(xslashdefaultarg);
984+
}
985+
986+
:\"[A-Za-z0-9_]*{
987+
/* Throw back everything but the colon */
988+
yyless(1);
989+
ECHO;
990+
BEGIN(xslashdefaultarg);
991+
}
992+
962993
"|"{
963994
ECHO;
964995
if (option_type == OT_FILEPIPE)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp