Browse Source

ckdb - add a nameram cmd_query

master
kanoi 8 years ago
parent
commit
aa4865265e
  1. 2
      src/ckdb.h
  2. 25
      src/ckdb_cmd.c

2
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__

25
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);

Loading…
Cancel
Save