| 174 | } |
| 175 | |
| 176 | void db_exec_prepared_v2(struct db_stmt *stmt TAKES) |
| 177 | { |
| 178 | bool ret; |
| 179 | |
| 180 | db_need_transaction(stmt->db, stmt->query->query); |
| 181 | trace_span_start("db_exec_prepared", stmt); |
| 182 | trace_span_tag(stmt, "query", stmt->query->query); |
| 183 | ret = stmt->db->config->exec_fn(stmt); |
| 184 | trace_span_end(stmt); |
| 185 | |
| 186 | if (stmt->db->readonly) |
| 187 | assert(stmt->query->readonly); |
| 188 | |
| 189 | /* If this was a write we need to bump the data_version upon commit. */ |
| 190 | stmt->db->dirty = stmt->db->dirty || !stmt->query->readonly; |
| 191 | |
| 192 | stmt->executed = true; |
| 193 | list_del_from(&stmt->db->pending_statements, &stmt->list); |
| 194 | |
| 195 | /* The driver itself doesn't call `fatal` since we want to override it |
| 196 | * for testing. Instead we check here that the error message is set if |
| 197 | * we report an error. */ |
| 198 | if (!ret) { |
| 199 | assert(stmt->error); |
| 200 | db_fatal(stmt->db, "Error executing statement: %s", stmt->error); |
| 201 | } |
| 202 | |
| 203 | tal_free_if_taken(stmt); |
| 204 | } |
| 205 | |
| 206 | size_t db_count_changes(struct db_stmt *stmt) |
| 207 | { |