未验证 提交 b769e760 编写于 作者: D dapan1121 提交者: GitHub

Merge pull request #8289 from taosdata/enhance/TD-10642

Modified taos_schemaless_insert api to include affected rows and error msg buffer
...@@ -23,6 +23,8 @@ extern "C" { ...@@ -23,6 +23,8 @@ extern "C" {
#define SML_TIMESTAMP_SECOND_DIGITS 10 #define SML_TIMESTAMP_SECOND_DIGITS 10
#define SML_TIMESTAMP_MILLI_SECOND_DIGITS 13 #define SML_TIMESTAMP_MILLI_SECOND_DIGITS 13
typedef TSDB_SML_PROTOCOL_TYPE SMLProtocolType;
typedef struct { typedef struct {
char* key; char* key;
uint8_t type; uint8_t type;
...@@ -46,22 +48,16 @@ typedef struct { ...@@ -46,22 +48,16 @@ typedef struct {
} TAOS_SML_DATA_POINT; } TAOS_SML_DATA_POINT;
typedef enum { typedef enum {
SML_TIME_STAMP_NOW, SML_TIME_STAMP_NOT_CONFIGURED,
SML_TIME_STAMP_HOURS, SML_TIME_STAMP_HOURS,
SML_TIME_STAMP_MINUTES, SML_TIME_STAMP_MINUTES,
SML_TIME_STAMP_SECONDS, SML_TIME_STAMP_SECONDS,
SML_TIME_STAMP_MILLI_SECONDS, SML_TIME_STAMP_MILLI_SECONDS,
SML_TIME_STAMP_MICRO_SECONDS, SML_TIME_STAMP_MICRO_SECONDS,
SML_TIME_STAMP_NANO_SECONDS, SML_TIME_STAMP_NANO_SECONDS,
SML_TIME_STAMP_NOT_CONFIGURED SML_TIME_STAMP_NOW
} 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;
SMLProtocolType protocol; SMLProtocolType protocol;
...@@ -85,12 +81,12 @@ int32_t convertSmlTimeStamp(TAOS_SML_KV *pVal, char *value, ...@@ -85,12 +81,12 @@ 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_lines(TAOS* taos, char* lines[], int numLines, SMLProtocolType protocol,
SMLProtocolType protocol, SMLTimeStampType tsType); SMLTimeStampType tsType, int* affectedRows);
int taos_insert_telnet_lines(TAOS* taos, char* lines[], int numLines, int taos_insert_telnet_lines(TAOS* taos, char* lines[], int numLines, SMLProtocolType protocol,
SMLProtocolType protocol, SMLTimeStampType tsType); SMLTimeStampType tsType, int* affectedRows);
int taos_insert_json_payload(TAOS* taos, char* payload, int taos_insert_json_payload(TAOS* taos, char* payload, SMLProtocolType protocol,
SMLProtocolType protocol, SMLTimeStampType tsType); SMLTimeStampType tsType, int* affectedRows);
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -1053,7 +1053,8 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setTableNameTagsI ...@@ -1053,7 +1053,8 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setTableNameTagsI
} }
JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp(JNIEnv *env, jobject jobj, JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp(JNIEnv *env, jobject jobj,
jobjectArray lines, jlong conn) { jobjectArray lines, jlong conn,
jint protocol, jint precision) {
TAOS *taos = (TAOS *)conn; TAOS *taos = (TAOS *)conn;
if (taos == NULL) { if (taos == NULL) {
jniError("jobj:%p, connection already closed", jobj); jniError("jobj:%p, connection already closed", jobj);
...@@ -1071,7 +1072,8 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp(J ...@@ -1071,7 +1072,8 @@ 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_schemaless_insert(taos, c_lines, numLines, SML_LINE_PROTOCOL, "ms"); SSqlObj* result = (SSqlObj*)taos_schemaless_insert(taos, c_lines, numLines, protocol, precision);
int code = taos_errno(result);
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));
...@@ -1080,9 +1082,10 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp(J ...@@ -1080,9 +1082,10 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp(J
tfree(c_lines); tfree(c_lines);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
jniError("jobj:%p, conn:%p, code:%s", jobj, taos, tstrerror(code)); jniError("jobj:%p, conn:%p, code:%s, msg:%s", jobj, taos, tstrerror(code), taos_errstr(result));
return JNI_TDENGINE_ERROR; return JNI_TDENGINE_ERROR;
} }
return code;
return (jlong)result;
} }
...@@ -1446,13 +1446,13 @@ static bool isTimeStamp(char *pVal, uint16_t len, SMLTimeStampType *tsType, SSml ...@@ -1446,13 +1446,13 @@ static bool isTimeStamp(char *pVal, uint16_t len, SMLTimeStampType *tsType, SSml
//Default no appendix //Default no appendix
if (isdigit(pVal[len - 1]) && isdigit(pVal[len - 2])) { if (isdigit(pVal[len - 1]) && isdigit(pVal[len - 2])) {
if (info->protocol == SML_LINE_PROTOCOL) { if (info->protocol == TSDB_SML_LINE_PROTOCOL) {
if (info->tsType != SML_TIME_STAMP_NOT_CONFIGURED) { if (info->tsType != SML_TIME_STAMP_NOT_CONFIGURED) {
*tsType = info->tsType; *tsType = info->tsType;
} else { } else {
*tsType = SML_TIME_STAMP_NANO_SECONDS; *tsType = SML_TIME_STAMP_NANO_SECONDS;
} }
} else if (info->protocol == SML_TELNET_PROTOCOL) { } else if (info->protocol == TSDB_SML_TELNET_PROTOCOL) {
if (len == SML_TIMESTAMP_SECOND_DIGITS) { if (len == SML_TIMESTAMP_SECOND_DIGITS) {
*tsType = SML_TIME_STAMP_SECONDS; *tsType = SML_TIME_STAMP_SECONDS;
} else if (len == SML_TIMESTAMP_MILLI_SECOND_DIGITS) { } else if (len == SML_TIMESTAMP_MILLI_SECOND_DIGITS) {
...@@ -2273,7 +2273,7 @@ int32_t tscParseLines(char* lines[], int numLines, SArray* points, SArray* faile ...@@ -2273,7 +2273,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, SMLProtocolType protocol, SMLTimeStampType tsType) { int taos_insert_lines(TAOS* taos, char* lines[], int numLines, SMLProtocolType protocol, SMLTimeStampType tsType, int *affectedRows) {
int32_t code = 0; int32_t code = 0;
SSmlLinesInfo* info = tcalloc(1, sizeof(SSmlLinesInfo)); SSmlLinesInfo* info = tcalloc(1, sizeof(SSmlLinesInfo));
...@@ -2317,6 +2317,9 @@ int taos_insert_lines(TAOS* taos, char* lines[], int numLines, SMLProtocolType p ...@@ -2317,6 +2317,9 @@ int taos_insert_lines(TAOS* taos, char* lines[], int numLines, SMLProtocolType p
if (code != 0) { if (code != 0) {
tscError("SML:0x%"PRIx64" taos_sml_insert error: %s", info->id, tstrerror((code))); tscError("SML:0x%"PRIx64" taos_sml_insert error: %s", info->id, tstrerror((code)));
} }
if (affectedRows != NULL) {
*affectedRows = info->affectedRows;
}
cleanup: cleanup:
tscDebug("SML:0x%"PRIx64" taos_insert_lines finish inserting %d lines. code: %d", info->id, numLines, code); tscDebug("SML:0x%"PRIx64" taos_insert_lines finish inserting %d lines. code: %d", info->id, numLines, code);
...@@ -2332,52 +2335,56 @@ cleanup: ...@@ -2332,52 +2335,56 @@ cleanup:
return code; return code;
} }
int32_t convertPrecisionStrType(char* precision, SMLTimeStampType *tsType) { static int32_t convertPrecisionType(int precision, SMLTimeStampType *tsType) {
if (precision == NULL) { switch (precision) {
*tsType = SML_TIME_STAMP_NOT_CONFIGURED; case TSDB_SML_TIMESTAMP_NOT_CONFIGURED:
return TSDB_CODE_SUCCESS; *tsType = SML_TIME_STAMP_NOT_CONFIGURED;
} break;
if (strcmp(precision, "μ") == 0) { case TSDB_SML_TIMESTAMP_HOURS:
*tsType = SML_TIME_STAMP_MICRO_SECONDS; *tsType = SML_TIME_STAMP_HOURS;
return TSDB_CODE_SUCCESS; break;
case TSDB_SML_TIMESTAMP_MILLI_SECONDS:
*tsType = SML_TIME_STAMP_MILLI_SECONDS;
break;
case TSDB_SML_TIMESTAMP_NANO_SECONDS:
*tsType = SML_TIME_STAMP_NANO_SECONDS;
break;
case TSDB_SML_TIMESTAMP_MICRO_SECONDS:
*tsType = SML_TIME_STAMP_MICRO_SECONDS;
break;
case TSDB_SML_TIMESTAMP_SECONDS:
*tsType = SML_TIME_STAMP_SECONDS;
break;
case TSDB_SML_TIMESTAMP_MINUTES:
*tsType = SML_TIME_STAMP_MINUTES;
break;
default:
return TSDB_CODE_TSC_INVALID_PRECISION_TYPE;
} }
int32_t len = (int32_t)strlen(precision); return TSDB_CODE_SUCCESS;
if (len == 1) { }
switch (precision[0]) {
case 'u': //make a dummy SSqlObj
*tsType = SML_TIME_STAMP_MICRO_SECONDS; static SSqlObj* createSmlQueryObj(TAOS* taos, int32_t affected_rows, int32_t code) {
break; SSqlObj *pNew = (SSqlObj*)calloc(1, sizeof(SSqlObj));
case 's': if (pNew == NULL) {
*tsType = SML_TIME_STAMP_SECONDS; return NULL;
break;
case 'm':
*tsType = SML_TIME_STAMP_MINUTES;
break;
case 'h':
*tsType = SML_TIME_STAMP_HOURS;
break;
default:
return TSDB_CODE_TSC_INVALID_PRECISION_TYPE;
}
} else if (len == 2 && precision[1] == 's') {
switch (precision[0]) {
case 'm':
*tsType = SML_TIME_STAMP_MILLI_SECONDS;
break;
case 'n':
*tsType = SML_TIME_STAMP_NANO_SECONDS;
break;
default:
return TSDB_CODE_TSC_INVALID_PRECISION_TYPE;
}
} else {
return TSDB_CODE_TSC_INVALID_PRECISION_TYPE;
} }
pNew->signature = pNew;
pNew->pTscObj = taos;
return TSDB_CODE_SUCCESS; tsem_init(&pNew->rspSem, 0, 0);
registerSqlObj(pNew);
pNew->res.numOfRows = affected_rows;
pNew->res.code = code;
return pNew;
} }
/** /**
* taos_schemaless_insert() parse and insert data points into database according to * taos_schemaless_insert() parse and insert data points into database according to
* different protocol. * different protocol.
...@@ -2399,31 +2406,35 @@ int32_t convertPrecisionStrType(char* precision, SMLTimeStampType *tsType) { ...@@ -2399,31 +2406,35 @@ int32_t convertPrecisionStrType(char* precision, SMLTimeStampType *tsType) {
* *
*/ */
int taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int protocol, char* timePrecision) { TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int protocol, int precision) {
int code; int code = TSDB_CODE_SUCCESS;
int affected_rows = 0;
SMLTimeStampType tsType; SMLTimeStampType tsType;
if (protocol == SML_LINE_PROTOCOL) { if (protocol == TSDB_SML_LINE_PROTOCOL) {
code = convertPrecisionStrType(timePrecision, &tsType); code = convertPrecisionType(precision, &tsType);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
return code; return NULL;
} }
} }
switch (protocol) { switch (protocol) {
case SML_LINE_PROTOCOL: case TSDB_SML_LINE_PROTOCOL:
code = taos_insert_lines(taos, lines, numLines, protocol, tsType); code = taos_insert_lines(taos, lines, numLines, protocol, tsType, &affected_rows);
break; break;
case SML_TELNET_PROTOCOL: case TSDB_SML_TELNET_PROTOCOL:
code = taos_insert_telnet_lines(taos, lines, numLines, protocol, tsType); code = taos_insert_telnet_lines(taos, lines, numLines, protocol, tsType, &affected_rows);
break; break;
case SML_JSON_PROTOCOL: case TSDB_SML_JSON_PROTOCOL:
code = taos_insert_json_payload(taos, *lines, protocol, tsType); code = taos_insert_json_payload(taos, *lines, protocol, tsType, &affected_rows);
break; break;
default: default:
code = TSDB_CODE_TSC_INVALID_PROTOCOL_TYPE; code = TSDB_CODE_TSC_INVALID_PROTOCOL_TYPE;
break; break;
} }
return code;
SSqlObj *pSql = createSmlQueryObj(taos, affected_rows, code);
return (TAOS_RES*)pSql;
} }
...@@ -409,7 +409,7 @@ static int32_t tscParseTelnetLines(char* lines[], int numLines, SArray* points, ...@@ -409,7 +409,7 @@ static int32_t tscParseTelnetLines(char* lines[], int numLines, SArray* points,
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int taos_insert_telnet_lines(TAOS* taos, char* lines[], int numLines, SMLProtocolType protocol, SMLTimeStampType tsType) { int taos_insert_telnet_lines(TAOS* taos, char* lines[], int numLines, SMLProtocolType protocol, SMLTimeStampType tsType, int* affectedRows) {
int32_t code = 0; int32_t code = 0;
SSmlLinesInfo* info = tcalloc(1, sizeof(SSmlLinesInfo)); SSmlLinesInfo* info = tcalloc(1, sizeof(SSmlLinesInfo));
...@@ -453,6 +453,9 @@ int taos_insert_telnet_lines(TAOS* taos, char* lines[], int numLines, SMLProtoco ...@@ -453,6 +453,9 @@ int taos_insert_telnet_lines(TAOS* taos, char* lines[], int numLines, SMLProtoco
if (code != 0) { if (code != 0) {
tscError("OTD:0x%"PRIx64" taos_insert_telnet_lines error: %s", info->id, tstrerror((code))); tscError("OTD:0x%"PRIx64" taos_insert_telnet_lines error: %s", info->id, tstrerror((code)));
} }
if (affectedRows != NULL) {
*affectedRows = info->affectedRows;
}
cleanup: cleanup:
tscDebug("OTD:0x%"PRIx64" taos_insert_telnet_lines finish inserting %d lines. code: %d", info->id, numLines, code); tscDebug("OTD:0x%"PRIx64" taos_insert_telnet_lines finish inserting %d lines. code: %d", info->id, numLines, code);
...@@ -1045,7 +1048,7 @@ PARSE_JSON_OVER: ...@@ -1045,7 +1048,7 @@ PARSE_JSON_OVER:
return ret; return ret;
} }
int taos_insert_json_payload(TAOS* taos, char* payload, SMLProtocolType protocol, SMLTimeStampType tsType) { int taos_insert_json_payload(TAOS* taos, char* payload, SMLProtocolType protocol, SMLTimeStampType tsType, int* affectedRows) {
int32_t code = 0; int32_t code = 0;
SSmlLinesInfo* info = tcalloc(1, sizeof(SSmlLinesInfo)); SSmlLinesInfo* info = tcalloc(1, sizeof(SSmlLinesInfo));
...@@ -1080,6 +1083,9 @@ int taos_insert_json_payload(TAOS* taos, char* payload, SMLProtocolType protocol ...@@ -1080,6 +1083,9 @@ int taos_insert_json_payload(TAOS* taos, char* payload, SMLProtocolType protocol
if (code != 0) { if (code != 0) {
tscError("OTD:0x%"PRIx64" taos_insert_json_payload error: %s", info->id, tstrerror((code))); tscError("OTD:0x%"PRIx64" taos_insert_json_payload error: %s", info->id, tstrerror((code)));
} }
if (affectedRows != NULL) {
*affectedRows = info->affectedRows;
}
cleanup: cleanup:
tscDebug("OTD:0x%"PRIx64" taos_insert_json_payload finish inserting 1 Point. code: %d", info->id, code); tscDebug("OTD:0x%"PRIx64" taos_insert_json_payload finish inserting 1 Point. code: %d", info->id, code);
......
...@@ -822,11 +822,16 @@ def taos_schemaless_insert(connection, lines, protocol, precision): ...@@ -822,11 +822,16 @@ def taos_schemaless_insert(connection, lines, protocol, precision):
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)
if precision != None: res = c_void_p(_libtaos.taos_schemaless_insert(connection, p_lines, num_of_lines, protocol, precision))
precision = c_char_p(precision.encode("utf-8")) errno = taos_errno(res)
errno = _libtaos.taos_schemaless_insert(connection, p_lines, num_of_lines, protocol, precision)
if errno != 0: if errno != 0:
raise SchemalessError("schemaless insert error", errno) errstr = taos_errstr(res)
taos_free_result(res)
print("schemaless_insert error affected rows: {}".format(taos_affected_rows(res)))
raise SchemalessError(errstr, errno)
taos_free_result(res)
return errno
class CTaosInterface(object): class CTaosInterface(object):
def __init__(self, config=None): def __init__(self, config=None):
......
...@@ -72,6 +72,23 @@ typedef enum { ...@@ -72,6 +72,23 @@ typedef enum {
SET_CONF_RET_ERR_TOO_LONG = -6 SET_CONF_RET_ERR_TOO_LONG = -6
} SET_CONF_RET_CODE; } SET_CONF_RET_CODE;
typedef enum {
TSDB_SML_UNKNOWN_PROTOCOL = 0,
TSDB_SML_LINE_PROTOCOL = 1,
TSDB_SML_TELNET_PROTOCOL = 2,
TSDB_SML_JSON_PROTOCOL = 3,
} TSDB_SML_PROTOCOL_TYPE;
typedef enum {
TSDB_SML_TIMESTAMP_NOT_CONFIGURED = 0,
TSDB_SML_TIMESTAMP_HOURS,
TSDB_SML_TIMESTAMP_MINUTES,
TSDB_SML_TIMESTAMP_SECONDS,
TSDB_SML_TIMESTAMP_MILLI_SECONDS,
TSDB_SML_TIMESTAMP_MICRO_SECONDS,
TSDB_SML_TIMESTAMP_NANO_SECONDS,
} TSDB_SML_TIMESTAMP_TYPE;
#define RET_MSG_LENGTH 1024 #define RET_MSG_LENGTH 1024
typedef struct setConfRet { typedef struct setConfRet {
SET_CONF_RET_CODE retCode; SET_CONF_RET_CODE retCode;
...@@ -188,7 +205,7 @@ DLL_EXPORT void taos_close_stream(TAOS_STREAM *tstr); ...@@ -188,7 +205,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_schemaless_insert(TAOS* taos, char* lines[], int numLines, int protocol, char* precision); DLL_EXPORT TAOS_RES *taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int protocol, int precision);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -288,7 +288,7 @@ void verify_stream(TAOS* taos) { ...@@ -288,7 +288,7 @@ void verify_stream(TAOS* taos) {
taos_close_stream(strm); taos_close_stream(strm);
} }
int32_t verify_schema_less(TAOS* taos) { void verify_schema_less(TAOS* taos) {
TAOS_RES* result; TAOS_RES* result;
result = taos_query(taos, "drop database if exists test;"); result = taos_query(taos, "drop database if exists test;");
taos_free_result(result); taos_free_result(result);
...@@ -302,7 +302,7 @@ int32_t verify_schema_less(TAOS* taos) { ...@@ -302,7 +302,7 @@ int32_t verify_schema_less(TAOS* taos) {
taos_free_result(result); taos_free_result(result);
usleep(100000); usleep(100000);
int code = 0; int code = 0, affected_rows = 0;
char* lines[] = { char* lines[] = {
"st,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000", "st,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000",
...@@ -316,41 +316,91 @@ int32_t verify_schema_less(TAOS* taos) { ...@@ -316,41 +316,91 @@ int32_t verify_schema_less(TAOS* taos) {
"stf,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641000000" "stf,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641000000"
}; };
code = taos_schemaless_insert(taos, lines , sizeof(lines)/sizeof(char*), 0, "ns"); result = taos_schemaless_insert(taos, lines , sizeof(lines)/sizeof(char*), TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS);
code = taos_errno(result);
if (code != TSDB_CODE_SUCCESS) {
affected_rows = taos_affected_rows(result);
printf("\033[31m [lines1]taos_schemaless_insert failed, code: %d,%s, affected rows:%d \033[0m\n", code, taos_errstr(result), affected_rows);
}
taos_free_result(result);
char* lines2[] = { char* lines2[] = {
"stg,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000", "stg,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000",
"stg,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833641000000" "stg,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833641000000"
}; };
code = taos_schemaless_insert(taos, &lines2[0], 1, 0, "ns"); result = taos_schemaless_insert(taos, &lines2[0], 1, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS);
code = taos_schemaless_insert(taos, &lines2[1], 1, 0, "ns"); code = taos_errno(result);
if (code != TSDB_CODE_SUCCESS) {
affected_rows = taos_affected_rows(result);
printf("\033[31m [lines2_0]taos_schemaless_insert failed, code: %d,%s, affected rows:%d \033[0m\n", code, taos_errstr(result), affected_rows);
}
taos_free_result(result);
result = taos_schemaless_insert(taos, &lines2[1], 1, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS);
code = taos_errno(result);
if (code != TSDB_CODE_SUCCESS) {
affected_rows = taos_affected_rows(result);
printf("\033[31m [lines2_1]taos_schemaless_insert failed, code: %d,%s, affected rows:%d \033[0m\n", code, taos_errstr(result), affected_rows);
}
taos_free_result(result);
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 1626006933641", "sth,t1=4i64,t2=5f64,t4=5f64,ID=childTable c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641",
"sth,t1=4i64,t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933654" "sth,t1=4i64,t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933654"
}; };
code = taos_schemaless_insert(taos, lines3, 2, 0, "ms"); result = taos_schemaless_insert(taos, lines3, 2, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_MILLI_SECONDS);
code = taos_errno(result);
if (code != TSDB_CODE_SUCCESS) {
affected_rows = taos_affected_rows(result);
printf("\033[31m [lines3]taos_schemaless_insert failed, code: %d,%s, affected rows:%d \033[0m\n", code, taos_errstr(result), affected_rows);
}
taos_free_result(result);
char* lines4[] = { char* lines4[] = {
"st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000", "st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000",
"dgtyqodr,t2=5f64,t3=L\"ste\" c1=tRue,c2=4i64,c3=\"iam\" 1626056811823316532" "dgtyqodr,t2=5f64,t3=L\"ste\" c1=tRue,c2=4i64,c3=\"iam\" 1626056811823316532"
}; };
code = taos_schemaless_insert(taos, lines4, 2, 0, "ns"); result = taos_schemaless_insert(taos, lines4, 2, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS);
code = taos_errno(result);
if (code != TSDB_CODE_SUCCESS) {
affected_rows = taos_affected_rows(result);
printf("\033[31m [lines4]taos_schemaless_insert failed, code: %d,%s, affected rows:%d \033[0m\n", code, taos_errstr(result), affected_rows);
}
taos_free_result(result);
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 1626006833639000000", "zqlbgs,id=zqlbgs_39302_21680,t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"binaryColValue\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000",
"zqlbgs,t9=f,id=zqlbgs_39302_21680,t0=f,t1=127i8,t11=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\",t10=L\"ncharTagValue\" c10=f,c0=f,c1=127i8,c12=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"binaryColValue\",c8=L\"ncharColValue\",c9=7u64,c11=L\"ncharColValue\" 1626006833639000000" "zqlbgs,t9=f,id=zqlbgs_39302_21680,t0=f,t1=127i8,t11=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\",t10=L\"ncharTagValue\" c10=f,c0=f,c1=127i8,c12=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"binaryColValue\",c8=L\"ncharColValue\",c9=7u64,c11=L\"ncharColValue\" 1626006833639000000"
}; };
code = taos_schemaless_insert(taos, &lines5[0], 1, 0, "ns"); result = taos_schemaless_insert(taos, &lines5[0], 1, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS);
code = taos_schemaless_insert(taos, &lines5[1], 1, 0, "ns"); code = taos_errno(result);
if (code != TSDB_CODE_SUCCESS) {
affected_rows = taos_affected_rows(result);
printf("\033[31m [lines5_0]taos_schemaless_insert failed, code: %d,%s, affected rows:%d \033[0m\n", code, taos_errstr(result), affected_rows);
}
taos_free_result(result);
result = taos_schemaless_insert(taos, &lines5[1], 1, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS);
code = taos_errno(result);
if (code != TSDB_CODE_SUCCESS) {
affected_rows = taos_affected_rows(result);
printf("\033[31m [lines5_1]taos_schemaless_insert failed, code: %d,%s, affected rows:%d \033[0m\n", code, taos_errstr(result), affected_rows);
}
taos_free_result(result);
char* lines6[] = { char* lines6[] = {
"st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000", "st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000",
"dgtyqodr,t2=5f64,t3=L\"ste\" c1=tRue,c2=4i64,c3=\"iam\" 1626056811823316532" "dgtyqodr,t2=5f64,t3=L\"ste\" c1=tRue,c2=4i64,c3=\"iam\" 1626056811823316532"
}; };
code = taos_schemaless_insert(taos, lines6, 2, 0, "ns"); result = taos_schemaless_insert(taos, lines6, 2, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS);
code = taos_errno(result);
if (code != TSDB_CODE_SUCCESS) {
affected_rows = taos_affected_rows(result);
printf("\033[31m [lines6]taos_schemaless_insert failed, code: %d,%s, affected rows:%d \033[0m\n", code, taos_errstr(result), affected_rows);
}
taos_free_result(result);
return (code);
} }
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
......
...@@ -33,6 +33,8 @@ typedef struct { ...@@ -33,6 +33,8 @@ typedef struct {
int numBatches; int numBatches;
SThreadLinesBatch batches[MAX_THREAD_LINE_BATCHES]; SThreadLinesBatch batches[MAX_THREAD_LINE_BATCHES];
int64_t costTime; int64_t costTime;
int tsPrecision;
int lineProtocol;
} SThreadInsertArgs; } SThreadInsertArgs;
static void* insertLines(void* args) { static void* insertLines(void* args) {
...@@ -43,10 +45,12 @@ static void* insertLines(void* args) { ...@@ -43,10 +45,12 @@ static void* insertLines(void* args) {
SThreadLinesBatch* batch = insertArgs->batches + i; SThreadLinesBatch* batch = insertArgs->batches + i;
printf("%s, thread: 0x%s\n", "begin taos_insert_lines", tidBuf); printf("%s, thread: 0x%s\n", "begin taos_insert_lines", tidBuf);
int64_t begin = getTimeInUs(); int64_t begin = getTimeInUs();
int32_t code = taos_schemaless_insert(insertArgs->taos, batch->lines, batch->numLines, 0, "ms"); TAOS_RES *res = taos_schemaless_insert(insertArgs->taos, batch->lines, batch->numLines, insertArgs->lineProtocol, insertArgs->tsPrecision);
int32_t code = taos_errno(res);
int64_t end = getTimeInUs(); int64_t end = getTimeInUs();
insertArgs->costTime += end - begin; insertArgs->costTime += end - begin;
printf("code: %d, %s. time used:%"PRId64", thread: 0x%s\n", code, tstrerror(code), end - begin, tidBuf); printf("code: %d, %s. affected lines:%d time used:%"PRId64", thread: 0x%s\n", code, taos_errstr(res), taos_affected_rows(res), end - begin, tidBuf);
taos_free_result(res);
} }
return NULL; return NULL;
} }
...@@ -95,9 +99,11 @@ int main(int argc, char* argv[]) { ...@@ -95,9 +99,11 @@ int main(int argc, char* argv[]) {
int numFields = 13; int numFields = 13;
int maxLinesPerBatch = 16384; int maxLinesPerBatch = 16384;
int tsPrecision = TSDB_SML_TIMESTAMP_NOT_CONFIGURED;
int lineProtocol = TSDB_SML_UNKNOWN_PROTOCOL;
int opt; int opt;
while ((opt = getopt(argc, argv, "s:c:r:f:t:m:h")) != -1) { while ((opt = getopt(argc, argv, "s:c:r:f:t:m:p:P:h")) != -1) {
switch (opt) { switch (opt) {
case 's': case 's':
numSuperTables = atoi(optarg); numSuperTables = atoi(optarg);
...@@ -117,6 +123,12 @@ int main(int argc, char* argv[]) { ...@@ -117,6 +123,12 @@ int main(int argc, char* argv[]) {
case 'm': case 'm':
maxLinesPerBatch = atoi(optarg); maxLinesPerBatch = atoi(optarg);
break; break;
case 'p':
tsPrecision = atoi(optarg);
break;
case 'P':
lineProtocol = atoi(optarg);
break;
case 'h': case 'h':
fprintf(stderr, "Usage: %s -s supertable -c childtable -r rows -f fields -t threads -m maxlines_per_batch\n", fprintf(stderr, "Usage: %s -s supertable -c childtable -r rows -f fields -t threads -m maxlines_per_batch\n",
argv[0]); argv[0]);
...@@ -178,6 +190,8 @@ int main(int argc, char* argv[]) { ...@@ -178,6 +190,8 @@ int main(int argc, char* argv[]) {
args.taos = taos; args.taos = taos;
args.batches[0].lines = linesStb; args.batches[0].lines = linesStb;
args.batches[0].numLines = numSuperTables; args.batches[0].numLines = numSuperTables;
args.tsPrecision = tsPrecision;
args.lineProtocol = lineProtocol;
insertLines(&args); insertLines(&args);
for (int i = 0; i < numSuperTables; ++i) { for (int i = 0; i < numSuperTables; ++i) {
free(linesStb[i]); free(linesStb[i]);
......
...@@ -15,6 +15,7 @@ import sys ...@@ -15,6 +15,7 @@ import sys
from util.log import * from util.log import *
from util.cases import * from util.cases import *
from util.sql import * from util.sql import *
from util.types import TDSmlProtocolType, TDSmlTimestampType
class TDTestCase: class TDTestCase:
...@@ -46,7 +47,7 @@ class TDTestCase: ...@@ -46,7 +47,7 @@ class TDTestCase:
} }
} }
'''] ''']
code = self._conn.schemaless_insert(payload, 2, None) code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("describe `.stb.0.`") tdSql.query("describe `.stb.0.`")
...@@ -67,7 +68,7 @@ class TDTestCase: ...@@ -67,7 +68,7 @@ class TDTestCase:
} }
} }
'''] ''']
code = self._conn.schemaless_insert(payload, 2, None) code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("describe stb0_0") tdSql.query("describe stb0_0")
...@@ -86,7 +87,7 @@ class TDTestCase: ...@@ -86,7 +87,7 @@ class TDTestCase:
} }
} }
'''] ''']
code = self._conn.schemaless_insert(payload, 2, None) code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("describe stb0_1") tdSql.query("describe stb0_1")
...@@ -105,7 +106,7 @@ class TDTestCase: ...@@ -105,7 +106,7 @@ class TDTestCase:
} }
} }
'''] ''']
code = self._conn.schemaless_insert(payload, 2, None) code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("describe stb0_2") tdSql.query("describe stb0_2")
...@@ -124,7 +125,7 @@ class TDTestCase: ...@@ -124,7 +125,7 @@ class TDTestCase:
} }
} }
'''] ''']
code = self._conn.schemaless_insert(payload, 2, None) code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("describe stb0_3") tdSql.query("describe stb0_3")
...@@ -143,7 +144,7 @@ class TDTestCase: ...@@ -143,7 +144,7 @@ class TDTestCase:
} }
} }
'''] ''']
code = self._conn.schemaless_insert(payload, 2, None) code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("describe stb0_4") tdSql.query("describe stb0_4")
...@@ -162,7 +163,7 @@ class TDTestCase: ...@@ -162,7 +163,7 @@ class TDTestCase:
} }
} }
'''] ''']
code = self._conn.schemaless_insert(payload, 2, None) code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("describe stb0_5") tdSql.query("describe stb0_5")
...@@ -184,7 +185,7 @@ class TDTestCase: ...@@ -184,7 +185,7 @@ class TDTestCase:
} }
} }
'''] ''']
code = self._conn.schemaless_insert(payload, 2, None) code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
### timestamp 10 digits second ### ### timestamp 10 digits second ###
...@@ -201,7 +202,7 @@ class TDTestCase: ...@@ -201,7 +202,7 @@ class TDTestCase:
} }
} }
'''] ''']
code = self._conn.schemaless_insert(payload, 2, None) code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
print("============= step3 : test tags ================") print("============= step3 : test tags ================")
...@@ -216,7 +217,7 @@ class TDTestCase: ...@@ -216,7 +217,7 @@ class TDTestCase:
} }
} }
'''] ''']
code = self._conn.schemaless_insert(payload, 2, None) code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("describe stb0_8") tdSql.query("describe stb0_8")
...@@ -232,7 +233,7 @@ class TDTestCase: ...@@ -232,7 +233,7 @@ class TDTestCase:
} }
} }
'''] ''']
code = self._conn.schemaless_insert(payload, 2, None) code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("describe stb0_9") tdSql.query("describe stb0_9")
...@@ -248,7 +249,7 @@ class TDTestCase: ...@@ -248,7 +249,7 @@ class TDTestCase:
} }
} }
'''] ''']
code = self._conn.schemaless_insert(payload, 2, None) code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("describe stb0_10") tdSql.query("describe stb0_10")
...@@ -274,7 +275,7 @@ class TDTestCase: ...@@ -274,7 +275,7 @@ class TDTestCase:
} }
} }
'''] ''']
code = self._conn.schemaless_insert(payload, 2, None) code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("select ts from stb1_0") tdSql.query("select ts from stb1_0")
...@@ -297,7 +298,7 @@ class TDTestCase: ...@@ -297,7 +298,7 @@ class TDTestCase:
} }
} }
'''] ''']
code = self._conn.schemaless_insert(payload, 2, None) code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("select ts from stb1_1") tdSql.query("select ts from stb1_1")
...@@ -320,7 +321,7 @@ class TDTestCase: ...@@ -320,7 +321,7 @@ class TDTestCase:
} }
} }
'''] ''']
code = self._conn.schemaless_insert(payload, 2, None) code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("select ts from stb1_2") tdSql.query("select ts from stb1_2")
...@@ -343,7 +344,7 @@ class TDTestCase: ...@@ -343,7 +344,7 @@ class TDTestCase:
} }
} }
'''] ''']
code = self._conn.schemaless_insert(payload, 2, None) code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("select ts from stb1_3") tdSql.query("select ts from stb1_3")
...@@ -367,7 +368,7 @@ class TDTestCase: ...@@ -367,7 +368,7 @@ class TDTestCase:
} }
} }
'''] ''']
code = self._conn.schemaless_insert(payload, 2, None) code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
### metric value ### ### metric value ###
...@@ -390,7 +391,7 @@ class TDTestCase: ...@@ -390,7 +391,7 @@ class TDTestCase:
} }
} }
'''] ''']
code = self._conn.schemaless_insert(payload, 2, None) code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("describe stb2_0") tdSql.query("describe stb2_0")
...@@ -415,7 +416,7 @@ class TDTestCase: ...@@ -415,7 +416,7 @@ class TDTestCase:
} }
} }
'''] ''']
code = self._conn.schemaless_insert(payload, 2, None) code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("describe stb2_1") tdSql.query("describe stb2_1")
...@@ -440,7 +441,7 @@ class TDTestCase: ...@@ -440,7 +441,7 @@ class TDTestCase:
} }
} }
'''] ''']
code = self._conn.schemaless_insert(payload, 2, None) code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("describe stb2_2") tdSql.query("describe stb2_2")
...@@ -465,7 +466,7 @@ class TDTestCase: ...@@ -465,7 +466,7 @@ class TDTestCase:
} }
} }
'''] ''']
code = self._conn.schemaless_insert(payload, 2, None) code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("describe stb2_3") tdSql.query("describe stb2_3")
...@@ -490,7 +491,7 @@ class TDTestCase: ...@@ -490,7 +491,7 @@ class TDTestCase:
} }
} }
'''] ''']
code = self._conn.schemaless_insert(payload, 2, None) code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("describe stb2_4") tdSql.query("describe stb2_4")
...@@ -515,7 +516,7 @@ class TDTestCase: ...@@ -515,7 +516,7 @@ class TDTestCase:
} }
} }
'''] ''']
code = self._conn.schemaless_insert(payload, 2, None) code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("describe stb2_5") tdSql.query("describe stb2_5")
...@@ -540,7 +541,7 @@ class TDTestCase: ...@@ -540,7 +541,7 @@ class TDTestCase:
} }
} }
'''] ''']
code = self._conn.schemaless_insert(payload, 2, None) code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("describe stb2_6") tdSql.query("describe stb2_6")
...@@ -565,7 +566,7 @@ class TDTestCase: ...@@ -565,7 +566,7 @@ class TDTestCase:
} }
} }
'''] ''']
code = self._conn.schemaless_insert(payload, 2, None) code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("describe stb2_7") tdSql.query("describe stb2_7")
...@@ -590,7 +591,7 @@ class TDTestCase: ...@@ -590,7 +591,7 @@ class TDTestCase:
} }
} }
'''] ''']
code = self._conn.schemaless_insert(payload, 2, None) code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("describe stb2_8") tdSql.query("describe stb2_8")
...@@ -649,7 +650,7 @@ class TDTestCase: ...@@ -649,7 +650,7 @@ class TDTestCase:
} }
} }
'''] ''']
code = self._conn.schemaless_insert(payload, 2, None) code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("describe stb3_0") tdSql.query("describe stb3_0")
......
...@@ -15,7 +15,7 @@ import sys ...@@ -15,7 +15,7 @@ import sys
from util.log import * from util.log import *
from util.cases import * from util.cases import *
from util.sql import * from util.sql import *
from util.types import TDSmlProtocolType, TDSmlTimestampType
class TDTestCase: class TDTestCase:
def init(self, conn, logSql): def init(self, conn, logSql):
...@@ -38,7 +38,7 @@ class TDTestCase: ...@@ -38,7 +38,7 @@ class TDTestCase:
"`.stb0.3.` 1626006833639000000ns 4i8 host=\"host0\" interface=\"eth0\"", "`.stb0.3.` 1626006833639000000ns 4i8 host=\"host0\" interface=\"eth0\"",
] ]
code = self._conn.schemaless_insert(lines0, 1, None) code = self._conn.schemaless_insert(lines0, TDSmlProtocolType.TELNET.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("show stables") tdSql.query("show stables")
...@@ -68,7 +68,7 @@ class TDTestCase: ...@@ -68,7 +68,7 @@ class TDTestCase:
"stb1 0 7i8 host=\"host0\"", "stb1 0 7i8 host=\"host0\"",
] ]
code = self._conn.schemaless_insert(lines1, 1, None) code = self._conn.schemaless_insert(lines1, TDSmlProtocolType.TELNET.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb1") tdSql.query("select * from stb1")
...@@ -82,7 +82,7 @@ class TDTestCase: ...@@ -82,7 +82,7 @@ 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.schemaless_insert(lines2_0, 1, None) code = self._conn.schemaless_insert(lines2_0, TDSmlProtocolType.TELNET.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb2_0") tdSql.query("select * from stb2_0")
...@@ -97,7 +97,7 @@ class TDTestCase: ...@@ -97,7 +97,7 @@ 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.schemaless_insert(lines2_1, 1, None) code = self._conn.schemaless_insert(lines2_1, TDSmlProtocolType.TELNET.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb2_1") tdSql.query("select * from stb2_1")
...@@ -113,7 +113,7 @@ class TDTestCase: ...@@ -113,7 +113,7 @@ class TDTestCase:
"stb2_2 1626006833652ms 2147483647i32 host=\"host0\"" "stb2_2 1626006833652ms 2147483647i32 host=\"host0\""
] ]
code = self._conn.schemaless_insert(lines2_2, 1, None) code = self._conn.schemaless_insert(lines2_2, TDSmlProtocolType.TELNET.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb2_2") tdSql.query("select * from stb2_2")
...@@ -129,7 +129,7 @@ class TDTestCase: ...@@ -129,7 +129,7 @@ class TDTestCase:
"stb2_3 1626006833652ms 9223372036854775807i64 host=\"host0\"" "stb2_3 1626006833652ms 9223372036854775807i64 host=\"host0\""
] ]
code = self._conn.schemaless_insert(lines2_3, 1, None) code = self._conn.schemaless_insert(lines2_3, TDSmlProtocolType.TELNET.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb2_3") tdSql.query("select * from stb2_3")
...@@ -153,7 +153,7 @@ class TDTestCase: ...@@ -153,7 +153,7 @@ class TDTestCase:
"stb2_4 1626006833710ms -3.4E38f32 host=\"host0\"" "stb2_4 1626006833710ms -3.4E38f32 host=\"host0\""
] ]
code = self._conn.schemaless_insert(lines2_4, 1, None) code = self._conn.schemaless_insert(lines2_4, TDSmlProtocolType.TELNET.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb2_4") tdSql.query("select * from stb2_4")
...@@ -178,7 +178,7 @@ class TDTestCase: ...@@ -178,7 +178,7 @@ class TDTestCase:
"stb2_5 1626006833710ms 3 host=\"host0\"" "stb2_5 1626006833710ms 3 host=\"host0\""
] ]
code = self._conn.schemaless_insert(lines2_5, 1, None) code = self._conn.schemaless_insert(lines2_5, TDSmlProtocolType.TELNET.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb2_5") tdSql.query("select * from stb2_5")
...@@ -202,7 +202,7 @@ class TDTestCase: ...@@ -202,7 +202,7 @@ class TDTestCase:
"stb2_6 1626006833700ms FALSE host=\"host0\"" "stb2_6 1626006833700ms FALSE host=\"host0\""
] ]
code = self._conn.schemaless_insert(lines2_6, 1, None) code = self._conn.schemaless_insert(lines2_6, TDSmlProtocolType.TELNET.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb2_6") tdSql.query("select * from stb2_6")
...@@ -219,7 +219,7 @@ class TDTestCase: ...@@ -219,7 +219,7 @@ class TDTestCase:
"stb2_7 1626006833630ms \"binary_val.()[]{}<>\" host=\"host0\"" "stb2_7 1626006833630ms \"binary_val.()[]{}<>\" host=\"host0\""
] ]
code = self._conn.schemaless_insert(lines2_7, 1, None) code = self._conn.schemaless_insert(lines2_7, TDSmlProtocolType.TELNET.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb2_7") tdSql.query("select * from stb2_7")
...@@ -235,7 +235,7 @@ class TDTestCase: ...@@ -235,7 +235,7 @@ class TDTestCase:
"stb2_8 1626006833620ms L\"nchar_val数值二\" host=\"host0\"" "stb2_8 1626006833620ms L\"nchar_val数值二\" host=\"host0\""
] ]
code = self._conn.schemaless_insert(lines2_8, 1, None) code = self._conn.schemaless_insert(lines2_8, TDSmlProtocolType.TELNET.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb2_8") tdSql.query("select * from stb2_8")
...@@ -253,7 +253,7 @@ class TDTestCase: ...@@ -253,7 +253,7 @@ 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.schemaless_insert(lines3_0, 1, None) code = self._conn.schemaless_insert(lines3_0, TDSmlProtocolType.TELNET.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb3_0") tdSql.query("select * from stb3_0")
...@@ -297,7 +297,7 @@ class TDTestCase: ...@@ -297,7 +297,7 @@ class TDTestCase:
"stb3_1 1626006833610ms 3 ID=child_table3 host=host3" "stb3_1 1626006833610ms 3 ID=child_table3 host=host3"
] ]
code = self._conn.schemaless_insert(lines3_1, 1, None) code = self._conn.schemaless_insert(lines3_1, TDSmlProtocolType.TELNET.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb3_1") tdSql.query("select * from stb3_1")
......
...@@ -15,13 +15,14 @@ import sys ...@@ -15,13 +15,14 @@ import sys
from util.log import * from util.log import *
from util.cases import * from util.cases import *
from util.sql import * from util.sql import *
from util.types import TDSmlProtocolType, TDSmlTimestampType
class TDTestCase: class TDTestCase:
def init(self, conn, logSql): def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__) tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql) tdSql.init(conn.cursor(), logSql)
self._conn = conn self._conn = conn
def run(self): def run(self):
print("running {}".format(__file__)) print("running {}".format(__file__))
...@@ -42,17 +43,17 @@ class TDTestCase: ...@@ -42,17 +43,17 @@ class TDTestCase:
"stf,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641000000" "stf,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641000000"
] ]
code = self._conn.schemaless_insert(lines, 0, "ns") code = self._conn.schemaless_insert(lines, TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
lines2 = [ "stg,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000", lines2 = [ "stg,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000",
"stg,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000" "stg,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000"
] ]
code = self._conn.schemaless_insert([ lines2[0] ], 0, "ns") code = self._conn.schemaless_insert([ lines2[0] ], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
self._conn.schemaless_insert([ lines2[1] ], 0, "ns") code = self._conn.schemaless_insert([ lines2[1] ], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
print("schemaless_insert result {}".format(code)) print("schemaless_insert result {}".format(code))
tdSql.query("select * from st") tdSql.query("select * from st")
...@@ -76,7 +77,7 @@ class TDTestCase: ...@@ -76,7 +77,7 @@ class TDTestCase:
self._conn.schemaless_insert([ self._conn.schemaless_insert([
"sth,t1=4i64,t2=5f64,t4=5f64,ID=childtable c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641", "sth,t1=4i64,t2=5f64,t4=5f64,ID=childtable c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641",
"sth,t1=4i64,t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933654" "sth,t1=4i64,t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933654"
], 0, "ms") ], TDSmlProtocolType.LINE.value, TDSmlTimestampType.MILLI_SECOND.value)
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.query('select tbname, * from sth') tdSql.query('select tbname, * from sth')
......
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
from enum import Enum
class TDSmlProtocolType(Enum):
'''
Schemaless Protocol types
0 - unknown
1 - InfluxDB Line Protocol
2 - OpenTSDB Telnet Protocl
3 - OpenTSDB JSON Protocol
'''
UNKNOWN = 0
LINE = 1
TELNET = 2
JSON = 3
class TDSmlTimestampType(Enum):
NOT_CONFIGURED = 0
HOUR = 1
MINUTE = 2
SECOND = 3
MILLI_SECOND = 4
MICRO_SECOND = 5
NANO_SECOND = 6
...@@ -26,10 +26,12 @@ void verify_telnet_insert(TAOS* taos) { ...@@ -26,10 +26,12 @@ 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_schemaless_insert(taos, lines0, 3, 1, NULL); result = taos_schemaless_insert(taos, lines0, 3, TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
if (code) { if (code) {
printf("lines0 code: %d, %s.\n", code, tstrerror(code)); printf("lines0 code: %d, %s.\n", code, tstrerror(code));
} }
taos_free_result(result);
/* timestamp */ /* timestamp */
char* lines1[] = { char* lines1[] = {
...@@ -41,10 +43,12 @@ void verify_telnet_insert(TAOS* taos) { ...@@ -41,10 +43,12 @@ void verify_telnet_insert(TAOS* taos) {
"stb1 1626006833651ms 6i8 host=\"host0\"", "stb1 1626006833651ms 6i8 host=\"host0\"",
"stb1 0 7i8 host=\"host0\"", "stb1 0 7i8 host=\"host0\"",
}; };
code = taos_schemaless_insert(taos, lines1, 7, 1, NULL); result = taos_schemaless_insert(taos, lines1, 7, TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
if (code) { if (code) {
printf("lines1 code: %d, %s.\n", code, tstrerror(code)); printf("lines1 code: %d, %s.\n", code, tstrerror(code));
} }
taos_free_result(result);
/* metric value */ /* metric value */
//tinyint //tinyint
...@@ -52,40 +56,48 @@ void verify_telnet_insert(TAOS* taos) { ...@@ -52,40 +56,48 @@ 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_schemaless_insert(taos, lines2_0, 2, 1, NULL); result = taos_schemaless_insert(taos, lines2_0, 2, TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
if (code) { if (code) {
printf("lines2_0 code: %d, %s.\n", code, tstrerror(code)); printf("lines2_0 code: %d, %s.\n", code, tstrerror(code));
} }
taos_free_result(result);
//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_schemaless_insert(taos, lines2_1, 2, 1, NULL); result = taos_schemaless_insert(taos, lines2_1, 2, TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
if (code) { if (code) {
printf("lines2_1 code: %d, %s.\n", code, tstrerror(code)); printf("lines2_1 code: %d, %s.\n", code, tstrerror(code));
} }
taos_free_result(result);
//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_schemaless_insert(taos, lines2_2, 2, 1, NULL); result = taos_schemaless_insert(taos, lines2_2, 2, TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
if (code) { if (code) {
printf("lines2_2 code: %d, %s.\n", code, tstrerror(code)); printf("lines2_2 code: %d, %s.\n", code, tstrerror(code));
} }
taos_free_result(result);
//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_schemaless_insert(taos, lines2_3, 2, 1, NULL); result = taos_schemaless_insert(taos, lines2_3, 2, TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
if (code) { if (code) {
printf("lines2_3 code: %d, %s.\n", code, tstrerror(code)); printf("lines2_3 code: %d, %s.\n", code, tstrerror(code));
} }
taos_free_result(result);
//float //float
char* lines2_4[] = { char* lines2_4[] = {
...@@ -100,10 +112,12 @@ void verify_telnet_insert(TAOS* taos) { ...@@ -100,10 +112,12 @@ 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_schemaless_insert(taos, lines2_4, 10, 1, NULL); result = taos_schemaless_insert(taos, lines2_4, 10, TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
if (code) { if (code) {
printf("lines2_4 code: %d, %s.\n", code, tstrerror(code)); printf("lines2_4 code: %d, %s.\n", code, tstrerror(code));
} }
taos_free_result(result);
//double //double
char* lines2_5[] = { char* lines2_5[] = {
...@@ -119,10 +133,12 @@ void verify_telnet_insert(TAOS* taos) { ...@@ -119,10 +133,12 @@ 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_schemaless_insert(taos, lines2_5, 11, 1, NULL); result = taos_schemaless_insert(taos, lines2_5, 11, TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
if (code) { if (code) {
printf("lines2_5 code: %d, %s.\n", code, tstrerror(code)); printf("lines2_5 code: %d, %s.\n", code, tstrerror(code));
} }
taos_free_result(result);
//bool //bool
char* lines2_6[] = { char* lines2_6[] = {
...@@ -137,10 +153,12 @@ void verify_telnet_insert(TAOS* taos) { ...@@ -137,10 +153,12 @@ 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_schemaless_insert(taos, lines2_6, 10, 1, NULL); result = taos_schemaless_insert(taos, lines2_6, 10, TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
if (code) { if (code) {
printf("lines2_6 code: %d, %s.\n", code, tstrerror(code)); printf("lines2_6 code: %d, %s.\n", code, tstrerror(code));
} }
taos_free_result(result);
//binary //binary
char* lines2_7[] = { char* lines2_7[] = {
...@@ -148,20 +166,24 @@ void verify_telnet_insert(TAOS* taos) { ...@@ -148,20 +166,24 @@ 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_schemaless_insert(taos, lines2_7, 3, 1, NULL); result = taos_schemaless_insert(taos, lines2_7, 3, TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
if (code) { if (code) {
printf("lines2_7 code: %d, %s.\n", code, tstrerror(code)); printf("lines2_7 code: %d, %s.\n", code, tstrerror(code));
} }
taos_free_result(result);
//nchar //nchar
char* lines2_8[] = { char* lines2_8[] = {
"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_schemaless_insert(taos, lines2_8, 2, 1, NULL); result = taos_schemaless_insert(taos, lines2_8, 2, TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
if (code) { if (code) {
printf("lines2_8 code: %d, %s.\n", code, tstrerror(code)); printf("lines2_8 code: %d, %s.\n", code, tstrerror(code));
} }
taos_free_result(result);
/* tags */ /* tags */
//tag value types //tag value types
...@@ -169,10 +191,12 @@ void verify_telnet_insert(TAOS* taos) { ...@@ -169,10 +191,12 @@ 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_schemaless_insert(taos, lines3_0, 2, 1, NULL); result = taos_schemaless_insert(taos, lines3_0, 2, TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
if (code) { if (code) {
printf("lines3_0 code: %d, %s.\n", code, tstrerror(code)); printf("lines3_0 code: %d, %s.\n", code, tstrerror(code));
} }
taos_free_result(result);
//tag ID as child table name //tag ID as child table name
char* lines3_1[] = { char* lines3_1[] = {
...@@ -180,10 +204,12 @@ void verify_telnet_insert(TAOS* taos) { ...@@ -180,10 +204,12 @@ 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_schemaless_insert(taos, lines3_1, 3, 1, NULL); result = taos_schemaless_insert(taos, lines3_1, 3, TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
if (code) { if (code) {
printf("lines3_1 code: %d, %s.\n", code, tstrerror(code)); printf("lines3_1 code: %d, %s.\n", code, tstrerror(code));
} }
taos_free_result(result);
return; return;
} }
...@@ -214,10 +240,12 @@ void verify_json_insert(TAOS* taos) { ...@@ -214,10 +240,12 @@ void verify_json_insert(TAOS* taos) {
} \ } \
}"}; }"};
code = taos_schemaless_insert(taos, message, 0, 2, NULL); result = taos_schemaless_insert(taos, message, 0, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
if (code) { if (code) {
printf("payload_0 code: %d, %s.\n", code, tstrerror(code)); printf("payload_0 code: %d, %s.\n", code, tstrerror(code));
} }
taos_free_result(result);
char *message1[] = { char *message1[] = {
"[ \ "[ \
...@@ -245,10 +273,12 @@ void verify_json_insert(TAOS* taos) { ...@@ -245,10 +273,12 @@ void verify_json_insert(TAOS* taos) {
} \ } \
]"}; ]"};
code = taos_schemaless_insert(taos, message1, 0, 2, NULL); result = taos_schemaless_insert(taos, message1, 0, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
if (code) { if (code) {
printf("payload_1 code: %d, %s.\n", code, tstrerror(code)); printf("payload_1 code: %d, %s.\n", code, tstrerror(code));
} }
taos_free_result(result);
char *message2[] = { char *message2[] = {
"[ \ "[ \
...@@ -296,10 +326,12 @@ void verify_json_insert(TAOS* taos) { ...@@ -296,10 +326,12 @@ void verify_json_insert(TAOS* taos) {
} \ } \
} \ } \
]"}; ]"};
code = taos_schemaless_insert(taos, message2, 0, 2, NULL); result = taos_schemaless_insert(taos, message2, 0, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
if (code) { if (code) {
printf("payload_2 code: %d, %s.\n", code, tstrerror(code)); printf("payload_2 code: %d, %s.\n", code, tstrerror(code));
} }
taos_free_result(result);
cJSON *payload, *tags; cJSON *payload, *tags;
...@@ -320,12 +352,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -320,12 +352,14 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); result = taos_schemaless_insert(taos, payload_str, 0, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
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);
taos_free_result(result);
//true //true
payload = cJSON_CreateObject(); payload = cJSON_CreateObject();
...@@ -341,12 +375,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -341,12 +375,14 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); result = taos_schemaless_insert(taos, payload_str, 0, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
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);
taos_free_result(result);
//false //false
payload = cJSON_CreateObject(); payload = cJSON_CreateObject();
...@@ -362,12 +398,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -362,12 +398,14 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); result = taos_schemaless_insert(taos, payload_str, 0, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
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);
taos_free_result(result);
//string //string
payload = cJSON_CreateObject(); payload = cJSON_CreateObject();
...@@ -383,12 +421,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -383,12 +421,14 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); result = taos_schemaless_insert(taos, payload_str, 0, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
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);
taos_free_result(result);
//timestamp 0 -> current time //timestamp 0 -> current time
payload = cJSON_CreateObject(); payload = cJSON_CreateObject();
...@@ -404,12 +444,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -404,12 +444,14 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); result = taos_schemaless_insert(taos, payload_str, 0, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
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);
taos_free_result(result);
/* Nested format */ /* Nested format */
//timestamp //timestamp
...@@ -433,12 +475,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -433,12 +475,14 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); result = taos_schemaless_insert(taos, payload_str, 0, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
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);
taos_free_result(result);
//milleseconds //milleseconds
payload = cJSON_CreateObject(); payload = cJSON_CreateObject();
...@@ -459,12 +503,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -459,12 +503,14 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); result = taos_schemaless_insert(taos, payload_str, 0, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
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);
taos_free_result(result);
//microseconds //microseconds
payload = cJSON_CreateObject(); payload = cJSON_CreateObject();
...@@ -485,12 +531,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -485,12 +531,14 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); result = taos_schemaless_insert(taos, payload_str, 0, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
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);
taos_free_result(result);
//now //now
payload = cJSON_CreateObject(); payload = cJSON_CreateObject();
...@@ -511,12 +559,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -511,12 +559,14 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); result = taos_schemaless_insert(taos, payload_str, 0, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
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);
taos_free_result(result);
//metric value //metric value
cJSON *metric_val; cJSON *metric_val;
...@@ -543,12 +593,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -543,12 +593,14 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); result = taos_schemaless_insert(taos, payload_str, 0, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
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);
taos_free_result(result);
//tinyint //tinyint
payload = cJSON_CreateObject(); payload = cJSON_CreateObject();
...@@ -573,12 +625,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -573,12 +625,14 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); result = taos_schemaless_insert(taos, payload_str, 0, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
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);
taos_free_result(result);
//smallint //smallint
payload = cJSON_CreateObject(); payload = cJSON_CreateObject();
...@@ -603,12 +657,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -603,12 +657,14 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); result = taos_schemaless_insert(taos, payload_str, 0, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
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);
taos_free_result(result);
//int //int
payload = cJSON_CreateObject(); payload = cJSON_CreateObject();
...@@ -633,12 +689,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -633,12 +689,14 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); result = taos_schemaless_insert(taos, payload_str, 0, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
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);
taos_free_result(result);
//bigint //bigint
payload = cJSON_CreateObject(); payload = cJSON_CreateObject();
...@@ -663,12 +721,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -663,12 +721,14 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); result = taos_schemaless_insert(taos, payload_str, 0, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
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);
taos_free_result(result);
//float //float
payload = cJSON_CreateObject(); payload = cJSON_CreateObject();
...@@ -693,12 +753,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -693,12 +753,14 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); result = taos_schemaless_insert(taos, payload_str, 0, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
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);
taos_free_result(result);
//double //double
payload = cJSON_CreateObject(); payload = cJSON_CreateObject();
...@@ -723,12 +785,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -723,12 +785,14 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); result = taos_schemaless_insert(taos, payload_str, 0, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
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);
taos_free_result(result);
//binary //binary
payload = cJSON_CreateObject(); payload = cJSON_CreateObject();
...@@ -753,12 +817,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -753,12 +817,14 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); result = taos_schemaless_insert(taos, payload_str, 0, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
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);
taos_free_result(result);
//nchar //nchar
payload = cJSON_CreateObject(); payload = cJSON_CreateObject();
...@@ -783,12 +849,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -783,12 +849,14 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); result = taos_schemaless_insert(taos, payload_str, 0, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
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);
taos_free_result(result);
//tag value //tag value
cJSON *tag; cJSON *tag;
...@@ -863,12 +931,14 @@ void verify_json_insert(TAOS* taos) { ...@@ -863,12 +931,14 @@ void verify_json_insert(TAOS* taos) {
*payload_str = cJSON_Print(payload); *payload_str = cJSON_Print(payload);
//printf("%s\n", payload_str); //printf("%s\n", payload_str);
code = taos_schemaless_insert(taos, payload_str, 0, 2, NULL); result = taos_schemaless_insert(taos, payload_str, 0, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED);
code = taos_errno(result);
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);
taos_free_result(result);
} }
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
......
...@@ -1074,6 +1074,7 @@ bool simExecuteSqlErrorCmd(SScript *script, char *rest) { ...@@ -1074,6 +1074,7 @@ bool simExecuteSqlErrorCmd(SScript *script, char *rest) {
} }
bool simExecuteLineInsertCmd(SScript *script, char *rest) { bool simExecuteLineInsertCmd(SScript *script, char *rest) {
bool ret;
char buf[TSDB_MAX_BINARY_LEN]; char buf[TSDB_MAX_BINARY_LEN];
simVisuallizeOption(script, rest, buf); simVisuallizeOption(script, rest, buf);
...@@ -1083,20 +1084,24 @@ bool simExecuteLineInsertCmd(SScript *script, char *rest) { ...@@ -1083,20 +1084,24 @@ 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_schemaless_insert(script->taos, lines, 1, 0, "ns"); TAOS_RES *result = taos_schemaless_insert(script->taos, lines, 1, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS);
if (ret == TSDB_CODE_SUCCESS) { int32_t code = taos_errno(result);
if (code == 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++;
return true; ret = true;
} else { } else {
sprintf(script->error, "lineNum: %d. line: %s failed, ret:%d:%s", line->lineNum, rest, sprintf(script->error, "lineNum: %d. line: %s failed, code:%d:%s", line->lineNum, rest,
ret & 0XFFFF, tstrerror(ret)); code & 0XFFFF, taos_errstr(result));
return false; ret = false;
} }
taos_free_result(result);
return ret;
} }
bool simExecuteLineInsertErrorCmd(SScript *script, char *rest) { bool simExecuteLineInsertErrorCmd(SScript *script, char *rest) {
bool ret;
char buf[TSDB_MAX_BINARY_LEN]; char buf[TSDB_MAX_BINARY_LEN];
simVisuallizeOption(script, rest, buf); simVisuallizeOption(script, rest, buf);
...@@ -1107,14 +1112,17 @@ bool simExecuteLineInsertErrorCmd(SScript *script, char *rest) { ...@@ -1107,14 +1112,17 @@ 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_schemaless_insert(script->taos, lines, 1, 0, "ns"); TAOS_RES *result = taos_schemaless_insert(script->taos, lines, 1, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS);
if (ret == TSDB_CODE_SUCCESS) { int32_t code = taos_errno(result);
if (code == TSDB_CODE_SUCCESS) {
sprintf(script->error, "script:%s, taos:%p, %s executed. expect failed, but success.", script->fileName, script->taos, rest); sprintf(script->error, "script:%s, taos:%p, %s executed. expect failed, but success.", script->fileName, script->taos, rest);
script->linePos++; script->linePos++;
return false; ret = false;
} else { } else {
simDebug("lineNum: %d. line: %s failed, ret:%d:%s. Expect failed, so success", line->lineNum, rest, simDebug("lineNum: %d. line: %s failed, code:%d:%s. Expect failed, so success", line->lineNum, rest,
ret & 0XFFFF, tstrerror(ret)); code & 0XFFFF, taos_errstr(result));
return true; ret = true;
} }
taos_free_result(result);
return ret;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册