* Abort lingering subtransactions that have been explicitly started * by plpy.subtransaction().start() and not properly closed. */
| 1110 | * by plpy.subtransaction().start() and not properly closed. |
| 1111 | */ |
| 1112 | static void |
| 1113 | PLy_abort_open_subtransactions(int save_subxact_level) |
| 1114 | { |
| 1115 | Assert(save_subxact_level >= 0); |
| 1116 | |
| 1117 | while (list_length(explicit_subtransactions) > save_subxact_level) |
| 1118 | { |
| 1119 | PLySubtransactionData *subtransactiondata; |
| 1120 | |
| 1121 | Assert(explicit_subtransactions != NIL); |
| 1122 | |
| 1123 | ereport(WARNING, |
| 1124 | (errmsg("forcibly aborting a subtransaction that has not been exited"))); |
| 1125 | |
| 1126 | RollbackAndReleaseCurrentSubTransaction(); |
| 1127 | |
| 1128 | subtransactiondata = (PLySubtransactionData *) linitial(explicit_subtransactions); |
| 1129 | explicit_subtransactions = list_delete_first(explicit_subtransactions); |
| 1130 | |
| 1131 | MemoryContextSwitchTo(subtransactiondata->oldcontext); |
| 1132 | CurrentResourceOwner = subtransactiondata->oldowner; |
| 1133 | pfree(subtransactiondata); |
| 1134 | } |
| 1135 | } |
no test coverage detected