@@ -2013,8 +2013,11 @@ CommitTransaction(void)
20132013TransactionState s = CurrentTransactionState ;
20142014TransactionId latestXid ;
20152015bool is_parallel_worker ;
2016+ bool is_autonomous_transaction ;
20162017
20172018is_parallel_worker = (s -> blockState == TBLOCK_PARALLEL_INPROGRESS );
2019+ is_autonomous_transaction = getNestLevelATX ()!= 0 ;
2020+
20182021
20192022/* Enforce parallel mode restrictions during parallel worker commit. */
20202023if (is_parallel_worker )
@@ -2048,7 +2051,7 @@ CommitTransaction(void)
20482051 * If there weren't any, we are done ... otherwise loop back to check
20492052 * if they queued deferred triggers. Lather, rinse, repeat.
20502053 */
2051- if (getNestLevelATX () != 0 || !PreCommit_Portals (false))
2054+ if (is_autonomous_transaction || !PreCommit_Portals (false))
20522055break ;
20532056}
20542057
@@ -2160,7 +2163,7 @@ CommitTransaction(void)
21602163RESOURCE_RELEASE_BEFORE_LOCKS ,
21612164 true, true);
21622165
2163- if (getNestLevelATX () == 0 )
2166+ if (! is_autonomous_transaction )
21642167{
21652168/* Check we've released all buffer pins */
21662169AtEOXact_Buffers (true);
@@ -2180,38 +2183,45 @@ CommitTransaction(void)
21802183xactHasRelcacheInvalidationMessages = HasRelcacheInvalidationMessages ();
21812184AtEOXact_Inval (true);
21822185
2183- AtEOXact_MultiXact ();
2184-
2186+ if (!is_autonomous_transaction )
2187+ {
2188+ AtEOXact_MultiXact ();
2189+ }
21852190ResourceOwnerRelease (TopTransactionResourceOwner ,
21862191RESOURCE_RELEASE_LOCKS ,
21872192 true, true);
21882193ResourceOwnerRelease (TopTransactionResourceOwner ,
21892194RESOURCE_RELEASE_AFTER_LOCKS ,
21902195 true, true);
21912196
2192- /*
2193- * Likewise, dropping of files deleted during the transaction is best done
2194- * after releasing relcache and buffer pins. (This is not strictly
2195- * necessary during commit, since such pins should have been released
2196- * already, but this ordering is definitely critical during abort.) Since
2197- * this may take many seconds, also delay until after releasing locks.
2198- * Other backends will observe the attendant catalog changes and not
2199- * attempt to access affected files.
2200- */
2201- smgrDoPendingDeletes (true);
2197+ if (!is_autonomous_transaction )
2198+ {
2199+ /*
2200+ * Likewise, dropping of files deleted during the transaction is best done
2201+ * after releasing relcache and buffer pins. (This is not strictly
2202+ * necessary during commit, since such pins should have been released
2203+ * already, but this ordering is definitely critical during abort.) Since
2204+ * this may take many seconds, also delay until after releasing locks.
2205+ * Other backends will observe the attendant catalog changes and not
2206+ * attempt to access affected files.
2207+ */
2208+ smgrDoPendingDeletes (true);
2209+ }
22022210
22032211/* Check we've released all catcache entries */
22042212AtEOXact_CatCache (true);
22052213
22062214AtCommit_Notify ();
22072215AtEOXact_GUC (true,s -> gucNestLevel );
2208- if (getNestLevelATX ()== 0 )
2216+ if (!is_autonomous_transaction )
2217+ {
22092218AtEOXact_SPI (true);
2219+ }
22102220AtEOXact_on_commit_actions (true);
22112221AtEOXact_Namespace (true,is_parallel_worker );
2212- AtEOXact_SMgr ();
2213- if (getNestLevelATX ()== 0 )
2222+ if (!is_autonomous_transaction )
22142223{
2224+ AtEOXact_SMgr ();
22152225AtEOXact_Files ();
22162226AtEOXact_ComboCid ();
22172227}