fix: fix: increase the tag value overflow check when creating table
This commit is contained in:
parent
57dae9fcda
commit
7c5419b43e
|
@ -3300,8 +3300,8 @@ static int32_t checkTableTagsSchema(STranslateContext* pCxt, SHashObj* pHash, SN
|
||||||
code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_ONLY_ONE_JSON_TAG);
|
code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_ONLY_ONE_JSON_TAG);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
if ((TSDB_DATA_TYPE_VARCHAR == pTag->dataType.type && pTag->dataType.bytes > TSDB_MAX_BINARY_LEN) ||
|
if ((TSDB_DATA_TYPE_VARCHAR == pTag->dataType.type && calcTypeBytes(pTag->dataType) > TSDB_MAX_BINARY_LEN) ||
|
||||||
(TSDB_DATA_TYPE_NCHAR == pTag->dataType.type && pTag->dataType.bytes > TSDB_MAX_NCHAR_LEN)) {
|
(TSDB_DATA_TYPE_NCHAR == pTag->dataType.type && calcTypeBytes(pTag->dataType) > TSDB_MAX_NCHAR_LEN)) {
|
||||||
code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_VAR_COLUMN_LEN);
|
code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_VAR_COLUMN_LEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3322,11 +3322,11 @@ static int32_t checkTableTagsSchema(STranslateContext* pCxt, SHashObj* pHash, SN
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t checkTableColsSchema(STranslateContext* pCxt, SHashObj* pHash, SNodeList* pCols) {
|
static int32_t checkTableColsSchema(STranslateContext* pCxt, SHashObj* pHash, int32_t ntags, SNodeList* pCols) {
|
||||||
int32_t ncols = LIST_LENGTH(pCols);
|
int32_t ncols = LIST_LENGTH(pCols);
|
||||||
if (ncols < TSDB_MIN_COLUMNS) {
|
if (ncols < TSDB_MIN_COLUMNS) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COLUMNS_NUM);
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COLUMNS_NUM);
|
||||||
} else if (ncols > TSDB_MAX_COLUMNS) {
|
} else if (ncols + ntags > TSDB_MAX_COLUMNS) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_TOO_MANY_COLUMNS);
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_TOO_MANY_COLUMNS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3382,7 +3382,7 @@ static int32_t checkTableSchema(STranslateContext* pCxt, SCreateTableStmt* pStmt
|
||||||
|
|
||||||
int32_t code = checkTableTagsSchema(pCxt, pHash, pStmt->pTags);
|
int32_t code = checkTableTagsSchema(pCxt, pHash, pStmt->pTags);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checkTableColsSchema(pCxt, pHash, pStmt->pCols);
|
code = checkTableColsSchema(pCxt, pHash, LIST_LENGTH(pStmt->pTags), pStmt->pCols);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosHashCleanup(pHash);
|
taosHashCleanup(pHash);
|
||||||
|
|
|
@ -621,6 +621,21 @@ TEST_F(ParserInitialCTest, createTable) {
|
||||||
// run("CREATE TABLE IF NOT EXISTS t1 USING st1 TAGS(1, 'wxy', NOW + 1S)");
|
// run("CREATE TABLE IF NOT EXISTS t1 USING st1 TAGS(1, 'wxy', NOW + 1S)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(ParserInitialCTest, createTableSemanticCheck) {
|
||||||
|
useDb("root", "test");
|
||||||
|
|
||||||
|
string sql = "CREATE TABLE st1(ts TIMESTAMP, ";
|
||||||
|
for (int32_t i = 1; i < 4096; ++i) {
|
||||||
|
if (i > 1) {
|
||||||
|
sql.append(", ");
|
||||||
|
}
|
||||||
|
sql.append("c" + to_string(i) + " INT");
|
||||||
|
}
|
||||||
|
sql.append(") TAGS (t1 int)");
|
||||||
|
|
||||||
|
run(sql, TSDB_CODE_PAR_TOO_MANY_COLUMNS);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(ParserInitialCTest, createTopic) {
|
TEST_F(ParserInitialCTest, createTopic) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,7 @@ class TDTestCase:
|
||||||
)
|
)
|
||||||
for i in range(4):
|
for i in range(4):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
||||||
|
|
||||||
for i in range(9):
|
for i in range(9):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
|
|
|
@ -36,7 +36,7 @@ class TDTestCase:
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
for i in range(20):
|
for i in range(20):
|
||||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
||||||
|
|
||||||
for i in range(9):
|
for i in range(9):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
|
|
|
@ -53,7 +53,7 @@ class TDTestCase:
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
for i in range(20):
|
for i in range(20):
|
||||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
||||||
|
|
||||||
for i in range(9):
|
for i in range(9):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
|
|
|
@ -55,7 +55,7 @@ class TDTestCase:
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
for i in range(20):
|
for i in range(20):
|
||||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
||||||
|
|
||||||
for i in range(9):
|
for i in range(9):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
|
|
|
@ -55,7 +55,7 @@ class TDTestCase:
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
for i in range(20):
|
for i in range(20):
|
||||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
||||||
|
|
||||||
for i in range(9):
|
for i in range(9):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
|
|
|
@ -55,7 +55,7 @@ class TDTestCase:
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
for i in range(20):
|
for i in range(20):
|
||||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
||||||
|
|
||||||
for i in range(9):
|
for i in range(9):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
|
|
|
@ -55,7 +55,7 @@ class TDTestCase:
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
for i in range(20):
|
for i in range(20):
|
||||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
||||||
|
|
||||||
for i in range(9):
|
for i in range(9):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
|
|
|
@ -64,7 +64,7 @@ class TDTestCase:
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
for i in range(20):
|
for i in range(20):
|
||||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
||||||
|
|
||||||
for i in range(9):
|
for i in range(9):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
|
|
|
@ -53,7 +53,7 @@ class TDTestCase:
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
for i in range(20):
|
for i in range(20):
|
||||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
||||||
|
|
||||||
for i in range(9):
|
for i in range(9):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
|
|
|
@ -42,7 +42,7 @@ class TDTestCase:
|
||||||
)
|
)
|
||||||
for i in range(4):
|
for i in range(4):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
||||||
|
|
||||||
for i in range(9):
|
for i in range(9):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
|
|
|
@ -97,7 +97,7 @@ class TDTestCase:
|
||||||
)
|
)
|
||||||
for i in range(4):
|
for i in range(4):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
||||||
|
|
||||||
for i in range(9):
|
for i in range(9):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
|
|
|
@ -109,7 +109,7 @@ class TDTestCase:
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
for i in range(20):
|
for i in range(20):
|
||||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
||||||
|
|
||||||
for i in range(9):
|
for i in range(9):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
|
|
|
@ -34,7 +34,7 @@ class TDTestCase:
|
||||||
)
|
)
|
||||||
|
|
||||||
for i in range(self.tb_nums):
|
for i in range(self.tb_nums):
|
||||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
||||||
ts = self.ts
|
ts = self.ts
|
||||||
for j in range(self.row_nums):
|
for j in range(self.row_nums):
|
||||||
ts+=j*self.time_step
|
ts+=j*self.time_step
|
||||||
|
|
Loading…
Reference in New Issue