From 91aa3d0e367ed8bb998cbfdd188e526edbb2c3a3 Mon Sep 17 00:00:00 2001 From: kanoi Date: Thu, 15 Jan 2015 21:25:17 +1100 Subject: [PATCH] ckdb - workmarkers processing: no sharesummaries is not an error --- src/ckdb.h | 2 +- src/ckdb_dbio.c | 70 ++++++++++++++++++++++++------------------------- 2 files changed, 35 insertions(+), 37 deletions(-) diff --git a/src/ckdb.h b/src/ckdb.h index 03184147..b0733d55 100644 --- a/src/ckdb.h +++ b/src/ckdb.h @@ -52,7 +52,7 @@ #define DB_VLOCK "1" #define DB_VERSION "0.9.6" -#define CKDB_VERSION DB_VERSION"-0.831" +#define CKDB_VERSION DB_VERSION"-0.832" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__ diff --git a/src/ckdb_dbio.c b/src/ckdb_dbio.c index 74877f58..6c453461 100644 --- a/src/ckdb_dbio.c +++ b/src/ckdb_dbio.c @@ -2904,32 +2904,30 @@ bool sharesummaries_to_markersummaries(PGconn *conn, WORKMARKERS *workmarkers, ss_item = ss_prev; } - if (old_sharesummary_store->count == 0) - reason = "no sharesummaries"; - else { - if (conn == NULL) { - conn = dbconnect(); - conned = true; - } + if (conn == NULL) { + conn = dbconnect(); + conned = true; + } - res = PQexec(conn, "Begin", CKPQ_WRITE); - rescode = PQresultStatus(res); - PQclear(res); - if (!PGOK(rescode)) { - PGLOGERR("Begin", rescode, conn); - goto flail; - } + res = PQexec(conn, "Begin", CKPQ_WRITE); + rescode = PQresultStatus(res); + PQclear(res); + if (!PGOK(rescode)) { + PGLOGERR("Begin", rescode, conn); + goto flail; + } - ms_item = new_markersummary_store->head; - while (ms_item) { - if (!(markersummary_add(conn, ms_item, by, code, inet, - cd, trf_root))) { - reason = "db error"; - goto rollback; - } - ms_item = ms_item->next; + ms_item = new_markersummary_store->head; + while (ms_item) { + if (!(markersummary_add(conn, ms_item, by, code, inet, + cd, trf_root))) { + reason = "db error"; + goto rollback; } + ms_item = ms_item->next; + } + if (old_sharesummary_store->count > 0) { par = 0; params[par++] = bigint_to_buf(workmarkers->workinfoidstart, NULL, 0); params[par++] = bigint_to_buf(workmarkers->workinfoidend, NULL, 0); @@ -2958,23 +2956,23 @@ bool sharesummaries_to_markersummaries(PGconn *conn, WORKMARKERS *workmarkers, reason = "delete mismatch"; goto rollback; } + } - ok = workmarkers_process(conn, true, true, - workmarkers->markerid, - workmarkers->poolinstance, - workmarkers->workinfoidend, - workmarkers->workinfoidstart, - workmarkers->description, - MARKER_PROCESSED_STR, - by, code, inet, cd, trf_root); + ok = workmarkers_process(conn, true, true, + workmarkers->markerid, + workmarkers->poolinstance, + workmarkers->workinfoidend, + workmarkers->workinfoidstart, + workmarkers->description, + MARKER_PROCESSED_STR, + by, code, inet, cd, trf_root); rollback: - if (ok) - res = PQexec(conn, "Commit", CKPQ_WRITE); - else - res = PQexec(conn, "Rollback", CKPQ_WRITE); + if (ok) + res = PQexec(conn, "Commit", CKPQ_WRITE); + else + res = PQexec(conn, "Rollback", CKPQ_WRITE); - PQclear(res); - } + PQclear(res); flail: for (n = 0; n < par; n++) free(params[n]);