From ac592b073b029f62f59a68d7d5753abafebc95d8 Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Tue, 2 Aug 2022 20:03:45 +0800 Subject: [PATCH] feat: add table create limit --- source/dnode/vnode/src/vnd/vnodeSvr.c | 24 ++++++++++++++++++++++++ source/util/src/terror.c | 2 ++ tools/shell/src/shellCommand.c | 6 +++++- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index 54fc4065ea..ef484cbc2d 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -490,6 +490,16 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pR goto _exit; } + if ((terrno = grantCheck(TSDB_GRANT_STABLE)) < 0) { + rcode = -1; + goto _exit; + } + + if ((terrno = grantCheck(TSDB_GRANT_TABLE)) < 0) { + rcode = -1; + goto _exit; + } + // validate hash sprintf(tbName, "%s.%s", pVnode->config.dbname, pCreateReq->name); if (vnodeValidateTableHash(pVnode, tbName) < 0) { @@ -840,6 +850,20 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq goto _exit; } + if ((terrno = grantCheck(TSDB_GRANT_STABLE)) < 0) { + pRsp->code = terrno; + tDecoderClear(&decoder); + taosArrayDestroy(createTbReq.ctb.tagName); + goto _exit; + } + + if ((terrno = grantCheck(TSDB_GRANT_TABLE)) < 0) { + pRsp->code = terrno; + tDecoderClear(&decoder); + taosArrayDestroy(createTbReq.ctb.tagName); + goto _exit; + } + if (metaCreateTable(pVnode->pMeta, version, &createTbReq) < 0) { if (terrno != TSDB_CODE_TDB_TABLE_ALREADY_EXIST) { submitBlkRsp.code = terrno; diff --git a/source/util/src/terror.c b/source/util/src/terror.c index 51dfa1ce13..a124d8a00f 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -410,6 +410,8 @@ TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_SPEED_LIMITED, "Write speed limited b TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_STORAGE_LIMITED, "Storage capacity limited by license") TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_QUERYTIME_LIMITED, "Query time limited by license") TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_CPU_LIMITED, "CPU cores limited by license") +TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_STABLE_LIMITED, "STable creation limited by license") +TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_TABLE_LIMITED, "Table creation limited by license") // sync TAOS_DEFINE_ERROR(TSDB_CODE_SYN_TIMEOUT, "Sync timeout") diff --git a/tools/shell/src/shellCommand.c b/tools/shell/src/shellCommand.c index 1af6ee4c06..d87e10fd08 100644 --- a/tools/shell/src/shellCommand.c +++ b/tools/shell/src/shellCommand.c @@ -525,7 +525,11 @@ int32_t shellReadCommand(char *command) { switch (c) { case 'A': // Up arrow hist_counter = (hist_counter + SHELL_MAX_HISTORY_SIZE - 1) % SHELL_MAX_HISTORY_SIZE; - shellResetCommand(&cmd, (pHistory->hist[hist_counter] == NULL) ? "" : pHistory->hist[hist_counter]); + if (pHistory->hist[hist_counter] == NULL) { + hist_counter = (hist_counter + SHELL_MAX_HISTORY_SIZE + 1) % SHELL_MAX_HISTORY_SIZE; + } else { + shellResetCommand(&cmd, pHistory->hist[hist_counter]); + } break; case 'B': // Down arrow if (hist_counter != pHistory->hend) { -- GitLab