parser_hook.patch
application/octet-stream
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
| File | + | − |
|---|---|---|
| src/backend/parser/parser.c | 15 | 0 |
| src/include/parser/parser.h | 5 | 0 |
diff --git a/src/backend/parser/parser.c b/src/backend/parser/parser.c
index 875de7ba28..0dabbcecc5 100644
--- a/src/backend/parser/parser.c
+++ b/src/backend/parser/parser.c
@@ -26,6 +26,9 @@
#include "parser/parser.h"
#include "parser/scansup.h"
+/* Hook for plugins to get control in raw_parser() */
+parser_hook_type parser_hook = NULL;
+
static bool check_uescapechar(unsigned char escape);
static char *str_udeescape(const char *str, char escape,
int position, core_yyscan_t yyscanner);
@@ -40,6 +43,18 @@ static char *str_udeescape(const char *str, char escape,
*/
List *
raw_parser(const char *str, RawParseMode mode)
+{
+ List *result;
+
+ if (parser_hook)
+ result = (*parser_hook) (str, mode);
+ else
+ result = standard_raw_parser(str, mode);
+ return result;
+}
+
+List *
+standard_raw_parser(const char *str, RawParseMode mode)
{
core_yyscan_t yyscanner;
base_yy_extra_type yyextra;
diff --git a/src/include/parser/parser.h b/src/include/parser/parser.h
index 853b0f1606..ad772e4849 100644
--- a/src/include/parser/parser.h
+++ b/src/include/parser/parser.h
@@ -57,9 +57,14 @@ extern int backslash_quote;
extern bool escape_string_warning;
extern PGDLLIMPORT bool standard_conforming_strings;
+/* Hook for plugins to get control in raw_parser() */
+typedef List *(*parser_hook_type) (const char *str, RawParseMode mode);;
+
+extern PGDLLIMPORT parser_hook_type parser_hook;
/* Primary entry point for the raw parsing functions */
extern List *raw_parser(const char *str, RawParseMode mode);
+extern List *standard_raw_parser(const char *str, RawParseMode mode);
/* Utility functions exported by gram.y (perhaps these should be elsewhere) */
extern List *SystemFuncName(char *name);