This commit is contained in:
yihaoDeng 2022-11-04 19:16:04 +08:00
parent 9610efbdf4
commit 1613b43f49
3 changed files with 279 additions and 295 deletions

View File

@ -15,6 +15,7 @@ IF (TD_LINUX)
add_executable(tmq "") add_executable(tmq "")
add_executable(stream_demo "") add_executable(stream_demo "")
add_executable(demoapi "") add_executable(demoapi "")
add_executable(api_reqid "")
target_sources(tmq target_sources(tmq
PRIVATE PRIVATE
@ -31,6 +32,12 @@ IF (TD_LINUX)
"demoapi.c" "demoapi.c"
) )
target_sources(api_reqid
PRIVATE
"api_with_reqid_test.c"
)
target_link_libraries(tmq target_link_libraries(tmq
taos_static taos_static
) )
@ -43,6 +50,11 @@ IF (TD_LINUX)
taos_static taos_static
) )
target_link_libraries(api_reqid
taos_static
)
target_include_directories(tmq target_include_directories(tmq
PUBLIC "${TD_SOURCE_DIR}/include/os" PUBLIC "${TD_SOURCE_DIR}/include/os"
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
@ -58,9 +70,16 @@ IF (TD_LINUX)
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
) )
target_include_directories(api_reqid
PUBLIC "${TD_SOURCE_DIR}/include/client"
PUBLIC "${TD_SOURCE_DIR}/include/os"
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
)
SET_TARGET_PROPERTIES(tmq PROPERTIES OUTPUT_NAME tmq) SET_TARGET_PROPERTIES(tmq PROPERTIES OUTPUT_NAME tmq)
SET_TARGET_PROPERTIES(stream_demo PROPERTIES OUTPUT_NAME stream_demo) SET_TARGET_PROPERTIES(stream_demo PROPERTIES OUTPUT_NAME stream_demo)
SET_TARGET_PROPERTIES(demoapi PROPERTIES OUTPUT_NAME demoapi) SET_TARGET_PROPERTIES(demoapi PROPERTIES OUTPUT_NAME demoapi)
SET_TARGET_PROPERTIES(api_reqid PROPERTIES OUTPUT_NAME api_reqid)
ENDIF () ENDIF ()
IF (TD_DARWIN) IF (TD_DARWIN)
INCLUDE_DIRECTORIES(. ${TD_SOURCE_DIR}/src/inc ${TD_SOURCE_DIR}/src/client/inc ${TD_SOURCE_DIR}/inc) INCLUDE_DIRECTORIES(. ${TD_SOURCE_DIR}/src/inc ${TD_SOURCE_DIR}/src/client/inc ${TD_SOURCE_DIR}/inc)

View File

@ -1,8 +1,8 @@
// sample code to verify all TDengine API // sample code to verify all TDengine API
// to compile: gcc -o apitest apitest.c -ltaos // to compile: gcc -o apitest apitest.c -ltaos
#include "taoserror.h"
#include "cJSON.h" #include "cJSON.h"
#include "taoserror.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -44,7 +44,8 @@ static void prepare_data(TAOS* taos) {
result = taos_query(taos, "create table t9 using meters tags(9);"); result = taos_query(taos, "create table t9 using meters tags(9);");
taos_free_result(result); taos_free_result(result);
result = taos_query(taos, "insert into t0 values('2020-01-01 00:00:00.000', 0)" result = taos_query(taos,
"insert into t0 values('2020-01-01 00:00:00.000', 0)"
" ('2020-01-01 00:01:00.000', 0)" " ('2020-01-01 00:01:00.000', 0)"
" ('2020-01-01 00:02:00.000', 0)" " ('2020-01-01 00:02:00.000', 0)"
" t1 values('2020-01-01 00:00:00.000', 0)" " t1 values('2020-01-01 00:00:00.000', 0)"
@ -127,7 +128,7 @@ static void verify_query(TAOS* taos) {
printf("\033[31mimpossible, the table does exists: 0x%08x\033[0m\n", code); printf("\033[31mimpossible, the table does exists: 0x%08x\033[0m\n", code);
} }
TAOS_RES* res = taos_query(taos, "select * from meters"); TAOS_RES* res = taos_query_with_reqid(taos, "select * from meters", genReqid());
check_row_count(__LINE__, res, 18); check_row_count(__LINE__, res, 18);
printf("result precision is: %d\n", taos_result_precision(res)); printf("result precision is: %d\n", taos_result_precision(res));
int c = taos_field_count(res); int c = taos_field_count(res);
@ -138,16 +139,16 @@ static void verify_query(TAOS* taos) {
} }
taos_free_result(res); taos_free_result(res);
res = taos_query(taos, "select * from t0"); res = taos_query_with_reqid(taos, "select * from t0", genReqid());
check_row_count(__LINE__, res, 3); check_row_count(__LINE__, res, 3);
taos_free_result(res); taos_free_result(res);
res = taos_query(taos, "select * from nonexisttable"); res = taos_query_with_reqid(taos, "select * from nonexisttable", genReqid());
code = taos_errno(res); code = taos_errno(res);
printf("code=%d, error msg=%s\n", code, taos_errstr(res)); printf("code=%d, error msg=%s\n", code, taos_errstr(res));
taos_free_result(res); taos_free_result(res);
res = taos_query(taos, "select * from meters"); res = taos_query_with_reqid(taos, "select * from meters", genReqid());
taos_stop_query(res); taos_stop_query(res);
taos_free_result(res); taos_free_result(res);
} }
@ -253,8 +254,10 @@ void verify_prepare(TAOS* taos) {
taos_select_db(taos, "test"); taos_select_db(taos, "test");
// create table // create table
const char* sql = "create table m1 (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, bin binary(40), blob nchar(10))"; const char* sql =
result = taos_query(taos, sql); "create table m1 (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, bin "
"binary(40), blob nchar(10))";
result = taos_query_with_reqid(taos, sql, genReqid());
code = taos_errno(result); code = taos_errno(result);
if (code != 0) { if (code != 0) {
printf("\033[31mfailed to create table, reason:%s\033[0m\n", taos_errstr(result)); printf("\033[31mfailed to create table, reason:%s\033[0m\n", taos_errstr(result));
@ -425,7 +428,9 @@ void verify_prepare2(TAOS* taos) {
taos_select_db(taos, "test"); taos_select_db(taos, "test");
// create table // create table
const char* sql = "create table m1 (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, bin binary(40), blob nchar(10))"; const char* sql =
"create table m1 (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, bin "
"binary(40), blob nchar(10))";
result = taos_query(taos, sql); result = taos_query(taos, sql);
code = taos_errno(result); code = taos_errno(result);
if (code != 0) { if (code != 0) {
@ -657,7 +662,9 @@ void verify_prepare3(TAOS* taos) {
taos_select_db(taos, "test"); taos_select_db(taos, "test");
// create table // create table
const char* sql = "create stable st1 (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, bin binary(40), blob nchar(10)) tags (id1 int, id2 binary(40))"; const char* sql =
"create stable st1 (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, bin "
"binary(40), blob nchar(10)) tags (id1 int, id2 binary(40))";
result = taos_query(taos, sql); result = taos_query(taos, sql);
code = taos_errno(result); code = taos_errno(result);
if (code != 0) { if (code != 0) {
@ -685,7 +692,6 @@ void verify_prepare3(TAOS* taos) {
tags[1].length = &id2_len; tags[1].length = &id2_len;
tags[1].is_null = NULL; tags[1].is_null = NULL;
// insert 10 records // insert 10 records
struct { struct {
int64_t ts[10]; int64_t ts[10];
@ -783,7 +789,6 @@ void verify_prepare3(TAOS* taos) {
params[9].is_null = is_null; params[9].is_null = is_null;
params[9].num = 10; params[9].num = 10;
sql = "insert into ? using st1 tags(?,?) values(?,?,?,?,?,?,?,?,?,?)"; sql = "insert into ? using st1 tags(?,?) values(?,?,?,?,?,?,?,?,?,?)";
code = taos_stmt_prepare(stmt, sql, 0); code = taos_stmt_prepare(stmt, sql, 0);
if (code != 0) { if (code != 0) {
@ -891,8 +896,7 @@ void verify_prepare3(TAOS* taos) {
free(blob_len); free(blob_len);
} }
void retrieve_callback(void *param, TAOS_RES *tres, int numOfRows) void retrieve_callback(void* param, TAOS_RES* tres, int numOfRows) {
{
if (numOfRows > 0) { if (numOfRows > 0) {
printf("%d rows async retrieved\n", numOfRows); printf("%d rows async retrieved\n", numOfRows);
taos_fetch_rows_a(tres, retrieve_callback, param); taos_fetch_rows_a(tres, retrieve_callback, param);
@ -906,8 +910,7 @@ void retrieve_callback(void *param, TAOS_RES *tres, int numOfRows)
} }
} }
void select_callback(void *param, TAOS_RES *tres, int code) void select_callback(void* param, TAOS_RES* tres, int code) {
{
if (code == 0 && tres) { if (code == 0 && tres) {
taos_fetch_rows_a(tres, retrieve_callback, param); taos_fetch_rows_a(tres, retrieve_callback, param);
} else { } else {
@ -937,13 +940,8 @@ void stream_callback(void *param, TAOS_RES *res, TAOS_ROW row) {
void verify_stream(TAOS* taos) { void verify_stream(TAOS* taos) {
prepare_data(taos); prepare_data(taos);
TAOS_STREAM* strm = taos_open_stream( TAOS_STREAM* strm =
taos, taos_open_stream(taos, "select count(*) from meters interval(1m)", stream_callback, 0, NULL, NULL);
"select count(*) from meters interval(1m)",
stream_callback,
0,
NULL,
NULL);
printf("waiting for stream data\n"); printf("waiting for stream data\n");
usleep(100000); usleep(100000);
TAOS_RES* result = taos_query(taos, "insert into t0 values(now, 0)(now+5s,1)(now+10s, 2);"); TAOS_RES* result = taos_query(taos, "insert into t0 values(now, 0)(now+5s,1)(now+10s, 2);");
@ -975,44 +973,46 @@ int32_t verify_schema_less(TAOS* taos) {
"st,t1=4i64,t2=5f64,t3=\"t4\" c1=3i64,c3=L\"passitagain\",c2=true,c4=5f64 1626006833642000000ns", "st,t1=4i64,t2=5f64,t3=\"t4\" c1=3i64,c3=L\"passitagain\",c2=true,c4=5f64 1626006833642000000ns",
"ste,t2=5f64,t3=L\"ste2\" c3=\"iamszhou\",c4=false 1626056811843316532ns", "ste,t2=5f64,t3=L\"ste2\" c3=\"iamszhou\",c4=false 1626056811843316532ns",
"ste,t2=5f64,t3=L\"ste2\" c3=\"iamszhou\",c4=false,c5=32i8,c6=64i16,c7=32i32,c8=88.88f32 1626056812843316532ns", "ste,t2=5f64,t3=L\"ste2\" c3=\"iamszhou\",c4=false,c5=32i8,c6=64i16,c7=32i32,c8=88.88f32 1626056812843316532ns",
"st,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000ns", "st,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64,c6=7u64 "
"stf,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000ns", "1626006933640000000ns",
"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\",c2=true,c4=5f64,c5=5f64,c6=7u64 "
}; "1626006933640000000ns",
"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*));
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);
code = taos_insert_lines(taos, &lines2[1], 1); code = taos_insert_lines(taos, &lines2[1], 1);
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 "
"sth,t1=4i64,t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933654ms" "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);
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);
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."
"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" "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[0], 1);
code = taos_insert_lines(taos, &lines5[1], 1); code = taos_insert_lines(taos, &lines5[1], 1);
char* lines6[] = {"st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000ns",
char* lines6[] = { "dgtyqodr,t2=5f64,t3=L\"ste\" c1=tRue,c2=4i64,c3=\"iam\" 1626056811823316532ns"};
"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);
return (code); return (code);
} }
@ -1043,12 +1043,9 @@ void verify_telnet_insert(TAOS* taos) {
/* timestamp */ /* timestamp */
char* lines1[] = { char* lines1[] = {
"stb1 1626006833s 1i8 host=\"host0\"", "stb1 1626006833s 1i8 host=\"host0\"", "stb1 1626006833639000000ns 2i8 host=\"host0\"",
"stb1 1626006833639000000ns 2i8 host=\"host0\"", "stb1 1626006833640000us 3i8 host=\"host0\"", "stb1 1626006833641123 4i8 host=\"host0\"",
"stb1 1626006833640000us 3i8 host=\"host0\"", "stb1 1626006833651ms 5i8 host=\"host0\"", "stb1 0 6i8 host=\"host0\"",
"stb1 1626006833641123 4i8 host=\"host0\"",
"stb1 1626006833651ms 5i8 host=\"host0\"",
"stb1 0 6i8 host=\"host0\"",
}; };
code = taos_insert_telnet_lines(taos, lines1, 6); code = taos_insert_telnet_lines(taos, lines1, 6);
if (code) { if (code) {
@ -1057,40 +1054,31 @@ void verify_telnet_insert(TAOS* taos) {
/* metric value */ /* metric value */
// tinyin // tinyin
char* lines2_0[] = { char* lines2_0[] = {"stb2_0 1626006833651ms -127i8 host=\"host0\"", "stb2_0 1626006833652ms 127i8 host=\"host0\""};
"stb2_0 1626006833651ms -127i8 host=\"host0\"",
"stb2_0 1626006833652ms 127i8 host=\"host0\""
};
code = taos_insert_telnet_lines(taos, lines2_0, 2); code = taos_insert_telnet_lines(taos, lines2_0, 2);
if (code) { if (code) {
printf("lines2_0 code: %d, %s.\n", code, tstrerror(code)); printf("lines2_0 code: %d, %s.\n", code, tstrerror(code));
} }
// smallint // smallint
char* lines2_1[] = { char* lines2_1[] = {"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_telnet_lines(taos, lines2_1, 2);
if (code) { if (code) {
printf("lines2_1 code: %d, %s.\n", code, tstrerror(code)); printf("lines2_1 code: %d, %s.\n", code, tstrerror(code));
} }
// int // int
char* lines2_2[] = { char* lines2_2[] = {"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_telnet_lines(taos, lines2_2, 2);
if (code) { if (code) {
printf("lines2_2 code: %d, %s.\n", code, tstrerror(code)); printf("lines2_2 code: %d, %s.\n", code, tstrerror(code));
} }
// bigint // bigint
char* lines2_3[] = { char* lines2_3[] = {"stb2_3 1626006833651ms -9223372036854775807i64 host=\"host0\"",
"stb2_3 1626006833651ms -9223372036854775807i64 host=\"host0\"", "stb2_3 1626006833652ms 9223372036854775807i64 host=\"host0\""};
"stb2_3 1626006833652ms 9223372036854775807i64 host=\"host0\""
};
code = taos_insert_telnet_lines(taos, lines2_3, 2); code = taos_insert_telnet_lines(taos, lines2_3, 2);
if (code) { if (code) {
printf("lines2_3 code: %d, %s.\n", code, tstrerror(code)); printf("lines2_3 code: %d, %s.\n", code, tstrerror(code));
@ -1098,18 +1086,12 @@ void verify_telnet_insert(TAOS* taos) {
// float // float
char* lines2_4[] = { char* lines2_4[] = {
"stb2_4 1626006833610ms 3f32 host=\"host0\"", "stb2_4 1626006833610ms 3f32 host=\"host0\"", "stb2_4 1626006833620ms -3f32 host=\"host0\"",
"stb2_4 1626006833620ms -3f32 host=\"host0\"", "stb2_4 1626006833630ms 3.4f32 host=\"host0\"", "stb2_4 1626006833640ms -3.4f32 host=\"host0\"",
"stb2_4 1626006833630ms 3.4f32 host=\"host0\"", "stb2_4 1626006833650ms 3.4E10f32 host=\"host0\"", "stb2_4 1626006833660ms -3.4e10f32 host=\"host0\"",
"stb2_4 1626006833640ms -3.4f32 host=\"host0\"", "stb2_4 1626006833670ms 3.4E+2f32 host=\"host0\"", "stb2_4 1626006833680ms -3.4e-2f32 host=\"host0\"",
"stb2_4 1626006833650ms 3.4E10f32 host=\"host0\"", "stb2_4 1626006833690ms 3.15 host=\"host0\"", "stb2_4 1626006833700ms 3.4E38f32 host=\"host0\"",
"stb2_4 1626006833660ms -3.4e10f32 host=\"host0\"", "stb2_4 1626006833710ms -3.4E38f32 host=\"host0\""};
"stb2_4 1626006833670ms 3.4E+2f32 host=\"host0\"",
"stb2_4 1626006833680ms -3.4e-2f32 host=\"host0\"",
"stb2_4 1626006833690ms 3.15 host=\"host0\"",
"stb2_4 1626006833700ms 3.4E38f32 host=\"host0\"",
"stb2_4 1626006833710ms -3.4E38f32 host=\"host0\""
};
code = taos_insert_telnet_lines(taos, lines2_4, 11); code = taos_insert_telnet_lines(taos, lines2_4, 11);
if (code) { if (code) {
printf("lines2_4 code: %d, %s.\n", code, tstrerror(code)); printf("lines2_4 code: %d, %s.\n", code, tstrerror(code));
@ -1117,46 +1099,31 @@ void verify_telnet_insert(TAOS* taos) {
// double // double
char* lines2_5[] = { char* lines2_5[] = {
"stb2_5 1626006833610ms 3f64 host=\"host0\"", "stb2_5 1626006833610ms 3f64 host=\"host0\"", "stb2_5 1626006833620ms -3f64 host=\"host0\"",
"stb2_5 1626006833620ms -3f64 host=\"host0\"", "stb2_5 1626006833630ms 3.4f64 host=\"host0\"", "stb2_5 1626006833640ms -3.4f64 host=\"host0\"",
"stb2_5 1626006833630ms 3.4f64 host=\"host0\"", "stb2_5 1626006833650ms 3.4E10f64 host=\"host0\"", "stb2_5 1626006833660ms -3.4e10f64 host=\"host0\"",
"stb2_5 1626006833640ms -3.4f64 host=\"host0\"", "stb2_5 1626006833670ms 3.4E+2f64 host=\"host0\"", "stb2_5 1626006833680ms -3.4e-2f64 host=\"host0\"",
"stb2_5 1626006833650ms 3.4E10f64 host=\"host0\"", "stb2_5 1626006833690ms 1.7E308f64 host=\"host0\"", "stb2_5 1626006833700ms -1.7E308f64 host=\"host0\""};
"stb2_5 1626006833660ms -3.4e10f64 host=\"host0\"",
"stb2_5 1626006833670ms 3.4E+2f64 host=\"host0\"",
"stb2_5 1626006833680ms -3.4e-2f64 host=\"host0\"",
"stb2_5 1626006833690ms 1.7E308f64 host=\"host0\"",
"stb2_5 1626006833700ms -1.7E308f64 host=\"host0\""
};
code = taos_insert_telnet_lines(taos, lines2_5, 10); code = taos_insert_telnet_lines(taos, lines2_5, 10);
if (code) { if (code) {
printf("lines2_5 code: %d, %s.\n", code, tstrerror(code)); printf("lines2_5 code: %d, %s.\n", code, tstrerror(code));
} }
// bool // bool
char* lines2_6[] = { char* lines2_6[] = {"stb2_6 1626006833610ms t host=\"host0\"", "stb2_6 1626006833620ms T host=\"host0\"",
"stb2_6 1626006833610ms t host=\"host0\"", "stb2_6 1626006833630ms true host=\"host0\"", "stb2_6 1626006833640ms True host=\"host0\"",
"stb2_6 1626006833620ms T host=\"host0\"", "stb2_6 1626006833650ms TRUE host=\"host0\"", "stb2_6 1626006833660ms f host=\"host0\"",
"stb2_6 1626006833630ms true host=\"host0\"", "stb2_6 1626006833670ms F host=\"host0\"", "stb2_6 1626006833680ms false host=\"host0\"",
"stb2_6 1626006833640ms True host=\"host0\"", "stb2_6 1626006833690ms False host=\"host0\"", "stb2_6 1626006833700ms FALSE host=\"host0\""};
"stb2_6 1626006833650ms TRUE host=\"host0\"",
"stb2_6 1626006833660ms f host=\"host0\"",
"stb2_6 1626006833670ms F host=\"host0\"",
"stb2_6 1626006833680ms false host=\"host0\"",
"stb2_6 1626006833690ms False host=\"host0\"",
"stb2_6 1626006833700ms FALSE host=\"host0\""
};
code = taos_insert_telnet_lines(taos, lines2_6, 10); code = taos_insert_telnet_lines(taos, lines2_6, 10);
if (code) { if (code) {
printf("lines2_6 code: %d, %s.\n", code, tstrerror(code)); printf("lines2_6 code: %d, %s.\n", code, tstrerror(code));
} }
// binary // binary
char* lines2_7[] = { char* lines2_7[] = {"stb2_7 1626006833610ms \"binary_val.!@#$%^&*\" host=\"host0\"",
"stb2_7 1626006833610ms \"binary_val.!@#$%^&*\" host=\"host0\"",
"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_telnet_lines(taos, lines2_7, 3);
if (code) { if (code) {
printf("lines2_7 code: %d, %s.\n", code, tstrerror(code)); printf("lines2_7 code: %d, %s.\n", code, tstrerror(code));
@ -1175,20 +1142,21 @@ void verify_telnet_insert(TAOS* taos) {
/* tags */ /* tags */
// tag value types // tag value types
char* lines3_0[] = { char* lines3_0[] = {
"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 "
"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\"" "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_telnet_lines(taos, lines3_0, 2);
if (code) { if (code) {
printf("lines3_0 code: %d, %s.\n", code, tstrerror(code)); printf("lines3_0 code: %d, %s.\n", code, tstrerror(code));
} }
// tag ID as child table name // tag ID as child table name
char* lines3_1[] = { char* lines3_1[] = {"stb3_1 1626006833610ms 1 id=\"child_table1\",host=\"host1\"",
"stb3_1 1626006833610ms 1 id=\"child_table1\",host=\"host1\"",
"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_telnet_lines(taos, lines3_1, 3);
if (code) { if (code) {
printf("lines3_1 code: %d, %s.\n", code, tstrerror(code)); printf("lines3_1 code: %d, %s.\n", code, tstrerror(code));
@ -1310,7 +1278,6 @@ void verify_json_insert(TAOS* taos) {
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;

View File

@ -2654,9 +2654,7 @@ end:
* 0 - influxDB line protocol * 0 - influxDB line protocol
* 1 - OpenTSDB telnet line protocol * 1 - OpenTSDB telnet line protocol
* 2 - OpenTSDB JSON format protocol * 2 - OpenTSDB JSON format protocol
* @return return zero for successful insertion. Otherwise return none-zero error code of * @return TAOS_RES
* failure reason.
*
*/ */
TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int protocol, int precision) { TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int protocol, int precision) {