diff --git a/source/client/test/clientTests.cpp b/source/client/test/clientTests.cpp index 013cf794e3b79fb624065ee1de676fa846cd7302..f2c79bfd5a24a7d2209ad8fe1ff9543266932105 100644 --- a/source/client/test/clientTests.cpp +++ b/source/client/test/clientTests.cpp @@ -462,3 +462,31 @@ TEST(testCase, show_table_Test) { taos_free_result(pRes); taos_close(pConn); } + +TEST(testCase, create_multiple_tables) { + TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); + assert(pConn != NULL); + + TAOS_RES* pRes = taos_query(pConn, "use abc1"); + taos_free_result(pRes); + + pRes = taos_query(pConn, "create table t_2 using st1 tags(1) t_3 using st2 tags(2)"); + if (taos_errno(pRes) != 0) { + printf("failed to show vgroups, reason:%s\n", taos_errstr(pRes)); + taos_free_result(pRes); + ASSERT_TRUE(false); + } + + TAOS_ROW pRow = NULL; + TAOS_FIELD* pFields = taos_fetch_fields(pRes); + int32_t numOfFields = taos_num_fields(pRes); + + char str[512] = {0}; + while((pRow = taos_fetch_row(pRes)) != NULL) { + int32_t code = taos_print_row(str, pRow, pFields, numOfFields); + printf("%s\n", str); + } + + taos_free_result(pRes); + taos_close(pConn); +} diff --git a/source/libs/parser/inc/astGenerator.h b/source/libs/parser/inc/astGenerator.h index 0febc5ea33171d96916d5c155b3762bafe1f3fe0..22806969afd43c8bcca47db0121d34bc67f53994 100644 --- a/source/libs/parser/inc/astGenerator.h +++ b/source/libs/parser/inc/astGenerator.h @@ -125,7 +125,6 @@ typedef struct SCreatedTableInfo { SArray *pTagNames; // create by using super table, tag name SArray *pTagVals; // create by using super table, tag value char *fullname; // table full name - STagData tagdata; // true tag data, super table full name is in STagData int8_t igExist; // ignore if exists } SCreatedTableInfo; diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index bf59a0f80a873f96779c638cbbacd4d1d5a0f9d0..789f5a98e2d504845b899b55728af62da97c6d8f 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -188,7 +188,7 @@ cmd ::= COMPACT VNODES IN LP exprlist(Y) RP. { setCompactVnodeSql(pInfo, TSDB // And "ids" is an identifer-or-string. %type ids {SToken} ids(A) ::= ID(X). {A = X; } -ids(A) ::= STRING(X). {A = X; } +//ids(A) ::= STRING(X). {A = X; } %type ifexists {SToken} ifexists(X) ::= IF EXISTS. { X.n = 1;} diff --git a/source/libs/parser/src/astGenerator.c b/source/libs/parser/src/astGenerator.c index 3d12f0f3b7ae8e18239ef3c0a7962c3ffacd1166..9122b0df969c5d7cdd0add49249e6e4baf26c658 100644 --- a/source/libs/parser/src/astGenerator.c +++ b/source/libs/parser/src/astGenerator.c @@ -692,7 +692,6 @@ void freeCreateTableInfo(void* p) { taosArrayDestroy(pInfo->pTagNames); taosArrayDestroyEx(pInfo->pTagVals, freeItem); tfree(pInfo->fullname); - tfree(pInfo->tagdata.data); } SSqlInfo* setSqlInfo(SSqlInfo *pInfo, void *pSqlExprInfo, SToken *pTableName, int32_t type) { diff --git a/source/libs/parser/src/dCDAstProcess.c b/source/libs/parser/src/dCDAstProcess.c index 6aa4ad827504ebb5bfedd0a55a81cfa05d4c731a..fd99cb6f669ab944b5bd042cf293fb14ed5c5165 100644 --- a/source/libs/parser/src/dCDAstProcess.c +++ b/source/libs/parser/src/dCDAstProcess.c @@ -363,7 +363,6 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SMsgBuf* p // too long tag values will return invalid sql, not be truncated automatically SSchema* pTagSchema = getTableTagSchema(pSuperTableMeta); STableComInfo tinfo = getTableInfo(pSuperTableMeta); - STagData* pTag = &pCreateTableInfo->tagdata; SKVRowBuilder kvRowBuilder = {0}; if (tdInitKVRowBuilder(&kvRowBuilder) < 0) { @@ -463,22 +462,6 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SMsgBuf* p SSchema* pSchema = &pTagSchema[i]; SToken* pItem = taosArrayGet(pValList, i); - if (pSchema->type == TSDB_DATA_TYPE_BINARY || pSchema->type == TSDB_DATA_TYPE_NCHAR) { - if (pItem->n > pSchema->bytes) { - tdDestroyKVRowBuilder(&kvRowBuilder); - return buildInvalidOperationMsg(pMsgBuf, msg3); - } - } else if (pSchema->type == TSDB_DATA_TYPE_TIMESTAMP) { - // if (pItem->pVar.nType == TSDB_DATA_TYPE_BINARY) { - //// code = convertTimestampStrToInt64(&(pItem->pVar), tinfo.precision); - // if (code != TSDB_CODE_SUCCESS) { - // return buildInvalidOperationMsg(pMsgBuf, msg4); - // } - // } else if (pItem->pVar.nType == TSDB_DATA_TYPE_TIMESTAMP) { - // pItem->pVar.i = convertTimePrecision(pItem->pVar.i, TSDB_TIME_PRECISION_NANO, tinfo.precision); - // } - } - char tmpTokenBuf[TSDB_MAX_TAGS_LEN] = {0}; SKvParam param = {.builder = &kvRowBuilder, .schema = pSchema}; diff --git a/source/libs/parser/src/parserUtil.c b/source/libs/parser/src/parserUtil.c index 6c7ecbe0ed8094f89a2fdf0451d758f5203a8b7b..22545255a36f60b83cce7de36dff3fcea61aabbc 100644 --- a/source/libs/parser/src/parserUtil.c +++ b/source/libs/parser/src/parserUtil.c @@ -571,7 +571,9 @@ void setColumn(SColumn* pColumn, uint64_t uid, const char* tableName, int8_t fla pColumn->info.type = pSchema->type; if (tableName != NULL) { - snprintf(pColumn->name, tListLen(pColumn->name), "%s.%s", tableName, pSchema->name); + char n[TSDB_COL_NAME_LEN + 1 + TSDB_TABLE_NAME_LEN] = {0}; + snprintf(n, tListLen(n), "%s.%s", tableName, pSchema->name); + tstrncpy(pColumn->name, n, tListLen(pColumn->name)); } else { tstrncpy(pColumn->name, pSchema->name, tListLen(pColumn->name)); } @@ -586,7 +588,10 @@ SColumn createColumn(uint64_t uid, const char* tableName, int8_t flag, const SSc c.info.type = pSchema->type; if (tableName != NULL) { - snprintf(c.name, tListLen(c.name), "%s.%s", tableName, pSchema->name); + char n[TSDB_COL_NAME_LEN + 1 + TSDB_TABLE_NAME_LEN] = {0}; + snprintf(n, tListLen(n), "%s.%s", tableName, pSchema->name); + + tstrncpy(c.name, n, tListLen(c.name)); } else { tstrncpy(c.name, pSchema->name, tListLen(c.name)); }