mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
db: Track whether a db_stmt has been executed
For some of the query methods in the next step we need to have an idea of whether the stmt was executed (db_step function) so let's track that explicitly. Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
committed by
Rusty Russell
parent
e65e4fcf4b
commit
98963c58e4
@@ -593,6 +593,7 @@ struct db_stmt *db_prepare_v2_(const char *location, struct db *db,
|
|||||||
stmt->location = location;
|
stmt->location = location;
|
||||||
stmt->error = NULL;
|
stmt->error = NULL;
|
||||||
stmt->db = db;
|
stmt->db = db;
|
||||||
|
stmt->executed = false;
|
||||||
stmt->inner_stmt = NULL;
|
stmt->inner_stmt = NULL;
|
||||||
|
|
||||||
tal_add_destructor(stmt, db_stmt_free);
|
tal_add_destructor(stmt, db_stmt_free);
|
||||||
@@ -1346,6 +1347,7 @@ bool db_exec_prepared_v2(struct db_stmt *stmt TAKES)
|
|||||||
{
|
{
|
||||||
const char *expanded_sql;
|
const char *expanded_sql;
|
||||||
bool ret = stmt->db->config->exec_fn(stmt);
|
bool ret = stmt->db->config->exec_fn(stmt);
|
||||||
|
stmt->executed = true;
|
||||||
if (stmt->db->config->expand_fn != NULL && ret &&
|
if (stmt->db->config->expand_fn != NULL && ret &&
|
||||||
!stmt->query->readonly) {
|
!stmt->query->readonly) {
|
||||||
expanded_sql = stmt->db->config->expand_fn(stmt);
|
expanded_sql = stmt->db->config->expand_fn(stmt);
|
||||||
|
|||||||
@@ -78,6 +78,8 @@ struct db_stmt {
|
|||||||
|
|
||||||
/* Pointer to DB-specific statement. */
|
/* Pointer to DB-specific statement. */
|
||||||
void *inner_stmt;
|
void *inner_stmt;
|
||||||
|
|
||||||
|
bool executed;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct db_config {
|
struct db_config {
|
||||||
|
|||||||
Reference in New Issue
Block a user