From 6989eff11a9b07ddf3a83a3d93bb5aa8a31e7384 Mon Sep 17 00:00:00 2001 From: Teodor Sigaev Date: Wed, 5 Apr 2017 18:39:41 +0300 Subject: [PATCH] support pgsql 10 --- online_analyze.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/online_analyze.c b/online_analyze.c index b1a3578..f9c8ffd 100644 --- a/online_analyze.c +++ b/online_analyze.c @@ -50,6 +50,10 @@ #include "utils/timestamp.h" #if PG_VERSION_NUM >= 90500 #include "nodes/makefuncs.h" +#if PG_VERSION_NUM >= 100000 +#include "utils/varlena.h" +#include "utils/regproc.h" +#endif #endif #endif @@ -111,6 +115,7 @@ static HTAB *relstats = NULL; static void relstatsInit(void); +#if PG_VERSION_NUM < 100000 static int oid_cmp(const void *a, const void *b) { @@ -118,6 +123,7 @@ oid_cmp(const void *a, const void *b) return 0; return (*(Oid*)a > *(Oid*)b) ? 1 : -1; } +#endif static const char * tableListAssign(const char * newval, bool doit, TableList *tbl) @@ -607,22 +613,45 @@ onlineAnalyzeHooker(QueryDesc *queryDesc) #if PG_VERSION_NUM >= 90200 static void -onlineAnalyzeHookerUtility(Node *parsetree, const char *queryString, +onlineAnalyzeHookerUtility( +#if PG_VERSION_NUM >= 100000 + PlannedStmt *pstmt, +#else + Node *parsetree, +#endif + const char *queryString, #if PG_VERSION_NUM >= 90300 ProcessUtilityContext context, ParamListInfo params, +#if PG_VERSION_NUM >= 100000 + QueryEnvironment *queryEnv, +#endif #else ParamListInfo params, bool isTopLevel, #endif DestReceiver *dest, char *completionTag) { RangeVar *tblname = NULL; +#if PG_VERSION_NUM >= 100000 + Node *parsetree = NULL; + + if (pstmt->commandType == CMD_UTILITY) + parsetree = pstmt->utilityStmt; +#endif - if (IsA(parsetree, CreateTableAsStmt) && ((CreateTableAsStmt*)parsetree)->into) + if (parsetree && IsA(parsetree, CreateTableAsStmt) && + ((CreateTableAsStmt*)parsetree)->into) tblname = (RangeVar*)copyObject(((CreateTableAsStmt*)parsetree)->into->rel); +#if PG_VERSION_NUM >= 100000 +#define parsetree pstmt +#endif + if (oldProcessUtilityHook) oldProcessUtilityHook(parsetree, queryString, #if PG_VERSION_NUM >= 90300 context, params, +#if PG_VERSION_NUM >= 100000 + queryEnv, +#endif #else params, isTopLevel, #endif @@ -631,11 +660,18 @@ onlineAnalyzeHookerUtility(Node *parsetree, const char *queryString, standard_ProcessUtility(parsetree, queryString, #if PG_VERSION_NUM >= 90300 context, params, +#if PG_VERSION_NUM >= 100000 + queryEnv, +#endif #else params, isTopLevel, #endif dest, completionTag); +#if PG_VERSION_NUM >= 100000 +#undef parsetree +#endif + if (tblname) { Oid tblOid = RangeVarGetRelid(tblname, NoLock, true); -- 2.46.1