support pgsql 10
authorTeodor Sigaev <teodor@sigaev.ru>
Wed, 5 Apr 2017 15:39:41 +0000 (18:39 +0300)
committerTeodor Sigaev <teodor@sigaev.ru>
Wed, 5 Apr 2017 15:39:41 +0000 (18:39 +0300)
online_analyze.c

index b1a3578..f9c8ffd 100644 (file)
 #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);