提交 005d7349 编写于 作者: G Ganlin Zhao

[TD-10445]<enhance>: Unify OpenTSDB APIs to taos_insert_lines

上级 efccb8b0
...@@ -47,6 +47,12 @@ typedef enum { ...@@ -47,6 +47,12 @@ typedef enum {
SML_TIME_STAMP_NANO_SECONDS SML_TIME_STAMP_NANO_SECONDS
} SMLTimeStampType; } SMLTimeStampType;
typedef enum {
SML_LINE_PROTOCOL = 0,
SML_TELNET_PROTOCOL = 1,
SML_JSON_PROTOCOL = 2,
} SMLProtocolType;
typedef struct { typedef struct {
uint64_t id; uint64_t id;
SHashObj* smlDataToSchema; SHashObj* smlDataToSchema;
...@@ -66,6 +72,11 @@ int32_t convertSmlTimeStamp(TAOS_SML_KV *pVal, char *value, ...@@ -66,6 +72,11 @@ int32_t convertSmlTimeStamp(TAOS_SML_KV *pVal, char *value,
void destroySmlDataPoint(TAOS_SML_DATA_POINT* point); 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 #ifdef __cplusplus
} }
#endif #endif
......
...@@ -1070,7 +1070,7 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp(J ...@@ -1070,7 +1070,7 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp(J
c_lines[i] = (char *)(*env)->GetStringUTFChars(env, line, 0); 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) { for (int i = 0; i < numLines; ++i) {
jstring line = (jstring)((*env)->GetObjectArrayElement(env, lines, i)); jstring line = (jstring)((*env)->GetObjectArrayElement(env, lines, i));
...@@ -1084,4 +1084,4 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp(J ...@@ -1084,4 +1084,4 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp(J
return JNI_TDENGINE_ERROR; return JNI_TDENGINE_ERROR;
} }
return code; return code;
} }
\ No newline at end of file
...@@ -2127,7 +2127,7 @@ int32_t tscParseLines(char* lines[], int numLines, SArray* points, SArray* faile ...@@ -2127,7 +2127,7 @@ int32_t tscParseLines(char* lines[], int numLines, SArray* points, SArray* faile
return TSDB_CODE_SUCCESS; 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; int32_t code = 0;
SSmlLinesInfo* info = tcalloc(1, sizeof(SSmlLinesInfo)); SSmlLinesInfo* info = tcalloc(1, sizeof(SSmlLinesInfo));
...@@ -2184,3 +2184,22 @@ cleanup: ...@@ -2184,3 +2184,22 @@ cleanup:
return code; 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;
}
...@@ -817,13 +817,13 @@ except AttributeError: ...@@ -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 # type: (c_void_p, list[str] | tuple(str)) -> None
num_of_lines = len(lines) num_of_lines = len(lines)
lines = (c_char_p(line.encode("utf-8")) for line in lines) lines = (c_char_p(line.encode("utf-8")) for line in lines)
lines_type = ctypes.c_char_p * num_of_lines lines_type = ctypes.c_char_p * num_of_lines
p_lines = lines_type(*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: if errno != 0:
raise LinesError("insert lines error", errno) raise LinesError("insert lines error", errno)
......
...@@ -117,9 +117,10 @@ class TaosConnection(object): ...@@ -117,9 +117,10 @@ class TaosConnection(object):
stream = taos_open_stream(self._conn, sql, callback, stime, param, callback2) stream = taos_open_stream(self._conn, sql, callback, stime, param, callback2)
return TaosStream(stream) return TaosStream(stream)
def insert_lines(self, lines): def insert_lines(self, lines, protocol):
# type: (list[str]) -> None # type: (list[str]) -> None
"""Line protocol and schemaless support """
1.Line protocol and schemaless support
## Example ## Example
...@@ -134,28 +135,13 @@ class TaosConnection(object): ...@@ -134,28 +135,13 @@ class TaosConnection(object):
conn.insert_lines(lines) conn.insert_lines(lines)
``` ```
## Exception 2.OpenTSDB telnet style API format support
```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
## Example ## Example
cpu_load 1626056811855516532ns 2.0f32 id="tb1",host="host0",interface="eth0" 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): 3.OpenTSDB HTTP JSON format support
"""OpenTSDB HTTP JSON format support
## Example ## Example
"{ "{
...@@ -170,8 +156,18 @@ class TaosConnection(object): ...@@ -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): def cursor(self):
# type: () -> TaosCursor # type: () -> TaosCursor
......
...@@ -187,11 +187,7 @@ DLL_EXPORT void taos_close_stream(TAOS_STREAM *tstr); ...@@ -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_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_lines(TAOS* taos, char* lines[], int numLines, int protocol);
DLL_EXPORT int taos_insert_telnet_lines(TAOS* taos, char* lines[], int numLines);
DLL_EXPORT int taos_insert_json_payload(TAOS* taos, char* payload);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -112,6 +112,7 @@ int32_t* taosGetErrno(); ...@@ -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_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_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_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 // mnode
#define TSDB_CODE_MND_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0300) //"Message not processed") #define TSDB_CODE_MND_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0300) //"Message not processed")
......
...@@ -120,6 +120,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_JSON, "Invalid JSON format") ...@@ -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_TYPE, "Invalid JSON data type")
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_JSON_CONFIG, "Invalid JSON configuration") 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_VALUE_OUT_OF_RANGE, "Value out of range")
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_PROTOCOL_TYPE, "Invalid line protocol type")
// mnode // mnode
TAOS_DEFINE_ERROR(TSDB_CODE_MND_MSG_NOT_PROCESSED, "Message not processed") TAOS_DEFINE_ERROR(TSDB_CODE_MND_MSG_NOT_PROCESSED, "Message not processed")
......
...@@ -980,40 +980,40 @@ int32_t verify_schema_less(TAOS* taos) { ...@@ -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" "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[] = { char* lines2[] = {
"stg,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000ns", "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" "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[0], 1, 0);
code = taos_insert_lines(taos, &lines2[1], 1); code = taos_insert_lines(taos, &lines2[1], 1, 0);
char* lines3[] = { 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,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"
}; };
code = taos_insert_lines(taos, lines3, 2); code = taos_insert_lines(taos, lines3, 2, 0);
char* lines4[] = { char* lines4[] = {
"st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000ns", "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" "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[] = { 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,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" "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[0], 1, 0);
code = taos_insert_lines(taos, &lines5[1], 1); code = taos_insert_lines(taos, &lines5[1], 1, 0);
char* lines6[] = { char* lines6[] = {
"st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000ns", "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" "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); return (code);
} }
......
...@@ -79,7 +79,7 @@ int main(int argc, char* argv[]) { ...@@ -79,7 +79,7 @@ int main(int argc, char* argv[]) {
printf("%s\n", "begin taos_insert_lines"); printf("%s\n", "begin taos_insert_lines");
int64_t begin = getTimeInUs(); 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(); int64_t end = getTimeInUs();
printf("code: %d, %s. time used: %"PRId64"\n", code, tstrerror(code), end-begin); printf("code: %d, %s. time used: %"PRId64"\n", code, tstrerror(code), end-begin);
......
...@@ -33,7 +33,7 @@ class TDTestCase: ...@@ -33,7 +33,7 @@ class TDTestCase:
### Default format ### ### Default format ###
### metric ### ### metric ###
print("============= step0 : test metric ================") print("============= step0 : test metric ================")
payload = ''' payload = ['''
{ {
"metric": ".stb.0.", "metric": ".stb.0.",
"timestamp": 1626006833610123, "timestamp": 1626006833610123,
...@@ -45,16 +45,16 @@ class TDTestCase: ...@@ -45,16 +45,16 @@ class TDTestCase:
"t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
} }
} }
''' ''']
code = self._conn.insert_json_payload(payload) code = self._conn.insert_lines(payload, 2)
print("insert_json_payload result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("describe _stb_0_") tdSql.query("describe _stb_0_")
tdSql.checkRows(6) tdSql.checkRows(6)
### metric value ### ### metric value ###
print("============= step1 : test metric value types ================") print("============= step1 : test metric value types ================")
payload = ''' payload = ['''
{ {
"metric": "stb0_0", "metric": "stb0_0",
"timestamp": 1626006833610123, "timestamp": 1626006833610123,
...@@ -66,14 +66,14 @@ class TDTestCase: ...@@ -66,14 +66,14 @@ class TDTestCase:
"t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
} }
} }
''' ''']
code = self._conn.insert_json_payload(payload) code = self._conn.insert_lines(payload, 2)
print("insert_json_payload result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("describe stb0_0") tdSql.query("describe stb0_0")
tdSql.checkData(1, 1, "BIGINT") tdSql.checkData(1, 1, "BIGINT")
payload = ''' payload = ['''
{ {
"metric": "stb0_1", "metric": "stb0_1",
"timestamp": 1626006833610123, "timestamp": 1626006833610123,
...@@ -85,14 +85,14 @@ class TDTestCase: ...@@ -85,14 +85,14 @@ class TDTestCase:
"t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
} }
} }
''' ''']
code = self._conn.insert_json_payload(payload) code = self._conn.insert_lines(payload, 2)
print("insert_json_payload result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("describe stb0_1") tdSql.query("describe stb0_1")
tdSql.checkData(1, 1, "BOOL") tdSql.checkData(1, 1, "BOOL")
payload = ''' payload = ['''
{ {
"metric": "stb0_2", "metric": "stb0_2",
"timestamp": 1626006833610123, "timestamp": 1626006833610123,
...@@ -104,14 +104,14 @@ class TDTestCase: ...@@ -104,14 +104,14 @@ class TDTestCase:
"t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
} }
} }
''' ''']
code = self._conn.insert_json_payload(payload) code = self._conn.insert_lines(payload, 2)
print("insert_json_payload result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("describe stb0_2") tdSql.query("describe stb0_2")
tdSql.checkData(1, 1, "BOOL") tdSql.checkData(1, 1, "BOOL")
payload = ''' payload = ['''
{ {
"metric": "stb0_3", "metric": "stb0_3",
"timestamp": 1626006833610123, "timestamp": 1626006833610123,
...@@ -123,14 +123,14 @@ class TDTestCase: ...@@ -123,14 +123,14 @@ class TDTestCase:
"t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
} }
} }
''' ''']
code = self._conn.insert_json_payload(payload) code = self._conn.insert_lines(payload, 2)
print("insert_json_payload result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("describe stb0_3") tdSql.query("describe stb0_3")
tdSql.checkData(1, 1, "BINARY") tdSql.checkData(1, 1, "BINARY")
payload = ''' payload = ['''
{ {
"metric": "stb0_4", "metric": "stb0_4",
"timestamp": 1626006833610123, "timestamp": 1626006833610123,
...@@ -142,14 +142,14 @@ class TDTestCase: ...@@ -142,14 +142,14 @@ class TDTestCase:
"t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
} }
} }
''' ''']
code = self._conn.insert_json_payload(payload) code = self._conn.insert_lines(payload, 2)
print("insert_json_payload result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("describe stb0_4") tdSql.query("describe stb0_4")
tdSql.checkData(1, 1, "DOUBLE") tdSql.checkData(1, 1, "DOUBLE")
payload = ''' payload = ['''
{ {
"metric": "stb0_5", "metric": "stb0_5",
"timestamp": 1626006833610123, "timestamp": 1626006833610123,
...@@ -161,9 +161,9 @@ class TDTestCase: ...@@ -161,9 +161,9 @@ class TDTestCase:
"t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
} }
} }
''' ''']
code = self._conn.insert_json_payload(payload) code = self._conn.insert_lines(payload, 2)
print("insert_json_payload result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("describe stb0_5") tdSql.query("describe stb0_5")
tdSql.checkData(1, 1, "DOUBLE") tdSql.checkData(1, 1, "DOUBLE")
...@@ -171,7 +171,7 @@ class TDTestCase: ...@@ -171,7 +171,7 @@ class TDTestCase:
print("============= step2 : test timestamp ================") print("============= step2 : test timestamp ================")
### timestamp 0 ### ### timestamp 0 ###
payload = ''' payload = ['''
{ {
"metric": "stb0_6", "metric": "stb0_6",
"timestamp": 0, "timestamp": 0,
...@@ -183,14 +183,14 @@ class TDTestCase: ...@@ -183,14 +183,14 @@ class TDTestCase:
"t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
} }
} }
''' ''']
code = self._conn.insert_json_payload(payload) code = self._conn.insert_lines(payload, 2)
print("insert_json_payload result {}".format(code)) print("insert_lines result {}".format(code))
print("============= step3 : test tags ================") print("============= step3 : test tags ================")
### Default tag numeric types ### ### Default tag numeric types ###
payload = ''' payload = ['''
{ {
"metric": "stb0_8", "metric": "stb0_8",
"timestamp": 0, "timestamp": 0,
...@@ -199,14 +199,14 @@ class TDTestCase: ...@@ -199,14 +199,14 @@ class TDTestCase:
"t1": 123 "t1": 123
} }
} }
''' ''']
code = self._conn.insert_json_payload(payload) code = self._conn.insert_lines(payload, 2)
print("insert_json_payload result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("describe stb0_8") tdSql.query("describe stb0_8")
tdSql.checkData(2, 1, "BIGINT") tdSql.checkData(2, 1, "BIGINT")
payload = ''' payload = ['''
{ {
"metric": "stb0_9", "metric": "stb0_9",
"timestamp": 0, "timestamp": 0,
...@@ -215,14 +215,14 @@ class TDTestCase: ...@@ -215,14 +215,14 @@ class TDTestCase:
"t1": 123.00 "t1": 123.00
} }
} }
''' ''']
code = self._conn.insert_json_payload(payload) code = self._conn.insert_lines(payload, 2)
print("insert_json_payload result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("describe stb0_9") tdSql.query("describe stb0_9")
tdSql.checkData(2, 1, "DOUBLE") tdSql.checkData(2, 1, "DOUBLE")
payload = ''' payload = ['''
{ {
"metric": "stb0_10", "metric": "stb0_10",
"timestamp": 0, "timestamp": 0,
...@@ -231,9 +231,9 @@ class TDTestCase: ...@@ -231,9 +231,9 @@ class TDTestCase:
"t1": 123E-1 "t1": 123E-1
} }
} }
''' ''']
code = self._conn.insert_json_payload(payload) code = self._conn.insert_lines(payload, 2)
print("insert_json_payload result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("describe stb0_10") tdSql.query("describe stb0_10")
tdSql.checkData(2, 1, "DOUBLE") tdSql.checkData(2, 1, "DOUBLE")
...@@ -242,7 +242,7 @@ class TDTestCase: ...@@ -242,7 +242,7 @@ class TDTestCase:
print("============= step4 : test nested format ================") print("============= step4 : test nested format ================")
### timestamp ### ### timestamp ###
#seconds #seconds
payload = ''' payload = ['''
{ {
"metric": "stb1_0", "metric": "stb1_0",
"timestamp": { "timestamp": {
...@@ -257,15 +257,15 @@ class TDTestCase: ...@@ -257,15 +257,15 @@ class TDTestCase:
"t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
} }
} }
''' ''']
code = self._conn.insert_json_payload(payload) code = self._conn.insert_lines(payload, 2)
print("insert_json_payload result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("select ts from stb1_0") tdSql.query("select ts from stb1_0")
tdSql.checkData(0, 0, "2021-07-11 20:33:53.000000") tdSql.checkData(0, 0, "2021-07-11 20:33:53.000000")
#milliseconds #milliseconds
payload = ''' payload = ['''
{ {
"metric": "stb1_1", "metric": "stb1_1",
"timestamp": { "timestamp": {
...@@ -280,15 +280,15 @@ class TDTestCase: ...@@ -280,15 +280,15 @@ class TDTestCase:
"t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
} }
} }
''' ''']
code = self._conn.insert_json_payload(payload) code = self._conn.insert_lines(payload, 2)
print("insert_json_payload result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("select ts from stb1_1") tdSql.query("select ts from stb1_1")
tdSql.checkData(0, 0, "2021-07-11 20:33:53.610000") tdSql.checkData(0, 0, "2021-07-11 20:33:53.610000")
#microseconds #microseconds
payload = ''' payload = ['''
{ {
"metric": "stb1_2", "metric": "stb1_2",
"timestamp": { "timestamp": {
...@@ -303,15 +303,15 @@ class TDTestCase: ...@@ -303,15 +303,15 @@ class TDTestCase:
"t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
} }
} }
''' ''']
code = self._conn.insert_json_payload(payload) code = self._conn.insert_lines(payload, 2)
print("insert_json_payload result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("select ts from stb1_2") tdSql.query("select ts from stb1_2")
tdSql.checkData(0, 0, "2021-07-11 20:33:53.610123") tdSql.checkData(0, 0, "2021-07-11 20:33:53.610123")
#nanoseconds #nanoseconds
payload = ''' payload = ['''
{ {
"metric": "stb1_3", "metric": "stb1_3",
"timestamp": { "timestamp": {
...@@ -326,16 +326,16 @@ class TDTestCase: ...@@ -326,16 +326,16 @@ class TDTestCase:
"t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
} }
} }
''' ''']
code = self._conn.insert_json_payload(payload) code = self._conn.insert_lines(payload, 2)
print("insert_json_payload result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("select ts from stb1_3") tdSql.query("select ts from stb1_3")
tdSql.checkData(0, 0, "2021-07-11 20:33:53.610123") tdSql.checkData(0, 0, "2021-07-11 20:33:53.610123")
#now #now
tdSql.execute('use test') tdSql.execute('use test')
payload = ''' payload = ['''
{ {
"metric": "stb1_4", "metric": "stb1_4",
"timestamp": { "timestamp": {
...@@ -350,12 +350,12 @@ class TDTestCase: ...@@ -350,12 +350,12 @@ class TDTestCase:
"t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
} }
} }
''' ''']
code = self._conn.insert_json_payload(payload) code = self._conn.insert_lines(payload, 2)
print("insert_json_payload result {}".format(code)) print("insert_lines result {}".format(code))
### metric value ### ### metric value ###
payload = ''' payload = ['''
{ {
"metric": "stb2_0", "metric": "stb2_0",
"timestamp": { "timestamp": {
...@@ -373,14 +373,14 @@ class TDTestCase: ...@@ -373,14 +373,14 @@ class TDTestCase:
"t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
} }
} }
''' ''']
code = self._conn.insert_json_payload(payload) code = self._conn.insert_lines(payload, 2)
print("insert_json_payload result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("describe stb2_0") tdSql.query("describe stb2_0")
tdSql.checkData(1, 1, "BOOL") tdSql.checkData(1, 1, "BOOL")
payload = ''' payload = ['''
{ {
"metric": "stb2_1", "metric": "stb2_1",
"timestamp": { "timestamp": {
...@@ -398,14 +398,14 @@ class TDTestCase: ...@@ -398,14 +398,14 @@ class TDTestCase:
"t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
} }
} }
''' ''']
code = self._conn.insert_json_payload(payload) code = self._conn.insert_lines(payload, 2)
print("insert_json_payload result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("describe stb2_1") tdSql.query("describe stb2_1")
tdSql.checkData(1, 1, "TINYINT") tdSql.checkData(1, 1, "TINYINT")
payload = ''' payload = ['''
{ {
"metric": "stb2_2", "metric": "stb2_2",
"timestamp": { "timestamp": {
...@@ -423,14 +423,14 @@ class TDTestCase: ...@@ -423,14 +423,14 @@ class TDTestCase:
"t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
} }
} }
''' ''']
code = self._conn.insert_json_payload(payload) code = self._conn.insert_lines(payload, 2)
print("insert_json_payload result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("describe stb2_2") tdSql.query("describe stb2_2")
tdSql.checkData(1, 1, "SMALLINT") tdSql.checkData(1, 1, "SMALLINT")
payload = ''' payload = ['''
{ {
"metric": "stb2_3", "metric": "stb2_3",
"timestamp": { "timestamp": {
...@@ -448,14 +448,14 @@ class TDTestCase: ...@@ -448,14 +448,14 @@ class TDTestCase:
"t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
} }
} }
''' ''']
code = self._conn.insert_json_payload(payload) code = self._conn.insert_lines(payload, 2)
print("insert_json_payload result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("describe stb2_3") tdSql.query("describe stb2_3")
tdSql.checkData(1, 1, "INT") tdSql.checkData(1, 1, "INT")
payload = ''' payload = ['''
{ {
"metric": "stb2_4", "metric": "stb2_4",
"timestamp": { "timestamp": {
...@@ -473,14 +473,14 @@ class TDTestCase: ...@@ -473,14 +473,14 @@ class TDTestCase:
"t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
} }
} }
''' ''']
code = self._conn.insert_json_payload(payload) code = self._conn.insert_lines(payload, 2)
print("insert_json_payload result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("describe stb2_4") tdSql.query("describe stb2_4")
tdSql.checkData(1, 1, "BIGINT") tdSql.checkData(1, 1, "BIGINT")
payload = ''' payload = ['''
{ {
"metric": "stb2_5", "metric": "stb2_5",
"timestamp": { "timestamp": {
...@@ -498,14 +498,14 @@ class TDTestCase: ...@@ -498,14 +498,14 @@ class TDTestCase:
"t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
} }
} }
''' ''']
code = self._conn.insert_json_payload(payload) code = self._conn.insert_lines(payload, 2)
print("insert_json_payload result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("describe stb2_5") tdSql.query("describe stb2_5")
tdSql.checkData(1, 1, "FLOAT") tdSql.checkData(1, 1, "FLOAT")
payload = ''' payload = ['''
{ {
"metric": "stb2_6", "metric": "stb2_6",
"timestamp": { "timestamp": {
...@@ -523,14 +523,14 @@ class TDTestCase: ...@@ -523,14 +523,14 @@ class TDTestCase:
"t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
} }
} }
''' ''']
code = self._conn.insert_json_payload(payload) code = self._conn.insert_lines(payload, 2)
print("insert_json_payload result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("describe stb2_6") tdSql.query("describe stb2_6")
tdSql.checkData(1, 1, "DOUBLE") tdSql.checkData(1, 1, "DOUBLE")
payload = ''' payload = ['''
{ {
"metric": "stb2_7", "metric": "stb2_7",
"timestamp": { "timestamp": {
...@@ -548,14 +548,14 @@ class TDTestCase: ...@@ -548,14 +548,14 @@ class TDTestCase:
"t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
} }
} }
''' ''']
code = self._conn.insert_json_payload(payload) code = self._conn.insert_lines(payload, 2)
print("insert_json_payload result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("describe stb2_7") tdSql.query("describe stb2_7")
tdSql.checkData(1, 1, "BINARY") tdSql.checkData(1, 1, "BINARY")
payload = ''' payload = ['''
{ {
"metric": "stb2_8", "metric": "stb2_8",
"timestamp": { "timestamp": {
...@@ -573,16 +573,16 @@ class TDTestCase: ...@@ -573,16 +573,16 @@ class TDTestCase:
"t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
} }
} }
''' ''']
code = self._conn.insert_json_payload(payload) code = self._conn.insert_lines(payload, 2)
print("insert_json_payload result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("describe stb2_8") tdSql.query("describe stb2_8")
tdSql.checkData(1, 1, "NCHAR") tdSql.checkData(1, 1, "NCHAR")
### tag value ### ### tag value ###
payload = ''' payload = ['''
{ {
"metric": "stb3_0", "metric": "stb3_0",
"timestamp": { "timestamp": {
...@@ -632,9 +632,9 @@ class TDTestCase: ...@@ -632,9 +632,9 @@ class TDTestCase:
} }
} }
} }
''' ''']
code = self._conn.insert_json_payload(payload) code = self._conn.insert_lines(payload, 2)
print("insert_json_payload result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("describe stb3_0") tdSql.query("describe stb3_0")
tdSql.checkData(2, 1, "BOOL") tdSql.checkData(2, 1, "BOOL")
......
...@@ -39,8 +39,8 @@ class TDTestCase: ...@@ -39,8 +39,8 @@ class TDTestCase:
".stb0.3. 1626006833639000000ns 4i8 host=\"host0\" interface=\"eth0\"", ".stb0.3. 1626006833639000000ns 4i8 host=\"host0\" interface=\"eth0\"",
] ]
code = self._conn.insert_telnet_lines(lines0) code = self._conn.insert_lines(lines0, 1)
print("insert_telnet_lines result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("show stables") tdSql.query("show stables")
tdSql.checkRows(4) tdSql.checkRows(4)
...@@ -68,8 +68,8 @@ class TDTestCase: ...@@ -68,8 +68,8 @@ class TDTestCase:
"stb1 0 6i8 host=\"host0\"", "stb1 0 6i8 host=\"host0\"",
] ]
code = self._conn.insert_telnet_lines(lines1) code = self._conn.insert_lines(lines1, 1)
print("insert_telnet_lines result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("select * from stb1") tdSql.query("select * from stb1")
tdSql.checkRows(6) tdSql.checkRows(6)
...@@ -82,8 +82,8 @@ class TDTestCase: ...@@ -82,8 +82,8 @@ class TDTestCase:
"stb2_0 1626006833651ms -127i8 host=\"host0\"", "stb2_0 1626006833651ms -127i8 host=\"host0\"",
"stb2_0 1626006833652ms 127i8 host=\"host0\"" "stb2_0 1626006833652ms 127i8 host=\"host0\""
] ]
code = self._conn.insert_telnet_lines(lines2_0) code = self._conn.insert_lines(lines2_0, 1)
print("insert_telnet_lines result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("select * from stb2_0") tdSql.query("select * from stb2_0")
tdSql.checkRows(2) tdSql.checkRows(2)
...@@ -97,8 +97,8 @@ class TDTestCase: ...@@ -97,8 +97,8 @@ class TDTestCase:
"stb2_1 1626006833651ms -32767i16 host=\"host0\"", "stb2_1 1626006833651ms -32767i16 host=\"host0\"",
"stb2_1 1626006833652ms 32767i16 host=\"host0\"" "stb2_1 1626006833652ms 32767i16 host=\"host0\""
] ]
code = self._conn.insert_telnet_lines(lines2_1) code = self._conn.insert_lines(lines2_1, 1)
print("insert_telnet_lines result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("select * from stb2_1") tdSql.query("select * from stb2_1")
tdSql.checkRows(2) tdSql.checkRows(2)
...@@ -113,8 +113,8 @@ class TDTestCase: ...@@ -113,8 +113,8 @@ class TDTestCase:
"stb2_2 1626006833652ms 2147483647i32 host=\"host0\"" "stb2_2 1626006833652ms 2147483647i32 host=\"host0\""
] ]
code = self._conn.insert_telnet_lines(lines2_2) code = self._conn.insert_lines(lines2_2, 1)
print("insert_telnet_lines result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("select * from stb2_2") tdSql.query("select * from stb2_2")
tdSql.checkRows(2) tdSql.checkRows(2)
...@@ -130,8 +130,8 @@ class TDTestCase: ...@@ -130,8 +130,8 @@ class TDTestCase:
"stb2_3 1626006833662ms 9223372036854775807 host=\"host0\"" "stb2_3 1626006833662ms 9223372036854775807 host=\"host0\""
] ]
code = self._conn.insert_telnet_lines(lines2_3) code = self._conn.insert_lines(lines2_3, 1)
print("insert_telnet_lines result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("select * from stb2_3") tdSql.query("select * from stb2_3")
tdSql.checkRows(3) tdSql.checkRows(3)
...@@ -154,8 +154,8 @@ class TDTestCase: ...@@ -154,8 +154,8 @@ class TDTestCase:
"stb2_4 1626006833710ms -3.4E38f32 host=\"host0\"" "stb2_4 1626006833710ms -3.4E38f32 host=\"host0\""
] ]
code = self._conn.insert_telnet_lines(lines2_4) code = self._conn.insert_lines(lines2_4, 1)
print("insert_telnet_lines result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("select * from stb2_4") tdSql.query("select * from stb2_4")
tdSql.checkRows(10) tdSql.checkRows(10)
...@@ -179,8 +179,8 @@ class TDTestCase: ...@@ -179,8 +179,8 @@ class TDTestCase:
"stb2_5 1626006833710ms 3.15 host=\"host0\"" "stb2_5 1626006833710ms 3.15 host=\"host0\""
] ]
code = self._conn.insert_telnet_lines(lines2_5) code = self._conn.insert_lines(lines2_5, 1)
print("insert_telnet_lines result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("select * from stb2_5") tdSql.query("select * from stb2_5")
tdSql.checkRows(11) tdSql.checkRows(11)
...@@ -203,8 +203,8 @@ class TDTestCase: ...@@ -203,8 +203,8 @@ class TDTestCase:
"stb2_6 1626006833700ms FALSE host=\"host0\"" "stb2_6 1626006833700ms FALSE host=\"host0\""
] ]
code = self._conn.insert_telnet_lines(lines2_6) code = self._conn.insert_lines(lines2_6, 1)
print("insert_telnet_lines result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("select * from stb2_6") tdSql.query("select * from stb2_6")
tdSql.checkRows(10) tdSql.checkRows(10)
...@@ -220,8 +220,8 @@ class TDTestCase: ...@@ -220,8 +220,8 @@ class TDTestCase:
"stb2_7 1626006833630ms \"binary_val.()[]{}<>\" host=\"host0\"" "stb2_7 1626006833630ms \"binary_val.()[]{}<>\" host=\"host0\""
] ]
code = self._conn.insert_telnet_lines(lines2_7) code = self._conn.insert_lines(lines2_7, 1)
print("insert_telnet_lines result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("select * from stb2_7") tdSql.query("select * from stb2_7")
tdSql.checkRows(3) tdSql.checkRows(3)
...@@ -236,8 +236,8 @@ class TDTestCase: ...@@ -236,8 +236,8 @@ class TDTestCase:
"stb2_8 1626006833620ms L\"nchar_val数值二\" host=\"host0\"" "stb2_8 1626006833620ms L\"nchar_val数值二\" host=\"host0\""
] ]
code = self._conn.insert_telnet_lines(lines2_8) code = self._conn.insert_lines(lines2_8, 1)
print("insert_telnet_lines result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("select * from stb2_8") tdSql.query("select * from stb2_8")
tdSql.checkRows(2) tdSql.checkRows(2)
...@@ -254,8 +254,8 @@ class TDTestCase: ...@@ -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\"" "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) code = self._conn.insert_lines(lines3_0, 1)
print("insert_telnet_lines result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("select * from stb3_0") tdSql.query("select * from stb3_0")
tdSql.checkRows(2) tdSql.checkRows(2)
...@@ -298,8 +298,8 @@ class TDTestCase: ...@@ -298,8 +298,8 @@ class TDTestCase:
"stb3_1 1626006833610ms 3 ID=\"child_table3\" host=\"host3\"" "stb3_1 1626006833610ms 3 ID=\"child_table3\" host=\"host3\""
] ]
code = self._conn.insert_telnet_lines(lines3_1) code = self._conn.insert_lines(lines3_1, 1)
print("insert_telnet_lines result {}".format(code)) print("insert_lines result {}".format(code))
tdSql.query("select * from stb3_1") tdSql.query("select * from stb3_1")
tdSql.checkRows(3) tdSql.checkRows(3)
......
...@@ -42,17 +42,17 @@ class TDTestCase: ...@@ -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" "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)) print("insert_lines result {}".format(code))
lines2 = [ "stg,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000ns", 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" "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)) 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)) print("insert_lines result {}".format(code))
tdSql.query("select * from st") tdSql.query("select * from st")
...@@ -75,8 +75,8 @@ class TDTestCase: ...@@ -75,8 +75,8 @@ class TDTestCase:
self._conn.insert_lines([ 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,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.execute('reset query cache')
tdSql.query('select tbname, * from sth') tdSql.query('select tbname, * from sth')
......
...@@ -26,7 +26,7 @@ void verify_telnet_insert(TAOS* taos) { ...@@ -26,7 +26,7 @@ void verify_telnet_insert(TAOS* taos) {
"stb0_1 1626006833639000000ns 4i8 host=\"host0\" interface=\"eth0\"", "stb0_1 1626006833639000000ns 4i8 host=\"host0\" interface=\"eth0\"",
"stb0_2 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) { if (code) {
printf("lines0 code: %d, %s.\n", code, tstrerror(code)); printf("lines0 code: %d, %s.\n", code, tstrerror(code));
} }
...@@ -40,7 +40,7 @@ void verify_telnet_insert(TAOS* taos) { ...@@ -40,7 +40,7 @@ void verify_telnet_insert(TAOS* taos) {
"stb1 1626006833651ms 5i8 host=\"host0\"", "stb1 1626006833651ms 5i8 host=\"host0\"",
"stb1 0 6i8 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) { if (code) {
printf("lines1 code: %d, %s.\n", code, tstrerror(code)); printf("lines1 code: %d, %s.\n", code, tstrerror(code));
} }
...@@ -51,7 +51,7 @@ void verify_telnet_insert(TAOS* taos) { ...@@ -51,7 +51,7 @@ void verify_telnet_insert(TAOS* taos) {
"stb2_0 1626006833651ms -127i8 host=\"host0\"", "stb2_0 1626006833651ms -127i8 host=\"host0\"",
"stb2_0 1626006833652ms 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) { if (code) {
printf("lines2_0 code: %d, %s.\n", code, tstrerror(code)); printf("lines2_0 code: %d, %s.\n", code, tstrerror(code));
} }
...@@ -61,7 +61,7 @@ void verify_telnet_insert(TAOS* taos) { ...@@ -61,7 +61,7 @@ void verify_telnet_insert(TAOS* taos) {
"stb2_1 1626006833651ms -32767i16 host=\"host0\"", "stb2_1 1626006833651ms -32767i16 host=\"host0\"",
"stb2_1 1626006833652ms 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) { if (code) {
printf("lines2_1 code: %d, %s.\n", code, tstrerror(code)); printf("lines2_1 code: %d, %s.\n", code, tstrerror(code));
} }
...@@ -71,7 +71,7 @@ void verify_telnet_insert(TAOS* taos) { ...@@ -71,7 +71,7 @@ void verify_telnet_insert(TAOS* taos) {
"stb2_2 1626006833651ms -2147483647i32 host=\"host0\"", "stb2_2 1626006833651ms -2147483647i32 host=\"host0\"",
"stb2_2 1626006833652ms 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) { if (code) {
printf("lines2_2 code: %d, %s.\n", code, tstrerror(code)); printf("lines2_2 code: %d, %s.\n", code, tstrerror(code));
} }
...@@ -82,7 +82,7 @@ void verify_telnet_insert(TAOS* taos) { ...@@ -82,7 +82,7 @@ void verify_telnet_insert(TAOS* taos) {
"stb2_3 1626006833652ms 9223372036854775807i64 host=\"host0\"", "stb2_3 1626006833652ms 9223372036854775807i64 host=\"host0\"",
"stb2_3 1626006833662ms 9223372036854775807 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) { if (code) {
printf("lines2_3 code: %d, %s.\n", code, tstrerror(code)); printf("lines2_3 code: %d, %s.\n", code, tstrerror(code));
} }
...@@ -100,7 +100,7 @@ void verify_telnet_insert(TAOS* taos) { ...@@ -100,7 +100,7 @@ void verify_telnet_insert(TAOS* taos) {
"stb2_4 1626006833700ms 3.4E38f32 host=\"host0\"", "stb2_4 1626006833700ms 3.4E38f32 host=\"host0\"",
"stb2_4 1626006833710ms -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) { if (code) {
printf("lines2_4 code: %d, %s.\n", code, tstrerror(code)); printf("lines2_4 code: %d, %s.\n", code, tstrerror(code));
} }
...@@ -119,7 +119,7 @@ void verify_telnet_insert(TAOS* taos) { ...@@ -119,7 +119,7 @@ void verify_telnet_insert(TAOS* taos) {
"stb2_5 1626006833700ms -1.7E308f64 host=\"host0\"", "stb2_5 1626006833700ms -1.7E308f64 host=\"host0\"",
"stb2_5 1626006833710ms 3.15 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) { if (code) {
printf("lines2_5 code: %d, %s.\n", code, tstrerror(code)); printf("lines2_5 code: %d, %s.\n", code, tstrerror(code));
} }
...@@ -137,7 +137,7 @@ void verify_telnet_insert(TAOS* taos) { ...@@ -137,7 +137,7 @@ void verify_telnet_insert(TAOS* taos) {
"stb2_6 1626006833690ms False host=\"host0\"", "stb2_6 1626006833690ms False host=\"host0\"",
"stb2_6 1626006833700ms 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) { if (code) {
printf("lines2_6 code: %d, %s.\n", code, tstrerror(code)); printf("lines2_6 code: %d, %s.\n", code, tstrerror(code));
} }
...@@ -148,7 +148,7 @@ void verify_telnet_insert(TAOS* taos) { ...@@ -148,7 +148,7 @@ void verify_telnet_insert(TAOS* taos) {
"stb2_7 1626006833620ms \"binary_val.:;,./?|+-=\" host=\"host0\"", "stb2_7 1626006833620ms \"binary_val.:;,./?|+-=\" host=\"host0\"",
"stb2_7 1626006833630ms \"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) { if (code) {
printf("lines2_7 code: %d, %s.\n", code, tstrerror(code)); printf("lines2_7 code: %d, %s.\n", code, tstrerror(code));
} }
...@@ -158,7 +158,7 @@ void verify_telnet_insert(TAOS* taos) { ...@@ -158,7 +158,7 @@ void verify_telnet_insert(TAOS* taos) {
"stb2_8 1626006833610ms L\"nchar_val数值一\" host=\"host0\"", "stb2_8 1626006833610ms L\"nchar_val数值一\" host=\"host0\"",
"stb2_8 1626006833620ms 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) { if (code) {
printf("lines2_8 code: %d, %s.\n", code, tstrerror(code)); printf("lines2_8 code: %d, %s.\n", code, tstrerror(code));
} }
...@@ -169,7 +169,7 @@ void verify_telnet_insert(TAOS* taos) { ...@@ -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 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\"" "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) { if (code) {
printf("lines3_0 code: %d, %s.\n", code, tstrerror(code)); printf("lines3_0 code: %d, %s.\n", code, tstrerror(code));
} }
...@@ -180,7 +180,7 @@ void verify_telnet_insert(TAOS* taos) { ...@@ -180,7 +180,7 @@ void verify_telnet_insert(TAOS* taos) {
"stb3_1 1626006833610ms 2 host=\"host2\" iD=\"child_table2\"", "stb3_1 1626006833610ms 2 host=\"host2\" iD=\"child_table2\"",
"stb3_1 1626006833610ms 3 ID=\"child_table3\" host=\"host3\"" "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) { if (code) {
printf("lines3_1 code: %d, %s.\n", code, tstrerror(code)); printf("lines3_1 code: %d, %s.\n", code, tstrerror(code));
} }
...@@ -201,7 +201,7 @@ void verify_json_insert(TAOS* taos) { ...@@ -201,7 +201,7 @@ void verify_json_insert(TAOS* taos) {
(void)taos_select_db(taos, "db"); (void)taos_select_db(taos, "db");
int32_t code = 0; int32_t code = 0;
char *message = char *message[] = {
"{ \ "{ \
\"metric\":\"cpu_load_0\", \ \"metric\":\"cpu_load_0\", \
\"timestamp\": 1626006833610123, \ \"timestamp\": 1626006833610123, \
...@@ -212,14 +212,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -212,14 +212,14 @@ void verify_json_insert(TAOS* taos) {
\"interface1\": \"eth0\", \ \"interface1\": \"eth0\", \
\"Id\": \"tb0\" \ \"Id\": \"tb0\" \
} \ } \
}"; }"};
code = taos_insert_json_payload(taos, message); code = taos_insert_lines(taos, message, 0, 2);
if (code) { if (code) {
printf("payload_0 code: %d, %s.\n", code, tstrerror(code)); printf("payload_0 code: %d, %s.\n", code, tstrerror(code));
} }
char *message1 = char *message1[] = {
"[ \ "[ \
{ \ { \
\"metric\":\"cpu_load_1\", \ \"metric\":\"cpu_load_1\", \
...@@ -243,14 +243,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -243,14 +243,14 @@ void verify_json_insert(TAOS* taos) {
\"Id\": \"tb2\" \ \"Id\": \"tb2\" \
} \ } \
} \ } \
]"; ]"};
code = taos_insert_json_payload(taos, message1); code = taos_insert_lines(taos, message1, 0, 2);
if (code) { if (code) {
printf("payload_1 code: %d, %s.\n", code, tstrerror(code)); printf("payload_1 code: %d, %s.\n", code, tstrerror(code));
} }
char *message2 = char *message2[] = {
"[ \ "[ \
{ \ { \
\"metric\":\"cpu_load_3\", \ \"metric\":\"cpu_load_3\", \
...@@ -295,15 +295,15 @@ void verify_json_insert(TAOS* taos) { ...@@ -295,15 +295,15 @@ void verify_json_insert(TAOS* taos) {
\"Id\": \"tb4\" \ \"Id\": \"tb4\" \
} \ } \
} \ } \
]"; ]"};
code = taos_insert_json_payload(taos, message2); code = taos_insert_lines(taos, message2, 0, 2);
if (code) { if (code) {
printf("payload_2 code: %d, %s.\n", code, tstrerror(code)); printf("payload_2 code: %d, %s.\n", code, tstrerror(code));
} }
cJSON *payload, *tags; cJSON *payload, *tags;
char *payload_str; char *payload_str[1];
/* Default format */ /* Default format */
//number //number
...@@ -317,14 +317,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -317,14 +317,14 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddNumberToObject(tags, "t3", 10);
cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>");
cJSON_AddItemToObject(payload, "tags", tags); cJSON_AddItemToObject(payload, "tags", tags);
payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_insert_json_payload(taos, payload_str); code = taos_insert_lines(taos, payload_str, 0, 2);
if (code) { if (code) {
printf("payload0_0 code: %d, %s.\n", code, tstrerror(code)); printf("payload0_0 code: %d, %s.\n", code, tstrerror(code));
} }
free(payload_str); free(*payload_str);
cJSON_Delete(payload); cJSON_Delete(payload);
//true //true
...@@ -338,14 +338,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -338,14 +338,14 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddNumberToObject(tags, "t3", 10);
cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>");
cJSON_AddItemToObject(payload, "tags", tags); cJSON_AddItemToObject(payload, "tags", tags);
payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_insert_json_payload(taos, payload_str); code = taos_insert_lines(taos, payload_str, 0, 2);
if (code) { if (code) {
printf("payload0_1 code: %d, %s.\n", code, tstrerror(code)); printf("payload0_1 code: %d, %s.\n", code, tstrerror(code));
} }
free(payload_str); free(*payload_str);
cJSON_Delete(payload); cJSON_Delete(payload);
//false //false
...@@ -359,14 +359,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -359,14 +359,14 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddNumberToObject(tags, "t3", 10);
cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>");
cJSON_AddItemToObject(payload, "tags", tags); cJSON_AddItemToObject(payload, "tags", tags);
payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_insert_json_payload(taos, payload_str); code = taos_insert_lines(taos, payload_str, 0, 2);
if (code) { if (code) {
printf("payload0_2 code: %d, %s.\n", code, tstrerror(code)); printf("payload0_2 code: %d, %s.\n", code, tstrerror(code));
} }
free(payload_str); free(*payload_str);
cJSON_Delete(payload); cJSON_Delete(payload);
//string //string
...@@ -380,14 +380,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -380,14 +380,14 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddNumberToObject(tags, "t3", 10);
cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>");
cJSON_AddItemToObject(payload, "tags", tags); cJSON_AddItemToObject(payload, "tags", tags);
payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_insert_json_payload(taos, payload_str); code = taos_insert_lines(taos, payload_str, 0, 2);
if (code) { if (code) {
printf("payload0_3 code: %d, %s.\n", code, tstrerror(code)); printf("payload0_3 code: %d, %s.\n", code, tstrerror(code));
} }
free(payload_str); free(*payload_str);
cJSON_Delete(payload); cJSON_Delete(payload);
//timestamp 0 -> current time //timestamp 0 -> current time
...@@ -401,14 +401,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -401,14 +401,14 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddNumberToObject(tags, "t3", 10);
cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>");
cJSON_AddItemToObject(payload, "tags", tags); cJSON_AddItemToObject(payload, "tags", tags);
payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_insert_json_payload(taos, payload_str); code = taos_insert_lines(taos, payload_str, 0, 2);
if (code) { if (code) {
printf("payload0_4 code: %d, %s.\n", code, tstrerror(code)); printf("payload0_4 code: %d, %s.\n", code, tstrerror(code));
} }
free(payload_str); free(*payload_str);
cJSON_Delete(payload); cJSON_Delete(payload);
/* Nested format */ /* Nested format */
...@@ -430,14 +430,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -430,14 +430,14 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddNumberToObject(tags, "t3", 10);
cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>");
cJSON_AddItemToObject(payload, "tags", tags); cJSON_AddItemToObject(payload, "tags", tags);
payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_insert_json_payload(taos, payload_str); code = taos_insert_lines(taos, payload_str, 0, 2);
if (code) { if (code) {
printf("payload1_0 code: %d, %s.\n", code, tstrerror(code)); printf("payload1_0 code: %d, %s.\n", code, tstrerror(code));
} }
free(payload_str); free(*payload_str);
cJSON_Delete(payload); cJSON_Delete(payload);
//milleseconds //milleseconds
...@@ -456,14 +456,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -456,14 +456,14 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddNumberToObject(tags, "t3", 10);
cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>");
cJSON_AddItemToObject(payload, "tags", tags); cJSON_AddItemToObject(payload, "tags", tags);
payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_insert_json_payload(taos, payload_str); code = taos_insert_lines(taos, payload_str, 0, 2);
if (code) { if (code) {
printf("payload1_1 code: %d, %s.\n", code, tstrerror(code)); printf("payload1_1 code: %d, %s.\n", code, tstrerror(code));
} }
free(payload_str); free(*payload_str);
cJSON_Delete(payload); cJSON_Delete(payload);
//microseconds //microseconds
...@@ -482,14 +482,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -482,14 +482,14 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddNumberToObject(tags, "t3", 10);
cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>");
cJSON_AddItemToObject(payload, "tags", tags); cJSON_AddItemToObject(payload, "tags", tags);
payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_insert_json_payload(taos, payload_str); code = taos_insert_lines(taos, payload_str, 0, 2);
if (code) { if (code) {
printf("payload1_2 code: %d, %s.\n", code, tstrerror(code)); printf("payload1_2 code: %d, %s.\n", code, tstrerror(code));
} }
free(payload_str); free(*payload_str);
cJSON_Delete(payload); cJSON_Delete(payload);
//nanoseconds //nanoseconds
...@@ -508,14 +508,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -508,14 +508,14 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddNumberToObject(tags, "t3", 10);
cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>");
cJSON_AddItemToObject(payload, "tags", tags); cJSON_AddItemToObject(payload, "tags", tags);
payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_insert_json_payload(taos, payload_str); code = taos_insert_lines(taos, payload_str, 0, 2);
if (code) { if (code) {
printf("payload1_3 code: %d, %s.\n", code, tstrerror(code)); printf("payload1_3 code: %d, %s.\n", code, tstrerror(code));
} }
free(payload_str); free(*payload_str);
cJSON_Delete(payload); cJSON_Delete(payload);
//now //now
...@@ -534,14 +534,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -534,14 +534,14 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddNumberToObject(tags, "t3", 10);
cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>");
cJSON_AddItemToObject(payload, "tags", tags); cJSON_AddItemToObject(payload, "tags", tags);
payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_insert_json_payload(taos, payload_str); code = taos_insert_lines(taos, payload_str, 0, 2);
if (code) { if (code) {
printf("payload1_4 code: %d, %s.\n", code, tstrerror(code)); printf("payload1_4 code: %d, %s.\n", code, tstrerror(code));
} }
free(payload_str); free(*payload_str);
cJSON_Delete(payload); cJSON_Delete(payload);
//metric value //metric value
...@@ -566,14 +566,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -566,14 +566,14 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddNumberToObject(tags, "t3", 10);
cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>");
cJSON_AddItemToObject(payload, "tags", tags); cJSON_AddItemToObject(payload, "tags", tags);
payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_insert_json_payload(taos, payload_str); code = taos_insert_lines(taos, payload_str, 0, 2);
if (code) { if (code) {
printf("payload2_0 code: %d, %s.\n", code, tstrerror(code)); printf("payload2_0 code: %d, %s.\n", code, tstrerror(code));
} }
free(payload_str); free(*payload_str);
cJSON_Delete(payload); cJSON_Delete(payload);
//tinyint //tinyint
...@@ -596,14 +596,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -596,14 +596,14 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddNumberToObject(tags, "t3", 10);
cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>");
cJSON_AddItemToObject(payload, "tags", tags); cJSON_AddItemToObject(payload, "tags", tags);
payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_insert_json_payload(taos, payload_str); code = taos_insert_lines(taos, payload_str, 0, 2);
if (code) { if (code) {
printf("payload2_1 code: %d, %s.\n", code, tstrerror(code)); printf("payload2_1 code: %d, %s.\n", code, tstrerror(code));
} }
free(payload_str); free(*payload_str);
cJSON_Delete(payload); cJSON_Delete(payload);
//smallint //smallint
...@@ -626,14 +626,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -626,14 +626,14 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddNumberToObject(tags, "t3", 10);
cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>");
cJSON_AddItemToObject(payload, "tags", tags); cJSON_AddItemToObject(payload, "tags", tags);
payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_insert_json_payload(taos, payload_str); code = taos_insert_lines(taos, payload_str, 0, 2);
if (code) { if (code) {
printf("payload2_2 code: %d, %s.\n", code, tstrerror(code)); printf("payload2_2 code: %d, %s.\n", code, tstrerror(code));
} }
free(payload_str); free(*payload_str);
cJSON_Delete(payload); cJSON_Delete(payload);
//int //int
...@@ -656,14 +656,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -656,14 +656,14 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddNumberToObject(tags, "t3", 10);
cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>");
cJSON_AddItemToObject(payload, "tags", tags); cJSON_AddItemToObject(payload, "tags", tags);
payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_insert_json_payload(taos, payload_str); code = taos_insert_lines(taos, payload_str, 0, 2);
if (code) { if (code) {
printf("payload2_3 code: %d, %s.\n", code, tstrerror(code)); printf("payload2_3 code: %d, %s.\n", code, tstrerror(code));
} }
free(payload_str); free(*payload_str);
cJSON_Delete(payload); cJSON_Delete(payload);
//bigint //bigint
...@@ -686,14 +686,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -686,14 +686,14 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddNumberToObject(tags, "t3", 10);
cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>");
cJSON_AddItemToObject(payload, "tags", tags); cJSON_AddItemToObject(payload, "tags", tags);
payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_insert_json_payload(taos, payload_str); code = taos_insert_lines(taos, payload_str, 0, 2);
if (code) { if (code) {
printf("payload2_4 code: %d, %s.\n", code, tstrerror(code)); printf("payload2_4 code: %d, %s.\n", code, tstrerror(code));
} }
free(payload_str); free(*payload_str);
cJSON_Delete(payload); cJSON_Delete(payload);
//float //float
...@@ -716,14 +716,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -716,14 +716,14 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddNumberToObject(tags, "t3", 10);
cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>");
cJSON_AddItemToObject(payload, "tags", tags); cJSON_AddItemToObject(payload, "tags", tags);
payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_insert_json_payload(taos, payload_str); code = taos_insert_lines(taos, payload_str, 0, 2);
if (code) { if (code) {
printf("payload2_5 code: %d, %s.\n", code, tstrerror(code)); printf("payload2_5 code: %d, %s.\n", code, tstrerror(code));
} }
free(payload_str); free(*payload_str);
cJSON_Delete(payload); cJSON_Delete(payload);
//double //double
...@@ -746,14 +746,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -746,14 +746,14 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddNumberToObject(tags, "t3", 10);
cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>");
cJSON_AddItemToObject(payload, "tags", tags); cJSON_AddItemToObject(payload, "tags", tags);
payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_insert_json_payload(taos, payload_str); code = taos_insert_lines(taos, payload_str, 0, 2);
if (code) { if (code) {
printf("payload2_6 code: %d, %s.\n", code, tstrerror(code)); printf("payload2_6 code: %d, %s.\n", code, tstrerror(code));
} }
free(payload_str); free(*payload_str);
cJSON_Delete(payload); cJSON_Delete(payload);
//binary //binary
...@@ -776,14 +776,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -776,14 +776,14 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddNumberToObject(tags, "t3", 10);
cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>");
cJSON_AddItemToObject(payload, "tags", tags); cJSON_AddItemToObject(payload, "tags", tags);
payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_insert_json_payload(taos, payload_str); code = taos_insert_lines(taos, payload_str, 0, 2);
if (code) { if (code) {
printf("payload2_7 code: %d, %s.\n", code, tstrerror(code)); printf("payload2_7 code: %d, %s.\n", code, tstrerror(code));
} }
free(payload_str); free(*payload_str);
cJSON_Delete(payload); cJSON_Delete(payload);
//nchar //nchar
...@@ -806,14 +806,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -806,14 +806,14 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddNumberToObject(tags, "t3", 10); cJSON_AddNumberToObject(tags, "t3", 10);
cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"); cJSON_AddStringToObject(tags, "t4", "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>");
cJSON_AddItemToObject(payload, "tags", tags); cJSON_AddItemToObject(payload, "tags", tags);
payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_insert_json_payload(taos, payload_str); code = taos_insert_lines(taos, payload_str, 0, 2);
if (code) { if (code) {
printf("payload2_8 code: %d, %s.\n", code, tstrerror(code)); printf("payload2_8 code: %d, %s.\n", code, tstrerror(code));
} }
free(payload_str); free(*payload_str);
cJSON_Delete(payload); cJSON_Delete(payload);
//tag value //tag value
...@@ -886,14 +886,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -886,14 +886,14 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddItemToObject(payload, "tags", tags); cJSON_AddItemToObject(payload, "tags", tags);
payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_insert_json_payload(taos, payload_str); code = taos_insert_lines(taos, payload_str, 0, 2);
if (code) { if (code) {
printf("payload3_0 code: %d, %s.\n", code, tstrerror(code)); printf("payload3_0 code: %d, %s.\n", code, tstrerror(code));
} }
free(payload_str); free(*payload_str);
cJSON_Delete(payload); cJSON_Delete(payload);
} }
......
...@@ -1084,7 +1084,7 @@ bool simExecuteLineInsertCmd(SScript *script, char *rest) { ...@@ -1084,7 +1084,7 @@ bool simExecuteLineInsertCmd(SScript *script, char *rest) {
simInfo("script:%s, %s", script->fileName, rest); simInfo("script:%s, %s", script->fileName, rest);
simLogSql(buf, true); simLogSql(buf, true);
char * lines[] = {rest}; 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) { if (ret == TSDB_CODE_SUCCESS) {
simDebug("script:%s, taos:%p, %s executed. success.", script->fileName, script->taos, rest); simDebug("script:%s, taos:%p, %s executed. success.", script->fileName, script->taos, rest);
script->linePos++; script->linePos++;
...@@ -1107,7 +1107,7 @@ bool simExecuteLineInsertErrorCmd(SScript *script, char *rest) { ...@@ -1107,7 +1107,7 @@ bool simExecuteLineInsertErrorCmd(SScript *script, char *rest) {
simInfo("script:%s, %s", script->fileName, rest); simInfo("script:%s, %s", script->fileName, rest);
simLogSql(buf, true); simLogSql(buf, true);
char * lines[] = {rest}; 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) { if (ret == TSDB_CODE_SUCCESS) {
sprintf(script->error, "script:%s, taos:%p, %s executed. expect failed, but success.", script->fileName, script->taos, rest); sprintf(script->error, "script:%s, taos:%p, %s executed. expect failed, but success.", script->fileName, script->taos, rest);
script->linePos++; script->linePos++;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册