Check for non-utility commands in PlannedStmt
authorPavan Deolasee <[email protected]>
Thu, 15 Jun 2017 05:26:04 +0000 (10:56 +0530)
committerPavan Deolasee <[email protected]>
Thu, 15 Jun 2017 05:26:04 +0000 (10:56 +0530)
Starting PG 10, even utility statements are wrapped in a PlannedStmt. So we
must ensure that we are dealing with non-utility statements before trying to
look into the planTree because it won't be set for utility statements.

src/pl/plpgsql/src/pl_exec.c

index 0d75a99361d7eab933bba0181b0a9143b8761622..73dddec35fbd4624e67e7cf9c90472ad83b5aba1 100644 (file)
@@ -5367,6 +5367,7 @@ exec_for_query(PLpgSQL_execstate *estate, PLpgSQL_stmt_forq *stmt,
         */
 #define MAX_REMOTE_QUERY_FETCH 10000   
        if (IsA(linitial(portal->stmts), PlannedStmt) &&
+               (((PlannedStmt *) linitial(portal->stmts))->commandType != CMD_UTILITY) &&
                IsA(((PlannedStmt *) linitial(portal->stmts))->planTree, RemoteQuery))
                count = MAX_REMOTE_QUERY_FETCH;
        else