From: Teodor Sigaev Date: Wed, 5 Apr 2017 15:39:41 +0000 (+0300) Subject: support pgsql 10 X-Git-Url: http://sigaev.ru/git/gitweb.cgi?a=commitdiff_plain;h=6989eff11a9b07ddf3a83a3d93bb5aa8a31e7384;p=online_analyze.git support pgsql 10 --- 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);