| 165 | } |
| 166 | |
| 167 | bool db_exec_prepared_v2(struct db_stmt *stmt TAKES) |
| 168 | { |
| 169 | bool ret = stmt->db->config->exec_fn(stmt); |
| 170 | |
| 171 | /* If this was a write we need to bump the data_version upon commit. */ |
| 172 | stmt->db->dirty = stmt->db->dirty || !stmt->query->readonly; |
| 173 | |
| 174 | stmt->executed = true; |
| 175 | list_del_from(&stmt->db->pending_statements, &stmt->list); |
| 176 | |
| 177 | /* The driver itself doesn't call `fatal` since we want to override it |
| 178 | * for testing. Instead we check here that the error message is set if |
| 179 | * we report an error. */ |
| 180 | if (!ret) { |
| 181 | assert(stmt->error); |
| 182 | db_fatal("Error executing statement: %s", stmt->error); |
| 183 | } |
| 184 | |
| 185 | if (taken(stmt)) |
| 186 | tal_free(stmt); |
| 187 | |
| 188 | return ret; |
| 189 | } |
| 190 | |
| 191 | size_t db_count_changes(struct db_stmt *stmt) |
| 192 | { |