diff --git a/src/client/inc/tscParseLine.h b/src/client/inc/tscParseLine.h index e36c0bbc0b2d9c02e798aed1fe1e68dbe02939f5..62040359963c3814326bcb7c7de0bce1e2891198 100644 --- a/src/client/inc/tscParseLine.h +++ b/src/client/inc/tscParseLine.h @@ -47,6 +47,12 @@ typedef enum { SML_TIME_STAMP_NANO_SECONDS } SMLTimeStampType; +typedef enum { + SML_LINE_PROTOCOL = 0, + SML_TELNET_PROTOCOL = 1, + SML_JSON_PROTOCOL = 2, +} SMLProtocolType; + typedef struct { uint64_t id; SHashObj* smlDataToSchema; @@ -66,6 +72,11 @@ int32_t convertSmlTimeStamp(TAOS_SML_KV *pVal, char *value, void destroySmlDataPoint(TAOS_SML_DATA_POINT* point); +int taos_insert_sml_lines(TAOS* taos, char* lines[], int numLines); +int taos_insert_telnet_lines(TAOS* taos, char* lines[], int numLines); +int taos_insert_json_payload(TAOS* taos, char* payload); + + #ifdef __cplusplus } #endif diff --git a/src/client/src/TSDBJNIConnector.c b/src/client/src/TSDBJNIConnector.c index 925b7d75db9f88c9905270aa365c60990e9f45a3..945aff8f893665b6cf8c878d61e5ef4d8a9d26e2 100644 --- a/src/client/src/TSDBJNIConnector.c +++ b/src/client/src/TSDBJNIConnector.c @@ -1070,7 +1070,7 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp(J c_lines[i] = (char *)(*env)->GetStringUTFChars(env, line, 0); } - int code = taos_insert_lines(taos, c_lines, numLines); + int code = taos_insert_lines(taos, c_lines, numLines, 0); for (int i = 0; i < numLines; ++i) { jstring line = (jstring)((*env)->GetObjectArrayElement(env, lines, i)); @@ -1084,4 +1084,4 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp(J return JNI_TDENGINE_ERROR; } return code; -} \ No newline at end of file +} diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index 22392ba306faeed05af5d695ca0090057ac211cf..9032e33667362c3ad234317fcb355a4693c55d8c 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -2127,7 +2127,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) { +int taos_insert_sml_lines(TAOS* taos, char* lines[], int numLines) { int32_t code = 0; SSmlLinesInfo* info = tcalloc(1, sizeof(SSmlLinesInfo)); @@ -2184,3 +2184,22 @@ cleanup: return code; } +int taos_insert_lines(TAOS* taos, char* lines[], int numLines, int protocol) { + int code; + switch (protocol) { + case SML_LINE_PROTOCOL: + code = taos_insert_sml_lines(taos, lines, numLines); + break; + case SML_TELNET_PROTOCOL: + code = taos_insert_telnet_lines(taos, lines, numLines); + break; + case SML_JSON_PROTOCOL: + code = taos_insert_json_payload(taos, *lines); + break; + default: + code = TSDB_CODE_TSC_INVALID_PROTOCOL_TYPE; + break; + } + + return code; +} diff --git a/src/connector/python/taos/cinterface.py b/src/connector/python/taos/cinterface.py index c5737ea5a07b7678e058307dfe3b47546dd99909..81766bf56d6bb44e834632dd239037dc32ac5dea 100644 --- a/src/connector/python/taos/cinterface.py +++ b/src/connector/python/taos/cinterface.py @@ -817,13 +817,13 @@ except AttributeError: -def taos_insert_lines(connection, lines): +def taos_insert_lines(connection, lines, protocol): # type: (c_void_p, list[str] | tuple(str)) -> None num_of_lines = len(lines) lines = (c_char_p(line.encode("utf-8")) for line in lines) lines_type = ctypes.c_char_p * num_of_lines p_lines = lines_type(*lines) - errno = _libtaos.taos_insert_lines(connection, p_lines, num_of_lines) + errno = _libtaos.taos_insert_lines(connection, p_lines, num_of_lines, protocol) if errno != 0: raise LinesError("insert lines error", errno) diff --git a/src/connector/python/taos/connection.py b/src/connector/python/taos/connection.py index 35aca1fb26c1e612c3b3f6b1d8c794495bed0035..37fab4fc5fff3f7b74cd7053817de7d14339b73c 100644 --- a/src/connector/python/taos/connection.py +++ b/src/connector/python/taos/connection.py @@ -117,9 +117,10 @@ class TaosConnection(object): stream = taos_open_stream(self._conn, sql, callback, stime, param, callback2) return TaosStream(stream) - def insert_lines(self, lines): + def insert_lines(self, lines, protocol): # type: (list[str]) -> None - """Line protocol and schemaless support + """ + 1.Line protocol and schemaless support ## Example @@ -134,28 +135,13 @@ class TaosConnection(object): conn.insert_lines(lines) ``` - ## Exception - - ```python - try: - conn.insert_lines(lines) - except SchemalessError as err: - print(err) - ``` - """ - return taos_insert_lines(self._conn, lines) - - def insert_telnet_lines(self, lines): - """OpenTSDB telnet style API format support + 2.OpenTSDB telnet style API format support ## Example cpu_load 1626056811855516532ns 2.0f32 id="tb1",host="host0",interface="eth0" - """ - return taos_insert_telnet_lines(self._conn, lines) - def insert_json_payload(self, payload): - """OpenTSDB HTTP JSON format support + 3.OpenTSDB HTTP JSON format support ## Example "{ @@ -170,8 +156,18 @@ class TaosConnection(object): } }" + ## Exception + + ```python + try: + conn.insert_lines(lines) + except SchemalessError as err: + print(err) + ``` + """ - return taos_insert_json_payload(self._conn, payload) + return taos_insert_lines(self._conn, lines, protocol) + def cursor(self): # type: () -> TaosCursor diff --git a/src/inc/taos.h b/src/inc/taos.h index be5123797069696ffad817c0db7bc2c8c03e9606..a4d686baca715f26a7b430286670c92a74fe17e4 100644 --- a/src/inc/taos.h +++ b/src/inc/taos.h @@ -187,11 +187,7 @@ 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_insert_lines(TAOS* taos, char* lines[], int numLines); - -DLL_EXPORT int taos_insert_telnet_lines(TAOS* taos, char* lines[], int numLines); - -DLL_EXPORT int taos_insert_json_payload(TAOS* taos, char* payload); +DLL_EXPORT int taos_insert_lines(TAOS* taos, char* lines[], int numLines, int protocol); #ifdef __cplusplus } diff --git a/src/inc/taoserror.h b/src/inc/taoserror.h index 887c51f10c5a6c10e213bb893725a837a0be77cd..6b62a123cac417031d27c5cf74a118f42d22150b 100644 --- a/src/inc/taoserror.h +++ b/src/inc/taoserror.h @@ -112,6 +112,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_TSC_INVALID_JSON_TYPE TAOS_DEF_ERROR_CODE(0, 0x0222) //"Invalid JSON data type") #define TSDB_CODE_TSC_INVALID_JSON_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0223) //"Invalid JSON configuration") #define TSDB_CODE_TSC_VALUE_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x0224) //"Value out of range") +#define TSDB_CODE_TSC_INVALID_PROTOCOL_TYPE TAOS_DEF_ERROR_CODE(0, 0x0225) //"Invalid line protocol type") // mnode #define TSDB_CODE_MND_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0300) //"Message not processed") diff --git a/src/util/src/terror.c b/src/util/src/terror.c index 404d4ad0c18944826abebf6d0e73c573dbe54756..cb482aa8f151eab794965e14a2280cde22bd0852 100644 --- a/src/util/src/terror.c +++ b/src/util/src/terror.c @@ -120,6 +120,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_JSON, "Invalid JSON format") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_JSON_TYPE, "Invalid JSON data type") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_JSON_CONFIG, "Invalid JSON configuration") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_VALUE_OUT_OF_RANGE, "Value out of range") +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_PROTOCOL_TYPE, "Invalid line protocol type") // mnode TAOS_DEFINE_ERROR(TSDB_CODE_MND_MSG_NOT_PROCESSED, "Message not processed") diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c index 18569196993de2c424f8449db3461b6ff0471d0d..78edd7b34971e0660a4c87586883f0842762b663 100644 --- a/tests/examples/c/apitest.c +++ b/tests/examples/c/apitest.c @@ -980,40 +980,40 @@ 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 1626006933641000000ns" }; - code = taos_insert_lines(taos, lines , sizeof(lines)/sizeof(char*)); + code = taos_insert_lines(taos, lines , sizeof(lines)/sizeof(char*), 0); char* lines2[] = { "stg,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000ns", "stg,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000ns" }; - code = taos_insert_lines(taos, &lines2[0], 1); - code = taos_insert_lines(taos, &lines2[1], 1); + code = taos_insert_lines(taos, &lines2[0], 1, 0); + code = taos_insert_lines(taos, &lines2[1], 1, 0); char* lines3[] = { "sth,t1=4i64,t2=5f64,t4=5f64,ID=\"childtable\" c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641ms", "sth,t1=4i64,t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933654ms" }; - code = taos_insert_lines(taos, lines3, 2); + code = taos_insert_lines(taos, lines3, 2, 0); char* lines4[] = { "st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000ns", "dgtyqodr,t2=5f64,t3=L\"ste\" c1=tRue,c2=4i64,c3=\"iam\" 1626056811823316532ns" }; - code = taos_insert_lines(taos, lines4, 2); + code = taos_insert_lines(taos, lines4, 2, 0); 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 1626006833639000000ns", "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\" 1626006833639000000ns" }; - code = taos_insert_lines(taos, &lines5[0], 1); - code = taos_insert_lines(taos, &lines5[1], 1); + code = taos_insert_lines(taos, &lines5[0], 1, 0); + code = taos_insert_lines(taos, &lines5[1], 1, 0); char* lines6[] = { "st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000ns", "dgtyqodr,t2=5f64,t3=L\"ste\" c1=tRue,c2=4i64,c3=\"iam\" 1626056811823316532ns" }; - code = taos_insert_lines(taos, lines6, 2); + code = taos_insert_lines(taos, lines6, 2, 0); return (code); } diff --git a/tests/examples/c/schemaless.c b/tests/examples/c/schemaless.c index 1a551cc5f7bd600ccaf87701953f7109743e8302..bd4773c199bef1b764e503367441298baefe4df3 100644 --- a/tests/examples/c/schemaless.c +++ b/tests/examples/c/schemaless.c @@ -79,7 +79,7 @@ int main(int argc, char* argv[]) { printf("%s\n", "begin taos_insert_lines"); int64_t begin = getTimeInUs(); - int32_t code = taos_insert_lines(taos, lines, numSuperTables * numChildTables * numRowsPerChildTable); + int32_t code = taos_insert_lines(taos, lines, numSuperTables * numChildTables * numRowsPerChildTable, 0); int64_t end = getTimeInUs(); printf("code: %d, %s. time used: %"PRId64"\n", code, tstrerror(code), end-begin); diff --git a/tests/pytest/insert/insertJSONPayload.py b/tests/pytest/insert/insertJSONPayload.py index 6f45450c892637946be6f90453ecb047ee818092..64b9e6290043297926aaa5b263a4529c462d6520 100644 --- a/tests/pytest/insert/insertJSONPayload.py +++ b/tests/pytest/insert/insertJSONPayload.py @@ -33,7 +33,7 @@ class TDTestCase: ### Default format ### ### metric ### print("============= step0 : test metric ================") - payload = ''' + payload = [''' { "metric": ".stb.0.", "timestamp": 1626006833610123, @@ -45,16 +45,16 @@ class TDTestCase: "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" } } - ''' - code = self._conn.insert_json_payload(payload) - print("insert_json_payload result {}".format(code)) + '''] + code = self._conn.insert_lines(payload, 2) + print("insert_lines result {}".format(code)) tdSql.query("describe _stb_0_") tdSql.checkRows(6) ### metric value ### print("============= step1 : test metric value types ================") - payload = ''' + payload = [''' { "metric": "stb0_0", "timestamp": 1626006833610123, @@ -66,14 +66,14 @@ class TDTestCase: "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" } } - ''' - code = self._conn.insert_json_payload(payload) - print("insert_json_payload result {}".format(code)) + '''] + code = self._conn.insert_lines(payload, 2) + print("insert_lines result {}".format(code)) tdSql.query("describe stb0_0") tdSql.checkData(1, 1, "BIGINT") - payload = ''' + payload = [''' { "metric": "stb0_1", "timestamp": 1626006833610123, @@ -85,14 +85,14 @@ class TDTestCase: "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" } } - ''' - code = self._conn.insert_json_payload(payload) - print("insert_json_payload result {}".format(code)) + '''] + code = self._conn.insert_lines(payload, 2) + print("insert_lines result {}".format(code)) tdSql.query("describe stb0_1") tdSql.checkData(1, 1, "BOOL") - payload = ''' + payload = [''' { "metric": "stb0_2", "timestamp": 1626006833610123, @@ -104,14 +104,14 @@ class TDTestCase: "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" } } - ''' - code = self._conn.insert_json_payload(payload) - print("insert_json_payload result {}".format(code)) + '''] + code = self._conn.insert_lines(payload, 2) + print("insert_lines result {}".format(code)) tdSql.query("describe stb0_2") tdSql.checkData(1, 1, "BOOL") - payload = ''' + payload = [''' { "metric": "stb0_3", "timestamp": 1626006833610123, @@ -123,14 +123,14 @@ class TDTestCase: "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" } } - ''' - code = self._conn.insert_json_payload(payload) - print("insert_json_payload result {}".format(code)) + '''] + code = self._conn.insert_lines(payload, 2) + print("insert_lines result {}".format(code)) tdSql.query("describe stb0_3") tdSql.checkData(1, 1, "BINARY") - payload = ''' + payload = [''' { "metric": "stb0_4", "timestamp": 1626006833610123, @@ -142,14 +142,14 @@ class TDTestCase: "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" } } - ''' - code = self._conn.insert_json_payload(payload) - print("insert_json_payload result {}".format(code)) + '''] + code = self._conn.insert_lines(payload, 2) + print("insert_lines result {}".format(code)) tdSql.query("describe stb0_4") tdSql.checkData(1, 1, "DOUBLE") - payload = ''' + payload = [''' { "metric": "stb0_5", "timestamp": 1626006833610123, @@ -161,9 +161,9 @@ class TDTestCase: "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" } } - ''' - code = self._conn.insert_json_payload(payload) - print("insert_json_payload result {}".format(code)) + '''] + code = self._conn.insert_lines(payload, 2) + print("insert_lines result {}".format(code)) tdSql.query("describe stb0_5") tdSql.checkData(1, 1, "DOUBLE") @@ -171,7 +171,7 @@ class TDTestCase: print("============= step2 : test timestamp ================") ### timestamp 0 ### - payload = ''' + payload = [''' { "metric": "stb0_6", "timestamp": 0, @@ -183,14 +183,14 @@ class TDTestCase: "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" } } - ''' - code = self._conn.insert_json_payload(payload) - print("insert_json_payload result {}".format(code)) + '''] + code = self._conn.insert_lines(payload, 2) + print("insert_lines result {}".format(code)) print("============= step3 : test tags ================") ### Default tag numeric types ### - payload = ''' + payload = [''' { "metric": "stb0_8", "timestamp": 0, @@ -199,14 +199,14 @@ class TDTestCase: "t1": 123 } } - ''' - code = self._conn.insert_json_payload(payload) - print("insert_json_payload result {}".format(code)) + '''] + code = self._conn.insert_lines(payload, 2) + print("insert_lines result {}".format(code)) tdSql.query("describe stb0_8") tdSql.checkData(2, 1, "BIGINT") - payload = ''' + payload = [''' { "metric": "stb0_9", "timestamp": 0, @@ -215,14 +215,14 @@ class TDTestCase: "t1": 123.00 } } - ''' - code = self._conn.insert_json_payload(payload) - print("insert_json_payload result {}".format(code)) + '''] + code = self._conn.insert_lines(payload, 2) + print("insert_lines result {}".format(code)) tdSql.query("describe stb0_9") tdSql.checkData(2, 1, "DOUBLE") - payload = ''' + payload = [''' { "metric": "stb0_10", "timestamp": 0, @@ -231,9 +231,9 @@ class TDTestCase: "t1": 123E-1 } } - ''' - code = self._conn.insert_json_payload(payload) - print("insert_json_payload result {}".format(code)) + '''] + code = self._conn.insert_lines(payload, 2) + print("insert_lines result {}".format(code)) tdSql.query("describe stb0_10") tdSql.checkData(2, 1, "DOUBLE") @@ -242,7 +242,7 @@ class TDTestCase: print("============= step4 : test nested format ================") ### timestamp ### #seconds - payload = ''' + payload = [''' { "metric": "stb1_0", "timestamp": { @@ -257,15 +257,15 @@ class TDTestCase: "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" } } - ''' - code = self._conn.insert_json_payload(payload) - print("insert_json_payload result {}".format(code)) + '''] + code = self._conn.insert_lines(payload, 2) + print("insert_lines result {}".format(code)) tdSql.query("select ts from stb1_0") tdSql.checkData(0, 0, "2021-07-11 20:33:53.000000") #milliseconds - payload = ''' + payload = [''' { "metric": "stb1_1", "timestamp": { @@ -280,15 +280,15 @@ class TDTestCase: "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" } } - ''' - code = self._conn.insert_json_payload(payload) - print("insert_json_payload result {}".format(code)) + '''] + code = self._conn.insert_lines(payload, 2) + print("insert_lines result {}".format(code)) tdSql.query("select ts from stb1_1") tdSql.checkData(0, 0, "2021-07-11 20:33:53.610000") #microseconds - payload = ''' + payload = [''' { "metric": "stb1_2", "timestamp": { @@ -303,15 +303,15 @@ class TDTestCase: "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" } } - ''' - code = self._conn.insert_json_payload(payload) - print("insert_json_payload result {}".format(code)) + '''] + code = self._conn.insert_lines(payload, 2) + print("insert_lines result {}".format(code)) tdSql.query("select ts from stb1_2") tdSql.checkData(0, 0, "2021-07-11 20:33:53.610123") #nanoseconds - payload = ''' + payload = [''' { "metric": "stb1_3", "timestamp": { @@ -326,16 +326,16 @@ class TDTestCase: "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" } } - ''' - code = self._conn.insert_json_payload(payload) - print("insert_json_payload result {}".format(code)) + '''] + code = self._conn.insert_lines(payload, 2) + print("insert_lines result {}".format(code)) tdSql.query("select ts from stb1_3") tdSql.checkData(0, 0, "2021-07-11 20:33:53.610123") #now tdSql.execute('use test') - payload = ''' + payload = [''' { "metric": "stb1_4", "timestamp": { @@ -350,12 +350,12 @@ class TDTestCase: "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" } } - ''' - code = self._conn.insert_json_payload(payload) - print("insert_json_payload result {}".format(code)) + '''] + code = self._conn.insert_lines(payload, 2) + print("insert_lines result {}".format(code)) ### metric value ### - payload = ''' + payload = [''' { "metric": "stb2_0", "timestamp": { @@ -373,14 +373,14 @@ class TDTestCase: "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" } } - ''' - code = self._conn.insert_json_payload(payload) - print("insert_json_payload result {}".format(code)) + '''] + code = self._conn.insert_lines(payload, 2) + print("insert_lines result {}".format(code)) tdSql.query("describe stb2_0") tdSql.checkData(1, 1, "BOOL") - payload = ''' + payload = [''' { "metric": "stb2_1", "timestamp": { @@ -398,14 +398,14 @@ class TDTestCase: "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" } } - ''' - code = self._conn.insert_json_payload(payload) - print("insert_json_payload result {}".format(code)) + '''] + code = self._conn.insert_lines(payload, 2) + print("insert_lines result {}".format(code)) tdSql.query("describe stb2_1") tdSql.checkData(1, 1, "TINYINT") - payload = ''' + payload = [''' { "metric": "stb2_2", "timestamp": { @@ -423,14 +423,14 @@ class TDTestCase: "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" } } - ''' - code = self._conn.insert_json_payload(payload) - print("insert_json_payload result {}".format(code)) + '''] + code = self._conn.insert_lines(payload, 2) + print("insert_lines result {}".format(code)) tdSql.query("describe stb2_2") tdSql.checkData(1, 1, "SMALLINT") - payload = ''' + payload = [''' { "metric": "stb2_3", "timestamp": { @@ -448,14 +448,14 @@ class TDTestCase: "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" } } - ''' - code = self._conn.insert_json_payload(payload) - print("insert_json_payload result {}".format(code)) + '''] + code = self._conn.insert_lines(payload, 2) + print("insert_lines result {}".format(code)) tdSql.query("describe stb2_3") tdSql.checkData(1, 1, "INT") - payload = ''' + payload = [''' { "metric": "stb2_4", "timestamp": { @@ -473,14 +473,14 @@ class TDTestCase: "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" } } - ''' - code = self._conn.insert_json_payload(payload) - print("insert_json_payload result {}".format(code)) + '''] + code = self._conn.insert_lines(payload, 2) + print("insert_lines result {}".format(code)) tdSql.query("describe stb2_4") tdSql.checkData(1, 1, "BIGINT") - payload = ''' + payload = [''' { "metric": "stb2_5", "timestamp": { @@ -498,14 +498,14 @@ class TDTestCase: "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" } } - ''' - code = self._conn.insert_json_payload(payload) - print("insert_json_payload result {}".format(code)) + '''] + code = self._conn.insert_lines(payload, 2) + print("insert_lines result {}".format(code)) tdSql.query("describe stb2_5") tdSql.checkData(1, 1, "FLOAT") - payload = ''' + payload = [''' { "metric": "stb2_6", "timestamp": { @@ -523,14 +523,14 @@ class TDTestCase: "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" } } - ''' - code = self._conn.insert_json_payload(payload) - print("insert_json_payload result {}".format(code)) + '''] + code = self._conn.insert_lines(payload, 2) + print("insert_lines result {}".format(code)) tdSql.query("describe stb2_6") tdSql.checkData(1, 1, "DOUBLE") - payload = ''' + payload = [''' { "metric": "stb2_7", "timestamp": { @@ -548,14 +548,14 @@ class TDTestCase: "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" } } - ''' - code = self._conn.insert_json_payload(payload) - print("insert_json_payload result {}".format(code)) + '''] + code = self._conn.insert_lines(payload, 2) + print("insert_lines result {}".format(code)) tdSql.query("describe stb2_7") tdSql.checkData(1, 1, "BINARY") - payload = ''' + payload = [''' { "metric": "stb2_8", "timestamp": { @@ -573,16 +573,16 @@ class TDTestCase: "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" } } - ''' - code = self._conn.insert_json_payload(payload) - print("insert_json_payload result {}".format(code)) + '''] + code = self._conn.insert_lines(payload, 2) + print("insert_lines result {}".format(code)) tdSql.query("describe stb2_8") tdSql.checkData(1, 1, "NCHAR") ### tag value ### - payload = ''' + payload = [''' { "metric": "stb3_0", "timestamp": { @@ -632,9 +632,9 @@ class TDTestCase: } } } - ''' - code = self._conn.insert_json_payload(payload) - print("insert_json_payload result {}".format(code)) + '''] + code = self._conn.insert_lines(payload, 2) + print("insert_lines result {}".format(code)) tdSql.query("describe stb3_0") tdSql.checkData(2, 1, "BOOL") diff --git a/tests/pytest/insert/insertTelnetLines.py b/tests/pytest/insert/insertTelnetLines.py index b47a74249bbad57ef758e886c513a7eea78b7634..cad8d940c91fcb44c06e113b04ffde1d712dd612 100644 --- a/tests/pytest/insert/insertTelnetLines.py +++ b/tests/pytest/insert/insertTelnetLines.py @@ -39,8 +39,8 @@ class TDTestCase: ".stb0.3. 1626006833639000000ns 4i8 host=\"host0\" interface=\"eth0\"", ] - code = self._conn.insert_telnet_lines(lines0) - print("insert_telnet_lines result {}".format(code)) + code = self._conn.insert_lines(lines0, 1) + print("insert_lines result {}".format(code)) tdSql.query("show stables") tdSql.checkRows(4) @@ -68,8 +68,8 @@ class TDTestCase: "stb1 0 6i8 host=\"host0\"", ] - code = self._conn.insert_telnet_lines(lines1) - print("insert_telnet_lines result {}".format(code)) + code = self._conn.insert_lines(lines1, 1) + print("insert_lines result {}".format(code)) tdSql.query("select * from stb1") tdSql.checkRows(6) @@ -82,8 +82,8 @@ class TDTestCase: "stb2_0 1626006833651ms -127i8 host=\"host0\"", "stb2_0 1626006833652ms 127i8 host=\"host0\"" ] - code = self._conn.insert_telnet_lines(lines2_0) - print("insert_telnet_lines result {}".format(code)) + code = self._conn.insert_lines(lines2_0, 1) + print("insert_lines result {}".format(code)) tdSql.query("select * from stb2_0") tdSql.checkRows(2) @@ -97,8 +97,8 @@ class TDTestCase: "stb2_1 1626006833651ms -32767i16 host=\"host0\"", "stb2_1 1626006833652ms 32767i16 host=\"host0\"" ] - code = self._conn.insert_telnet_lines(lines2_1) - print("insert_telnet_lines result {}".format(code)) + code = self._conn.insert_lines(lines2_1, 1) + print("insert_lines result {}".format(code)) tdSql.query("select * from stb2_1") tdSql.checkRows(2) @@ -113,8 +113,8 @@ class TDTestCase: "stb2_2 1626006833652ms 2147483647i32 host=\"host0\"" ] - code = self._conn.insert_telnet_lines(lines2_2) - print("insert_telnet_lines result {}".format(code)) + code = self._conn.insert_lines(lines2_2, 1) + print("insert_lines result {}".format(code)) tdSql.query("select * from stb2_2") tdSql.checkRows(2) @@ -130,8 +130,8 @@ class TDTestCase: "stb2_3 1626006833662ms 9223372036854775807 host=\"host0\"" ] - code = self._conn.insert_telnet_lines(lines2_3) - print("insert_telnet_lines result {}".format(code)) + code = self._conn.insert_lines(lines2_3, 1) + print("insert_lines result {}".format(code)) tdSql.query("select * from stb2_3") tdSql.checkRows(3) @@ -154,8 +154,8 @@ class TDTestCase: "stb2_4 1626006833710ms -3.4E38f32 host=\"host0\"" ] - code = self._conn.insert_telnet_lines(lines2_4) - print("insert_telnet_lines result {}".format(code)) + code = self._conn.insert_lines(lines2_4, 1) + print("insert_lines result {}".format(code)) tdSql.query("select * from stb2_4") tdSql.checkRows(10) @@ -179,8 +179,8 @@ class TDTestCase: "stb2_5 1626006833710ms 3.15 host=\"host0\"" ] - code = self._conn.insert_telnet_lines(lines2_5) - print("insert_telnet_lines result {}".format(code)) + code = self._conn.insert_lines(lines2_5, 1) + print("insert_lines result {}".format(code)) tdSql.query("select * from stb2_5") tdSql.checkRows(11) @@ -203,8 +203,8 @@ class TDTestCase: "stb2_6 1626006833700ms FALSE host=\"host0\"" ] - code = self._conn.insert_telnet_lines(lines2_6) - print("insert_telnet_lines result {}".format(code)) + code = self._conn.insert_lines(lines2_6, 1) + print("insert_lines result {}".format(code)) tdSql.query("select * from stb2_6") tdSql.checkRows(10) @@ -220,8 +220,8 @@ class TDTestCase: "stb2_7 1626006833630ms \"binary_val.()[]{}<>\" host=\"host0\"" ] - code = self._conn.insert_telnet_lines(lines2_7) - print("insert_telnet_lines result {}".format(code)) + code = self._conn.insert_lines(lines2_7, 1) + print("insert_lines result {}".format(code)) tdSql.query("select * from stb2_7") tdSql.checkRows(3) @@ -236,8 +236,8 @@ class TDTestCase: "stb2_8 1626006833620ms L\"nchar_val数值二\" host=\"host0\"" ] - code = self._conn.insert_telnet_lines(lines2_8) - print("insert_telnet_lines result {}".format(code)) + code = self._conn.insert_lines(lines2_8, 1) + print("insert_lines result {}".format(code)) tdSql.query("select * from stb2_8") tdSql.checkRows(2) @@ -254,8 +254,8 @@ class TDTestCase: "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 = self._conn.insert_telnet_lines(lines3_0) - print("insert_telnet_lines result {}".format(code)) + code = self._conn.insert_lines(lines3_0, 1) + print("insert_lines result {}".format(code)) tdSql.query("select * from stb3_0") tdSql.checkRows(2) @@ -298,8 +298,8 @@ class TDTestCase: "stb3_1 1626006833610ms 3 ID=\"child_table3\" host=\"host3\"" ] - code = self._conn.insert_telnet_lines(lines3_1) - print("insert_telnet_lines result {}".format(code)) + code = self._conn.insert_lines(lines3_1, 1) + print("insert_lines result {}".format(code)) tdSql.query("select * from stb3_1") tdSql.checkRows(3) diff --git a/tests/pytest/insert/line_insert.py b/tests/pytest/insert/line_insert.py index 92fdd0f28e612994df414ea1b560152a3f2001a8..920d3c17571d6d8781aa046462a62e8bd9d79da6 100644 --- a/tests/pytest/insert/line_insert.py +++ b/tests/pytest/insert/line_insert.py @@ -42,17 +42,17 @@ class TDTestCase: "stf,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641000000ns" ] - code = self._conn.insert_lines(lines) + code = self._conn.insert_lines(lines, 0) print("insert_lines result {}".format(code)) lines2 = [ "stg,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000ns", "stg,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000ns" ] - - code = self._conn.insert_lines([ lines2[0] ]) + + code = self._conn.insert_lines([ lines2[0] ], 0) print("insert_lines result {}".format(code)) - self._conn.insert_lines([ lines2[1] ]) + self._conn.insert_lines([ lines2[1] ], 0) print("insert_lines result {}".format(code)) tdSql.query("select * from st") @@ -75,8 +75,8 @@ class TDTestCase: self._conn.insert_lines([ "sth,t1=4i64,t2=5f64,t4=5f64,ID=\"childtable\" c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641ms", - "sth,t1=4i64,t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933654ms" - ]) + "sth,t1=4i64,t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933654ms" + ], 0) tdSql.execute('reset query cache') tdSql.query('select tbname, * from sth') diff --git a/tests/script/api/openTSDBTest.c b/tests/script/api/openTSDBTest.c index 02f21f70e8d29c426b5eb8fb9721d08f521a4c33..b4219f30e0e8a4b1c415b1fbfce2d0a93690c416 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_insert_telnet_lines(taos, lines0, 3); + code = taos_insert_lines(taos, lines0, 3, 1); if (code) { printf("lines0 code: %d, %s.\n", code, tstrerror(code)); } @@ -40,7 +40,7 @@ void verify_telnet_insert(TAOS* taos) { "stb1 1626006833651ms 5i8 host=\"host0\"", "stb1 0 6i8 host=\"host0\"", }; - code = taos_insert_telnet_lines(taos, lines1, 6); + code = taos_insert_lines(taos, lines1, 6, 1); if (code) { printf("lines1 code: %d, %s.\n", code, tstrerror(code)); } @@ -51,7 +51,7 @@ void verify_telnet_insert(TAOS* taos) { "stb2_0 1626006833651ms -127i8 host=\"host0\"", "stb2_0 1626006833652ms 127i8 host=\"host0\"" }; - code = taos_insert_telnet_lines(taos, lines2_0, 2); + code = taos_insert_lines(taos, lines2_0, 2, 1); if (code) { printf("lines2_0 code: %d, %s.\n", code, tstrerror(code)); } @@ -61,7 +61,7 @@ void verify_telnet_insert(TAOS* taos) { "stb2_1 1626006833651ms -32767i16 host=\"host0\"", "stb2_1 1626006833652ms 32767i16 host=\"host0\"" }; - code = taos_insert_telnet_lines(taos, lines2_1, 2); + code = taos_insert_lines(taos, lines2_1, 2, 1); if (code) { printf("lines2_1 code: %d, %s.\n", code, tstrerror(code)); } @@ -71,7 +71,7 @@ void verify_telnet_insert(TAOS* taos) { "stb2_2 1626006833651ms -2147483647i32 host=\"host0\"", "stb2_2 1626006833652ms 2147483647i32 host=\"host0\"" }; - code = taos_insert_telnet_lines(taos, lines2_2, 2); + code = taos_insert_lines(taos, lines2_2, 2, 1); if (code) { printf("lines2_2 code: %d, %s.\n", code, tstrerror(code)); } @@ -82,7 +82,7 @@ void verify_telnet_insert(TAOS* taos) { "stb2_3 1626006833652ms 9223372036854775807i64 host=\"host0\"", "stb2_3 1626006833662ms 9223372036854775807 host=\"host0\"" }; - code = taos_insert_telnet_lines(taos, lines2_3, 3); + code = taos_insert_lines(taos, lines2_3, 3, 1); 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_insert_telnet_lines(taos, lines2_4, 10); + code = taos_insert_lines(taos, lines2_4, 10, 1); 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_insert_telnet_lines(taos, lines2_5, 11); + code = taos_insert_lines(taos, lines2_5, 11, 1); 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_insert_telnet_lines(taos, lines2_6, 10); + code = taos_insert_lines(taos, lines2_6, 10, 1); 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_insert_telnet_lines(taos, lines2_7, 3); + code = taos_insert_lines(taos, lines2_7, 3, 1); 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_insert_telnet_lines(taos, lines2_8, 2); + code = taos_insert_lines(taos, lines2_8, 2, 1); 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_insert_telnet_lines(taos, lines3_0, 2); + code = taos_insert_lines(taos, lines3_0, 2, 1); 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_insert_telnet_lines(taos, lines3_1, 3); + code = taos_insert_lines(taos, lines3_1, 3, 1); if (code) { printf("lines3_1 code: %d, %s.\n", code, tstrerror(code)); } @@ -201,7 +201,7 @@ void verify_json_insert(TAOS* taos) { (void)taos_select_db(taos, "db"); int32_t code = 0; - char *message = + char *message[] = { "{ \ \"metric\":\"cpu_load_0\", \ \"timestamp\": 1626006833610123, \ @@ -212,14 +212,14 @@ void verify_json_insert(TAOS* taos) { \"interface1\": \"eth0\", \ \"Id\": \"tb0\" \ } \ - }"; + }"}; - code = taos_insert_json_payload(taos, message); + code = taos_insert_lines(taos, message, 0, 2); if (code) { printf("payload_0 code: %d, %s.\n", code, tstrerror(code)); } - char *message1 = + char *message1[] = { "[ \ { \ \"metric\":\"cpu_load_1\", \ @@ -243,14 +243,14 @@ void verify_json_insert(TAOS* taos) { \"Id\": \"tb2\" \ } \ } \ - ]"; + ]"}; - code = taos_insert_json_payload(taos, message1); + code = taos_insert_lines(taos, message1, 0, 2); if (code) { printf("payload_1 code: %d, %s.\n", code, tstrerror(code)); } - char *message2 = + char *message2[] = { "[ \ { \ \"metric\":\"cpu_load_3\", \ @@ -295,15 +295,15 @@ void verify_json_insert(TAOS* taos) { \"Id\": \"tb4\" \ } \ } \ - ]"; - code = taos_insert_json_payload(taos, message2); + ]"}; + code = taos_insert_lines(taos, message2, 0, 2); if (code) { printf("payload_2 code: %d, %s.\n", code, tstrerror(code)); } cJSON *payload, *tags; - char *payload_str; + char *payload_str[1]; /* Default format */ //number @@ -317,14 +317,14 @@ void verify_json_insert(TAOS* taos) { cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddItemToObject(payload, "tags", tags); - payload_str = cJSON_Print(payload); + *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_insert_json_payload(taos, payload_str); + code = taos_insert_lines(taos, payload_str, 0, 2); if (code) { printf("payload0_0 code: %d, %s.\n", code, tstrerror(code)); } - free(payload_str); + free(*payload_str); cJSON_Delete(payload); //true @@ -338,14 +338,14 @@ void verify_json_insert(TAOS* taos) { cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddItemToObject(payload, "tags", tags); - payload_str = cJSON_Print(payload); + *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_insert_json_payload(taos, payload_str); + code = taos_insert_lines(taos, payload_str, 0, 2); if (code) { printf("payload0_1 code: %d, %s.\n", code, tstrerror(code)); } - free(payload_str); + free(*payload_str); cJSON_Delete(payload); //false @@ -359,14 +359,14 @@ void verify_json_insert(TAOS* taos) { cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddItemToObject(payload, "tags", tags); - payload_str = cJSON_Print(payload); + *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_insert_json_payload(taos, payload_str); + code = taos_insert_lines(taos, payload_str, 0, 2); if (code) { printf("payload0_2 code: %d, %s.\n", code, tstrerror(code)); } - free(payload_str); + free(*payload_str); cJSON_Delete(payload); //string @@ -380,14 +380,14 @@ void verify_json_insert(TAOS* taos) { cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddItemToObject(payload, "tags", tags); - payload_str = cJSON_Print(payload); + *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_insert_json_payload(taos, payload_str); + code = taos_insert_lines(taos, payload_str, 0, 2); if (code) { printf("payload0_3 code: %d, %s.\n", code, tstrerror(code)); } - free(payload_str); + free(*payload_str); cJSON_Delete(payload); //timestamp 0 -> current time @@ -401,14 +401,14 @@ void verify_json_insert(TAOS* taos) { cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddItemToObject(payload, "tags", tags); - payload_str = cJSON_Print(payload); + *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_insert_json_payload(taos, payload_str); + code = taos_insert_lines(taos, payload_str, 0, 2); if (code) { printf("payload0_4 code: %d, %s.\n", code, tstrerror(code)); } - free(payload_str); + free(*payload_str); cJSON_Delete(payload); /* Nested format */ @@ -430,14 +430,14 @@ void verify_json_insert(TAOS* taos) { cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddItemToObject(payload, "tags", tags); - payload_str = cJSON_Print(payload); + *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_insert_json_payload(taos, payload_str); + code = taos_insert_lines(taos, payload_str, 0, 2); if (code) { printf("payload1_0 code: %d, %s.\n", code, tstrerror(code)); } - free(payload_str); + free(*payload_str); cJSON_Delete(payload); //milleseconds @@ -456,14 +456,14 @@ void verify_json_insert(TAOS* taos) { cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddItemToObject(payload, "tags", tags); - payload_str = cJSON_Print(payload); + *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_insert_json_payload(taos, payload_str); + code = taos_insert_lines(taos, payload_str, 0, 2); if (code) { printf("payload1_1 code: %d, %s.\n", code, tstrerror(code)); } - free(payload_str); + free(*payload_str); cJSON_Delete(payload); //microseconds @@ -482,14 +482,14 @@ void verify_json_insert(TAOS* taos) { cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddItemToObject(payload, "tags", tags); - payload_str = cJSON_Print(payload); + *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_insert_json_payload(taos, payload_str); + code = taos_insert_lines(taos, payload_str, 0, 2); if (code) { printf("payload1_2 code: %d, %s.\n", code, tstrerror(code)); } - free(payload_str); + free(*payload_str); cJSON_Delete(payload); //nanoseconds @@ -508,14 +508,14 @@ void verify_json_insert(TAOS* taos) { cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddItemToObject(payload, "tags", tags); - payload_str = cJSON_Print(payload); + *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_insert_json_payload(taos, payload_str); + code = taos_insert_lines(taos, payload_str, 0, 2); if (code) { printf("payload1_3 code: %d, %s.\n", code, tstrerror(code)); } - free(payload_str); + free(*payload_str); cJSON_Delete(payload); //now @@ -534,14 +534,14 @@ void verify_json_insert(TAOS* taos) { cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddItemToObject(payload, "tags", tags); - payload_str = cJSON_Print(payload); + *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_insert_json_payload(taos, payload_str); + code = taos_insert_lines(taos, payload_str, 0, 2); if (code) { printf("payload1_4 code: %d, %s.\n", code, tstrerror(code)); } - free(payload_str); + free(*payload_str); cJSON_Delete(payload); //metric value @@ -566,14 +566,14 @@ void verify_json_insert(TAOS* taos) { cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddItemToObject(payload, "tags", tags); - payload_str = cJSON_Print(payload); + *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_insert_json_payload(taos, payload_str); + code = taos_insert_lines(taos, payload_str, 0, 2); if (code) { printf("payload2_0 code: %d, %s.\n", code, tstrerror(code)); } - free(payload_str); + free(*payload_str); cJSON_Delete(payload); //tinyint @@ -596,14 +596,14 @@ void verify_json_insert(TAOS* taos) { cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddItemToObject(payload, "tags", tags); - payload_str = cJSON_Print(payload); + *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_insert_json_payload(taos, payload_str); + code = taos_insert_lines(taos, payload_str, 0, 2); if (code) { printf("payload2_1 code: %d, %s.\n", code, tstrerror(code)); } - free(payload_str); + free(*payload_str); cJSON_Delete(payload); //smallint @@ -626,14 +626,14 @@ void verify_json_insert(TAOS* taos) { cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddItemToObject(payload, "tags", tags); - payload_str = cJSON_Print(payload); + *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_insert_json_payload(taos, payload_str); + code = taos_insert_lines(taos, payload_str, 0, 2); if (code) { printf("payload2_2 code: %d, %s.\n", code, tstrerror(code)); } - free(payload_str); + free(*payload_str); cJSON_Delete(payload); //int @@ -656,14 +656,14 @@ void verify_json_insert(TAOS* taos) { cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddItemToObject(payload, "tags", tags); - payload_str = cJSON_Print(payload); + *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_insert_json_payload(taos, payload_str); + code = taos_insert_lines(taos, payload_str, 0, 2); if (code) { printf("payload2_3 code: %d, %s.\n", code, tstrerror(code)); } - free(payload_str); + free(*payload_str); cJSON_Delete(payload); //bigint @@ -686,14 +686,14 @@ void verify_json_insert(TAOS* taos) { cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddItemToObject(payload, "tags", tags); - payload_str = cJSON_Print(payload); + *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_insert_json_payload(taos, payload_str); + code = taos_insert_lines(taos, payload_str, 0, 2); if (code) { printf("payload2_4 code: %d, %s.\n", code, tstrerror(code)); } - free(payload_str); + free(*payload_str); cJSON_Delete(payload); //float @@ -716,14 +716,14 @@ void verify_json_insert(TAOS* taos) { cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddItemToObject(payload, "tags", tags); - payload_str = cJSON_Print(payload); + *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_insert_json_payload(taos, payload_str); + code = taos_insert_lines(taos, payload_str, 0, 2); if (code) { printf("payload2_5 code: %d, %s.\n", code, tstrerror(code)); } - free(payload_str); + free(*payload_str); cJSON_Delete(payload); //double @@ -746,14 +746,14 @@ void verify_json_insert(TAOS* taos) { cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddItemToObject(payload, "tags", tags); - payload_str = cJSON_Print(payload); + *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_insert_json_payload(taos, payload_str); + code = taos_insert_lines(taos, payload_str, 0, 2); if (code) { printf("payload2_6 code: %d, %s.\n", code, tstrerror(code)); } - free(payload_str); + free(*payload_str); cJSON_Delete(payload); //binary @@ -776,14 +776,14 @@ void verify_json_insert(TAOS* taos) { cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddItemToObject(payload, "tags", tags); - payload_str = cJSON_Print(payload); + *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_insert_json_payload(taos, payload_str); + code = taos_insert_lines(taos, payload_str, 0, 2); if (code) { printf("payload2_7 code: %d, %s.\n", code, tstrerror(code)); } - free(payload_str); + free(*payload_str); cJSON_Delete(payload); //nchar @@ -806,14 +806,14 @@ void verify_json_insert(TAOS* taos) { cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddItemToObject(payload, "tags", tags); - payload_str = cJSON_Print(payload); + *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_insert_json_payload(taos, payload_str); + code = taos_insert_lines(taos, payload_str, 0, 2); if (code) { printf("payload2_8 code: %d, %s.\n", code, tstrerror(code)); } - free(payload_str); + free(*payload_str); cJSON_Delete(payload); //tag value @@ -886,14 +886,14 @@ void verify_json_insert(TAOS* taos) { cJSON_AddItemToObject(payload, "tags", tags); - payload_str = cJSON_Print(payload); + *payload_str = cJSON_Print(payload); //printf("%s\n", payload_str); - code = taos_insert_json_payload(taos, payload_str); + code = taos_insert_lines(taos, payload_str, 0, 2); if (code) { printf("payload3_0 code: %d, %s.\n", code, tstrerror(code)); } - free(payload_str); + free(*payload_str); cJSON_Delete(payload); } diff --git a/tests/tsim/src/simExe.c b/tests/tsim/src/simExe.c index 397accfea57fec92dbe2b7f9b5c4b730a91e9cbd..49273d9c8edabee3b6d85aaf6a31e08a29eaeee5 100644 --- a/tests/tsim/src/simExe.c +++ b/tests/tsim/src/simExe.c @@ -1084,7 +1084,7 @@ bool simExecuteLineInsertCmd(SScript *script, char *rest) { simInfo("script:%s, %s", script->fileName, rest); simLogSql(buf, true); char * lines[] = {rest}; - int32_t ret = taos_insert_lines(script->taos, lines, 1); + int32_t ret = taos_insert_lines(script->taos, lines, 1, 0); if (ret == TSDB_CODE_SUCCESS) { simDebug("script:%s, taos:%p, %s executed. success.", script->fileName, script->taos, rest); script->linePos++; @@ -1107,7 +1107,7 @@ bool simExecuteLineInsertErrorCmd(SScript *script, char *rest) { simInfo("script:%s, %s", script->fileName, rest); simLogSql(buf, true); char * lines[] = {rest}; - int32_t ret = taos_insert_lines(script->taos, lines, 1); + int32_t ret = taos_insert_lines(script->taos, lines, 1, 0); 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++;