未验证 提交 c733b76b 编写于 作者: S Shengliang Guan 提交者: GitHub

Merge pull request #2013 from taosdata/patch/td-317

fix td-317: max table name length now is 392
......@@ -29,6 +29,7 @@ void extractTableName(const char* tableId, char* name) {
size_t s2 = strcspn(&tableId[s1 + 1], &TS_PATH_DELIMITER[0]);
strncpy(name, &tableId[s1 + s2 + 2], TSDB_TABLE_NAME_LEN);
name[TSDB_TABLE_NAME_LEN] = 0;
}
char* extractDBName(const char* tableId, char* name) {
......
......@@ -1139,7 +1139,7 @@ int32_t mgmtRetrieveShowSuperTables(SShowObj *pShow, char *data, int32_t rows, v
prefixLen = strlen(prefix);
SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER;
char stableName[TSDB_TABLE_NAME_LEN] = {0};
char stableName[TSDB_TABLE_NAME_LEN + 1] = {0};
while (numOfRows < rows) {
pShow->pIter = mgmtGetNextSuperTable(pShow->pIter, &pTable);
......@@ -2154,7 +2154,7 @@ static int32_t mgmtRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows,
continue;
}
char tableName[TSDB_TABLE_NAME_LEN] = {0};
char tableName[TSDB_TABLE_NAME_LEN + 1] = {0};
// pattern compare for table name
mgmtExtractTableName(pTable->info.tableId, tableName);
......
......@@ -10,7 +10,7 @@ from util.sql import *
class TDTestCase:
def init(self, conn):
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
......@@ -95,18 +95,43 @@ class TDTestCase:
maxTableNameLen = self.getLimitFromSourceCode('TSDB_TABLE_NAME_LEN')
tdLog.notice("table name max length is %d" % maxTableNameLen)
name = self.generateString(maxTableNameLen - 1)
tdLog.info("table name is '%s'" % name)
# create a super table with name exceed max length
sname = self.generateString(maxTableNameLen + 1)
tdLog.info("create a super table with length %d" % len(sname))
tdSql.error("create table %s (ts timestamp, value int) tags(id int)" % sname)
tdSql.execute("create table %s (ts timestamp, value int)" % name)
tdSql.execute("insert into %s values(now, 0)" % name)
# create a super table with name of max length
sname = self.generateString(maxTableNameLen)
tdLog.info("create a super table with length %d" % len(sname))
tdSql.execute("create table %s (ts timestamp, value int) tags(id int)" % sname)
tdLog.info("check table count, should be one")
tdSql.query('show stables')
tdSql.checkRows(1)
# create a child table with name exceed max length
name = self.generateString(maxTableNameLen + 1)
tdLog.info("create a child table with length %d" % len(name))
tdSql.error("create table %s using %s tags(0)" % (name, sname))
# create a child table with name of max length
name = self.generateString(maxTableNameLen)
tdLog.info("create a child table with length %d" % len(name))
tdSql.execute("create table %s using %s tags(0)" % (name, sname))
tdSql.query('show tables')
tdSql.checkRows(1)
tdSql.query('select * from %s' % name)
# insert one row
tdLog.info("insert one row of data")
tdSql.execute("insert into %s values(now, 0)" % name)
tdSql.query("select * from " + name)
tdSql.checkRows(1)
tdSql.query("select * from " + sname)
tdSql.checkRows(1)
name = name[:len(name) - 1]
tdSql.error("select * from " + name)
tdSql.checkRows(0)
def checkRowBoundaries(self):
tdLog.debug("checking row boundaries")
tdSql.prepare()
......
......@@ -58,6 +58,9 @@ class TDSql:
"%s failed: sql:%s, expect error not occured" %
(callerFilename, sql))
else:
self.queryRows = 0
self.queryCols = 0
self.queryResult = None
tdLog.info("sql:%s, expect error occured" % (sql))
def query(self, sql):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册