@@ -2013,8 +2013,11 @@ CommitTransaction(void)
2013
2013
TransactionState s = CurrentTransactionState ;
2014
2014
TransactionId latestXid ;
2015
2015
bool is_parallel_worker ;
2016
+ bool is_autonomous_transaction ;
2016
2017
2017
2018
is_parallel_worker = (s -> blockState == TBLOCK_PARALLEL_INPROGRESS );
2019
+ is_autonomous_transaction = getNestLevelATX () != 0 ;
2020
+
2018
2021
2019
2022
/* Enforce parallel mode restrictions during parallel worker commit. */
2020
2023
if (is_parallel_worker )
@@ -2048,7 +2051,7 @@ CommitTransaction(void)
2048
2051
* If there weren't any, we are done ... otherwise loop back to check
2049
2052
* if they queued deferred triggers. Lather, rinse, repeat.
2050
2053
*/
2051
- if (getNestLevelATX () != 0 || !PreCommit_Portals (false))
2054
+ if (is_autonomous_transaction || !PreCommit_Portals (false))
2052
2055
break ;
2053
2056
}
2054
2057
@@ -2160,7 +2163,7 @@ CommitTransaction(void)
2160
2163
RESOURCE_RELEASE_BEFORE_LOCKS ,
2161
2164
true, true);
2162
2165
2163
- if (getNestLevelATX () == 0 )
2166
+ if (! is_autonomous_transaction )
2164
2167
{
2165
2168
/* Check we've released all buffer pins */
2166
2169
AtEOXact_Buffers (true);
@@ -2180,38 +2183,45 @@ CommitTransaction(void)
2180
2183
xactHasRelcacheInvalidationMessages = HasRelcacheInvalidationMessages ();
2181
2184
AtEOXact_Inval (true);
2182
2185
2183
- AtEOXact_MultiXact ();
2184
-
2186
+ if (!is_autonomous_transaction )
2187
+ {
2188
+ AtEOXact_MultiXact ();
2189
+ }
2185
2190
ResourceOwnerRelease (TopTransactionResourceOwner ,
2186
2191
RESOURCE_RELEASE_LOCKS ,
2187
2192
true, true);
2188
2193
ResourceOwnerRelease (TopTransactionResourceOwner ,
2189
2194
RESOURCE_RELEASE_AFTER_LOCKS ,
2190
2195
true, true);
2191
2196
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
+ }
2202
2210
2203
2211
/* Check we've released all catcache entries */
2204
2212
AtEOXact_CatCache (true);
2205
2213
2206
2214
AtCommit_Notify ();
2207
2215
AtEOXact_GUC (true, s -> gucNestLevel );
2208
- if (getNestLevelATX () == 0 )
2216
+ if (!is_autonomous_transaction )
2217
+ {
2209
2218
AtEOXact_SPI (true);
2219
+ }
2210
2220
AtEOXact_on_commit_actions (true);
2211
2221
AtEOXact_Namespace (true, is_parallel_worker );
2212
- AtEOXact_SMgr ();
2213
- if (getNestLevelATX () == 0 )
2222
+ if (!is_autonomous_transaction )
2214
2223
{
2224
+ AtEOXact_SMgr ();
2215
2225
AtEOXact_Files ();
2216
2226
AtEOXact_ComboCid ();
2217
2227
}
0 commit comments