From fc925b5eeee06b8306bb08fc312d668af36d54d0 Mon Sep 17 00:00:00 2001 From: kailixu Date: Mon, 24 Jun 2024 16:14:41 +0800 Subject: [PATCH 1/2] fix: expire time for show cluster --- source/common/src/systable.c | 2 +- source/dnode/mnode/impl/src/mndCluster.c | 19 +++---------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/source/common/src/systable.c b/source/common/src/systable.c index 1693e5c480..65c58abdda 100644 --- a/source/common/src/systable.c +++ b/source/common/src/systable.c @@ -85,7 +85,7 @@ static const SSysDbTableSchema clusterSchema[] = { {.name = "uptime", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true}, {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = true}, {.name = "version", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, - {.name = "expire_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, + {.name = "expire_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = true}, }; static const SSysDbTableSchema userDBSchema[] = { diff --git a/source/dnode/mnode/impl/src/mndCluster.c b/source/dnode/mnode/impl/src/mndCluster.c index 31ebc6609d..74e0940cba 100644 --- a/source/dnode/mnode/impl/src/mndCluster.c +++ b/source/dnode/mnode/impl/src/mndCluster.c @@ -311,24 +311,11 @@ static int32_t mndRetrieveClusters(SRpcMsg *pMsg, SShowObj *pShow, SSDataBlock * pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); COL_DATA_SET_VAL_RET((const char *)ver, false, pCluster); - char expireTime[25] = {0}; - pColInfo = taosArrayGet(pBlock->pDataBlock, cols); - if (GRANT_EXPIRE_UNLIMITED(tsExpireTime / 1000)) { - STR_WITH_MAXSIZE_TO_VARSTR(expireTime, "unlimited", pShow->pMeta->pSchemas[cols].bytes); - COL_DATA_SET_VAL_RET(expireTime, false, pCluster); - } else if (tsExpireTime <= 0) { + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + if (tsExpireTime <= 0) { colDataSetNULL(pColInfo, numOfRows); } else { - char ts[20] = {0}; - time_t expireSec = tsExpireTime / 1000; - struct tm ptm; - if (taosLocalTime(&expireSec, &ptm, ts) != NULL) { - strftime(ts, 20, "%Y-%m-%d %H:%M:%S", &ptm); - } else { - ts[0] = 0; - } - STR_WITH_MAXSIZE_TO_VARSTR(expireTime, ts, pShow->pMeta->pSchemas[cols].bytes); - COL_DATA_SET_VAL_RET(expireTime, false, pCluster); + COL_DATA_SET_VAL_RET((const char *)&tsExpireTime, false, pCluster); } sdbRelease(pSdb, pCluster); From a6e0fbd76af25c918c4afe55ef6eba1e8687be78 Mon Sep 17 00:00:00 2001 From: kailixu Date: Mon, 24 Jun 2024 16:21:10 +0800 Subject: [PATCH 2/2] fix: expire time for show cluster --- include/common/tgrant.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/include/common/tgrant.h b/include/common/tgrant.h index 42adabd6f7..e2f259b4f3 100644 --- a/include/common/tgrant.h +++ b/include/common/tgrant.h @@ -28,13 +28,12 @@ extern "C" { #define GRANTS_COL_MAX_LEN 196 #endif -#define GRANT_HEART_BEAT_MIN 2 -#define GRANT_EXPIRE_VALUE (31556995201) -#define GRANT_EXPIRE_UNLIMITED(v) ((v) == GRANT_EXPIRE_VALUE) -#define GRANT_ACTIVE_CODE "activeCode" -#define GRANT_FLAG_ALL (0x01) -#define GRANT_FLAG_AUDIT (0x02) -#define GRANT_FLAG_VIEW (0x04) +#define GRANT_HEART_BEAT_MIN 2 +#define GRANT_EXPIRE_VALUE (31556995201) +#define GRANT_ACTIVE_CODE "activeCode" +#define GRANT_FLAG_ALL (0x01) +#define GRANT_FLAG_AUDIT (0x02) +#define GRANT_FLAG_VIEW (0x04) typedef enum { TSDB_GRANT_ALL,