@@ -632,39 +632,51 @@ pathman_post_parse_analysis_hook(ParseState *pstate, Query *query)
632632 if (post_parse_analyze_hook_next )
633633 post_parse_analyze_hook_next (pstate , query );
634634
635- /* Hooks can be disabled */
635+ /* See cook_partitioning_expression() */
636636 if (!pathman_hooks_enabled )
637637 return ;
638638
639- /* Finish delayed invalidation jobs */
640- if (IsPathmanReady ())
641- finish_delayed_invalidation ();
639+ /* We shouldn't proceed on: ... */
640+ if (query -> commandType == CMD_UTILITY )
641+ {
642+ /* ... BEGIN */
643+ if (xact_is_transaction_stmt (query -> utilityStmt ))
644+ return ;
642645
643- /*
644- * We shouldn't proceed on:
645- * BEGIN
646- * SET [TRANSACTION]
647- */
648- if (query -> commandType == CMD_UTILITY &&
649- (xact_is_transaction_stmt (query -> utilityStmt ) ||
650- xact_is_set_stmt (query -> utilityStmt )))
651- return ;
646+ /* ... SET pg_pathman.enable */
647+ if (xact_is_set_stmt (query -> utilityStmt , PATHMAN_ENABLE ))
648+ {
649+ /* Accept all events in case it's "enable = OFF" */
650+ if (IsPathmanReady ())
651+ finish_delayed_invalidation ();
652652
653- /*
654- * We should also disable pg_pathman on:
655- * ALTER EXTENSION pg_pathman
656- */
657- if (query -> commandType == CMD_UTILITY &&
658- xact_is_alter_pathman_stmt (query -> utilityStmt ))
659- {
660- /* Disable pg_pathman to perform a painless update */
661- (void ) set_config_option (PATHMAN_ENABLE , "off" ,
662- PGC_SUSET , PGC_S_SESSION ,
663- GUC_ACTION_SAVE , true, 0 , false);
653+ return ;
654+ }
664655
665- return ;
656+ /* ... SET [TRANSACTION] */
657+ if (xact_is_set_stmt (query -> utilityStmt , NULL ))
658+ return ;
659+
660+ /* ... ALTER EXTENSION pg_pathman */
661+ if (xact_is_alter_pathman_stmt (query -> utilityStmt ))
662+ {
663+ /* Leave no delayed events before ALTER EXTENSION */
664+ if (IsPathmanReady ())
665+ finish_delayed_invalidation ();
666+
667+ /* Disable pg_pathman to perform a painless update */
668+ (void ) set_config_option (PATHMAN_ENABLE , "off" ,
669+ PGC_SUSET , PGC_S_SESSION ,
670+ GUC_ACTION_SAVE , true, 0 , false);
671+
672+ return ;
673+ }
666674 }
667675
676+ /* Finish all delayed invalidation jobs */
677+ if (IsPathmanReady ())
678+ finish_delayed_invalidation ();
679+
668680 /* Load config if pg_pathman exists & it's still necessary */
669681 if (IsPathmanEnabled () &&
670682 !IsPathmanInitialized () &&
@@ -746,7 +758,7 @@ pathman_relcache_hook(Datum arg, Oid relid)
746758{
747759 Oid parent_relid ;
748760
749- /* Hooks can be disabled */
761+ /* See cook_partitioning_expression() */
750762 if (!pathman_hooks_enabled )
751763 return ;
752764
0 commit comments