Merge pull request #21090 from taosdata/fix/TD-23881
fix:[TD-23881] check the max row's length in schemaless
This commit is contained in:
commit
985d000377
|
@ -649,6 +649,17 @@ static int32_t smlBuildFieldsList(SSmlHandle *info, SSchema *schemaField, SHashO
|
||||||
field->bytes = getBytes(kv->type, kv->length);
|
field->bytes = getBytes(kv->type, kv->length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t maxLen = isTag ? TSDB_MAX_TAGS_LEN : TSDB_MAX_BYTES_PER_ROW;
|
||||||
|
int32_t len = 0;
|
||||||
|
for (int j = 0; j < taosArrayGetSize(results); ++j) {
|
||||||
|
SField *field = taosArrayGet(results, j);
|
||||||
|
len += field->bytes;
|
||||||
|
}
|
||||||
|
if(len > maxLen){
|
||||||
|
return TSDB_CODE_TSC_INVALID_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -781,11 +792,15 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
||||||
code = smlBuildFieldsList(info, NULL, NULL, sTableData->tags, pTags, 0, true);
|
code = smlBuildFieldsList(info, NULL, NULL, sTableData->tags, pTags, 0, true);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
uError("SML:0x%" PRIx64 " smlBuildFieldsList tag1 failed. %s", info->id, pName.tname);
|
uError("SML:0x%" PRIx64 " smlBuildFieldsList tag1 failed. %s", info->id, pName.tname);
|
||||||
|
taosArrayDestroy(pColumns);
|
||||||
|
taosArrayDestroy(pTags);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
code = smlBuildFieldsList(info, NULL, NULL, sTableData->cols, pColumns, 0, false);
|
code = smlBuildFieldsList(info, NULL, NULL, sTableData->cols, pColumns, 0, false);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
uError("SML:0x%" PRIx64 " smlBuildFieldsList col1 failed. %s", info->id, pName.tname);
|
uError("SML:0x%" PRIx64 " smlBuildFieldsList col1 failed. %s", info->id, pName.tname);
|
||||||
|
taosArrayDestroy(pColumns);
|
||||||
|
taosArrayDestroy(pTags);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
code = smlSendMetaMsg(info, &pName, pColumns, pTags, NULL, SCHEMA_ACTION_CREATE_STABLE);
|
code = smlSendMetaMsg(info, &pName, pColumns, pTags, NULL, SCHEMA_ACTION_CREATE_STABLE);
|
||||||
|
@ -837,6 +852,23 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
||||||
pTableMeta->tableInfo.numOfColumns, true);
|
pTableMeta->tableInfo.numOfColumns, true);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
uError("SML:0x%" PRIx64 " smlBuildFieldsList tag2 failed. %s", info->id, pName.tname);
|
uError("SML:0x%" PRIx64 " smlBuildFieldsList tag2 failed. %s", info->id, pName.tname);
|
||||||
|
taosArrayDestroy(pColumns);
|
||||||
|
taosArrayDestroy(pTags);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (taosArrayGetSize(pTags) + pTableMeta->tableInfo.numOfColumns > TSDB_MAX_COLUMNS) {
|
||||||
|
uError("SML:0x%" PRIx64 " too many columns than 4096", info->id);
|
||||||
|
code = TSDB_CODE_PAR_TOO_MANY_COLUMNS;
|
||||||
|
taosArrayDestroy(pColumns);
|
||||||
|
taosArrayDestroy(pTags);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
if (taosArrayGetSize(pTags) > TSDB_MAX_TAGS) {
|
||||||
|
uError("SML:0x%" PRIx64 " too many tags than 128", info->id);
|
||||||
|
code = TSDB_CODE_PAR_INVALID_TAGS_NUM;
|
||||||
|
taosArrayDestroy(pColumns);
|
||||||
|
taosArrayDestroy(pTags);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -891,6 +923,16 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
||||||
pTableMeta->tableInfo.numOfColumns, false);
|
pTableMeta->tableInfo.numOfColumns, false);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
uError("SML:0x%" PRIx64 " smlBuildFieldsList col2 failed. %s", info->id, pName.tname);
|
uError("SML:0x%" PRIx64 " smlBuildFieldsList col2 failed. %s", info->id, pName.tname);
|
||||||
|
taosArrayDestroy(pColumns);
|
||||||
|
taosArrayDestroy(pTags);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (taosArrayGetSize(pColumns) + pTableMeta->tableInfo.numOfTags > TSDB_MAX_COLUMNS) {
|
||||||
|
uError("SML:0x%" PRIx64 " too many columns than 4096", info->id);
|
||||||
|
code = TSDB_CODE_PAR_TOO_MANY_COLUMNS;
|
||||||
|
taosArrayDestroy(pColumns);
|
||||||
|
taosArrayDestroy(pTags);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1514,7 +1556,8 @@ static int smlProcess(SSmlHandle *info, char *lines[], char *rawLine, char *rawL
|
||||||
|
|
||||||
do {
|
do {
|
||||||
code = smlModifyDBSchemas(info);
|
code = smlModifyDBSchemas(info);
|
||||||
if (code == 0 || code == TSDB_CODE_SML_INVALID_DATA) break;
|
if (code == 0 || code == TSDB_CODE_SML_INVALID_DATA || code == TSDB_CODE_PAR_TOO_MANY_COLUMNS
|
||||||
|
|| code == TSDB_CODE_PAR_INVALID_TAGS_NUM) break;
|
||||||
taosMsleep(100);
|
taosMsleep(100);
|
||||||
uInfo("SML:0x%" PRIx64 " smlModifyDBSchemas retry code:%s, times:%d", info->id, tstrerror(code), retryNum);
|
uInfo("SML:0x%" PRIx64 " smlModifyDBSchemas retry code:%s, times:%d", info->id, tstrerror(code), retryNum);
|
||||||
} while (retryNum++ < taosHashGetSize(info->superTables) * MAX_RETRY_TIMES);
|
} while (retryNum++ < taosHashGetSize(info->superTables) * MAX_RETRY_TIMES);
|
||||||
|
|
|
@ -575,7 +575,7 @@ static int32_t smlConvertJSONString(SSmlKv *pVal, char *typeStr, cJSON *value) {
|
||||||
uError("OTD:invalid type(%s) for JSON String", typeStr);
|
uError("OTD:invalid type(%s) for JSON String", typeStr);
|
||||||
return TSDB_CODE_TSC_INVALID_JSON_TYPE;
|
return TSDB_CODE_TSC_INVALID_JSON_TYPE;
|
||||||
}
|
}
|
||||||
pVal->length = (int16_t)strlen(value->valuestring);
|
pVal->length = strlen(value->valuestring);
|
||||||
|
|
||||||
if (pVal->type == TSDB_DATA_TYPE_BINARY && pVal->length > TSDB_MAX_BINARY_LEN - VARSTR_HEADER_SIZE) {
|
if (pVal->type == TSDB_DATA_TYPE_BINARY && pVal->length > TSDB_MAX_BINARY_LEN - VARSTR_HEADER_SIZE) {
|
||||||
return TSDB_CODE_PAR_INVALID_VAR_COLUMN_LEN;
|
return TSDB_CODE_PAR_INVALID_VAR_COLUMN_LEN;
|
||||||
|
|
|
@ -1132,6 +1132,33 @@ int sml_td22900_Test() {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int sml_td23881_Test() {
|
||||||
|
TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
|
|
||||||
|
TAOS_RES *pRes =
|
||||||
|
taos_query(taos, "CREATE DATABASE IF NOT EXISTS line_23881 PRECISION 'ns'");
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
char tmp[16375] = {0};
|
||||||
|
memset(tmp, 'a', 16374);
|
||||||
|
char sql[102400] = {0};
|
||||||
|
sprintf(sql,"lujixfvqor,t0=t c0=f,c1=\"%s\",c2=\"%s\",c3=\"%s\",c4=\"wthvqxcsrlps\" 1626006833639000000", tmp, tmp, tmp);
|
||||||
|
|
||||||
|
pRes = taos_query(taos, "use line_23881");
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
int totalRows = 0;
|
||||||
|
pRes = taos_schemaless_insert_raw(taos, sql, strlen(sql), &totalRows, TSDB_SML_LINE_PROTOCOL,
|
||||||
|
TSDB_SML_TIMESTAMP_NANO_SECONDS);
|
||||||
|
|
||||||
|
printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes));
|
||||||
|
int code = taos_errno(pRes);
|
||||||
|
taos_free_result(pRes);
|
||||||
|
taos_close(taos);
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
int sml_ttl_Test() {
|
int sml_ttl_Test() {
|
||||||
TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
|
|
||||||
|
@ -1301,6 +1328,8 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
ret = sml_td23881_Test();
|
||||||
|
ASSERT(ret);
|
||||||
ret = sml_escape_Test();
|
ret = sml_escape_Test();
|
||||||
ASSERT(!ret);
|
ASSERT(!ret);
|
||||||
ret = sml_ts3116_Test();
|
ret = sml_ts3116_Test();
|
||||||
|
|
Loading…
Reference in New Issue