fix support 'COPY .. TO file'. Daniil Davidov & Dmitriy Koval
authorTeodor Sigaev <teodor@sigaev.ru>
Tue, 22 Oct 2024 08:39:49 +0000 (11:39 +0300)
committerTeodor Sigaev <teodor@sigaev.ru>
Tue, 22 Oct 2024 08:39:49 +0000 (11:39 +0300)
online_analyze.c

index b9aae90..0479dbf 100644 (file)
@@ -1051,8 +1051,13 @@ onlineAnalyzeHookerUtility(
                } else if (IsA(parsetree, CopyStmt)) {
                        CopyStmt   *cpystmt = (CopyStmt*) parsetree;
 
-                       tblnames = list_make1((RangeVar*)copyObject(cpystmt->relation));
-                       op = CK_CREATE;
+                       /* 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);
                }
        }