diff --git a/src/ckdb.c b/src/ckdb.c index e0bfaa91..299c177e 100644 --- a/src/ckdb.c +++ b/src/ckdb.c @@ -483,6 +483,9 @@ K_STORE *markersummary_store; K_TREE *markersummary_pool_root; K_STORE *markersummary_pool_store; +// The markerid load start for markersummary +char *mark_start = NULL; + // WORKMARKERS K_TREE *workmarkers_root; K_TREE *workmarkers_workinfoid_root; @@ -5639,6 +5642,7 @@ static struct option long_options[] = { { "loglevel", required_argument, 0, 'l' }, // marker = enable mark/workmarker/markersummary auto generation { "marker", no_argument, 0, 'm' }, + { "markstart", required_argument, 0, 'M' }, { "name", required_argument, 0, 'n' }, { "dbpass", required_argument, 0, 'p' }, { "btc-pass", required_argument, 0, 'P' }, @@ -5683,7 +5687,7 @@ int main(int argc, char **argv) memset(&ckp, 0, sizeof(ckp)); ckp.loglevel = LOG_NOTICE; - while ((c = getopt_long(argc, argv, "c:d:ghkl:mn:p:P:r:R:s:S:t:u:U:vw:yY:", long_options, &i)) != -1) { + while ((c = getopt_long(argc, argv, "c:d:ghkl:mM:n:p:P:r:R:s:S:t:u:U:vw:yY:", long_options, &i)) != -1) { switch(c) { case 'c': ckp.config = strdup(optarg); @@ -5742,6 +5746,9 @@ int main(int argc, char **argv) case 'm': markersummary_auto = true; break; + case 'M': + mark_start = strdup(optarg); + break; case 'n': ckp.name = strdup(optarg); break; diff --git a/src/ckdb.h b/src/ckdb.h index b626e048..16e33eb7 100644 --- a/src/ckdb.h +++ b/src/ckdb.h @@ -55,7 +55,7 @@ #define DB_VLOCK "1" #define DB_VERSION "1.0.4" -#define CKDB_VERSION DB_VERSION"-1.612" +#define CKDB_VERSION DB_VERSION"-1.620" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__ @@ -1958,6 +1958,9 @@ extern K_STORE *markersummary_store; extern K_TREE *markersummary_pool_root; extern K_STORE *markersummary_pool_store; +// The markerid load start for markersummary +extern char *mark_start; + // WORKMARKERS typedef struct workmarkers { int64_t markerid; diff --git a/src/ckdb_dbio.c b/src/ckdb_dbio.c index 2aa6d8cf..5c481963 100644 --- a/src/ckdb_dbio.c +++ b/src/ckdb_dbio.c @@ -6766,9 +6766,10 @@ bool markersummary_fill(PGconn *conn) K_ITEM *item, *p_item; int n, t, i, p_n; MARKERSUMMARY *row, *p_row; + char *params[1]; char *field; char *sel; - int fields = 20; + int fields = 20, par = 0; bool ok = false; LOGDEBUG("%s(): select", __func__); @@ -6783,7 +6784,16 @@ bool markersummary_fill(PGconn *conn) "sharecount,errorcount,firstshare,lastshare,firstshareacc," "lastshareacc,lastdiffacc" MODIFYDATECONTROL - " from markersummary"; + " from markersummary where markerid>=$1"; + par = 0; + if (mark_start) + params[par++] = mark_start; + else + params[par++] = "0"; + PARCHK(par, params); + + LOGWARNING("%s(): loading from markerid>=%s", __func__, params[0]); + res = PQexec(conn, "Begin", CKPQ_READ); rescode = PQresultStatus(res); PQclear(res); @@ -6792,7 +6802,7 @@ bool markersummary_fill(PGconn *conn) return false; } - res = PQexec(conn, sel, CKPQ_READ); + res = PQexecParams(conn, sel, par, NULL, (const char **)params, NULL, NULL, 0, CKPQ_READ); rescode = PQresultStatus(res); PQclear(res); if (!PGOK(rescode)) {