Adjust code to PG14 post_parse_analyze_hook changes

PG14 adds an argument to post_parse_analyze_hook

https://github.com/postgres/postgres/commit/5fd9dfa5f5
This commit is contained in:
Sven Klemm 2021-06-05 13:12:57 +02:00 committed by Sven Klemm
parent 044441e02a
commit 1a05529c40
2 changed files with 38 additions and 8 deletions

View File

@ -111,7 +111,12 @@ static ProcessUtility_hook_type prev_ProcessUtility_hook;
static post_parse_analyze_hook_type extension_post_parse_analyze_hook = NULL;
static void inline extension_check(void);
#if PG14_LT
static void call_extension_post_parse_analyze_hook(ParseState *pstate, Query *query);
#else
static void call_extension_post_parse_analyze_hook(ParseState *pstate, Query *query,
JumbleState *jstate);
#endif
extern char *
ts_loader_extension_version(void)
@ -332,7 +337,11 @@ stop_workers_on_db_drop(DropdbStmt *drop_db_statement)
}
static void
#if PG14_LT
post_analyze_hook(ParseState *pstate, Query *query)
#else
post_analyze_hook(ParseState *pstate, Query *query, JumbleState *jstate)
#endif
{
if (query->commandType == CMD_UTILITY)
{
@ -437,19 +446,27 @@ post_analyze_hook(ParseState *pstate, Query *query)
(query->commandType != CMD_UTILITY || load_utility_cmd(query->utilityStmt)))
extension_check();
/*
* Call the extension's hook. This is necessary since the extension is
* installed during the hook. If we did not do this the extension's hook
* would not be called during the first command because the extension
* would not have yet been installed. Thus the loader captures the
* extension hook and calls it explicitly after the check for installing
* the extension.
*/
/*
* Call the extension's hook. This is necessary since the extension is
* installed during the hook. If we did not do this the extension's hook
* would not be called during the first command because the extension
* would not have yet been installed. Thus the loader captures the
* extension hook and calls it explicitly after the check for installing
* the extension.
*/
#if PG14_LT
call_extension_post_parse_analyze_hook(pstate, query);
#else
call_extension_post_parse_analyze_hook(pstate, query, jstate);
#endif
if (prev_post_parse_analyze_hook != NULL)
{
#if PG14_LT
prev_post_parse_analyze_hook(pstate, query);
#else
prev_post_parse_analyze_hook(pstate, query, jstate);
#endif
}
}
@ -696,10 +713,18 @@ ts_loader_extension_check(void)
}
static void
#if PG14_LT
call_extension_post_parse_analyze_hook(ParseState *pstate, Query *query)
#else
call_extension_post_parse_analyze_hook(ParseState *pstate, Query *query, JumbleState *jstate)
#endif
{
if (loaded && extension_post_parse_analyze_hook != NULL)
{
#if PG14_LT
extension_post_parse_analyze_hook(pstate, query);
#else
extension_post_parse_analyze_hook(pstate, query, jstate);
#endif
}
}

View File

@ -15,6 +15,7 @@
#include <utils/guc.h>
#include <utils/inval.h>
#include <parser/analyze.h>
#include "compat/compat.h"
#include "export.h"
#define STR_EXPAND(x) #x
@ -44,7 +45,11 @@ cache_invalidate_callback(Datum arg, Oid relid)
}
static void
#if PG14_LT
post_analyze_hook(ParseState *pstate, Query *query)
#else
post_analyze_hook(ParseState *pstate, Query *query, JumbleState *jstate)
#endif
{
if (ts_extension_is_loaded())
elog(WARNING, "mock post_analyze_hook " STR(TIMESCALEDB_VERSION_MOD));