@@ -649,8 +649,7 @@ isFastTruncateCall(QueryDesc *queryDesc)
649
649
queryDesc -> operation == CMD_SELECT &&
650
650
queryDesc -> plannedstmt -> planTree &&
651
651
queryDesc -> plannedstmt -> planTree -> targetlist &&
652
- list_length (queryDesc -> plannedstmt -> planTree -> targetlist ) == 1 &&
653
- IsA (linitial (queryDesc -> plannedstmt -> planTree -> targetlist ), TargetEntry )
652
+ list_length (queryDesc -> plannedstmt -> planTree -> targetlist ) == 1
654
653
))
655
654
return NULL ;
656
655
@@ -667,8 +666,7 @@ isFastTruncateCall(QueryDesc *queryDesc)
667
666
fe -> funcretset == false &&
668
667
fe -> funcresulttype == VOIDOID &&
669
668
fe -> funcvariadic == false &&
670
- list_length (fe -> args ) == 1 &&
671
- IsA (linitial (fe -> args ), Const )
669
+ list_length (fe -> args ) == 1
672
670
))
673
671
return NULL ;
674
672
@@ -685,7 +683,6 @@ isFastTruncateCall(QueryDesc *queryDesc)
685
683
}
686
684
687
685
688
-
689
686
extern PGDLLIMPORT void onlineAnalyzeHooker (QueryDesc * queryDesc );
690
687
void
691
688
onlineAnalyzeHooker (QueryDesc * queryDesc )
@@ -753,21 +750,34 @@ onlineAnalyzeHooker(QueryDesc *queryDesc)
753
750
standard_ExecutorEnd (queryDesc );
754
751
}
755
752
753
+ static List * toremove = NIL ;
754
+
755
+ /*
756
+ * removeTable called on transaction end, see call RegisterXactCallback() below
757
+ */
756
758
static void
757
759
removeTable (XactEvent event , void * arg )
758
760
{
759
- List * toremove = arg ;
760
761
ListCell * cell ;
761
762
762
- if (event != XACT_EVENT_COMMIT )
763
- return ;
763
+ switch (event )
764
+ {
765
+ case XACT_EVENT_COMMIT :
766
+ break ;
767
+ case XACT_EVENT_ABORT :
768
+ toremove = NIL ;
769
+ default :
770
+ return ;
771
+ }
764
772
765
773
foreach (cell , toremove )
766
774
{
767
775
Oid relOid = lfirst_oid (cell );
768
776
769
777
hash_search (relstats , & relOid , HASH_REMOVE , NULL );
770
778
}
779
+
780
+ toremove = NIL ;
771
781
}
772
782
773
783
@@ -816,7 +826,6 @@ onlineAnalyzeHookerUtility(
816
826
((DropStmt * )parsetree )-> removeType == OBJECT_TABLE )
817
827
{
818
828
ListCell * cell ;
819
- List * toremove = NIL ;
820
829
821
830
foreach (cell , ((DropStmt * )parsetree )-> objects )
822
831
{
@@ -833,9 +842,6 @@ onlineAnalyzeHookerUtility(
833
842
MemoryContextSwitchTo (ctx );
834
843
}
835
844
}
836
-
837
- if (list_length (toremove ) > 0 )
838
- RegisterXactCallback (removeTable , toremove );
839
845
}
840
846
else if (IsA (parsetree , VacuumStmt ))
841
847
{
@@ -1178,6 +1184,7 @@ _PG_init(void)
1178
1184
NULL
1179
1185
);
1180
1186
1187
+ RegisterXactCallback (removeTable , NULL );
1181
1188
}
1182
1189
1183
1190
void _PG_fini (void );
0 commit comments