diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index d875a056aac614df42b8ed6321d3980b717cdf22..51e9d43a7e4cbbc4e659af34ba7b70d68c437e3b 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -9295,13 +9295,16 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) { free(row); bool dbIncluded2 = false; + char tmp[TSDB_TABLE_FNAME_LEN] = {0}; + SStrToken tbName = taosTokenDup(&pCreateTableInfo->name, tmp, tListLen(tmp)); + // table name - if (tscValidateName(&(pCreateTableInfo->name), true, &dbIncluded2) != TSDB_CODE_SUCCESS) { + if (tscValidateName(&tbName, true, &dbIncluded2) != TSDB_CODE_SUCCESS) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), STR_INVALID_TABLE_NAME); } STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, TABLE_INDEX); - ret = tscSetTableFullName(&pTableMetaInfo->name, &pCreateTableInfo->name, pSql, dbIncluded2); + ret = tscSetTableFullName(&pTableMetaInfo->name, &tbName, pSql, dbIncluded2); if (ret != TSDB_CODE_SUCCESS) { return ret; } diff --git a/tests/pytest/table/create.py b/tests/pytest/table/create.py index 4bd630f4c00d70df857d81bfe97d6aab85398ec3..6a059f34bfc0eb3a8c5208507247f359323d684f 100644 --- a/tests/pytest/table/create.py +++ b/tests/pytest/table/create.py @@ -348,6 +348,17 @@ class TDTestCase: tdSql.query("show create table meter1") tdSql.checkData(0, 1, "CREATE TABLE `meter1` USING `meters` TAGS (1,2,3,4,5,6)") + # TS-1508 + tdSql.execute("create database if not exists test") + tdSql.execute("use test") + sql = "CREATE TABLE " + for i in range(7): + tdSql.execute("create table stb%d(ts timestamp, c1 int, c2 nchar(20)) tags(t1 binary(20))" % i) + sql += "IF NOT EXISTS 'tb%d' USING 'stb%d' TAGS ('LZ5NB7D34MB013827') " % (i, i) + + tdSql.execute(sql) + tdSql.query("show tables") + tdSql.checkRows(7) def stop(self): tdSql.close()