diff options
author | Stelios Fragkakis <52996999+stelfrag@users.noreply.github.com> | 2021-04-26 14:23:02 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-26 14:23:02 +0300 |
commit | dc2ccfe5eab7dc35165d8c8718d32d24d208022f (patch) | |
tree | afecc42b8789de5e7372af3b8578601372c990f5 /database | |
parent | 055d32dc1faa27d03aa91b6b1e25ad0da622c92a (diff) |
Store null claim id in the database for non claimed children (#11036)
Diffstat (limited to 'database')
-rw-r--r-- | database/sqlite/sqlite_functions.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/database/sqlite/sqlite_functions.c b/database/sqlite/sqlite_functions.c index 88d8d9ea55..a41ad44339 100644 --- a/database/sqlite/sqlite_functions.c +++ b/database/sqlite/sqlite_functions.c @@ -1341,8 +1341,7 @@ failed: #define SQL_STORE_CLAIM_ID "insert into node_instance " \ "(host_id, claim_id, date_created) values (@host_id, @claim_id, strftime('%s')) " \ - "on conflict(host_id) do update set node_id = null, claim_id = excluded.claim_id " \ - "where claim_id <> excluded.claim_id;" + "on conflict(host_id) do update set claim_id = excluded.claim_id;" void store_claim_id(uuid_t *host_id, uuid_t *claim_id) { @@ -1367,7 +1366,10 @@ void store_claim_id(uuid_t *host_id, uuid_t *claim_id) goto failed; } - rc = sqlite3_bind_blob(res, 2, claim_id, sizeof(*claim_id), SQLITE_STATIC); + if (claim_id) + rc = sqlite3_bind_blob(res, 2, claim_id, sizeof(*claim_id), SQLITE_STATIC); + else + rc = sqlite3_bind_null(res, 2); if (unlikely(rc != SQLITE_OK)) { error_report("Failed to bind claim_id parameter to store node instance information"); goto failed; |