提交 dc13ae8a 编写于 作者: G Ganlin Zhao

fixed simExe.c

上级 b04933f0
......@@ -2330,18 +2330,25 @@ static int32_t convertPrecisionType(int precision, SMLTimeStampType *tsType) {
return TSDB_CODE_SUCCESS;
}
//make a dummy SSqlObj
static SSqlObj* createSmlQueryObj(int32_t affected_rows, int32_t code) {
SSqlObj *pNew = (SSqlObj*)calloc(1, sizeof(SSqlObj));
if (pNew == NULL) {
return NULL;
}
pNew->signature = pNew;
pNew->pTscObj = (STscObj*)calloc(1, sizeof(STscObj));
if (pNew->pTscObj == NULL) {
return NULL;
}
tsem_init(&pNew->rspSem, 0, 0);
registerSqlObj(pNew);
pNew->res.numOfRows = affected_rows;
pNew->res.code = code;
return pNew;
}
......
......@@ -316,10 +316,10 @@ void verify_schema_less(TAOS* taos) {
"stf,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641000000"
};
result = taos_schemaless_insert(taos, lines , sizeof(lines)/sizeof(char*), SML_LINE_PROTOCOL, SML_TIMESTAMP_MILLI_SECONDS);
result = taos_schemaless_insert(taos, lines , sizeof(lines)/sizeof(char*), SML_LINE_PROTOCOL, SML_TIMESTAMP_NANO_SECONDS);
code = taos_errno(result);
affected_rows = taos_affected_rows(result);
if (code != TSDB_CODE_SUCCESS) {
affected_rows = taos_affected_rows(result);
printf("\033[31m [lines1]taos_schemaless_insert failed, code: %d,%s, affected rows:%d \033[0m\n", code, taos_errstr(result), affected_rows);
}
taos_free_result(result);
......@@ -328,18 +328,18 @@ void verify_schema_less(TAOS* taos) {
"stg,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000",
"stg,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833641000000"
};
result = taos_schemaless_insert(taos, &lines2[0], 1, SML_LINE_PROTOCOL, SML_TIMESTAMP_MILLI_SECONDS);
result = taos_schemaless_insert(taos, &lines2[0], 1, SML_LINE_PROTOCOL, SML_TIMESTAMP_NANO_SECONDS);
code = taos_errno(result);
affected_rows = taos_affected_rows(result);
if (code != TSDB_CODE_SUCCESS) {
affected_rows = taos_affected_rows(result);
printf("\033[31m [lines2_0]taos_schemaless_insert failed, code: %d,%s, affected rows:%d \033[0m\n", code, taos_errstr(result), affected_rows);
}
taos_free_result(result);
result = taos_schemaless_insert(taos, &lines2[1], 1, SML_LINE_PROTOCOL, SML_TIMESTAMP_MILLI_SECONDS);
result = taos_schemaless_insert(taos, &lines2[1], 1, SML_LINE_PROTOCOL, SML_TIMESTAMP_NANO_SECONDS);
code = taos_errno(result);
affected_rows = taos_affected_rows(result);
if (code != TSDB_CODE_SUCCESS) {
affected_rows = taos_affected_rows(result);
printf("\033[31m [lines2_1]taos_schemaless_insert failed, code: %d,%s, affected rows:%d \033[0m\n", code, taos_errstr(result), affected_rows);
}
taos_free_result(result);
......@@ -350,8 +350,8 @@ void verify_schema_less(TAOS* taos) {
};
result = taos_schemaless_insert(taos, lines3, 2, SML_LINE_PROTOCOL, SML_TIMESTAMP_MILLI_SECONDS);
code = taos_errno(result);
affected_rows = taos_affected_rows(result);
if (code != TSDB_CODE_SUCCESS) {
affected_rows = taos_affected_rows(result);
printf("\033[31m [lines3]taos_schemaless_insert failed, code: %d,%s, affected rows:%d \033[0m\n", code, taos_errstr(result), affected_rows);
}
taos_free_result(result);
......@@ -360,10 +360,10 @@ void verify_schema_less(TAOS* taos) {
"st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000",
"dgtyqodr,t2=5f64,t3=L\"ste\" c1=tRue,c2=4i64,c3=\"iam\" 1626056811823316532"
};
result = taos_schemaless_insert(taos, lines4, 2, SML_LINE_PROTOCOL, SML_TIMESTAMP_MILLI_SECONDS);
result = taos_schemaless_insert(taos, lines4, 2, SML_LINE_PROTOCOL, SML_TIMESTAMP_NANO_SECONDS);
code = taos_errno(result);
affected_rows = taos_affected_rows(result);
if (code != TSDB_CODE_SUCCESS) {
affected_rows = taos_affected_rows(result);
printf("\033[31m [lines4]taos_schemaless_insert failed, code: %d,%s, affected rows:%d \033[0m\n", code, taos_errstr(result), affected_rows);
}
taos_free_result(result);
......@@ -373,18 +373,18 @@ void verify_schema_less(TAOS* taos) {
"zqlbgs,id=zqlbgs_39302_21680,t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"binaryColValue\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000",
"zqlbgs,t9=f,id=zqlbgs_39302_21680,t0=f,t1=127i8,t11=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\",t10=L\"ncharTagValue\" c10=f,c0=f,c1=127i8,c12=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"binaryColValue\",c8=L\"ncharColValue\",c9=7u64,c11=L\"ncharColValue\" 1626006833639000000"
};
result = taos_schemaless_insert(taos, &lines5[0], 1, SML_LINE_PROTOCOL, SML_TIMESTAMP_MILLI_SECONDS);
result = taos_schemaless_insert(taos, &lines5[0], 1, SML_LINE_PROTOCOL, SML_TIMESTAMP_NANO_SECONDS);
code = taos_errno(result);
affected_rows = taos_affected_rows(result);
if (code != TSDB_CODE_SUCCESS) {
affected_rows = taos_affected_rows(result);
printf("\033[31m [lines5_0]taos_schemaless_insert failed, code: %d,%s, affected rows:%d \033[0m\n", code, taos_errstr(result), affected_rows);
}
taos_free_result(result);
result = taos_schemaless_insert(taos, &lines5[1], 1, SML_LINE_PROTOCOL, SML_TIMESTAMP_MILLI_SECONDS);
result = taos_schemaless_insert(taos, &lines5[1], 1, SML_LINE_PROTOCOL, SML_TIMESTAMP_NANO_SECONDS);
code = taos_errno(result);
affected_rows = taos_affected_rows(result);
if (code != TSDB_CODE_SUCCESS) {
affected_rows = taos_affected_rows(result);
printf("\033[31m [lines5_1]taos_schemaless_insert failed, code: %d,%s, affected rows:%d \033[0m\n", code, taos_errstr(result), affected_rows);
}
taos_free_result(result);
......@@ -393,10 +393,10 @@ void verify_schema_less(TAOS* taos) {
"st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000",
"dgtyqodr,t2=5f64,t3=L\"ste\" c1=tRue,c2=4i64,c3=\"iam\" 1626056811823316532"
};
result = taos_schemaless_insert(taos, lines6, 2, SML_LINE_PROTOCOL, SML_TIMESTAMP_MILLI_SECONDS);
result = taos_schemaless_insert(taos, lines6, 2, SML_LINE_PROTOCOL, SML_TIMESTAMP_NANO_SECONDS);
code = taos_errno(result);
affected_rows = taos_affected_rows(result);
if (code != TSDB_CODE_SUCCESS) {
affected_rows = taos_affected_rows(result);
printf("\033[31m [lines6]taos_schemaless_insert failed, code: %d,%s, affected rows:%d \033[0m\n", code, taos_errstr(result), affected_rows);
}
taos_free_result(result);
......
......@@ -1074,9 +1074,8 @@ bool simExecuteSqlErrorCmd(SScript *script, char *rest) {
}
bool simExecuteLineInsertCmd(SScript *script, char *rest) {
bool ret;
char buf[TSDB_MAX_BINARY_LEN];
char msg[512] = {0};
int a_lines = 0;
simVisuallizeOption(script, rest, buf);
rest = buf;
......@@ -1085,23 +1084,25 @@ bool simExecuteLineInsertCmd(SScript *script, char *rest) {
simInfo("script:%s, %s", script->fileName, rest);
simLogSql(buf, true);
char * lines[] = {rest};
int32_t ret = taos_schemaless_insert(script->taos, lines, 1, 0, "ns", &a_lines, msg, sizeof(msg));
if (ret == TSDB_CODE_SUCCESS) {
char* lines[] = {rest};
TAOS_RES *result = taos_schemaless_insert(script->taos, lines, 1, SML_LINE_PROTOCOL, SML_TIMESTAMP_NANO_SECONDS);
int32_t code = taos_errno(result);
if (code == TSDB_CODE_SUCCESS) {
simDebug("script:%s, taos:%p, %s executed. success.", script->fileName, script->taos, rest);
script->linePos++;
return true;
ret = true;
} else {
sprintf(script->error, "lineNum: %d. line: %s failed, ret:%d:%s", line->lineNum, rest,
ret & 0XFFFF, msg);
return false;
sprintf(script->error, "lineNum: %d. line: %s failed, code:%d:%s", line->lineNum, rest,
code & 0XFFFF, taos_errstr(result));
ret = false;
}
taos_free_result(result);
return ret;
}
bool simExecuteLineInsertErrorCmd(SScript *script, char *rest) {
bool ret;
char buf[TSDB_MAX_BINARY_LEN];
char msg[512] = {0};
int a_lines = 0;
simVisuallizeOption(script, rest, buf);
rest = buf;
......@@ -1111,14 +1112,17 @@ bool simExecuteLineInsertErrorCmd(SScript *script, char *rest) {
simInfo("script:%s, %s", script->fileName, rest);
simLogSql(buf, true);
char * lines[] = {rest};
int32_t ret = taos_schemaless_insert(script->taos, lines, 1, 0, "ns", &a_lines, msg, sizeof(msg));
if (ret == TSDB_CODE_SUCCESS) {
TAOS_RES *result = taos_schemaless_insert(script->taos, lines, 1, SML_LINE_PROTOCOL, SML_TIMESTAMP_NANO_SECONDS);
int32_t code = taos_errno(result);
if (code == TSDB_CODE_SUCCESS) {
sprintf(script->error, "script:%s, taos:%p, %s executed. expect failed, but success.", script->fileName, script->taos, rest);
script->linePos++;
return false;
ret = false;
} else {
simDebug("lineNum: %d. line: %s failed, ret:%d:%s. Expect failed, so success", line->lineNum, rest,
ret & 0XFFFF, msg);
return true;
simDebug("lineNum: %d. line: %s failed, code:%d:%s. Expect failed, so success", line->lineNum, rest,
code & 0XFFFF, taos_errstr(result));
ret = true;
}
taos_free_result(result);
return ret;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册