From aa4865265e13ebb5f50f65510208671f7d7c23f5 Mon Sep 17 00:00:00 2001 From: kanoi Date: Thu, 1 Sep 2016 19:46:35 +1000 Subject: [PATCH] ckdb - add a nameram cmd_query --- src/ckdb.h | 2 +- src/ckdb_cmd.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/ckdb.h b/src/ckdb.h index a812a33c..a66576e0 100644 --- a/src/ckdb.h +++ b/src/ckdb.h @@ -58,7 +58,7 @@ #define DB_VLOCK "1" #define DB_VERSION "1.0.7" -#define CKDB_VERSION DB_VERSION"-2.442" +#define CKDB_VERSION DB_VERSION"-2.443" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__ diff --git a/src/ckdb_cmd.c b/src/ckdb_cmd.c index 48290342..18413aa8 100644 --- a/src/ckdb_cmd.c +++ b/src/ckdb_cmd.c @@ -7612,6 +7612,31 @@ static char *cmd_query(__maybe_unused PGconn *conn, char *cmd, char *id, rows++; } + ok = true; + } else if (strcasecmp(request, "nameram") == 0) { + NAMERAM *nameram = NULL; + K_ITEM *n_item; + + K_RLOCK(nameram_free); + n_item = STORE_RHEAD(nameram_store); + while (n_item) { + DATA_NAMERAM(nameram, n_item); + snprintf(tmp, sizeof(tmp), "rem:%d=%d%c", + rows, (int)sizeof(nameram->rem), FLDSEP); + APPEND_REALLOC(buf, off, len, tmp); + snprintf(tmp, sizeof(tmp), "left:%d=%d%c", + rows, (int)(nameram->left), FLDSEP); + APPEND_REALLOC(buf, off, len, tmp); + n_item = n_item->next; + rows++; + } + K_RUNLOCK(nameram_free); + snprintf(tmp, sizeof(tmp), "flds=%s%c", "rem,left", FLDSEP); + APPEND_REALLOC(buf, off, len, tmp); + snprintf(tmp, sizeof(tmp), "arn=%s%carp=%s%c", + "NameRAM", FLDSEP, "", FLDSEP); + APPEND_REALLOC(buf, off, len, tmp); + ok = true; } else { free(buf);