| 157 | } |
| 158 | |
| 159 | void db_commit_transaction(struct db *db) |
| 160 | { |
| 161 | bool ok; |
| 162 | assert(db->in_transaction); |
| 163 | |
| 164 | if (!db->transaction_started) { |
| 165 | db->in_transaction = NULL; |
| 166 | assert(!db->dirty); |
| 167 | return; |
| 168 | } |
| 169 | |
| 170 | db_assert_no_outstanding_statements(db); |
| 171 | |
| 172 | /* Increment before reporting changes to an eventual plugin. */ |
| 173 | if (db->dirty) |
| 174 | db_data_version_incr(db); |
| 175 | |
| 176 | db_report_changes(db, NULL, 0); |
| 177 | ok = db->config->commit_tx_fn(db); |
| 178 | |
| 179 | if (!ok) |
| 180 | db_fatal(db, "Failed to commit DB transaction: %s", db->error); |
| 181 | |
| 182 | db->in_transaction = NULL; |
| 183 | db->dirty = false; |
| 184 | db->transaction_started = false; |
| 185 | } |