From d9a5b7c3c2a98a26b985c23b0591471fdfa3df92 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Sun, 17 Oct 2021 01:27:46 +0800 Subject: [PATCH] [TD-10642]: [schemaless] add affected lines and msg buffer for receiving error message. --- src/client/inc/tscParseLine.h | 8 +-- src/client/src/TSDBJNIConnector.c | 9 +++- src/client/src/tscParseLineProtocol.c | 25 +++++++--- src/client/src/tscParseOpenTSDB.c | 10 +++- src/inc/taos.h | 3 +- tests/examples/c/apitest.c | 19 ++++---- tests/examples/c/schemaless.c | 7 +-- tests/script/api/openTSDBTest.c | 70 +++++++++++++-------------- tests/tsim/src/simExe.c | 12 +++-- 9 files changed, 96 insertions(+), 67 deletions(-) diff --git a/src/client/inc/tscParseLine.h b/src/client/inc/tscParseLine.h index bfc069c92c..89692323de 100644 --- a/src/client/inc/tscParseLine.h +++ b/src/client/inc/tscParseLine.h @@ -87,10 +87,10 @@ void destroySmlDataPoint(TAOS_SML_DATA_POINT* point); int taos_insert_sml_lines(TAOS* taos, char* lines[], int numLines, SMLProtocolType protocol, SMLTimeStampType tsType); -int taos_insert_telnet_lines(TAOS* taos, char* lines[], int numLines, - SMLProtocolType protocol, SMLTimeStampType tsType); -int taos_insert_json_payload(TAOS* taos, char* payload, - SMLProtocolType protocol, SMLTimeStampType tsType); +int taos_insert_telnet_lines(TAOS* taos, char* lines[], int numLines, SMLProtocolType protocol, + SMLTimeStampType tsType, int* affectedRows); +int taos_insert_json_payload(TAOS* taos, char* payload, SMLProtocolType protocol, + SMLTimeStampType tsType, int* affectedRows); #ifdef __cplusplus diff --git a/src/client/src/TSDBJNIConnector.c b/src/client/src/TSDBJNIConnector.c index 0444c2cb8d..0e08fd26a4 100644 --- a/src/client/src/TSDBJNIConnector.c +++ b/src/client/src/TSDBJNIConnector.c @@ -100,6 +100,8 @@ jmethodID g_blockdataSetNumOfColsFp; #define JNI_FETCH_END -6 #define JNI_OUT_OF_MEMORY -7 +#define JNI_ERR_MSG_BUF_LEN 50 + static void jniGetGlobalMethod(JNIEnv *env) { // make sure init function executed once switch (atomic_val_compare_exchange_32(&__init, 0, 1)) { @@ -1054,6 +1056,9 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setTableNameTagsI JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp(JNIEnv *env, jobject jobj, jobjectArray lines, jlong conn) { + int a_lines = 0; + char errMsg[JNI_ERR_MSG_BUF_LEN] = {0}; + TAOS *taos = (TAOS *)conn; if (taos == NULL) { jniError("jobj:%p, connection already closed", jobj); @@ -1071,7 +1076,7 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp(J c_lines[i] = (char *)(*env)->GetStringUTFChars(env, line, 0); } - int code = taos_schemaless_insert(taos, c_lines, numLines, SML_LINE_PROTOCOL, "ms"); + int code = taos_schemaless_insert(taos, c_lines, numLines, SML_LINE_PROTOCOL, "ms", &a_lines, errMsg, JNI_ERR_MSG_BUF_LEN); for (int i = 0; i < numLines; ++i) { jstring line = (jstring)((*env)->GetObjectArrayElement(env, lines, i)); @@ -1080,7 +1085,7 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp(J tfree(c_lines); if (code != TSDB_CODE_SUCCESS) { - jniError("jobj:%p, conn:%p, code:%s", jobj, taos, tstrerror(code)); + jniError("jobj:%p, conn:%p, code:%s, affected lines:%d", jobj, taos, errMsg, a_lines); return JNI_TDENGINE_ERROR; } diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index 8126b555a5..665fdfcb31 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -2238,7 +2238,7 @@ int32_t tscParseLines(char* lines[], int numLines, SArray* points, SArray* faile return TSDB_CODE_SUCCESS; } -int taos_insert_lines(TAOS* taos, char* lines[], int numLines, SMLProtocolType protocol, SMLTimeStampType tsType) { +int taos_insert_lines(TAOS* taos, char* lines[], int numLines, SMLProtocolType protocol, SMLTimeStampType tsType, int *affectedRows) { int32_t code = 0; SSmlLinesInfo* info = tcalloc(1, sizeof(SSmlLinesInfo)); @@ -2282,6 +2282,9 @@ int taos_insert_lines(TAOS* taos, char* lines[], int numLines, SMLProtocolType p if (code != 0) { tscError("SML:0x%"PRIx64" taos_sml_insert error: %s", info->id, tstrerror((code))); } + if (affectedRows != NULL) { + *affectedRows = info->affectedRows; + } cleanup: tscDebug("SML:0x%"PRIx64" taos_insert_lines finish inserting %d lines. code: %d", info->id, numLines, code); @@ -2297,7 +2300,7 @@ cleanup: return code; } -int32_t convertPrecisionStrType(char* precision, SMLTimeStampType *tsType) { +int32_t convertPrecisionStrType(const char* precision, SMLTimeStampType *tsType) { if (precision == NULL) { *tsType = SML_TIME_STAMP_NOT_CONFIGURED; return TSDB_CODE_SUCCESS; @@ -2364,31 +2367,39 @@ int32_t convertPrecisionStrType(char* precision, SMLTimeStampType *tsType) { * */ -int taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int protocol, char* timePrecision) { +int taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int protocol, const char* precision, + int* affectedRows, char* msg, int msgBufLen) { int code; SMLTimeStampType tsType; if (protocol == SML_LINE_PROTOCOL) { - code = convertPrecisionStrType(timePrecision, &tsType); + code = convertPrecisionStrType(precision, &tsType); if (code != TSDB_CODE_SUCCESS) { + if (msg != NULL) { + tstrncpy(msg, tstrerror(code), msgBufLen); + } return code; } } switch (protocol) { case SML_LINE_PROTOCOL: - code = taos_insert_lines(taos, lines, numLines, protocol, tsType); + code = taos_insert_lines(taos, lines, numLines, protocol, tsType, affectedRows); break; case SML_TELNET_PROTOCOL: - code = taos_insert_telnet_lines(taos, lines, numLines, protocol, tsType); + code = taos_insert_telnet_lines(taos, lines, numLines, protocol, tsType, affectedRows); break; case SML_JSON_PROTOCOL: - code = taos_insert_json_payload(taos, *lines, protocol, tsType); + code = taos_insert_json_payload(taos, *lines, protocol, tsType, affectedRows); break; default: code = TSDB_CODE_TSC_INVALID_PROTOCOL_TYPE; break; } + if (msg != NULL) { + tstrncpy(msg, tstrerror(code), msgBufLen); + } + return code; } diff --git a/src/client/src/tscParseOpenTSDB.c b/src/client/src/tscParseOpenTSDB.c index a079198be3..3024bb9c6e 100644 --- a/src/client/src/tscParseOpenTSDB.c +++ b/src/client/src/tscParseOpenTSDB.c @@ -389,7 +389,7 @@ static int32_t tscParseTelnetLines(char* lines[], int numLines, SArray* points, return TSDB_CODE_SUCCESS; } -int taos_insert_telnet_lines(TAOS* taos, char* lines[], int numLines, SMLProtocolType protocol, SMLTimeStampType tsType) { +int taos_insert_telnet_lines(TAOS* taos, char* lines[], int numLines, SMLProtocolType protocol, SMLTimeStampType tsType, int* affectedRows) { int32_t code = 0; SSmlLinesInfo* info = tcalloc(1, sizeof(SSmlLinesInfo)); @@ -433,6 +433,9 @@ int taos_insert_telnet_lines(TAOS* taos, char* lines[], int numLines, SMLProtoco if (code != 0) { tscError("OTD:0x%"PRIx64" taos_insert_telnet_lines error: %s", info->id, tstrerror((code))); } + if (affectedRows != NULL) { + *affectedRows = info->affectedRows; + } cleanup: tscDebug("OTD:0x%"PRIx64" taos_insert_telnet_lines finish inserting %d lines. code: %d", info->id, numLines, code); @@ -1025,7 +1028,7 @@ PARSE_JSON_OVER: return ret; } -int taos_insert_json_payload(TAOS* taos, char* payload, SMLProtocolType protocol, SMLTimeStampType tsType) { +int taos_insert_json_payload(TAOS* taos, char* payload, SMLProtocolType protocol, SMLTimeStampType tsType, int* affectedRows) { int32_t code = 0; SSmlLinesInfo* info = tcalloc(1, sizeof(SSmlLinesInfo)); @@ -1060,6 +1063,9 @@ int taos_insert_json_payload(TAOS* taos, char* payload, SMLProtocolType protocol if (code != 0) { tscError("OTD:0x%"PRIx64" taos_insert_json_payload error: %s", info->id, tstrerror((code))); } + if (affectedRows != NULL) { + *affectedRows = info->affectedRows; + } cleanup: tscDebug("OTD:0x%"PRIx64" taos_insert_json_payload finish inserting 1 Point. code: %d", info->id, code); diff --git a/src/inc/taos.h b/src/inc/taos.h index da91ed16c8..089effd21b 100644 --- a/src/inc/taos.h +++ b/src/inc/taos.h @@ -188,7 +188,8 @@ DLL_EXPORT void taos_close_stream(TAOS_STREAM *tstr); DLL_EXPORT int taos_load_table_info(TAOS *taos, const char* tableNameList); -DLL_EXPORT int taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int protocol, char* precision); +DLL_EXPORT int taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int protocol, const char* precision, + int* affectedRows, char* msg, int msgBufLen); #ifdef __cplusplus } diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c index d9d2a41cb2..21d0d94f42 100644 --- a/tests/examples/c/apitest.c +++ b/tests/examples/c/apitest.c @@ -302,7 +302,8 @@ int32_t verify_schema_less(TAOS* taos) { taos_free_result(result); usleep(100000); - int code = 0; + char msg[512]; + int code = 0, a_lines = 0; char* lines[] = { "st,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000", @@ -316,39 +317,39 @@ int32_t 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" }; - code = taos_schemaless_insert(taos, lines , sizeof(lines)/sizeof(char*), 0, "ns"); + code = taos_schemaless_insert(taos, lines , sizeof(lines)/sizeof(char*), 0, "ns", &a_lines, msg, sizeof(msg)); char* lines2[] = { "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" }; - code = taos_schemaless_insert(taos, &lines2[0], 1, 0, "ns"); - code = taos_schemaless_insert(taos, &lines2[1], 1, 0, "ns"); + code = taos_schemaless_insert(taos, &lines2[0], 1, 0, "ns", &a_lines, msg, sizeof(msg)); + code = taos_schemaless_insert(taos, &lines2[1], 1, 0, "ns", &a_lines, msg, sizeof(msg)); char* lines3[] = { "sth,t1=4i64,t2=5f64,t4=5f64,ID=childTable c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641", "sth,t1=4i64,t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933654" }; - code = taos_schemaless_insert(taos, lines3, 2, 0, "ms"); + code = taos_schemaless_insert(taos, lines3, 2, 0, "ms", &a_lines, msg, sizeof(msg)); char* lines4[] = { "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" }; - code = taos_schemaless_insert(taos, lines4, 2, 0, "ns"); + code = taos_schemaless_insert(taos, lines4, 2, 0, "ns", &a_lines, msg, sizeof(msg)); char* lines5[] = { "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" }; - code = taos_schemaless_insert(taos, &lines5[0], 1, 0, "ns"); - code = taos_schemaless_insert(taos, &lines5[1], 1, 0, "ns"); + code = taos_schemaless_insert(taos, &lines5[0], 1, 0, "ns", &a_lines, msg, sizeof(msg)); + code = taos_schemaless_insert(taos, &lines5[1], 1, 0, "ns", &a_lines, msg, sizeof(msg)); char* lines6[] = { "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" }; - code = taos_schemaless_insert(taos, lines6, 2, 0, "ns"); + code = taos_schemaless_insert(taos, lines6, 2, 0, "ns", &a_lines, msg, sizeof(msg)); return (code); } diff --git a/tests/examples/c/schemaless.c b/tests/examples/c/schemaless.c index 0d98acb03a..63ef146933 100644 --- a/tests/examples/c/schemaless.c +++ b/tests/examples/c/schemaless.c @@ -37,16 +37,17 @@ typedef struct { static void* insertLines(void* args) { SThreadInsertArgs* insertArgs = (SThreadInsertArgs*) args; - char tidBuf[32] = {0}; + char tidBuf[32] = {0}, errMsg[512] = {0}; + int a_lines = 0; printThreadId(pthread_self(), tidBuf); for (int i = 0; i < insertArgs->numBatches; ++i) { SThreadLinesBatch* batch = insertArgs->batches + i; printf("%s, thread: 0x%s\n", "begin taos_insert_lines", tidBuf); int64_t begin = getTimeInUs(); - int32_t code = taos_schemaless_insert(insertArgs->taos, batch->lines, batch->numLines, 0, "ms"); + int32_t code = taos_schemaless_insert(insertArgs->taos, batch->lines, batch->numLines, 0, "ms", &a_lines, errMsg, sizeof(errMsg)); int64_t end = getTimeInUs(); insertArgs->costTime += end - begin; - printf("code: %d, %s. time used:%"PRId64", thread: 0x%s\n", code, tstrerror(code), end - begin, tidBuf); + printf("code: %d, %s. affected lines:%d time used:%"PRId64", thread: 0x%s\n", code, errMsg, a_lines, end - begin, tidBuf); } return NULL; } diff --git a/tests/script/api/openTSDBTest.c b/tests/script/api/openTSDBTest.c index 2b9cf986f2..1fd142d5ce 100644 --- a/tests/script/api/openTSDBTest.c +++ b/tests/script/api/openTSDBTest.c @@ -26,7 +26,7 @@ void verify_telnet_insert(TAOS* taos) { "stb0_1 1626006833639000000ns 4i8 host=\"host0\" interface=\"eth0\"", "stb0_2 1626006833639000000ns 4i8 host=\"host0\" interface=\"eth0\"", }; - code = taos_schemaless_insert(taos, lines0, 3, 1, NULL); + code = taos_schemaless_insert(taos, lines0, 3, 1, NULL, NULL, NULL, 0); if (code) { printf("lines0 code: %d, %s.\n", code, tstrerror(code)); } @@ -41,7 +41,7 @@ void verify_telnet_insert(TAOS* taos) { "stb1 1626006833651ms 6i8 host=\"host0\"", "stb1 0 7i8 host=\"host0\"", }; - code = taos_schemaless_insert(taos, lines1, 7, 1, NULL); + code = taos_schemaless_insert(taos, lines1, 7, 1, NULL, NULL, NULL, 0); if (code) { printf("lines1 code: %d, %s.\n", code, tstrerror(code)); } @@ -52,7 +52,7 @@ void verify_telnet_insert(TAOS* taos) { "stb2_0 1626006833651ms -127i8 host=\"host0\"", "stb2_0 1626006833652ms 127i8 host=\"host0\"" }; - code = taos_schemaless_insert(taos, lines2_0, 2, 1, NULL); + code = taos_schemaless_insert(taos, lines2_0, 2, 1, NULL, NULL, NULL, 0); if (code) { printf("lines2_0 code: %d, %s.\n", code, tstrerror(code)); } @@ -62,7 +62,7 @@ void verify_telnet_insert(TAOS* taos) { "stb2_1 1626006833651ms -32767i16 host=\"host0\"", "stb2_1 1626006833652ms 32767i16 host=\"host0\"" }; - code = taos_schemaless_insert(taos, lines2_1, 2, 1, NULL); + code = taos_schemaless_insert(taos, lines2_1, 2, 1, NULL, NULL, NULL, 0); if (code) { printf("lines2_1 code: %d, %s.\n", code, tstrerror(code)); } @@ -72,7 +72,7 @@ void verify_telnet_insert(TAOS* taos) { "stb2_2 1626006833651ms -2147483647i32 host=\"host0\"", "stb2_2 1626006833652ms 2147483647i32 host=\"host0\"" }; - code = taos_schemaless_insert(taos, lines2_2, 2, 1, NULL); + code = taos_schemaless_insert(taos, lines2_2, 2, 1, NULL, NULL, NULL, 0); if (code) { printf("lines2_2 code: %d, %s.\n", code, tstrerror(code)); } @@ -82,7 +82,7 @@ void verify_telnet_insert(TAOS* taos) { "stb2_3 1626006833651ms -9223372036854775807i64 host=\"host0\"", "stb2_3 1626006833652ms 9223372036854775807i64 host=\"host0\"" }; - code = taos_schemaless_insert(taos, lines2_3, 2, 1, NULL); + code = taos_schemaless_insert(taos, lines2_3, 2, 1, NULL, NULL, NULL, 0); if (code) { printf("lines2_3 code: %d, %s.\n", code, tstrerror(code)); } @@ -100,7 +100,7 @@ void verify_telnet_insert(TAOS* taos) { "stb2_4 1626006833700ms 3.4E38f32 host=\"host0\"", "stb2_4 1626006833710ms -3.4E38f32 host=\"host0\"" }; - code = taos_schemaless_insert(taos, lines2_4, 10, 1, NULL); + code = taos_schemaless_insert(taos, lines2_4, 10, 1, NULL, NULL, NULL, 0); if (code) { printf("lines2_4 code: %d, %s.\n", code, tstrerror(code)); } @@ -119,7 +119,7 @@ void verify_telnet_insert(TAOS* taos) { "stb2_5 1626006833700ms -1.7E308f64 host=\"host0\"", "stb2_5 1626006833710ms 3.15 host=\"host0\"" }; - code = taos_schemaless_insert(taos, lines2_5, 11, 1, NULL); + code = taos_schemaless_insert(taos, lines2_5, 11, 1, NULL, NULL, NULL, 0); if (code) { printf("lines2_5 code: %d, %s.\n", code, tstrerror(code)); } @@ -137,7 +137,7 @@ void verify_telnet_insert(TAOS* taos) { "stb2_6 1626006833690ms False host=\"host0\"", "stb2_6 1626006833700ms FALSE host=\"host0\"" }; - code = taos_schemaless_insert(taos, lines2_6, 10, 1, NULL); + code = taos_schemaless_insert(taos, lines2_6, 10, 1, NULL, NULL, NULL, 0); if (code) { printf("lines2_6 code: %d, %s.\n", code, tstrerror(code)); } @@ -148,7 +148,7 @@ void verify_telnet_insert(TAOS* taos) { "stb2_7 1626006833620ms \"binary_val.:;,./?|+-=\" host=\"host0\"", "stb2_7 1626006833630ms \"binary_val.()[]{}<>\" host=\"host0\"" }; - code = taos_schemaless_insert(taos, lines2_7, 3, 1, NULL); + code = taos_schemaless_insert(taos, lines2_7, 3, 1, NULL, NULL, NULL, 0); if (code) { printf("lines2_7 code: %d, %s.\n", code, tstrerror(code)); } @@ -158,7 +158,7 @@ void verify_telnet_insert(TAOS* taos) { "stb2_8 1626006833610ms L\"nchar_val数值一\" host=\"host0\"", "stb2_8 1626006833620ms L\"nchar_val数值二\" host=\"host0\"" }; - code = taos_schemaless_insert(taos, lines2_8, 2, 1, NULL); + code = taos_schemaless_insert(taos, lines2_8, 2, 1, NULL, NULL, NULL, 0); if (code) { printf("lines2_8 code: %d, %s.\n", code, tstrerror(code)); } @@ -169,7 +169,7 @@ void verify_telnet_insert(TAOS* taos) { "stb3_0 1626006833610ms 1 t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=3.4E38f32 t6=1.7E308f64 t7=true t8=\"binary_val_1\" t9=L\"标签值1\"", "stb3_0 1626006833610ms 2 t1=-127i8 t2=-32767i16 t3=-2147483647i32 t4=-9223372036854775807i64 t5=-3.4E38f32 t6=-1.7E308f64 t7=false t8=\"binary_val_2\" t9=L\"标签值2\"" }; - code = taos_schemaless_insert(taos, lines3_0, 2, 1, NULL); + code = taos_schemaless_insert(taos, lines3_0, 2, 1, NULL, NULL, NULL, 0); if (code) { printf("lines3_0 code: %d, %s.\n", code, tstrerror(code)); } @@ -180,7 +180,7 @@ void verify_telnet_insert(TAOS* taos) { "stb3_1 1626006833610ms 2 host=host2 iD=child_table2", "stb3_1 1626006833610ms 3 ID=child_table3 host=host3" }; - code = taos_schemaless_insert(taos, lines3_1, 3, 1, NULL); + code = taos_schemaless_insert(taos, lines3_1, 3, 1, NULL, NULL, NULL, 0); if (code) { printf("lines3_1 code: %d, %s.\n", code, tstrerror(code)); } @@ -214,7 +214,7 @@ void verify_json_insert(TAOS* taos) { } \ }"}; - code = taos_schemaless_insert(taos, message, 0, 2, NULL); + code = taos_schemaless_insert(taos, message, 0, 2, NULL, NULL, NULL, 0); if (code) { printf("payload_0 code: %d, %s.\n", code, tstrerror(code)); } @@ -245,7 +245,7 @@ void verify_json_insert(TAOS* taos) { } \ ]"}; - code = taos_schemaless_insert(taos, message1, 0, 2, NULL); + code = taos_schemaless_insert(taos, message1, 0, 2, NULL, NULL, NULL, 0); if (code) { printf("payload_1 code: %d, %s.\n", code, tstrerror(code)); } @@ -296,7 +296,7 @@ void verify_json_insert(TAOS* taos) { } \ } \ ]"}; - code = taos_schemaless_insert(taos, message2, 0, 2, NULL); + code = taos_schemaless_insert(taos, message2, 0, 2, NULL, NULL, NULL, 0); if (code) { printf("payload_2 code: %d, %s.\n", code, tstrerror(code)); } @@ -320,7 +320,7 @@ void verify_json_insert(TAOS* taos) { *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); + code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL, NULL, NULL, 0); if (code) { printf("payload0_0 code: %d, %s.\n", code, tstrerror(code)); } @@ -341,7 +341,7 @@ void verify_json_insert(TAOS* taos) { *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); + code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL, NULL, NULL, 0); if (code) { printf("payload0_1 code: %d, %s.\n", code, tstrerror(code)); } @@ -362,7 +362,7 @@ void verify_json_insert(TAOS* taos) { *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); + code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL, NULL, NULL, 0); if (code) { printf("payload0_2 code: %d, %s.\n", code, tstrerror(code)); } @@ -383,7 +383,7 @@ void verify_json_insert(TAOS* taos) { *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); + code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL, NULL, NULL, 0); if (code) { printf("payload0_3 code: %d, %s.\n", code, tstrerror(code)); } @@ -404,7 +404,7 @@ void verify_json_insert(TAOS* taos) { *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); + code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL, NULL, NULL, 0); if (code) { printf("payload0_4 code: %d, %s.\n", code, tstrerror(code)); } @@ -433,7 +433,7 @@ void verify_json_insert(TAOS* taos) { *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); + code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL, NULL, NULL, 0); if (code) { printf("payload1_0 code: %d, %s.\n", code, tstrerror(code)); } @@ -459,7 +459,7 @@ void verify_json_insert(TAOS* taos) { *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); + code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL, NULL, NULL, 0); if (code) { printf("payload1_1 code: %d, %s.\n", code, tstrerror(code)); } @@ -485,7 +485,7 @@ void verify_json_insert(TAOS* taos) { *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); + code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL, NULL, NULL, 0); if (code) { printf("payload1_2 code: %d, %s.\n", code, tstrerror(code)); } @@ -511,7 +511,7 @@ void verify_json_insert(TAOS* taos) { *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); + code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL, NULL, NULL, 0); if (code) { printf("payload1_4 code: %d, %s.\n", code, tstrerror(code)); } @@ -543,7 +543,7 @@ void verify_json_insert(TAOS* taos) { *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); + code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL, NULL, NULL, 0); if (code) { printf("payload2_0 code: %d, %s.\n", code, tstrerror(code)); } @@ -573,7 +573,7 @@ void verify_json_insert(TAOS* taos) { *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); + code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL, NULL, NULL, 0); if (code) { printf("payload2_1 code: %d, %s.\n", code, tstrerror(code)); } @@ -603,7 +603,7 @@ void verify_json_insert(TAOS* taos) { *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); + code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL, NULL, NULL, 0); if (code) { printf("payload2_2 code: %d, %s.\n", code, tstrerror(code)); } @@ -633,7 +633,7 @@ void verify_json_insert(TAOS* taos) { *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); + code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL, NULL, NULL, 0); if (code) { printf("payload2_3 code: %d, %s.\n", code, tstrerror(code)); } @@ -663,7 +663,7 @@ void verify_json_insert(TAOS* taos) { *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); + code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL, NULL, NULL, 0); if (code) { printf("payload2_4 code: %d, %s.\n", code, tstrerror(code)); } @@ -693,7 +693,7 @@ void verify_json_insert(TAOS* taos) { *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); + code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL, NULL, NULL, 0); if (code) { printf("payload2_5 code: %d, %s.\n", code, tstrerror(code)); } @@ -723,7 +723,7 @@ void verify_json_insert(TAOS* taos) { *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); + code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL, NULL, NULL, 0); if (code) { printf("payload2_6 code: %d, %s.\n", code, tstrerror(code)); } @@ -753,7 +753,7 @@ void verify_json_insert(TAOS* taos) { *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); + code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL, NULL, NULL, 0); if (code) { printf("payload2_7 code: %d, %s.\n", code, tstrerror(code)); } @@ -783,7 +783,7 @@ void verify_json_insert(TAOS* taos) { *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); + code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL, NULL, NULL, 0); if (code) { printf("payload2_8 code: %d, %s.\n", code, tstrerror(code)); } @@ -863,7 +863,7 @@ void verify_json_insert(TAOS* taos) { *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); + code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL, NULL, NULL, 0); if (code) { printf("payload3_0 code: %d, %s.\n", code, tstrerror(code)); } diff --git a/tests/tsim/src/simExe.c b/tests/tsim/src/simExe.c index bca3f2a879..c0ed97aad3 100644 --- a/tests/tsim/src/simExe.c +++ b/tests/tsim/src/simExe.c @@ -1075,6 +1075,8 @@ bool simExecuteSqlErrorCmd(SScript *script, char *rest) { bool simExecuteLineInsertCmd(SScript *script, char *rest) { char buf[TSDB_MAX_BINARY_LEN]; + char msg[512] = {0}; + int a_lines = 0; simVisuallizeOption(script, rest, buf); rest = buf; @@ -1084,20 +1086,22 @@ 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"); + int32_t ret = taos_schemaless_insert(script->taos, lines, 1, 0, "ns", &a_lines, msg, sizeof(msg)); if (ret == TSDB_CODE_SUCCESS) { simDebug("script:%s, taos:%p, %s executed. success.", script->fileName, script->taos, rest); script->linePos++; return true; } else { sprintf(script->error, "lineNum: %d. line: %s failed, ret:%d:%s", line->lineNum, rest, - ret & 0XFFFF, tstrerror(ret)); + ret & 0XFFFF, msg); return false; } } bool simExecuteLineInsertErrorCmd(SScript *script, char *rest) { char buf[TSDB_MAX_BINARY_LEN]; + char msg[512] = {0}; + int a_lines = 0; simVisuallizeOption(script, rest, buf); rest = buf; @@ -1107,14 +1111,14 @@ 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"); + int32_t ret = taos_schemaless_insert(script->taos, lines, 1, 0, "ns", &a_lines, msg, sizeof(msg)); if (ret == 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; } else { simDebug("lineNum: %d. line: %s failed, ret:%d:%s. Expect failed, so success", line->lineNum, rest, - ret & 0XFFFF, tstrerror(ret)); + ret & 0XFFFF, msg); return true; } } -- GitLab