Browse Source

ckdb - allow setting a history limit on markersummary with -M

master
kanoi 9 years ago
parent
commit
3059afdf33
  1. 9
      src/ckdb.c
  2. 5
      src/ckdb.h
  3. 16
      src/ckdb_dbio.c

9
src/ckdb.c

@ -483,6 +483,9 @@ K_STORE *markersummary_store;
K_TREE *markersummary_pool_root; K_TREE *markersummary_pool_root;
K_STORE *markersummary_pool_store; K_STORE *markersummary_pool_store;
// The markerid load start for markersummary
char *mark_start = NULL;
// WORKMARKERS // WORKMARKERS
K_TREE *workmarkers_root; K_TREE *workmarkers_root;
K_TREE *workmarkers_workinfoid_root; K_TREE *workmarkers_workinfoid_root;
@ -5639,6 +5642,7 @@ static struct option long_options[] = {
{ "loglevel", required_argument, 0, 'l' }, { "loglevel", required_argument, 0, 'l' },
// marker = enable mark/workmarker/markersummary auto generation // marker = enable mark/workmarker/markersummary auto generation
{ "marker", no_argument, 0, 'm' }, { "marker", no_argument, 0, 'm' },
{ "markstart", required_argument, 0, 'M' },
{ "name", required_argument, 0, 'n' }, { "name", required_argument, 0, 'n' },
{ "dbpass", required_argument, 0, 'p' }, { "dbpass", required_argument, 0, 'p' },
{ "btc-pass", 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)); memset(&ckp, 0, sizeof(ckp));
ckp.loglevel = LOG_NOTICE; 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) { switch(c) {
case 'c': case 'c':
ckp.config = strdup(optarg); ckp.config = strdup(optarg);
@ -5742,6 +5746,9 @@ int main(int argc, char **argv)
case 'm': case 'm':
markersummary_auto = true; markersummary_auto = true;
break; break;
case 'M':
mark_start = strdup(optarg);
break;
case 'n': case 'n':
ckp.name = strdup(optarg); ckp.name = strdup(optarg);
break; break;

5
src/ckdb.h

@ -55,7 +55,7 @@
#define DB_VLOCK "1" #define DB_VLOCK "1"
#define DB_VERSION "1.0.4" #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 " - from %s %s() line %d"
#define WHERE_FFL_HERE __FILE__, __func__, __LINE__ #define WHERE_FFL_HERE __FILE__, __func__, __LINE__
@ -1958,6 +1958,9 @@ extern K_STORE *markersummary_store;
extern K_TREE *markersummary_pool_root; extern K_TREE *markersummary_pool_root;
extern K_STORE *markersummary_pool_store; extern K_STORE *markersummary_pool_store;
// The markerid load start for markersummary
extern char *mark_start;
// WORKMARKERS // WORKMARKERS
typedef struct workmarkers { typedef struct workmarkers {
int64_t markerid; int64_t markerid;

16
src/ckdb_dbio.c

@ -6766,9 +6766,10 @@ bool markersummary_fill(PGconn *conn)
K_ITEM *item, *p_item; K_ITEM *item, *p_item;
int n, t, i, p_n; int n, t, i, p_n;
MARKERSUMMARY *row, *p_row; MARKERSUMMARY *row, *p_row;
char *params[1];
char *field; char *field;
char *sel; char *sel;
int fields = 20; int fields = 20, par = 0;
bool ok = false; bool ok = false;
LOGDEBUG("%s(): select", __func__); LOGDEBUG("%s(): select", __func__);
@ -6783,7 +6784,16 @@ bool markersummary_fill(PGconn *conn)
"sharecount,errorcount,firstshare,lastshare,firstshareacc," "sharecount,errorcount,firstshare,lastshare,firstshareacc,"
"lastshareacc,lastdiffacc" "lastshareacc,lastdiffacc"
MODIFYDATECONTROL 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); res = PQexec(conn, "Begin", CKPQ_READ);
rescode = PQresultStatus(res); rescode = PQresultStatus(res);
PQclear(res); PQclear(res);
@ -6792,7 +6802,7 @@ bool markersummary_fill(PGconn *conn)
return false; 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); rescode = PQresultStatus(res);
PQclear(res); PQclear(res);
if (!PGOK(rescode)) { if (!PGOK(rescode)) {

Loading…
Cancel
Save