Imrote test to cover previous commit. Daniil Davidov
[online_analyze.git] / online_analyze.c
index afc6b29..0479dbf 100644 (file)
@@ -171,7 +171,12 @@ tableListAssign(const char * newval, bool doit, TableList *tbl)
        * follow work could be done only in normal processing because of
        * accsess to system catalog
        */
-       if (MyBackendId == InvalidBackendId || !IsUnderPostmaster ||
+#if PG_VERSION_NUM >= 170000
+       if (MyProcNumber == INVALID_PROC_NUMBER ||
+#else
+       if (MyBackendId == InvalidBackendId ||
+#endif
+               !IsUnderPostmaster ||
                !IsTransactionState())
        {
                includeTables.inited = false;
@@ -314,7 +319,12 @@ lateInit()
        TableList       *tl[] = {&includeTables, &excludeTables};
        int i;
 
-       if (MyBackendId == InvalidBackendId || !IsUnderPostmaster ||
+#if PG_VERSION_NUM >= 170000
+       if (MyProcNumber == INVALID_PROC_NUMBER ||
+#else
+       if (MyBackendId == InvalidBackendId ||
+#endif
+               !IsUnderPostmaster ||
                !IsTransactionState())
                return; /* we aren't in connected state */
 
@@ -1038,6 +1048,16 @@ onlineAnalyzeHookerUtility(
                        }
                        else
                                tblnames = NIL;
+               } else if (IsA(parsetree, CopyStmt)) {
+                       CopyStmt   *cpystmt = (CopyStmt*) parsetree;
+
+                       /* Create tblnames only if it is not "COPY (query) TO file" command */
+                       if (cpystmt->relation) {
+                               tblnames = list_make1((RangeVar*)copyObject(cpystmt->relation));
+                               op = CK_CREATE;
+                       }
+                       else
+                               Assert(cpystmt->query);
                }
        }
 
@@ -1386,23 +1406,3 @@ _PG_init(void)
 
        RegisterXactCallback(removeTable, NULL);
 }
-
-#if PG_VERSION_NUM < 150000
-void _PG_fini(void);
-void
-_PG_fini(void)
-{
-       ExecutorEnd_hook = oldExecutorEndHook;
-#if PG_VERSION_NUM >= 90200
-       ProcessUtility_hook = oldProcessUtilityHook;
-#endif
-
-       if (excludeTables.tables)
-               free(excludeTables.tables);
-       if (includeTables.tables)
-               free(includeTables.tables);
-
-       excludeTables.tables = includeTables.tables = NULL;
-       excludeTables.nTables = includeTables.nTables = 0;
-}
-#endif