From 7f9a1f54288ce52b3b1579e21b5151cadcbdbce1 Mon Sep 17 00:00:00 2001 From: l00584793 Date: Tue, 26 Apr 2022 20:15:42 +0800 Subject: [PATCH] Fix the bug that the pgplsql invokes the syntax parser error. --- src/common/pl/plpgsql/src/gram.y | 11 ++++++++++- src/include/utils/plpgsql.h | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/common/pl/plpgsql/src/gram.y b/src/common/pl/plpgsql/src/gram.y index dad560b29..a5ba9ac5f 100755 --- a/src/common/pl/plpgsql/src/gram.y +++ b/src/common/pl/plpgsql/src/gram.y @@ -10340,7 +10340,16 @@ check_sql_expr(const char *stmt, int location, int leaderlen) oldCxt = MemoryContextSwitchTo(u_sess->plsql_cxt.curr_compile_context->compile_tmp_cxt); u_sess->plsql_cxt.plpgsql_yylloc = plpgsql_yylloc; - (void) raw_parser(stmt); + RawParserHook parser_hook= raw_parser; +#ifndef ENABLE_MULTIPLE_NODES + if (u_sess->attr.attr_sql.b_sql_plugin) { + int id = GetCustomParserId(); + if (id >= 0 && g_instance.raw_parser_hook[id] != NULL) { + parser_hook = (RawParserHook)g_instance.raw_parser_hook[id]; + } + } +#endif + (void)parser_hook(stmt, NULL); MemoryContextSwitchTo(oldCxt); /* Restore former ereport callback */ diff --git a/src/include/utils/plpgsql.h b/src/include/utils/plpgsql.h index 98b20c126..381ecf80b 100644 --- a/src/include/utils/plpgsql.h +++ b/src/include/utils/plpgsql.h @@ -1385,6 +1385,8 @@ typedef struct PlDebugEntry { PLpgSQL_function* func; } PlDebugEntry; +typedef List* (*RawParserHook)(const char*, List**); + const int MAXINT8LEN = 25; const int DEFAULT_DEBUG_BUF_SIZE = 1024; const long NANOSECOND_PER_SECOND = 1000000000L; /* 1s */