From 979d73fbb26ff3eac2a9a55d954dfd6c4a9d3c9c Mon Sep 17 00:00:00 2001 From: stephenkgu Date: Sun, 6 Dec 2020 09:25:49 +0800 Subject: [PATCH] mnode/table: separate table id prefix from mnodeRetrieveShowTables prep for cross db create table checking in mnodeDoCreateChildTable --- src/common/inc/tname.h | 2 ++ src/common/src/tname.c | 9 ++++++++- src/mnode/src/mnodeTable.c | 4 +--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/common/inc/tname.h b/src/common/inc/tname.h index 6c48ca72f3..213aef1bd8 100644 --- a/src/common/inc/tname.h +++ b/src/common/inc/tname.h @@ -25,6 +25,8 @@ void extractTableName(const char *tableId, char *name); char* extractDBName(const char *tableId, char *name); +int32_t tableIdPrefix(const char* pDb, char* prefix, int32_t len); + void extractTableNameFromToken(SStrToken *pToken, SStrToken* pTable); SSchema tGetTableNameColumnSchema(); diff --git a/src/common/src/tname.c b/src/common/src/tname.c index bea8c52ef2..b86a0ad1d0 100644 --- a/src/common/src/tname.c +++ b/src/common/src/tname.c @@ -39,6 +39,13 @@ char* extractDBName(const char* tableId, char* name) { return strncpy(name, &tableId[offset1 + 1], len); } +int32_t tableIdPrefix(const char* name, char* prefix, int32_t len) { + tstrncpy(prefix, name, len); + strcat(prefix, TS_PATH_DELIMITER); + + return strlen(prefix); +} + SSchema tGetTableNameColumnSchema() { SSchema s = {0}; s.bytes = TSDB_TABLE_NAME_LEN - 1 + VARSTR_HEADER_SIZE; @@ -198,4 +205,4 @@ SSchema tscGetTbnameColumnSchema() { strcpy(s.name, TSQL_TBNAME_L); return s; -} \ No newline at end of file +} diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index 2149cb12c0..aa77f5531d 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -2629,9 +2629,7 @@ static int32_t mnodeRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER; char prefix[64] = {0}; - tstrncpy(prefix, pDb->name, 64); - strcat(prefix, TS_PATH_DELIMITER); - int32_t prefixLen = strlen(prefix); + int32_t prefixLen = tableIdPrefix(pDb->name, prefix, 64); char* pattern = NULL; if (pShow->payloadLen > 0) { -- GitLab