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

Commit2a7425d

Browse files
committed
jsonpath scanner: reentrant scanner
Use the flex %option reentrant to make the generated scannerreentrant and thread-safe. Note: The parser was already pure.Simplify flex scan buffer management: Instead of constructing thebuffer from pieces and then using yy_scan_buffer(), we can just useyy_scan_string(), which does the same thing internally. (Actually, weuse yy_scan_bytes() here because we already have the length.)Use flex yyextra to handle context information, instead of globalvariables. This complements the other changes to make the scannerreentrant.Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>Reviewed-by: Andreas Karlsson <andreas@proxel.se>Discussion:https://www.postgresql.org/message-id/flat/eb6faeac-2a8a-4b69-9189-c33c520e5b7b@eisentraut.org
1 parent9b25489 commit2a7425d

File tree

4 files changed

+145
-154
lines changed

4 files changed

+145
-154
lines changed

‎src/backend/nls.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ GETTEXT_TRIGGERS = $(BACKEND_COMMON_GETTEXT_TRIGGERS) \
77
GUC_check_errhint\
88
write_stderr\
99
yyerror\
10-
jsonpath_yyerror:3\
10+
jsonpath_yyerror:4\
1111
parser_yyerror\
1212
replication_yyerror:2\
1313
scanner_yyerror\

‎src/backend/utils/adt/jsonpath_gram.y

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ static bool makeItemLikeRegex(JsonPathParseItem *expr,
6060
%name-prefix="jsonpath_yy"
6161
%parse-param {JsonPathParseResult **result}
6262
%parse-param {structNode *escontext}
63+
%parse-param {yyscan_t yyscanner}
6364
%lex-param {JsonPathParseResult **result}
6465
%lex-param {structNode *escontext}
66+
%lex-param {yyscan_t yyscanner}
6567

6668
%union
6769
{

‎src/backend/utils/adt/jsonpath_internal.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,25 @@ typedef struct JsonPathString
2222
inttotal;
2323
}JsonPathString;
2424

25+
#ifndefYY_TYPEDEF_YY_SCANNER_T
26+
#defineYY_TYPEDEF_YY_SCANNER_T
27+
typedefvoid*yyscan_t;
28+
#endif
29+
2530
#include"utils/jsonpath.h"
2631
#include"jsonpath_gram.h"
2732

2833
#defineYY_DECL extern int jsonpath_yylex(YYSTYPE *yylval_param, \
2934
JsonPathParseResult **result, \
30-
struct Node *escontext)
35+
struct Node *escontext, \
36+
yyscan_t yyscanner)
3137
YY_DECL;
3238
externintjsonpath_yyparse(JsonPathParseResult**result,
33-
structNode*escontext);
39+
structNode*escontext,
40+
yyscan_tyyscanner);
3441
externvoidjsonpath_yyerror(JsonPathParseResult**result,
3542
structNode*escontext,
43+
yyscan_tyyscanner,
3644
constchar*message);
3745

3846
#endif/* JSONPATH_INTERNAL_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp