From 160725945f5bdb8d5582ade19d9eafba78a7c5ef Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 27 May 2020 10:40:08 +0000 Subject: [PATCH] fix name bug --- src/tsdb/src/tsdbMeta.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/tsdb/src/tsdbMeta.c b/src/tsdb/src/tsdbMeta.c index 427e15de37..8345dc5f8b 100644 --- a/src/tsdb/src/tsdbMeta.c +++ b/src/tsdb/src/tsdbMeta.c @@ -296,13 +296,6 @@ static STable *tsdbNewTable(STableCfg *pCfg, bool isSuper) { } pTable->type = pCfg->type; - tsize = strnlen(pCfg->sname, TSDB_TABLE_NAME_LEN); - pTable->name = calloc(1, tsize + VARSTR_HEADER_SIZE + 1); - if (pTable->name == NULL) { - terrno = TSDB_CODE_SERV_OUT_OF_MEMORY; - goto _err; - } - STR_WITH_SIZE_TO_VARSTR(pTable->name, pCfg->sname, tsize); if (isSuper) { pTable->type = TSDB_SUPER_TABLE; @@ -312,8 +305,16 @@ static STable *tsdbNewTable(STableCfg *pCfg, bool isSuper) { pTable->schema = tdDupSchema(pCfg->schema); pTable->tagSchema = tdDupSchema(pCfg->tagSchema); + tsize = strnlen(pCfg->sname, TSDB_TABLE_NAME_LEN); + pTable->name = calloc(1, tsize + VARSTR_HEADER_SIZE + 1); + if (pTable->name == NULL) { + terrno = TSDB_CODE_SERV_OUT_OF_MEMORY; + goto _err; + } + STR_WITH_SIZE_TO_VARSTR(pTable->name, pCfg->sname, tsize); + STColumn *pColSchema = schemaColAt(pTable->tagSchema, 0); - pTable->pIndex = tSkipListCreate(TSDB_SUPER_TABLE_SL_LEVEL, pColSchema->type, pColSchema->bytes, 1, 0, 1, + pTable->pIndex = tSkipListCreate(TSDB_SUPER_TABLE_SL_LEVEL, pColSchema->type, pColSchema->bytes, 1, 0, 0, getTagIndexKey); // Allow duplicate key, no lock if (pTable->pIndex == NULL) { terrno = TSDB_CODE_SERV_OUT_OF_MEMORY; @@ -325,6 +326,14 @@ static STable *tsdbNewTable(STableCfg *pCfg, bool isSuper) { pTable->tableId.tid = pCfg->tableId.tid; pTable->lastKey = TSKEY_INITIAL_VAL; + tsize = strnlen(pCfg->name, TSDB_TABLE_NAME_LEN); + pTable->name = calloc(1, tsize + VARSTR_HEADER_SIZE + 1); + if (pTable->name == NULL) { + terrno = TSDB_CODE_SERV_OUT_OF_MEMORY; + goto _err; + } + STR_WITH_SIZE_TO_VARSTR(pTable->name, pCfg->name, tsize); + if (pCfg->type == TSDB_CHILD_TABLE) { pTable->superUid = pCfg->superUid; pTable->tagVal = tdDataRowDup(pCfg->tagValues); -- GitLab