@@ -118,15 +118,34 @@ std::string TDTxStateToString(TestDrivenTransactionState state) {
118118 }
119119}
120120
121+ void AllowReadWriteTx (ClientContext &context) {
122+ if (!context.transaction .HasActiveTransaction ()) {
123+ return ;
124+ }
125+
126+ auto &meta_txn = MetaTransaction::Get (context);
127+
128+ // List all databases this transaction has touched
129+ auto &opened = meta_txn.OpenedTransactions ();
130+ for (auto &db_ref : opened) {
131+ auto &tx = Transaction::Get (context, db_ref.get ());
132+ if (tx.IsReadOnly ()) {
133+ tx.SetReadWrite ();
134+ }
135+ }
136+ }
137+
121138void UpdateTxStateAfterStatement (Connection &con, TestDrivenTransactionState &state, bool rollback_if_none) {
122139 const auto original_state = state;
123140 switch (state) {
124141 case TestDrivenTransactionState::NONE:
125142 if (rollback_if_none) {
126143 LOG_DEBUG (" Rolling-back implicit transaction" );
144+ AllowReadWriteTx (*con.context );
127145 con.Rollback ();
128146 } else {
129147 LOG_DEBUG (" Committing implicit transaction" );
148+ AllowReadWriteTx (*con.context );
130149 con.Commit ();
131150 }
132151 break ;
@@ -135,11 +154,13 @@ void UpdateTxStateAfterStatement(Connection &con, TestDrivenTransactionState &st
135154 case TestDrivenTransactionState::TO_COMMIT:
136155 state = TestDrivenTransactionState::NONE;
137156 LOG_DEBUG (" Committing test-driven transaction" );
157+ AllowReadWriteTx (*con.context );
138158 con.Commit ();
139159 break ;
140160 case TestDrivenTransactionState::TO_ROLLBACK:
141161 state = TestDrivenTransactionState::NONE;
142162 LOG_DEBUG (" Rolling-back test-driven transaction" );
163+ AllowReadWriteTx (*con.context );
143164 con.Rollback ();
144165 break ;
145166 default :
0 commit comments