Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b353b162
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
b353b162
编写于
10月 13, 2021
作者:
D
dapan1121
提交者:
GitHub
10月 13, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #8196 from taosdata/enhance/TD-10532
Allow schemaless default timestamp precision to be seconds and milliseconds
上级
d596a658
22b7ace8
变更
21
显示空白变更内容
内联
并排
Showing
21 changed file
with
456 addition
and
271 deletion
+456
-271
src/client/inc/tscParseLine.h
src/client/inc/tscParseLine.h
+16
-5
src/client/src/TSDBJNIConnector.c
src/client/src/TSDBJNIConnector.c
+1
-1
src/client/src/tscParseLineProtocol.c
src/client/src/tscParseLineProtocol.c
+149
-39
src/client/src/tscParseOpenTSDB.c
src/client/src/tscParseOpenTSDB.c
+72
-28
src/connector/python/README.md
src/connector/python/README.md
+5
-5
src/connector/python/examples/insert-lines.py
src/connector/python/examples/insert-lines.py
+3
-3
src/connector/python/taos/__init__.py
src/connector/python/taos/__init__.py
+6
-6
src/connector/python/taos/cinterface.py
src/connector/python/taos/cinterface.py
+4
-2
src/connector/python/taos/connection.py
src/connector/python/taos/connection.py
+5
-5
src/connector/python/tests/test_lines.py
src/connector/python/tests/test_lines.py
+6
-6
src/inc/taos.h
src/inc/taos.h
+1
-1
src/inc/taoserror.h
src/inc/taoserror.h
+1
-0
src/util/src/terror.c
src/util/src/terror.c
+1
-0
tests/examples/c/apitest.c
tests/examples/c/apitest.c
+27
-27
tests/examples/c/schemaless.c
tests/examples/c/schemaless.c
+1
-1
tests/pytest/insert/insertJSONPayload.py
tests/pytest/insert/insertJSONPayload.py
+51
-35
tests/pytest/insert/insertTelnetLines.py
tests/pytest/insert/insertTelnetLines.py
+32
-32
tests/pytest/insert/line_insert.py
tests/pytest/insert/line_insert.py
+17
-17
tests/script/api/openTSDBTest.c
tests/script/api/openTSDBTest.c
+53
-53
tests/script/general/parser/line_insert.sim
tests/script/general/parser/line_insert.sim
+3
-3
tests/tsim/src/simExe.c
tests/tsim/src/simExe.c
+2
-2
未找到文件。
src/client/inc/tscParseLine.h
浏览文件 @
b353b162
...
@@ -20,6 +20,9 @@
...
@@ -20,6 +20,9 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
#define SML_TIMESTAMP_SECOND_DIGITS 10
#define SML_TIMESTAMP_MILLI_SECOND_DIGITS 13
typedef
struct
{
typedef
struct
{
char
*
key
;
char
*
key
;
uint8_t
type
;
uint8_t
type
;
...
@@ -41,10 +44,13 @@ typedef struct {
...
@@ -41,10 +44,13 @@ typedef struct {
typedef
enum
{
typedef
enum
{
SML_TIME_STAMP_NOW
,
SML_TIME_STAMP_NOW
,
SML_TIME_STAMP_HOURS
,
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
}
SMLTimeStampType
;
}
SMLTimeStampType
;
typedef
enum
{
typedef
enum
{
...
@@ -55,6 +61,8 @@ typedef enum {
...
@@ -55,6 +61,8 @@ typedef enum {
typedef
struct
{
typedef
struct
{
uint64_t
id
;
uint64_t
id
;
SMLProtocolType
protocol
;
SMLTimeStampType
tsType
;
SHashObj
*
smlDataToSchema
;
SHashObj
*
smlDataToSchema
;
}
SSmlLinesInfo
;
}
SSmlLinesInfo
;
...
@@ -66,15 +74,18 @@ bool isValidFloat(char *str);
...
@@ -66,15 +74,18 @@ bool isValidFloat(char *str);
int32_t
isValidChildTableName
(
const
char
*
pTbName
,
int16_t
len
,
SSmlLinesInfo
*
info
);
int32_t
isValidChildTableName
(
const
char
*
pTbName
,
int16_t
len
,
SSmlLinesInfo
*
info
);
bool
convertSmlValueType
(
TAOS_SML_KV
*
pVal
,
char
*
value
,
bool
convertSmlValueType
(
TAOS_SML_KV
*
pVal
,
char
*
value
,
uint16_t
len
,
SSmlLinesInfo
*
info
);
uint16_t
len
,
SSmlLinesInfo
*
info
,
bool
isTag
);
int32_t
convertSmlTimeStamp
(
TAOS_SML_KV
*
pVal
,
char
*
value
,
int32_t
convertSmlTimeStamp
(
TAOS_SML_KV
*
pVal
,
char
*
value
,
uint16_t
len
,
SSmlLinesInfo
*
info
);
uint16_t
len
,
SSmlLinesInfo
*
info
);
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_sml_lines
(
TAOS
*
taos
,
char
*
lines
[],
int
numLines
,
int
taos_insert_telnet_lines
(
TAOS
*
taos
,
char
*
lines
[],
int
numLines
);
SMLProtocolType
protocol
,
SMLTimeStampType
tsType
);
int
taos_insert_json_payload
(
TAOS
*
taos
,
char
*
payload
);
int
taos_insert_telnet_lines
(
TAOS
*
taos
,
char
*
lines
[],
int
numLines
,
SMLProtocolType
protocol
,
SMLTimeStampType
tsType
);
int
taos_insert_json_payload
(
TAOS
*
taos
,
char
*
payload
,
SMLProtocolType
protocol
,
SMLTimeStampType
tsType
);
#ifdef __cplusplus
#ifdef __cplusplus
...
...
src/client/src/TSDBJNIConnector.c
浏览文件 @
b353b162
...
@@ -1071,7 +1071,7 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp(J
...
@@ -1071,7 +1071,7 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp(J
c_lines
[
i
]
=
(
char
*
)(
*
env
)
->
GetStringUTFChars
(
env
,
line
,
0
);
c_lines
[
i
]
=
(
char
*
)(
*
env
)
->
GetStringUTFChars
(
env
,
line
,
0
);
}
}
int
code
=
taos_schemaless_insert
(
taos
,
c_lines
,
numLines
,
SML_LINE_PROTOCOL
);
int
code
=
taos_schemaless_insert
(
taos
,
c_lines
,
numLines
,
SML_LINE_PROTOCOL
,
"ms"
);
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
));
...
...
src/client/src/tscParseLineProtocol.c
浏览文件 @
b353b162
...
@@ -1210,6 +1210,22 @@ bool isValidFloat(char *str) {
...
@@ -1210,6 +1210,22 @@ bool isValidFloat(char *str) {
return
true
;
return
true
;
}
}
static
bool
isInteger
(
char
*
pVal
,
uint16_t
len
,
bool
*
has_sign
)
{
if
(
len
<=
1
)
{
return
false
;
}
if
(
pVal
[
len
-
1
]
==
'i'
)
{
*
has_sign
=
true
;
return
true
;
}
if
(
pVal
[
len
-
1
]
==
'u'
)
{
*
has_sign
=
false
;
return
true
;
}
return
false
;
}
static
bool
isTinyInt
(
char
*
pVal
,
uint16_t
len
)
{
static
bool
isTinyInt
(
char
*
pVal
,
uint16_t
len
)
{
if
(
len
<=
2
)
{
if
(
len
<=
2
)
{
return
false
;
return
false
;
...
@@ -1383,24 +1399,35 @@ static bool isNchar(char *pVal, uint16_t len) {
...
@@ -1383,24 +1399,35 @@ static bool isNchar(char *pVal, uint16_t len) {
return
false
;
return
false
;
}
}
static
bool
isTimeStamp
(
char
*
pVal
,
uint16_t
len
,
SMLTimeStampType
*
tsType
)
{
static
bool
isTimeStamp
(
char
*
pVal
,
uint16_t
len
,
SMLTimeStampType
*
tsType
,
SSmlLinesInfo
*
info
)
{
if
(
len
==
0
)
{
if
(
len
==
0
)
{
return
true
;
return
true
;
}
}
if
((
len
==
1
)
&&
pVal
[
0
]
==
'0'
)
{
if
((
len
==
1
)
&&
pVal
[
0
]
==
'0'
)
{
*
tsType
=
SML_TIME_STAMP_NOW
;
*
tsType
=
SML_TIME_STAMP_NOW
;
//printf("Type is timestamp(%s)\n", pVal);
return
true
;
return
true
;
}
}
if
(
len
<
2
)
{
return
false
;
//Default no appendix
}
//No appendix use usec as default
if
(
isdigit
(
pVal
[
len
-
1
])
&&
isdigit
(
pVal
[
len
-
2
]))
{
if
(
isdigit
(
pVal
[
len
-
1
])
&&
isdigit
(
pVal
[
len
-
2
]))
{
*
tsType
=
SML_TIME_STAMP_MICRO_SECONDS
;
if
(
info
->
protocol
==
SML_LINE_PROTOCOL
)
{
//printf("Type is timestamp(%s)\n", pVal);
if
(
info
->
tsType
!=
SML_TIME_STAMP_NOT_CONFIGURED
)
{
*
tsType
=
info
->
tsType
;
}
else
{
*
tsType
=
SML_TIME_STAMP_NANO_SECONDS
;
}
}
else
if
(
info
->
protocol
==
SML_TELNET_PROTOCOL
)
{
if
(
len
==
SML_TIMESTAMP_SECOND_DIGITS
)
{
*
tsType
=
SML_TIME_STAMP_SECONDS
;
}
else
if
(
len
==
SML_TIMESTAMP_MILLI_SECOND_DIGITS
)
{
*
tsType
=
SML_TIME_STAMP_MILLI_SECONDS
;
}
else
{
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
}
}
return
true
;
return
true
;
}
}
if
(
pVal
[
len
-
1
]
==
's'
)
{
if
(
pVal
[
len
-
1
]
==
's'
)
{
switch
(
pVal
[
len
-
2
])
{
switch
(
pVal
[
len
-
2
])
{
case
'm'
:
case
'm'
:
...
@@ -1528,12 +1555,31 @@ static bool convertStrToNumber(TAOS_SML_KV *pVal, char *str, SSmlLinesInfo* info
...
@@ -1528,12 +1555,31 @@ static bool convertStrToNumber(TAOS_SML_KV *pVal, char *str, SSmlLinesInfo* info
}
}
//len does not include '\0' from value.
//len does not include '\0' from value.
bool
convertSmlValueType
(
TAOS_SML_KV
*
pVal
,
char
*
value
,
bool
convertSmlValueType
(
TAOS_SML_KV
*
pVal
,
char
*
value
,
uint16_t
len
,
SSmlLinesInfo
*
info
)
{
uint16_t
len
,
SSmlLinesInfo
*
info
,
bool
isTag
)
{
if
(
len
<=
0
)
{
if
(
len
<=
0
)
{
return
false
;
return
false
;
}
}
//convert tags value to Nchar
if
(
isTag
)
{
pVal
->
type
=
TSDB_DATA_TYPE_NCHAR
;
pVal
->
length
=
len
;
pVal
->
value
=
calloc
(
pVal
->
length
,
1
);
memcpy
(
pVal
->
value
,
value
,
pVal
->
length
);
return
true
;
}
//integer number
//integer number
bool
has_sign
;
if
(
isInteger
(
value
,
len
,
&
has_sign
))
{
pVal
->
type
=
has_sign
?
TSDB_DATA_TYPE_BIGINT
:
TSDB_DATA_TYPE_UBIGINT
;
pVal
->
length
=
(
int16_t
)
tDataTypes
[
pVal
->
type
].
bytes
;
value
[
len
-
1
]
=
'\0'
;
if
(
!
isValidInteger
(
value
)
||
!
convertStrToNumber
(
pVal
,
value
,
info
))
{
return
false
;
}
return
true
;
}
if
(
isTinyInt
(
value
,
len
))
{
if
(
isTinyInt
(
value
,
len
))
{
pVal
->
type
=
TSDB_DATA_TYPE_TINYINT
;
pVal
->
type
=
TSDB_DATA_TYPE_TINYINT
;
pVal
->
length
=
(
int16_t
)
tDataTypes
[
pVal
->
type
].
bytes
;
pVal
->
length
=
(
int16_t
)
tDataTypes
[
pVal
->
type
].
bytes
;
...
@@ -1652,18 +1698,9 @@ bool convertSmlValueType(TAOS_SML_KV *pVal, char *value,
...
@@ -1652,18 +1698,9 @@ bool convertSmlValueType(TAOS_SML_KV *pVal, char *value,
memcpy
(
pVal
->
value
,
&
bVal
,
pVal
->
length
);
memcpy
(
pVal
->
value
,
&
bVal
,
pVal
->
length
);
return
true
;
return
true
;
}
}
//Handle default(no appendix) interger type as BIGINT
if
(
isValidInteger
(
value
))
{
pVal
->
type
=
TSDB_DATA_TYPE_BIGINT
;
pVal
->
length
=
(
int16_t
)
tDataTypes
[
pVal
->
type
].
bytes
;
if
(
!
convertStrToNumber
(
pVal
,
value
,
info
))
{
return
false
;
}
return
true
;
}
//Handle default(no appendix)
floating number
type as DOUBLE
//Handle default(no appendix) type as DOUBLE
if
(
isValidFloat
(
value
))
{
if
(
isValid
Integer
(
value
)
||
isValid
Float
(
value
))
{
pVal
->
type
=
TSDB_DATA_TYPE_DOUBLE
;
pVal
->
type
=
TSDB_DATA_TYPE_DOUBLE
;
pVal
->
length
=
(
int16_t
)
tDataTypes
[
pVal
->
type
].
bytes
;
pVal
->
length
=
(
int16_t
)
tDataTypes
[
pVal
->
type
].
bytes
;
if
(
!
convertStrToNumber
(
pVal
,
value
,
info
))
{
if
(
!
convertStrToNumber
(
pVal
,
value
,
info
))
{
...
@@ -1675,7 +1712,7 @@ bool convertSmlValueType(TAOS_SML_KV *pVal, char *value,
...
@@ -1675,7 +1712,7 @@ bool convertSmlValueType(TAOS_SML_KV *pVal, char *value,
}
}
static
int32_t
getTimeStampValue
(
char
*
value
,
uint16_t
len
,
static
int32_t
getTimeStampValue
(
char
*
value
,
uint16_t
len
,
SMLTimeStampType
type
,
int64_t
*
ts
)
{
SMLTimeStampType
type
,
int64_t
*
ts
,
SSmlLinesInfo
*
info
)
{
if
(
len
>=
2
)
{
if
(
len
>=
2
)
{
for
(
int
i
=
0
;
i
<
len
-
2
;
++
i
)
{
for
(
int
i
=
0
;
i
<
len
-
2
;
++
i
)
{
...
@@ -1684,11 +1721,9 @@ static int32_t getTimeStampValue(char *value, uint16_t len,
...
@@ -1684,11 +1721,9 @@ static int32_t getTimeStampValue(char *value, uint16_t len,
}
}
}
}
}
}
//No appendix or no timestamp given (len = 0)
//No appendix or no timestamp given (len = 0)
if
(
len
>=
1
&&
isdigit
(
value
[
len
-
1
])
&&
type
!=
SML_TIME_STAMP_NOW
)
{
if
(
len
!=
0
&&
type
!=
SML_TIME_STAMP_NOW
)
{
type
=
SML_TIME_STAMP_MICRO_SECONDS
;
}
if
(
len
!=
0
)
{
*
ts
=
(
int64_t
)
strtoll
(
value
,
NULL
,
10
);
*
ts
=
(
int64_t
)
strtoll
(
value
,
NULL
,
10
);
}
else
{
}
else
{
type
=
SML_TIME_STAMP_NOW
;
type
=
SML_TIME_STAMP_NOW
;
...
@@ -1698,6 +1733,14 @@ static int32_t getTimeStampValue(char *value, uint16_t len,
...
@@ -1698,6 +1733,14 @@ static int32_t getTimeStampValue(char *value, uint16_t len,
*
ts
=
taosGetTimestampNs
();
*
ts
=
taosGetTimestampNs
();
break
;
break
;
}
}
case
SML_TIME_STAMP_HOURS
:
{
*
ts
=
(
int64_t
)(
*
ts
*
3600
*
1e9
);
break
;
}
case
SML_TIME_STAMP_MINUTES
:
{
*
ts
=
(
int64_t
)(
*
ts
*
60
*
1e9
);
break
;
}
case
SML_TIME_STAMP_SECONDS
:
{
case
SML_TIME_STAMP_SECONDS
:
{
*
ts
=
(
int64_t
)(
*
ts
*
1e9
);
*
ts
=
(
int64_t
)(
*
ts
*
1e9
);
break
;
break
;
...
@@ -1728,11 +1771,11 @@ int32_t convertSmlTimeStamp(TAOS_SML_KV *pVal, char *value,
...
@@ -1728,11 +1771,11 @@ int32_t convertSmlTimeStamp(TAOS_SML_KV *pVal, char *value,
int64_t
tsVal
;
int64_t
tsVal
;
strntolower_s
(
value
,
value
,
len
);
strntolower_s
(
value
,
value
,
len
);
if
(
!
isTimeStamp
(
value
,
len
,
&
type
))
{
if
(
!
isTimeStamp
(
value
,
len
,
&
type
,
info
))
{
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
}
}
ret
=
getTimeStampValue
(
value
,
len
,
type
,
&
tsVal
);
ret
=
getTimeStampValue
(
value
,
len
,
type
,
&
tsVal
,
info
);
if
(
ret
)
{
if
(
ret
)
{
return
ret
;
return
ret
;
}
}
...
@@ -1844,7 +1887,7 @@ static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **index, SHashObj *pHash
...
@@ -1844,7 +1887,7 @@ static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **index, SHashObj *pHash
static
bool
parseSmlValue
(
TAOS_SML_KV
*
pKV
,
const
char
**
index
,
static
bool
parseSmlValue
(
TAOS_SML_KV
*
pKV
,
const
char
**
index
,
bool
*
is_last_kv
,
SSmlLinesInfo
*
info
)
{
bool
*
is_last_kv
,
SSmlLinesInfo
*
info
,
bool
isTag
)
{
const
char
*
start
,
*
cur
;
const
char
*
start
,
*
cur
;
char
*
value
=
NULL
;
char
*
value
=
NULL
;
uint16_t
len
=
0
;
uint16_t
len
=
0
;
...
@@ -1855,8 +1898,13 @@ static bool parseSmlValue(TAOS_SML_KV *pKV, const char **index,
...
@@ -1855,8 +1898,13 @@ static bool parseSmlValue(TAOS_SML_KV *pKV, const char **index,
if
((
*
cur
==
','
||
*
cur
==
' '
||
*
cur
==
'\0'
)
&&
*
(
cur
-
1
)
!=
'\\'
)
{
if
((
*
cur
==
','
||
*
cur
==
' '
||
*
cur
==
'\0'
)
&&
*
(
cur
-
1
)
!=
'\\'
)
{
//unescaped ' ' or '\0' indicates end of value
//unescaped ' ' or '\0' indicates end of value
*
is_last_kv
=
(
*
cur
==
' '
||
*
cur
==
'\0'
)
?
true
:
false
;
*
is_last_kv
=
(
*
cur
==
' '
||
*
cur
==
'\0'
)
?
true
:
false
;
if
(
*
cur
==
' '
&&
*
(
cur
+
1
)
==
' '
)
{
cur
++
;
continue
;
}
else
{
break
;
break
;
}
}
}
//Escape special character
//Escape special character
if
(
*
cur
==
'\\'
)
{
if
(
*
cur
==
'\\'
)
{
escapeSpecialCharacter
(
2
,
&
cur
);
escapeSpecialCharacter
(
2
,
&
cur
);
...
@@ -1868,7 +1916,7 @@ static bool parseSmlValue(TAOS_SML_KV *pKV, const char **index,
...
@@ -1868,7 +1916,7 @@ static bool parseSmlValue(TAOS_SML_KV *pKV, const char **index,
value
=
calloc
(
len
+
1
,
1
);
value
=
calloc
(
len
+
1
,
1
);
memcpy
(
value
,
start
,
len
);
memcpy
(
value
,
start
,
len
);
value
[
len
]
=
'\0'
;
value
[
len
]
=
'\0'
;
if
(
!
convertSmlValueType
(
pKV
,
value
,
len
,
info
))
{
if
(
!
convertSmlValueType
(
pKV
,
value
,
len
,
info
,
isTag
))
{
tscError
(
"SML:0x%"
PRIx64
" Failed to convert sml value string(%s) to any type"
,
tscError
(
"SML:0x%"
PRIx64
" Failed to convert sml value string(%s) to any type"
,
info
->
id
,
value
);
info
->
id
,
value
);
//free previous alocated key field
//free previous alocated key field
...
@@ -1913,8 +1961,14 @@ static int32_t parseSmlMeasurement(TAOS_SML_DATA_POINT *pSml, const char **index
...
@@ -1913,8 +1961,14 @@ static int32_t parseSmlMeasurement(TAOS_SML_DATA_POINT *pSml, const char **index
break
;
break
;
}
}
if
(
*
cur
==
' '
&&
*
(
cur
-
1
)
!=
'\\'
)
{
if
(
*
cur
==
' '
&&
*
(
cur
-
1
)
!=
'\\'
)
{
if
(
*
(
cur
+
1
)
!=
' '
)
{
break
;
break
;
}
}
else
{
cur
++
;
continue
;
}
}
//Comma, Space, Backslash needs to be escaped if any
//Comma, Space, Backslash needs to be escaped if any
if
(
*
cur
==
'\\'
)
{
if
(
*
cur
==
'\\'
)
{
escapeSpecialCharacter
(
1
,
&
cur
);
escapeSpecialCharacter
(
1
,
&
cur
);
...
@@ -1974,13 +2028,12 @@ static int32_t parseSmlKvPairs(TAOS_SML_KV **pKVs, int *num_kvs,
...
@@ -1974,13 +2028,12 @@ static int32_t parseSmlKvPairs(TAOS_SML_KV **pKVs, int *num_kvs,
tscError
(
"SML:0x%"
PRIx64
" Unable to parse key"
,
info
->
id
);
tscError
(
"SML:0x%"
PRIx64
" Unable to parse key"
,
info
->
id
);
goto
error
;
goto
error
;
}
}
ret
=
parseSmlValue
(
pkv
,
&
cur
,
&
is_last_kv
,
info
);
ret
=
parseSmlValue
(
pkv
,
&
cur
,
&
is_last_kv
,
info
,
!
isField
);
if
(
ret
)
{
if
(
ret
)
{
tscError
(
"SML:0x%"
PRIx64
" Unable to parse value"
,
info
->
id
);
tscError
(
"SML:0x%"
PRIx64
" Unable to parse value"
,
info
->
id
);
goto
error
;
goto
error
;
}
}
if
(
!
isField
&&
if
(
!
isField
&&
(
strcasecmp
(
pkv
->
key
,
"ID"
)
==
0
))
{
(
strcasecmp
(
pkv
->
key
,
"ID"
)
==
0
)
&&
pkv
->
type
==
TSDB_DATA_TYPE_BINARY
)
{
ret
=
isValidChildTableName
(
pkv
->
value
,
pkv
->
length
,
info
);
ret
=
isValidChildTableName
(
pkv
->
value
,
pkv
->
length
,
info
);
if
(
ret
)
{
if
(
ret
)
{
goto
error
;
goto
error
;
...
@@ -2134,11 +2187,13 @@ int32_t tscParseLines(char* lines[], int numLines, SArray* points, SArray* faile
...
@@ -2134,11 +2187,13 @@ int32_t tscParseLines(char* lines[], int numLines, SArray* points, SArray* faile
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int
taos_insert_lines
(
TAOS
*
taos
,
char
*
lines
[],
int
numLines
)
{
int
taos_insert_lines
(
TAOS
*
taos
,
char
*
lines
[],
int
numLines
,
SMLProtocolType
protocol
,
SMLTimeStampType
tsType
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SSmlLinesInfo
*
info
=
tcalloc
(
1
,
sizeof
(
SSmlLinesInfo
));
SSmlLinesInfo
*
info
=
tcalloc
(
1
,
sizeof
(
SSmlLinesInfo
));
info
->
id
=
genLinesSmlId
();
info
->
id
=
genLinesSmlId
();
info
->
tsType
=
tsType
;
info
->
protocol
=
protocol
;
if
(
numLines
<=
0
||
numLines
>
65536
)
{
if
(
numLines
<=
0
||
numLines
>
65536
)
{
tscError
(
"SML:0x%"
PRIx64
" taos_insert_lines numLines should be between 1 and 65536. numLines: %d"
,
info
->
id
,
numLines
);
tscError
(
"SML:0x%"
PRIx64
" taos_insert_lines numLines should be between 1 and 65536. numLines: %d"
,
info
->
id
,
numLines
);
...
@@ -2191,6 +2246,52 @@ cleanup:
...
@@ -2191,6 +2246,52 @@ cleanup:
return
code
;
return
code
;
}
}
int32_t
convertPrecisionStrType
(
char
*
precision
,
SMLTimeStampType
*
tsType
)
{
if
(
precision
==
NULL
)
{
*
tsType
=
SML_TIME_STAMP_NOT_CONFIGURED
;
return
TSDB_CODE_SUCCESS
;
}
if
(
strcmp
(
precision
,
"μ"
)
==
0
)
{
*
tsType
=
SML_TIME_STAMP_MICRO_SECONDS
;
return
TSDB_CODE_SUCCESS
;
}
int32_t
len
=
(
int32_t
)
strlen
(
precision
);
if
(
len
==
1
)
{
switch
(
precision
[
0
])
{
case
'u'
:
*
tsType
=
SML_TIME_STAMP_MICRO_SECONDS
;
break
;
case
's'
:
*
tsType
=
SML_TIME_STAMP_SECONDS
;
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
;
}
return
TSDB_CODE_SUCCESS
;
}
/**
/**
* 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.
...
@@ -2212,17 +2313,26 @@ cleanup:
...
@@ -2212,17 +2313,26 @@ cleanup:
*
*
*/
*/
int
taos_schemaless_insert
(
TAOS
*
taos
,
char
*
lines
[],
int
numLines
,
int
protocol
)
{
int
taos_schemaless_insert
(
TAOS
*
taos
,
char
*
lines
[],
int
numLines
,
int
protocol
,
char
*
timePrecision
)
{
int
code
;
int
code
;
SMLTimeStampType
tsType
;
if
(
protocol
==
SML_LINE_PROTOCOL
)
{
code
=
convertPrecisionStrType
(
timePrecision
,
&
tsType
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
}
switch
(
protocol
)
{
switch
(
protocol
)
{
case
SML_LINE_PROTOCOL
:
case
SML_LINE_PROTOCOL
:
code
=
taos_insert_lines
(
taos
,
lines
,
numLines
);
code
=
taos_insert_lines
(
taos
,
lines
,
numLines
,
protocol
,
tsType
);
break
;
break
;
case
SML_TELNET_PROTOCOL
:
case
SML_TELNET_PROTOCOL
:
code
=
taos_insert_telnet_lines
(
taos
,
lines
,
numLines
);
code
=
taos_insert_telnet_lines
(
taos
,
lines
,
numLines
,
protocol
,
tsType
);
break
;
break
;
case
SML_JSON_PROTOCOL
:
case
SML_JSON_PROTOCOL
:
code
=
taos_insert_json_payload
(
taos
,
*
lines
);
code
=
taos_insert_json_payload
(
taos
,
*
lines
,
protocol
,
tsType
);
break
;
break
;
default:
default:
code
=
TSDB_CODE_TSC_INVALID_PROTOCOL_TYPE
;
code
=
TSDB_CODE_TSC_INVALID_PROTOCOL_TYPE
;
...
...
src/client/src/tscParseOpenTSDB.c
浏览文件 @
b353b162
...
@@ -55,7 +55,12 @@ static int32_t parseTelnetMetric(TAOS_SML_DATA_POINT *pSml, const char **index,
...
@@ -55,7 +55,12 @@ static int32_t parseTelnetMetric(TAOS_SML_DATA_POINT *pSml, const char **index,
}
}
if
(
*
cur
==
' '
)
{
if
(
*
cur
==
' '
)
{
if
(
*
(
cur
+
1
)
!=
' '
)
{
break
;
break
;
}
else
{
cur
++
;
continue
;
}
}
}
pSml
->
stableName
[
len
]
=
*
cur
;
pSml
->
stableName
[
len
]
=
*
cur
;
...
@@ -91,7 +96,12 @@ static int32_t parseTelnetTimeStamp(TAOS_SML_KV **pTS, int *num_kvs, const char
...
@@ -91,7 +96,12 @@ static int32_t parseTelnetTimeStamp(TAOS_SML_KV **pTS, int *num_kvs, const char
while
(
*
cur
!=
'\0'
)
{
while
(
*
cur
!=
'\0'
)
{
if
(
*
cur
==
' '
)
{
if
(
*
cur
==
' '
)
{
if
(
*
(
cur
+
1
)
!=
' '
)
{
break
;
break
;
}
else
{
cur
++
;
continue
;
}
}
}
cur
++
;
cur
++
;
len
++
;
len
++
;
...
@@ -135,7 +145,14 @@ static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const ch
...
@@ -135,7 +145,14 @@ static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const ch
while
(
*
cur
!=
'\0'
)
{
while
(
*
cur
!=
'\0'
)
{
if
(
*
cur
==
' '
)
{
if
(
*
cur
==
' '
)
{
if
(
*
cur
==
' '
)
{
if
(
*
(
cur
+
1
)
!=
' '
)
{
break
;
break
;
}
else
{
cur
++
;
continue
;
}
}
}
}
cur
++
;
cur
++
;
len
++
;
len
++
;
...
@@ -148,7 +165,7 @@ static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const ch
...
@@ -148,7 +165,7 @@ static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const ch
return
TSDB_CODE_TSC_LINE_SYNTAX_ERROR
;
return
TSDB_CODE_TSC_LINE_SYNTAX_ERROR
;
}
}
if
(
!
convertSmlValueType
(
pVal
,
value
,
len
,
info
))
{
if
(
!
convertSmlValueType
(
pVal
,
value
,
len
,
info
,
false
))
{
tscError
(
"OTD:0x%"
PRIx64
" Failed to convert metric value string(%s) to any type"
,
tscError
(
"OTD:0x%"
PRIx64
" Failed to convert metric value string(%s) to any type"
,
info
->
id
,
value
);
info
->
id
,
value
);
tfree
(
value
);
tfree
(
value
);
...
@@ -219,8 +236,13 @@ static int32_t parseTelnetTagValue(TAOS_SML_KV *pKV, const char **index,
...
@@ -219,8 +236,13 @@ static int32_t parseTelnetTagValue(TAOS_SML_KV *pKV, const char **index,
if
(
*
cur
==
' '
||
*
cur
==
'\0'
)
{
if
(
*
cur
==
' '
||
*
cur
==
'\0'
)
{
// '\0' indicates end of value
// '\0' indicates end of value
*
is_last_kv
=
(
*
cur
==
'\0'
)
?
true
:
false
;
*
is_last_kv
=
(
*
cur
==
'\0'
)
?
true
:
false
;
if
(
*
cur
==
' '
&&
*
(
cur
+
1
)
==
' '
)
{
cur
++
;
continue
;
}
else
{
break
;
break
;
}
}
}
cur
++
;
cur
++
;
len
++
;
len
++
;
}
}
...
@@ -233,7 +255,7 @@ static int32_t parseTelnetTagValue(TAOS_SML_KV *pKV, const char **index,
...
@@ -233,7 +255,7 @@ static int32_t parseTelnetTagValue(TAOS_SML_KV *pKV, const char **index,
value
=
tcalloc
(
len
+
1
,
1
);
value
=
tcalloc
(
len
+
1
,
1
);
memcpy
(
value
,
start
,
len
);
memcpy
(
value
,
start
,
len
);
value
[
len
]
=
'\0'
;
value
[
len
]
=
'\0'
;
if
(
!
convertSmlValueType
(
pKV
,
value
,
len
,
info
))
{
if
(
!
convertSmlValueType
(
pKV
,
value
,
len
,
info
,
true
))
{
tscError
(
"OTD:0x%"
PRIx64
" Failed to convert sml value string(%s) to any type"
,
tscError
(
"OTD:0x%"
PRIx64
" Failed to convert sml value string(%s) to any type"
,
info
->
id
,
value
);
info
->
id
,
value
);
//free previous alocated key field
//free previous alocated key field
...
@@ -270,7 +292,7 @@ static int32_t parseTelnetTagKvs(TAOS_SML_KV **pKVs, int *num_kvs,
...
@@ -270,7 +292,7 @@ static int32_t parseTelnetTagKvs(TAOS_SML_KV **pKVs, int *num_kvs,
tscError
(
"OTD:0x%"
PRIx64
" Unable to parse value"
,
info
->
id
);
tscError
(
"OTD:0x%"
PRIx64
" Unable to parse value"
,
info
->
id
);
return
ret
;
return
ret
;
}
}
if
((
strcasecmp
(
pkv
->
key
,
"ID"
)
==
0
)
&&
pkv
->
type
==
TSDB_DATA_TYPE_BINARY
)
{
if
((
strcasecmp
(
pkv
->
key
,
"ID"
)
==
0
))
{
ret
=
isValidChildTableName
(
pkv
->
value
,
pkv
->
length
,
info
);
ret
=
isValidChildTableName
(
pkv
->
value
,
pkv
->
length
,
info
);
if
(
ret
)
{
if
(
ret
)
{
return
ret
;
return
ret
;
...
@@ -367,11 +389,13 @@ static int32_t tscParseTelnetLines(char* lines[], int numLines, SArray* points,
...
@@ -367,11 +389,13 @@ 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
)
{
int
taos_insert_telnet_lines
(
TAOS
*
taos
,
char
*
lines
[],
int
numLines
,
SMLProtocolType
protocol
,
SMLTimeStampType
tsType
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SSmlLinesInfo
*
info
=
tcalloc
(
1
,
sizeof
(
SSmlLinesInfo
));
SSmlLinesInfo
*
info
=
tcalloc
(
1
,
sizeof
(
SSmlLinesInfo
));
info
->
id
=
genUID
();
info
->
id
=
genUID
();
info
->
tsType
=
tsType
;
info
->
protocol
=
protocol
;
if
(
numLines
<=
0
||
numLines
>
65536
)
{
if
(
numLines
<=
0
||
numLines
>
65536
)
{
tscError
(
"OTD:0x%"
PRIx64
" taos_insert_telnet_lines numLines should be between 1 and 65536. numLines: %d"
,
info
->
id
,
numLines
);
tscError
(
"OTD:0x%"
PRIx64
" taos_insert_telnet_lines numLines should be between 1 and 65536. numLines: %d"
,
info
->
id
,
numLines
);
...
@@ -529,7 +553,14 @@ static int32_t parseTimestampFromJSON(cJSON *root, TAOS_SML_KV **pTS, int *num_k
...
@@ -529,7 +553,14 @@ static int32_t parseTimestampFromJSON(cJSON *root, TAOS_SML_KV **pTS, int *num_k
tsVal
=
taosGetTimestampNs
();
tsVal
=
taosGetTimestampNs
();
}
else
{
}
else
{
tsVal
=
strtoll
(
timestamp
->
numberstring
,
NULL
,
10
);
tsVal
=
strtoll
(
timestamp
->
numberstring
,
NULL
,
10
);
tsVal
=
convertTimePrecision
(
tsVal
,
TSDB_TIME_PRECISION_MICRO
,
TSDB_TIME_PRECISION_NANO
);
size_t
tsLen
=
strlen
(
timestamp
->
numberstring
);
if
(
tsLen
==
SML_TIMESTAMP_SECOND_DIGITS
)
{
tsVal
=
(
int64_t
)(
tsVal
*
1e9
);
}
else
if
(
tsLen
==
SML_TIMESTAMP_MILLI_SECOND_DIGITS
)
{
tsVal
=
convertTimePrecision
(
tsVal
,
TSDB_TIME_PRECISION_MILLI
,
TSDB_TIME_PRECISION_NANO
);
}
else
{
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
}
}
}
}
else
if
(
cJSON_IsObject
(
timestamp
))
{
}
else
if
(
cJSON_IsObject
(
timestamp
))
{
int32_t
ret
=
parseTimestampFromJSONObj
(
timestamp
,
&
tsVal
,
info
);
int32_t
ret
=
parseTimestampFromJSONObj
(
timestamp
,
&
tsVal
,
info
);
...
@@ -738,28 +769,35 @@ static int32_t parseValueFromJSON(cJSON *root, TAOS_SML_KV *pVal, SSmlLinesInfo*
...
@@ -738,28 +769,35 @@ static int32_t parseValueFromJSON(cJSON *root, TAOS_SML_KV *pVal, SSmlLinesInfo*
}
}
case
cJSON_Number
:
{
case
cJSON_Number
:
{
//convert default JSON Number type to BIGINT/DOUBLE
//convert default JSON Number type to BIGINT/DOUBLE
if
(
isValidInteger
(
root
->
numberstring
))
{
//if (isValidInteger(root->numberstring)) {
pVal
->
type
=
TSDB_DATA_TYPE_BIGINT
;
// pVal->type = TSDB_DATA_TYPE_BIGINT;
pVal
->
length
=
(
int16_t
)
tDataTypes
[
pVal
->
type
].
bytes
;
// pVal->length = (int16_t)tDataTypes[pVal->type].bytes;
pVal
->
value
=
tcalloc
(
pVal
->
length
,
1
);
// pVal->value = tcalloc(pVal->length, 1);
/* cJSON conversion of legit BIGINT may overflow,
// /* cJSON conversion of legit BIGINT may overflow,
* use original string to do the conversion.
// * use original string to do the conversion.
*/
// */
errno
=
0
;
// errno = 0;
int64_t
val
=
(
int64_t
)
strtoll
(
root
->
numberstring
,
NULL
,
10
);
// int64_t val = (int64_t)strtoll(root->numberstring, NULL, 10);
if
(
errno
==
ERANGE
||
!
IS_VALID_BIGINT
(
val
))
{
// if (errno == ERANGE || !IS_VALID_BIGINT(val)) {
tscError
(
"OTD:0x%"
PRIx64
" JSON value(%s) cannot fit in type(bigint)"
,
info
->
id
,
root
->
numberstring
);
// tscError("OTD:0x%"PRIx64" JSON value(%s) cannot fit in type(bigint)", info->id, root->numberstring);
return
TSDB_CODE_TSC_VALUE_OUT_OF_RANGE
;
// return TSDB_CODE_TSC_VALUE_OUT_OF_RANGE;
}
// }
*
(
int64_t
*
)(
pVal
->
value
)
=
val
;
// *(int64_t *)(pVal->value) = val;
}
else
if
(
isValidFloat
(
root
->
numberstring
))
{
//} else if (isValidFloat(root->numberstring)) {
// pVal->type = TSDB_DATA_TYPE_DOUBLE;
// pVal->length = (int16_t)tDataTypes[pVal->type].bytes;
// pVal->value = tcalloc(pVal->length, 1);
// *(double *)(pVal->value) = (double)(root->valuedouble);
//} else {
// return TSDB_CODE_TSC_INVALID_JSON_TYPE;
//}
if
(
isValidInteger
(
root
->
numberstring
)
||
isValidFloat
(
root
->
numberstring
))
{
pVal
->
type
=
TSDB_DATA_TYPE_DOUBLE
;
pVal
->
type
=
TSDB_DATA_TYPE_DOUBLE
;
pVal
->
length
=
(
int16_t
)
tDataTypes
[
pVal
->
type
].
bytes
;
pVal
->
length
=
(
int16_t
)
tDataTypes
[
pVal
->
type
].
bytes
;
pVal
->
value
=
tcalloc
(
pVal
->
length
,
1
);
pVal
->
value
=
tcalloc
(
pVal
->
length
,
1
);
*
(
double
*
)(
pVal
->
value
)
=
(
double
)(
root
->
valuedouble
);
*
(
double
*
)(
pVal
->
value
)
=
(
double
)(
root
->
valuedouble
);
}
else
{
return
TSDB_CODE_TSC_INVALID_JSON_TYPE
;
}
}
break
;
break
;
}
}
case
cJSON_String
:
{
case
cJSON_String
:
{
...
@@ -831,6 +869,10 @@ static int32_t parseTagsFromJSON(cJSON *root, TAOS_SML_KV **pKVs, int *num_kvs,
...
@@ -831,6 +869,10 @@ static int32_t parseTagsFromJSON(cJSON *root, TAOS_SML_KV **pKVs, int *num_kvs,
//only pick up the first ID value as child table name
//only pick up the first ID value as child table name
cJSON
*
id
=
cJSON_GetObjectItem
(
tags
,
"ID"
);
cJSON
*
id
=
cJSON_GetObjectItem
(
tags
,
"ID"
);
if
(
id
!=
NULL
)
{
if
(
id
!=
NULL
)
{
if
(
!
cJSON_IsString
(
id
))
{
tscError
(
"OTD:0x%"
PRIx64
" ID must be JSON string"
,
info
->
id
);
return
TSDB_CODE_TSC_INVALID_JSON
;
}
size_t
idLen
=
strlen
(
id
->
valuestring
);
size_t
idLen
=
strlen
(
id
->
valuestring
);
ret
=
isValidChildTableName
(
id
->
valuestring
,
(
int16_t
)
idLen
,
info
);
ret
=
isValidChildTableName
(
id
->
valuestring
,
(
int16_t
)
idLen
,
info
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
...
@@ -965,7 +1007,7 @@ static int32_t tscParseMultiJSONPayload(char* payload, SArray* points, SSmlLines
...
@@ -965,7 +1007,7 @@ static int32_t tscParseMultiJSONPayload(char* payload, SArray* points, SSmlLines
for
(
int32_t
i
=
0
;
i
<
payloadNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
payloadNum
;
++
i
)
{
TAOS_SML_DATA_POINT
point
=
{
0
};
TAOS_SML_DATA_POINT
point
=
{
0
};
cJSON
*
dataPoint
=
(
payloadNum
==
1
)
?
root
:
cJSON_GetArrayItem
(
root
,
i
);
cJSON
*
dataPoint
=
(
payloadNum
==
1
&&
cJSON_IsObject
(
root
)
)
?
root
:
cJSON_GetArrayItem
(
root
,
i
);
ret
=
tscParseJSONPayload
(
dataPoint
,
&
point
,
info
);
ret
=
tscParseJSONPayload
(
dataPoint
,
&
point
,
info
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
...
@@ -983,11 +1025,13 @@ PARSE_JSON_OVER:
...
@@ -983,11 +1025,13 @@ PARSE_JSON_OVER:
return
ret
;
return
ret
;
}
}
int
taos_insert_json_payload
(
TAOS
*
taos
,
char
*
payload
)
{
int
taos_insert_json_payload
(
TAOS
*
taos
,
char
*
payload
,
SMLProtocolType
protocol
,
SMLTimeStampType
tsType
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SSmlLinesInfo
*
info
=
tcalloc
(
1
,
sizeof
(
SSmlLinesInfo
));
SSmlLinesInfo
*
info
=
tcalloc
(
1
,
sizeof
(
SSmlLinesInfo
));
info
->
id
=
genUID
();
info
->
id
=
genUID
();
info
->
tsType
=
tsType
;
info
->
protocol
=
protocol
;
if
(
payload
==
NULL
)
{
if
(
payload
==
NULL
)
{
tscError
(
"OTD:0x%"
PRIx64
" taos_insert_json_payload payload is NULL"
,
info
->
id
);
tscError
(
"OTD:0x%"
PRIx64
" taos_insert_json_payload payload is NULL"
,
info
->
id
);
...
...
src/connector/python/README.md
浏览文件 @
b353b162
...
@@ -401,16 +401,16 @@ conn.select_db(dbname)
...
@@ -401,16 +401,16 @@ conn.select_db(dbname)
lines
=
[
lines
=
[
'st,t1=3i64,t2=4f64,t3="t3" c1=3i64,c3=L"pass",c2=false,c4=4f64 1626006833639000000ns'
,
'st,t1=3i64,t2=4f64,t3="t3" c1=3i64,c3=L"pass",c2=false,c4=4f64 1626006833639000000ns'
,
'st,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"pass it again",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000
ns
'
,
'st,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"pass it again",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000'
,
'stf,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"pass it again_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000
ns
'
,
'stf,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"pass it again_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000'
,
]
]
conn
.
schemaless_insert
(
lines
,
0
)
conn
.
schemaless_insert
(
lines
,
0
,
"ns"
)
print
(
"inserted"
)
print
(
"inserted"
)
lines
=
[
lines
=
[
'stf,t1=5i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"pass it again_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000
ns
'
,
'stf,t1=5i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"pass it again_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000'
,
]
]
conn
.
schemaless_insert
(
lines
,
0
)
conn
.
schemaless_insert
(
lines
,
0
,
"ns"
)
result
=
conn
.
query
(
"show tables"
)
result
=
conn
.
query
(
"show tables"
)
for
row
in
result
:
for
row
in
result
:
...
...
src/connector/python/examples/insert-lines.py
浏览文件 @
b353b162
...
@@ -7,12 +7,12 @@ conn.execute("create database if not exists %s precision 'us'" % dbname)
...
@@ -7,12 +7,12 @@ conn.execute("create database if not exists %s precision 'us'" % dbname)
conn
.
select_db
(
dbname
)
conn
.
select_db
(
dbname
)
lines
=
[
lines
=
[
'st,t1=3i64,t2=4f64,t3="t3" c1=3i64,c3=L"pass",c2=false,c4=4f64 1626006833639000000
ns
'
,
'st,t1=3i64,t2=4f64,t3="t3" c1=3i64,c3=L"pass",c2=false,c4=4f64 1626006833639000000'
,
]
]
conn
.
schemaless_insert
(
lines
,
0
)
conn
.
schemaless_insert
(
lines
,
0
,
"ns"
)
print
(
"inserted"
)
print
(
"inserted"
)
conn
.
schemaless_insert
(
lines
,
0
)
conn
.
schemaless_insert
(
lines
,
0
,
"ns"
)
result
=
conn
.
query
(
"show tables"
)
result
=
conn
.
query
(
"show tables"
)
for
row
in
result
:
for
row
in
result
:
...
...
src/connector/python/taos/__init__.py
浏览文件 @
b353b162
...
@@ -402,17 +402,17 @@ conn.exec("create database if not exists %s precision 'us'" % dbname)
...
@@ -402,17 +402,17 @@ conn.exec("create database if not exists %s precision 'us'" % dbname)
conn.select_db(dbname)
conn.select_db(dbname)
lines = [
lines = [
'st,t1=3i64,t2=4f64,t3="t3" c1=3i64,c3=L"passit",c2=false,c4=4f64 1626006833639000000
ns
',
'st,t1=3i64,t2=4f64,t3="t3" c1=3i64,c3=L"passit",c2=false,c4=4f64 1626006833639000000',
'st,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000
ns
',
'st,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000',
'stf,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000
ns
',
'stf,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000',
]
]
conn.schemaless_insert(lines, 0)
conn.schemaless_insert(lines, 0
, "ns"
)
print("inserted")
print("inserted")
lines = [
lines = [
'stf,t1=5i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000
ns
',
'stf,t1=5i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000',
]
]
conn.schemaless_insert(lines, 0)
conn.schemaless_insert(lines, 0
, "ns"
)
result = conn.query("show tables")
result = conn.query("show tables")
for row in result:
for row in result:
...
...
src/connector/python/taos/cinterface.py
浏览文件 @
b353b162
...
@@ -817,13 +817,15 @@ except AttributeError:
...
@@ -817,13 +817,15 @@ except AttributeError:
def
taos_schemaless_insert
(
connection
,
lines
,
protocol
):
def
taos_schemaless_insert
(
connection
,
lines
,
protocol
,
precision
):
# type: (c_void_p, list[str] | tuple(str)) -> None
# type: (c_void_p, list[str] | tuple(str)) -> None
num_of_lines
=
len
(
lines
)
num_of_lines
=
len
(
lines
)
lines
=
(
c_char_p
(
line
.
encode
(
"utf-8"
))
for
line
in
lines
)
lines
=
(
c_char_p
(
line
.
encode
(
"utf-8"
))
for
line
in
lines
)
lines_type
=
ctypes
.
c_char_p
*
num_of_lines
lines_type
=
ctypes
.
c_char_p
*
num_of_lines
p_lines
=
lines_type
(
*
lines
)
p_lines
=
lines_type
(
*
lines
)
errno
=
_libtaos
.
taos_schemaless_insert
(
connection
,
p_lines
,
num_of_lines
,
protocol
)
if
precision
!=
None
:
precision
=
c_char_p
(
precision
.
encode
(
"utf-8"
))
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
)
raise
SchemalessError
(
"schemaless insert error"
,
errno
)
...
...
src/connector/python/taos/connection.py
浏览文件 @
b353b162
...
@@ -117,7 +117,7 @@ class TaosConnection(object):
...
@@ -117,7 +117,7 @@ class TaosConnection(object):
stream
=
taos_open_stream
(
self
.
_conn
,
sql
,
callback
,
stime
,
param
,
callback2
)
stream
=
taos_open_stream
(
self
.
_conn
,
sql
,
callback
,
stime
,
param
,
callback2
)
return
TaosStream
(
stream
)
return
TaosStream
(
stream
)
def
schemaless_insert
(
self
,
lines
,
protocol
):
def
schemaless_insert
(
self
,
lines
,
protocol
,
precision
):
# type: (list[str]) -> None
# type: (list[str]) -> None
"""
"""
1.Line protocol and schemaless support
1.Line protocol and schemaless support
...
@@ -132,7 +132,7 @@ class TaosConnection(object):
...
@@ -132,7 +132,7 @@ class TaosConnection(object):
lines = [
lines = [
'ste,t2=5,t3=L"ste" c1=true,c2=4,c3="string" 1626056811855516532',
'ste,t2=5,t3=L"ste" c1=true,c2=4,c3="string" 1626056811855516532',
]
]
conn.schemaless_insert(lines, 0)
conn.schemaless_insert(lines, 0
, "ns"
)
```
```
2.OpenTSDB telnet style API format support
2.OpenTSDB telnet style API format support
...
@@ -145,7 +145,7 @@ class TaosConnection(object):
...
@@ -145,7 +145,7 @@ class TaosConnection(object):
lines = [
lines = [
'cpu_load 1626056811855516532ns 2.0f32 id="tb1",host="host0",interface="eth0"',
'cpu_load 1626056811855516532ns 2.0f32 id="tb1",host="host0",interface="eth0"',
]
]
conn.schemaless_insert(lines, 1)
conn.schemaless_insert(lines, 1
, None
)
3.OpenTSDB HTTP JSON format support
3.OpenTSDB HTTP JSON format support
...
@@ -168,10 +168,10 @@ class TaosConnection(object):
...
@@ -168,10 +168,10 @@ class TaosConnection(object):
}
}
}
}
''']
''']
conn.schemaless_insert(lines, 2)
conn.schemaless_insert(lines, 2
, None
)
"""
"""
return
taos_schemaless_insert
(
self
.
_conn
,
lines
,
protocol
)
return
taos_schemaless_insert
(
self
.
_conn
,
lines
,
protocol
,
precision
)
def
cursor
(
self
):
def
cursor
(
self
):
...
...
src/connector/python/tests/test_lines.py
浏览文件 @
b353b162
...
@@ -23,17 +23,17 @@ def test_schemaless_insert(conn):
...
@@ -23,17 +23,17 @@ def test_schemaless_insert(conn):
conn
.
select_db
(
dbname
)
conn
.
select_db
(
dbname
)
lines
=
[
lines
=
[
'st,t1=3i64,t2=4f64,t3="t3" c1=3i64,c3=L"passit",c2=false,c4=4f64 1626006833639000000
ns
'
,
'st,t1=3i64,t2=4f64,t3="t3" c1=3i64,c3=L"passit",c2=false,c4=4f64 1626006833639000000'
,
'st,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000
ns
'
,
'st,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000'
,
'stf,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000
ns
'
,
'stf,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000'
,
]
]
conn
.
schemaless_insert
(
lines
,
0
)
conn
.
schemaless_insert
(
lines
,
0
,
"ns"
)
print
(
"inserted"
)
print
(
"inserted"
)
lines
=
[
lines
=
[
'stf,t1=5i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000
ns
'
,
'stf,t1=5i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000'
,
]
]
conn
.
schemaless_insert
(
lines
,
0
)
conn
.
schemaless_insert
(
lines
,
0
,
"ns"
)
print
(
"inserted"
)
print
(
"inserted"
)
result
=
conn
.
query
(
"select * from st"
)
result
=
conn
.
query
(
"select * from st"
)
print
(
*
result
.
fields
)
print
(
*
result
.
fields
)
...
...
src/inc/taos.h
浏览文件 @
b353b162
...
@@ -187,7 +187,7 @@ DLL_EXPORT void taos_close_stream(TAOS_STREAM *tstr);
...
@@ -187,7 +187,7 @@ DLL_EXPORT void taos_close_stream(TAOS_STREAM *tstr);
DLL_EXPORT
int
taos_load_table_info
(
TAOS
*
taos
,
const
char
*
tableNameList
);
DLL_EXPORT
int
taos_load_table_info
(
TAOS
*
taos
,
const
char
*
tableNameList
);
DLL_EXPORT
int
taos_schemaless_insert
(
TAOS
*
taos
,
char
*
lines
[],
int
numLines
,
int
protocol
);
DLL_EXPORT
int
taos_schemaless_insert
(
TAOS
*
taos
,
char
*
lines
[],
int
numLines
,
int
protocol
,
char
*
precision
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
src/inc/taoserror.h
浏览文件 @
b353b162
...
@@ -113,6 +113,7 @@ int32_t* taosGetErrno();
...
@@ -113,6 +113,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_TSC_INVALID_JSON_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0223) //"Invalid JSON configuration")
#define TSDB_CODE_TSC_INVALID_JSON_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0223) //"Invalid JSON configuration")
#define TSDB_CODE_TSC_VALUE_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x0224) //"Value out of range")
#define TSDB_CODE_TSC_VALUE_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x0224) //"Value out of range")
#define TSDB_CODE_TSC_INVALID_PROTOCOL_TYPE TAOS_DEF_ERROR_CODE(0, 0x0225) //"Invalid line protocol type")
#define TSDB_CODE_TSC_INVALID_PROTOCOL_TYPE TAOS_DEF_ERROR_CODE(0, 0x0225) //"Invalid line protocol type")
#define TSDB_CODE_TSC_INVALID_PRECISION_TYPE TAOS_DEF_ERROR_CODE(0, 0x0226) //"Invalid timestamp precision type")
// mnode
// mnode
#define TSDB_CODE_MND_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0300) //"Message not processed")
#define TSDB_CODE_MND_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0300) //"Message not processed")
...
...
src/util/src/terror.c
浏览文件 @
b353b162
...
@@ -121,6 +121,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_JSON_TYPE, "Invalid JSON data typ
...
@@ -121,6 +121,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_JSON_TYPE, "Invalid JSON data typ
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_INVALID_JSON_CONFIG
,
"Invalid JSON configuration"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_INVALID_JSON_CONFIG
,
"Invalid JSON configuration"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_VALUE_OUT_OF_RANGE
,
"Value out of range"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_VALUE_OUT_OF_RANGE
,
"Value out of range"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_INVALID_PROTOCOL_TYPE
,
"Invalid line protocol type"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_INVALID_PROTOCOL_TYPE
,
"Invalid line protocol type"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_INVALID_PRECISION_TYPE
,
"Invalid timestamp precision type"
)
// mnode
// mnode
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_MSG_NOT_PROCESSED
,
"Message not processed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_MSG_NOT_PROCESSED
,
"Message not processed"
)
...
...
tests/examples/c/apitest.c
浏览文件 @
b353b162
...
@@ -969,51 +969,51 @@ int32_t verify_schema_less(TAOS* taos) {
...
@@ -969,51 +969,51 @@ int32_t verify_schema_less(TAOS* taos) {
int
code
=
0
;
int
code
=
0
;
char
*
lines
[]
=
{
char
*
lines
[]
=
{
"st,t1=3i64,t2=4f64,t3=
\"
t3
\"
c1=3i64,c3=L
\"
passit
\"
,c2=false,c4=4f64 1626006833639000000
ns
"
,
"st,t1=3i64,t2=4f64,t3=
\"
t3
\"
c1=3i64,c3=L
\"
passit
\"
,c2=false,c4=4f64 1626006833639000000"
,
"st,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64 1626006833640000000
ns
"
,
"st,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64 1626006833640000000"
,
"ste,t2=5f64,t3=L
\"
ste
\"
c1=true,c2=4i64,c3=
\"
iam
\"
1626056811823316532
ns
"
,
"ste,t2=5f64,t3=L
\"
ste
\"
c1=true,c2=4i64,c3=
\"
iam
\"
1626056811823316532"
,
"st,t1=4i64,t2=5f64,t3=
\"
t4
\"
c1=3i64,c3=L
\"
passitagain
\"
,c2=true,c4=5f64 1626006833642000000
ns
"
,
"st,t1=4i64,t2=5f64,t3=
\"
t4
\"
c1=3i64,c3=L
\"
passitagain
\"
,c2=true,c4=5f64 1626006833642000000"
,
"ste,t2=5f64,t3=L
\"
ste2
\"
c3=
\"
iamszhou
\"
,c4=false 1626056811843316532
ns
"
,
"ste,t2=5f64,t3=L
\"
ste2
\"
c3=
\"
iamszhou
\"
,c4=false 1626056811843316532"
,
"ste,t2=5f64,t3=L
\"
ste2
\"
c3=
\"
iamszhou
\"
,c4=false,c5=32i8,c6=64i16,c7=32i32,c8=88.88f32 1626056812843316532
ns
"
,
"ste,t2=5f64,t3=L
\"
ste2
\"
c3=
\"
iamszhou
\"
,c4=false,c5=32i8,c6=64i16,c7=32i32,c8=88.88f32 1626056812843316532"
,
"st,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000
ns
"
,
"st,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000"
,
"stf,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000
ns
"
,
"stf,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000"
,
"stf,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin_stf
\"
,c2=false,c5=5f64,c6=7u64 1626006933641000000
ns
"
"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
);
code
=
taos_schemaless_insert
(
taos
,
lines
,
sizeof
(
lines
)
/
sizeof
(
char
*
),
0
,
"ns"
);
char
*
lines2
[]
=
{
char
*
lines2
[]
=
{
"stg,t1=3i64,t2=4f64,t3=
\"
t3
\"
c1=3i64,c3=L
\"
passit
\"
,c2=false,c4=4f64 1626006833639000000
ns
"
,
"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 162600683364
0000000ns
"
"stg,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64 162600683364
1000000
"
};
};
code
=
taos_schemaless_insert
(
taos
,
&
lines2
[
0
],
1
,
0
);
code
=
taos_schemaless_insert
(
taos
,
&
lines2
[
0
],
1
,
0
,
"ns"
);
code
=
taos_schemaless_insert
(
taos
,
&
lines2
[
1
],
1
,
0
);
code
=
taos_schemaless_insert
(
taos
,
&
lines2
[
1
],
1
,
0
,
"ns"
);
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 1626006933641
"
,
"sth,t1=4i64,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin_stf
\"
,c2=false,c5=5f64,c6=7u64 1626006933654
ms
"
"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
);
code
=
taos_schemaless_insert
(
taos
,
lines3
,
2
,
0
,
"ms"
);
char
*
lines4
[]
=
{
char
*
lines4
[]
=
{
"st123456,t1=3i64,t2=4f64,t3=
\"
t3
\"
c1=3i64,c3=L
\"
passit
\"
,c2=false,c4=4f64 1626006833639000000
ns
"
,
"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
ns
"
"dgtyqodr,t2=5f64,t3=L
\"
ste
\"
c1=tRue,c2=4i64,c3=
\"
iam
\"
1626056811823316532"
};
};
code
=
taos_schemaless_insert
(
taos
,
lines4
,
2
,
0
);
code
=
taos_schemaless_insert
(
taos
,
lines4
,
2
,
0
,
"ns"
);
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
ns
"
,
"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
ns
"
"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
);
code
=
taos_schemaless_insert
(
taos
,
&
lines5
[
0
],
1
,
0
,
"ns"
);
code
=
taos_schemaless_insert
(
taos
,
&
lines5
[
1
],
1
,
0
);
code
=
taos_schemaless_insert
(
taos
,
&
lines5
[
1
],
1
,
0
,
"ns"
);
char
*
lines6
[]
=
{
char
*
lines6
[]
=
{
"st123456,t1=3i64,t2=4f64,t3=
\"
t3
\"
c1=3i64,c3=L
\"
passit
\"
,c2=false,c4=4f64 1626006833639000000
ns
"
,
"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
ns
"
"dgtyqodr,t2=5f64,t3=L
\"
ste
\"
c1=tRue,c2=4i64,c3=
\"
iam
\"
1626056811823316532"
};
};
code
=
taos_schemaless_insert
(
taos
,
lines6
,
2
,
0
);
code
=
taos_schemaless_insert
(
taos
,
lines6
,
2
,
0
,
"ns"
);
return
(
code
);
return
(
code
);
}
}
...
...
tests/examples/c/schemaless.c
浏览文件 @
b353b162
...
@@ -79,7 +79,7 @@ int main(int argc, char* argv[]) {
...
@@ -79,7 +79,7 @@ int main(int argc, char* argv[]) {
printf
(
"%s
\n
"
,
"begin taos_schemaless_insert"
);
printf
(
"%s
\n
"
,
"begin taos_schemaless_insert"
);
int64_t
begin
=
getTimeInUs
();
int64_t
begin
=
getTimeInUs
();
int32_t
code
=
taos_schemaless_insert
(
taos
,
lines
,
numSuperTables
*
numChildTables
*
numRowsPerChildTable
,
0
);
int32_t
code
=
taos_schemaless_insert
(
taos
,
lines
,
numSuperTables
*
numChildTables
*
numRowsPerChildTable
,
0
,
"ms"
);
int64_t
end
=
getTimeInUs
();
int64_t
end
=
getTimeInUs
();
printf
(
"code: %d, %s. time used: %"
PRId64
"
\n
"
,
code
,
tstrerror
(
code
),
end
-
begin
);
printf
(
"code: %d, %s. time used: %"
PRId64
"
\n
"
,
code
,
tstrerror
(
code
),
end
-
begin
);
...
...
tests/pytest/insert/insertJSONPayload.py
浏览文件 @
b353b162
...
@@ -36,7 +36,7 @@ class TDTestCase:
...
@@ -36,7 +36,7 @@ class TDTestCase:
payload
=
[
'''
payload
=
[
'''
{
{
"metric": "`.stb.0.`",
"metric": "`.stb.0.`",
"timestamp": 1626006833610
123
,
"timestamp": 1626006833610,
"value": 10,
"value": 10,
"tags": {
"tags": {
"t1": true,
"t1": true,
...
@@ -46,7 +46,7 @@ class TDTestCase:
...
@@ -46,7 +46,7 @@ class TDTestCase:
}
}
}
}
'''
]
'''
]
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
)
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
tdSql
.
query
(
"describe `.stb.0.`"
)
tdSql
.
query
(
"describe `.stb.0.`"
)
...
@@ -57,7 +57,7 @@ class TDTestCase:
...
@@ -57,7 +57,7 @@ class TDTestCase:
payload
=
[
'''
payload
=
[
'''
{
{
"metric": "stb0_0",
"metric": "stb0_0",
"timestamp": 1626006833610
123
,
"timestamp": 1626006833610,
"value": 10,
"value": 10,
"tags": {
"tags": {
"t1": true,
"t1": true,
...
@@ -67,16 +67,16 @@ class TDTestCase:
...
@@ -67,16 +67,16 @@ class TDTestCase:
}
}
}
}
'''
]
'''
]
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
)
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
tdSql
.
query
(
"describe stb0_0"
)
tdSql
.
query
(
"describe stb0_0"
)
tdSql
.
checkData
(
1
,
1
,
"
BIGINT
"
)
tdSql
.
checkData
(
1
,
1
,
"
DOUBLE
"
)
payload
=
[
'''
payload
=
[
'''
{
{
"metric": "stb0_1",
"metric": "stb0_1",
"timestamp": 1626006833610
123
,
"timestamp": 1626006833610,
"value": true,
"value": true,
"tags": {
"tags": {
"t1": true,
"t1": true,
...
@@ -86,7 +86,7 @@ class TDTestCase:
...
@@ -86,7 +86,7 @@ class TDTestCase:
}
}
}
}
'''
]
'''
]
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
)
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
tdSql
.
query
(
"describe stb0_1"
)
tdSql
.
query
(
"describe stb0_1"
)
...
@@ -95,7 +95,7 @@ class TDTestCase:
...
@@ -95,7 +95,7 @@ class TDTestCase:
payload
=
[
'''
payload
=
[
'''
{
{
"metric": "stb0_2",
"metric": "stb0_2",
"timestamp": 1626006833610
123
,
"timestamp": 1626006833610,
"value": false,
"value": false,
"tags": {
"tags": {
"t1": true,
"t1": true,
...
@@ -105,7 +105,7 @@ class TDTestCase:
...
@@ -105,7 +105,7 @@ class TDTestCase:
}
}
}
}
'''
]
'''
]
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
)
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
tdSql
.
query
(
"describe stb0_2"
)
tdSql
.
query
(
"describe stb0_2"
)
...
@@ -114,7 +114,7 @@ class TDTestCase:
...
@@ -114,7 +114,7 @@ class TDTestCase:
payload
=
[
'''
payload
=
[
'''
{
{
"metric": "stb0_3",
"metric": "stb0_3",
"timestamp": 1626006833610
123
,
"timestamp": 1626006833610,
"value": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>",
"value": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>",
"tags": {
"tags": {
"t1": true,
"t1": true,
...
@@ -124,7 +124,7 @@ class TDTestCase:
...
@@ -124,7 +124,7 @@ class TDTestCase:
}
}
}
}
'''
]
'''
]
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
)
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
tdSql
.
query
(
"describe stb0_3"
)
tdSql
.
query
(
"describe stb0_3"
)
...
@@ -133,7 +133,7 @@ class TDTestCase:
...
@@ -133,7 +133,7 @@ class TDTestCase:
payload
=
[
'''
payload
=
[
'''
{
{
"metric": "stb0_4",
"metric": "stb0_4",
"timestamp": 1626006833610
123
,
"timestamp": 1626006833610,
"value": 3.14,
"value": 3.14,
"tags": {
"tags": {
"t1": true,
"t1": true,
...
@@ -143,7 +143,7 @@ class TDTestCase:
...
@@ -143,7 +143,7 @@ class TDTestCase:
}
}
}
}
'''
]
'''
]
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
)
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
tdSql
.
query
(
"describe stb0_4"
)
tdSql
.
query
(
"describe stb0_4"
)
...
@@ -152,7 +152,7 @@ class TDTestCase:
...
@@ -152,7 +152,7 @@ class TDTestCase:
payload
=
[
'''
payload
=
[
'''
{
{
"metric": "stb0_5",
"metric": "stb0_5",
"timestamp": 1626006833610
123
,
"timestamp": 1626006833610,
"value": 3.14E-2,
"value": 3.14E-2,
"tags": {
"tags": {
"t1": true,
"t1": true,
...
@@ -162,7 +162,7 @@ class TDTestCase:
...
@@ -162,7 +162,7 @@ class TDTestCase:
}
}
}
}
'''
]
'''
]
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
)
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
tdSql
.
query
(
"describe stb0_5"
)
tdSql
.
query
(
"describe stb0_5"
)
...
@@ -184,9 +184,25 @@ class TDTestCase:
...
@@ -184,9 +184,25 @@ class TDTestCase:
}
}
}
}
'''
]
'''
]
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
)
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
### timestamp 10 digits second ###
payload
=
[
'''
{
"metric": "stb0_7",
"timestamp": 1626006833,
"value": 123,
"tags": {
"t1": true,
"t2": false,
"t3": 10,
"t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
}
}
'''
]
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"============= step3 : test tags ================"
)
print
(
"============= step3 : test tags ================"
)
### Default tag numeric types ###
### Default tag numeric types ###
...
@@ -200,11 +216,11 @@ class TDTestCase:
...
@@ -200,11 +216,11 @@ class TDTestCase:
}
}
}
}
'''
]
'''
]
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
)
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
tdSql
.
query
(
"describe stb0_8"
)
tdSql
.
query
(
"describe stb0_8"
)
tdSql
.
checkData
(
2
,
1
,
"
BIGINT
"
)
tdSql
.
checkData
(
2
,
1
,
"
DOUBLE
"
)
payload
=
[
'''
payload
=
[
'''
{
{
...
@@ -216,7 +232,7 @@ class TDTestCase:
...
@@ -216,7 +232,7 @@ class TDTestCase:
}
}
}
}
'''
]
'''
]
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
)
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
tdSql
.
query
(
"describe stb0_9"
)
tdSql
.
query
(
"describe stb0_9"
)
...
@@ -232,7 +248,7 @@ class TDTestCase:
...
@@ -232,7 +248,7 @@ class TDTestCase:
}
}
}
}
'''
]
'''
]
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
)
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
tdSql
.
query
(
"describe stb0_10"
)
tdSql
.
query
(
"describe stb0_10"
)
...
@@ -258,7 +274,7 @@ class TDTestCase:
...
@@ -258,7 +274,7 @@ class TDTestCase:
}
}
}
}
'''
]
'''
]
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
)
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
,
None
)
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"
)
...
@@ -281,7 +297,7 @@ class TDTestCase:
...
@@ -281,7 +297,7 @@ class TDTestCase:
}
}
}
}
'''
]
'''
]
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
)
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
,
None
)
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"
)
...
@@ -304,7 +320,7 @@ class TDTestCase:
...
@@ -304,7 +320,7 @@ class TDTestCase:
}
}
}
}
'''
]
'''
]
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
)
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
,
None
)
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"
)
...
@@ -327,7 +343,7 @@ class TDTestCase:
...
@@ -327,7 +343,7 @@ class TDTestCase:
}
}
}
}
'''
]
'''
]
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
)
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
,
None
)
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"
)
...
@@ -351,7 +367,7 @@ class TDTestCase:
...
@@ -351,7 +367,7 @@ class TDTestCase:
}
}
}
}
'''
]
'''
]
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
)
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
### metric value ###
### metric value ###
...
@@ -374,7 +390,7 @@ class TDTestCase:
...
@@ -374,7 +390,7 @@ class TDTestCase:
}
}
}
}
'''
]
'''
]
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
)
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
tdSql
.
query
(
"describe stb2_0"
)
tdSql
.
query
(
"describe stb2_0"
)
...
@@ -399,7 +415,7 @@ class TDTestCase:
...
@@ -399,7 +415,7 @@ class TDTestCase:
}
}
}
}
'''
]
'''
]
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
)
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
tdSql
.
query
(
"describe stb2_1"
)
tdSql
.
query
(
"describe stb2_1"
)
...
@@ -424,7 +440,7 @@ class TDTestCase:
...
@@ -424,7 +440,7 @@ class TDTestCase:
}
}
}
}
'''
]
'''
]
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
)
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
tdSql
.
query
(
"describe stb2_2"
)
tdSql
.
query
(
"describe stb2_2"
)
...
@@ -449,7 +465,7 @@ class TDTestCase:
...
@@ -449,7 +465,7 @@ class TDTestCase:
}
}
}
}
'''
]
'''
]
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
)
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
tdSql
.
query
(
"describe stb2_3"
)
tdSql
.
query
(
"describe stb2_3"
)
...
@@ -474,7 +490,7 @@ class TDTestCase:
...
@@ -474,7 +490,7 @@ class TDTestCase:
}
}
}
}
'''
]
'''
]
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
)
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
tdSql
.
query
(
"describe stb2_4"
)
tdSql
.
query
(
"describe stb2_4"
)
...
@@ -499,7 +515,7 @@ class TDTestCase:
...
@@ -499,7 +515,7 @@ class TDTestCase:
}
}
}
}
'''
]
'''
]
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
)
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
tdSql
.
query
(
"describe stb2_5"
)
tdSql
.
query
(
"describe stb2_5"
)
...
@@ -524,7 +540,7 @@ class TDTestCase:
...
@@ -524,7 +540,7 @@ class TDTestCase:
}
}
}
}
'''
]
'''
]
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
)
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
tdSql
.
query
(
"describe stb2_6"
)
tdSql
.
query
(
"describe stb2_6"
)
...
@@ -549,7 +565,7 @@ class TDTestCase:
...
@@ -549,7 +565,7 @@ class TDTestCase:
}
}
}
}
'''
]
'''
]
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
)
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
tdSql
.
query
(
"describe stb2_7"
)
tdSql
.
query
(
"describe stb2_7"
)
...
@@ -574,7 +590,7 @@ class TDTestCase:
...
@@ -574,7 +590,7 @@ class TDTestCase:
}
}
}
}
'''
]
'''
]
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
)
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
tdSql
.
query
(
"describe stb2_8"
)
tdSql
.
query
(
"describe stb2_8"
)
...
@@ -633,7 +649,7 @@ class TDTestCase:
...
@@ -633,7 +649,7 @@ class TDTestCase:
}
}
}
}
'''
]
'''
]
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
)
code
=
self
.
_conn
.
schemaless_insert
(
payload
,
2
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
tdSql
.
query
(
"describe stb3_0"
)
tdSql
.
query
(
"describe stb3_0"
)
...
...
tests/pytest/insert/insertTelnetLines.py
浏览文件 @
b353b162
...
@@ -39,7 +39,7 @@ class TDTestCase:
...
@@ -39,7 +39,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
)
code
=
self
.
_conn
.
schemaless_insert
(
lines0
,
1
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
tdSql
.
query
(
"show stables"
)
tdSql
.
query
(
"show stables"
)
...
@@ -63,16 +63,17 @@ class TDTestCase:
...
@@ -63,16 +63,17 @@ class TDTestCase:
"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 1626006833640000us 3i8 host=
\"
host0
\"
"
,
"stb1 1626006833641123 4i8 host=
\"
host0
\"
"
,
"stb1 1626006833641 4i8 host=
\"
host0
\"
"
,
"stb1 1626006833651ms 5i8 host=
\"
host0
\"
"
,
"stb1 1626006834 5i8 host=
\"
host0
\"
"
,
"stb1 0 6i8 host=
\"
host0
\"
"
,
"stb1 1626006833651ms 6i8 host=
\"
host0
\"
"
,
"stb1 0 7i8 host=
\"
host0
\"
"
,
]
]
code
=
self
.
_conn
.
schemaless_insert
(
lines1
,
1
)
code
=
self
.
_conn
.
schemaless_insert
(
lines1
,
1
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
tdSql
.
query
(
"select * from stb1"
)
tdSql
.
query
(
"select * from stb1"
)
tdSql
.
checkRows
(
6
)
tdSql
.
checkRows
(
7
)
### metric value ###
### metric value ###
print
(
"============= step3 : test metric value ================"
)
print
(
"============= step3 : test metric value ================"
)
...
@@ -82,7 +83,7 @@ class TDTestCase:
...
@@ -82,7 +83,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
)
code
=
self
.
_conn
.
schemaless_insert
(
lines2_0
,
1
,
None
)
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 +98,7 @@ class TDTestCase:
...
@@ -97,7 +98,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
)
code
=
self
.
_conn
.
schemaless_insert
(
lines2_1
,
1
,
None
)
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 +114,7 @@ class TDTestCase:
...
@@ -113,7 +114,7 @@ class TDTestCase:
"stb2_2 1626006833652ms 2147483647i32 host=
\"
host0
\"
"
"stb2_2 1626006833652ms 2147483647i32 host=
\"
host0
\"
"
]
]
code
=
self
.
_conn
.
schemaless_insert
(
lines2_2
,
1
)
code
=
self
.
_conn
.
schemaless_insert
(
lines2_2
,
1
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
tdSql
.
query
(
"select * from stb2_2"
)
tdSql
.
query
(
"select * from stb2_2"
)
...
@@ -126,15 +127,14 @@ class TDTestCase:
...
@@ -126,15 +127,14 @@ class TDTestCase:
#bigint
#bigint
lines2_3
=
[
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
\"
"
"stb2_3 1626006833662ms 9223372036854775807 host=
\"
host0
\"
"
]
]
code
=
self
.
_conn
.
schemaless_insert
(
lines2_3
,
1
)
code
=
self
.
_conn
.
schemaless_insert
(
lines2_3
,
1
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
tdSql
.
query
(
"select * from stb2_3"
)
tdSql
.
query
(
"select * from stb2_3"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"describe stb2_3"
)
tdSql
.
query
(
"describe stb2_3"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
3
)
...
@@ -154,7 +154,7 @@ class TDTestCase:
...
@@ -154,7 +154,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
)
code
=
self
.
_conn
.
schemaless_insert
(
lines2_4
,
1
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
tdSql
.
query
(
"select * from stb2_4"
)
tdSql
.
query
(
"select * from stb2_4"
)
...
@@ -176,10 +176,10 @@ class TDTestCase:
...
@@ -176,10 +176,10 @@ class TDTestCase:
"stb2_5 1626006833680ms -3.4e-2f64 host=
\"
host0
\"
"
,
"stb2_5 1626006833680ms -3.4e-2f64 host=
\"
host0
\"
"
,
"stb2_5 1626006833690ms 1.7E308f64 host=
\"
host0
\"
"
,
"stb2_5 1626006833690ms 1.7E308f64 host=
\"
host0
\"
"
,
"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 host=
\"
host0
\"
"
]
]
code
=
self
.
_conn
.
schemaless_insert
(
lines2_5
,
1
)
code
=
self
.
_conn
.
schemaless_insert
(
lines2_5
,
1
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
tdSql
.
query
(
"select * from stb2_5"
)
tdSql
.
query
(
"select * from stb2_5"
)
...
@@ -203,7 +203,7 @@ class TDTestCase:
...
@@ -203,7 +203,7 @@ class TDTestCase:
"stb2_6 1626006833700ms FALSE host=
\"
host0
\"
"
"stb2_6 1626006833700ms FALSE host=
\"
host0
\"
"
]
]
code
=
self
.
_conn
.
schemaless_insert
(
lines2_6
,
1
)
code
=
self
.
_conn
.
schemaless_insert
(
lines2_6
,
1
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
tdSql
.
query
(
"select * from stb2_6"
)
tdSql
.
query
(
"select * from stb2_6"
)
...
@@ -220,7 +220,7 @@ class TDTestCase:
...
@@ -220,7 +220,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
)
code
=
self
.
_conn
.
schemaless_insert
(
lines2_7
,
1
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
tdSql
.
query
(
"select * from stb2_7"
)
tdSql
.
query
(
"select * from stb2_7"
)
...
@@ -236,7 +236,7 @@ class TDTestCase:
...
@@ -236,7 +236,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
)
code
=
self
.
_conn
.
schemaless_insert
(
lines2_8
,
1
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
tdSql
.
query
(
"select * from stb2_8"
)
tdSql
.
query
(
"select * from stb2_8"
)
...
@@ -254,7 +254,7 @@ class TDTestCase:
...
@@ -254,7 +254,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
)
code
=
self
.
_conn
.
schemaless_insert
(
lines3_0
,
1
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
tdSql
.
query
(
"select * from stb3_0"
)
tdSql
.
query
(
"select * from stb3_0"
)
...
@@ -263,28 +263,28 @@ class TDTestCase:
...
@@ -263,28 +263,28 @@ class TDTestCase:
tdSql
.
query
(
"describe stb3_0"
)
tdSql
.
query
(
"describe stb3_0"
)
tdSql
.
checkRows
(
11
)
tdSql
.
checkRows
(
11
)
tdSql
.
checkData
(
2
,
1
,
"
TINYINT
"
)
tdSql
.
checkData
(
2
,
1
,
"
NCHAR
"
)
tdSql
.
checkData
(
2
,
3
,
"TAG"
)
tdSql
.
checkData
(
2
,
3
,
"TAG"
)
tdSql
.
checkData
(
3
,
1
,
"
SMALLINT
"
)
tdSql
.
checkData
(
3
,
1
,
"
NCHAR
"
)
tdSql
.
checkData
(
3
,
3
,
"TAG"
)
tdSql
.
checkData
(
3
,
3
,
"TAG"
)
tdSql
.
checkData
(
4
,
1
,
"
INT
"
)
tdSql
.
checkData
(
4
,
1
,
"
NCHAR
"
)
tdSql
.
checkData
(
4
,
3
,
"TAG"
)
tdSql
.
checkData
(
4
,
3
,
"TAG"
)
tdSql
.
checkData
(
5
,
1
,
"
BIGINT
"
)
tdSql
.
checkData
(
5
,
1
,
"
NCHAR
"
)
tdSql
.
checkData
(
5
,
3
,
"TAG"
)
tdSql
.
checkData
(
5
,
3
,
"TAG"
)
tdSql
.
checkData
(
6
,
1
,
"
FLOAT
"
)
tdSql
.
checkData
(
6
,
1
,
"
NCHAR
"
)
tdSql
.
checkData
(
6
,
3
,
"TAG"
)
tdSql
.
checkData
(
6
,
3
,
"TAG"
)
tdSql
.
checkData
(
7
,
1
,
"
DOUBLE
"
)
tdSql
.
checkData
(
7
,
1
,
"
NCHAR
"
)
tdSql
.
checkData
(
7
,
3
,
"TAG"
)
tdSql
.
checkData
(
7
,
3
,
"TAG"
)
tdSql
.
checkData
(
8
,
1
,
"
BOOL
"
)
tdSql
.
checkData
(
8
,
1
,
"
NCHAR
"
)
tdSql
.
checkData
(
8
,
3
,
"TAG"
)
tdSql
.
checkData
(
8
,
3
,
"TAG"
)
tdSql
.
checkData
(
9
,
1
,
"
BINARY
"
)
tdSql
.
checkData
(
9
,
1
,
"
NCHAR
"
)
tdSql
.
checkData
(
9
,
3
,
"TAG"
)
tdSql
.
checkData
(
9
,
3
,
"TAG"
)
tdSql
.
checkData
(
10
,
1
,
"NCHAR"
)
tdSql
.
checkData
(
10
,
1
,
"NCHAR"
)
...
@@ -293,12 +293,12 @@ class TDTestCase:
...
@@ -293,12 +293,12 @@ class TDTestCase:
#tag ID as child table name
#tag ID as child table name
lines3_1
=
[
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
=
self
.
_conn
.
schemaless_insert
(
lines3_1
,
1
)
code
=
self
.
_conn
.
schemaless_insert
(
lines3_1
,
1
,
None
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
tdSql
.
query
(
"select * from stb3_1"
)
tdSql
.
query
(
"select * from stb3_1"
)
...
...
tests/pytest/insert/line_insert.py
浏览文件 @
b353b162
...
@@ -31,28 +31,28 @@ class TDTestCase:
...
@@ -31,28 +31,28 @@ class TDTestCase:
tdSql
.
execute
(
'create stable ste(ts timestamp, f int) tags(t1 bigint)'
)
tdSql
.
execute
(
'create stable ste(ts timestamp, f int) tags(t1 bigint)'
)
lines
=
[
"st,t1=3i64,t2=4f64,t3=
\"
t3
\"
c1=3i64,c3=L
\"
passit
\"
,c2=false,c4=4f64 1626006833639000000
ns
"
,
lines
=
[
"st,t1=3i64,t2=4f64,t3=
\"
t3
\"
c1=3i64,c3=L
\"
passit
\"
,c2=false,c4=4f64 1626006833639000000"
,
"st,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64 1626006833640000000
ns
"
,
"st,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64 1626006833640000000"
,
"ste,t2=5f64,t3=L
\"
ste
\"
c1=true,c2=4i64,c3=
\"
iam
\"
1626056811823316532
ns
"
,
"ste,t2=5f64,t3=L
\"
ste
\"
c1=true,c2=4i64,c3=
\"
iam
\"
1626056811823316532"
,
"stf,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000
ns
"
,
"stf,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000"
,
"st,t1=4i64,t2=5f64,t3=
\"
t4
\"
c1=3i64,c3=L
\"
passitagain
\"
,c2=true,c4=5f64 1626006833642000000
ns
"
,
"st,t1=4i64,t2=5f64,t3=
\"
t4
\"
c1=3i64,c3=L
\"
passitagain
\"
,c2=true,c4=5f64 1626006833642000000"
,
"ste,t2=5f64,t3=L
\"
ste2
\"
c3=
\"
iamszhou
\"
,c4=false 1626056811843316532
ns
"
,
"ste,t2=5f64,t3=L
\"
ste2
\"
c3=
\"
iamszhou
\"
,c4=false 1626056811843316532"
,
"ste,t2=5f64,t3=L
\"
ste2
\"
c3=
\"
iamszhou
\"
,c4=false,c5=32i8,c6=64i16,c7=32i32,c8=88.88f32 1626056812843316532
ns
"
,
"ste,t2=5f64,t3=L
\"
ste2
\"
c3=
\"
iamszhou
\"
,c4=false,c5=32i8,c6=64i16,c7=32i32,c8=88.88f32 1626056812843316532"
,
"st,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000
ns
"
,
"st,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000"
,
"stf,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin_stf
\"
,c2=false,c5=5f64,c6=7u64 1626006933641000000
ns
"
"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
)
code
=
self
.
_conn
.
schemaless_insert
(
lines
,
0
,
"ns"
)
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
ns
"
,
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
ns
"
"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
)
code
=
self
.
_conn
.
schemaless_insert
([
lines2
[
0
]
],
0
,
"ns"
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
self
.
_conn
.
schemaless_insert
([
lines2
[
1
]
],
0
)
self
.
_conn
.
schemaless_insert
([
lines2
[
1
]
],
0
,
"ns"
)
print
(
"schemaless_insert result {}"
.
format
(
code
))
print
(
"schemaless_insert result {}"
.
format
(
code
))
tdSql
.
query
(
"select * from st"
)
tdSql
.
query
(
"select * from st"
)
...
@@ -74,9 +74,9 @@ class TDTestCase:
...
@@ -74,9 +74,9 @@ class TDTestCase:
tdSql
.
checkData
(
2
,
2
,
14
)
tdSql
.
checkData
(
2
,
2
,
14
)
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 1626006933641ms
"
,
"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
ms
"
"sth,t1=4i64,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin_stf
\"
,c2=false,c5=5f64,c6=7u64 1626006933654"
],
0
)
],
0
,
"ms"
)
tdSql
.
execute
(
'reset query cache'
)
tdSql
.
execute
(
'reset query cache'
)
tdSql
.
query
(
'select tbname, * from sth'
)
tdSql
.
query
(
'select tbname, * from sth'
)
...
...
tests/script/api/openTSDBTest.c
浏览文件 @
b353b162
...
@@ -26,7 +26,7 @@ void verify_telnet_insert(TAOS* taos) {
...
@@ -26,7 +26,7 @@ void verify_telnet_insert(TAOS* taos) {
"stb0_1 1626006833639000000ns 4i8 host=
\"
host0
\"
interface=
\"
eth0
\"
"
,
"stb0_1 1626006833639000000ns 4i8 host=
\"
host0
\"
interface=
\"
eth0
\"
"
,
"stb0_2 1626006833639000000ns 4i8 host=
\"
host0
\"
interface=
\"
eth0
\"
"
,
"stb0_2 1626006833639000000ns 4i8 host=
\"
host0
\"
interface=
\"
eth0
\"
"
,
};
};
code
=
taos_schemaless_insert
(
taos
,
lines0
,
3
,
1
);
code
=
taos_schemaless_insert
(
taos
,
lines0
,
3
,
1
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"lines0 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"lines0 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
@@ -36,11 +36,12 @@ void verify_telnet_insert(TAOS* taos) {
...
@@ -36,11 +36,12 @@ void verify_telnet_insert(TAOS* taos) {
"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 1626006833640000us 3i8 host=
\"
host0
\"
"
,
"stb1 1626006833641123 4i8 host=
\"
host0
\"
"
,
"stb1 1626006833641 4i8 host=
\"
host0
\"
"
,
"stb1 1626006833651ms 5i8 host=
\"
host0
\"
"
,
"stb1 1626006832 5i8 host=
\"
host0
\"
"
,
"stb1 0 6i8 host=
\"
host0
\"
"
,
"stb1 1626006833651ms 6i8 host=
\"
host0
\"
"
,
"stb1 0 7i8 host=
\"
host0
\"
"
,
};
};
code
=
taos_schemaless_insert
(
taos
,
lines1
,
6
,
1
);
code
=
taos_schemaless_insert
(
taos
,
lines1
,
7
,
1
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"lines1 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"lines1 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
@@ -51,7 +52,7 @@ void verify_telnet_insert(TAOS* taos) {
...
@@ -51,7 +52,7 @@ void verify_telnet_insert(TAOS* taos) {
"stb2_0 1626006833651ms -127i8 host=
\"
host0
\"
"
,
"stb2_0 1626006833651ms -127i8 host=
\"
host0
\"
"
,
"stb2_0 1626006833652ms 127i8 host=
\"
host0
\"
"
"stb2_0 1626006833652ms 127i8 host=
\"
host0
\"
"
};
};
code
=
taos_schemaless_insert
(
taos
,
lines2_0
,
2
,
1
);
code
=
taos_schemaless_insert
(
taos
,
lines2_0
,
2
,
1
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"lines2_0 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"lines2_0 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
@@ -61,7 +62,7 @@ void verify_telnet_insert(TAOS* taos) {
...
@@ -61,7 +62,7 @@ void verify_telnet_insert(TAOS* taos) {
"stb2_1 1626006833651ms -32767i16 host=
\"
host0
\"
"
,
"stb2_1 1626006833651ms -32767i16 host=
\"
host0
\"
"
,
"stb2_1 1626006833652ms 32767i16 host=
\"
host0
\"
"
"stb2_1 1626006833652ms 32767i16 host=
\"
host0
\"
"
};
};
code
=
taos_schemaless_insert
(
taos
,
lines2_1
,
2
,
1
);
code
=
taos_schemaless_insert
(
taos
,
lines2_1
,
2
,
1
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"lines2_1 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"lines2_1 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
@@ -71,7 +72,7 @@ void verify_telnet_insert(TAOS* taos) {
...
@@ -71,7 +72,7 @@ void verify_telnet_insert(TAOS* taos) {
"stb2_2 1626006833651ms -2147483647i32 host=
\"
host0
\"
"
,
"stb2_2 1626006833651ms -2147483647i32 host=
\"
host0
\"
"
,
"stb2_2 1626006833652ms 2147483647i32 host=
\"
host0
\"
"
"stb2_2 1626006833652ms 2147483647i32 host=
\"
host0
\"
"
};
};
code
=
taos_schemaless_insert
(
taos
,
lines2_2
,
2
,
1
);
code
=
taos_schemaless_insert
(
taos
,
lines2_2
,
2
,
1
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"lines2_2 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"lines2_2 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
@@ -79,10 +80,9 @@ void verify_telnet_insert(TAOS* taos) {
...
@@ -79,10 +80,9 @@ void verify_telnet_insert(TAOS* taos) {
//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
\"
"
"stb2_3 1626006833662ms 9223372036854775807 host=
\"
host0
\"
"
};
};
code
=
taos_schemaless_insert
(
taos
,
lines2_3
,
3
,
1
);
code
=
taos_schemaless_insert
(
taos
,
lines2_3
,
2
,
1
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"lines2_3 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"lines2_3 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
@@ -100,7 +100,7 @@ void verify_telnet_insert(TAOS* taos) {
...
@@ -100,7 +100,7 @@ void verify_telnet_insert(TAOS* taos) {
"stb2_4 1626006833700ms 3.4E38f32 host=
\"
host0
\"
"
,
"stb2_4 1626006833700ms 3.4E38f32 host=
\"
host0
\"
"
,
"stb2_4 1626006833710ms -3.4E38f32 host=
\"
host0
\"
"
"stb2_4 1626006833710ms -3.4E38f32 host=
\"
host0
\"
"
};
};
code
=
taos_schemaless_insert
(
taos
,
lines2_4
,
10
,
1
);
code
=
taos_schemaless_insert
(
taos
,
lines2_4
,
10
,
1
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"lines2_4 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"lines2_4 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
@@ -119,7 +119,7 @@ void verify_telnet_insert(TAOS* taos) {
...
@@ -119,7 +119,7 @@ void verify_telnet_insert(TAOS* taos) {
"stb2_5 1626006833700ms -1.7E308f64 host=
\"
host0
\"
"
,
"stb2_5 1626006833700ms -1.7E308f64 host=
\"
host0
\"
"
,
"stb2_5 1626006833710ms 3.15 host=
\"
host0
\"
"
"stb2_5 1626006833710ms 3.15 host=
\"
host0
\"
"
};
};
code
=
taos_schemaless_insert
(
taos
,
lines2_5
,
11
,
1
);
code
=
taos_schemaless_insert
(
taos
,
lines2_5
,
11
,
1
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"lines2_5 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"lines2_5 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
@@ -137,7 +137,7 @@ void verify_telnet_insert(TAOS* taos) {
...
@@ -137,7 +137,7 @@ void verify_telnet_insert(TAOS* taos) {
"stb2_6 1626006833690ms False host=
\"
host0
\"
"
,
"stb2_6 1626006833690ms False host=
\"
host0
\"
"
,
"stb2_6 1626006833700ms FALSE host=
\"
host0
\"
"
"stb2_6 1626006833700ms FALSE host=
\"
host0
\"
"
};
};
code
=
taos_schemaless_insert
(
taos
,
lines2_6
,
10
,
1
);
code
=
taos_schemaless_insert
(
taos
,
lines2_6
,
10
,
1
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"lines2_6 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"lines2_6 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
@@ -148,7 +148,7 @@ void verify_telnet_insert(TAOS* taos) {
...
@@ -148,7 +148,7 @@ void verify_telnet_insert(TAOS* taos) {
"stb2_7 1626006833620ms
\"
binary_val.:;,./?|+-=
\"
host=
\"
host0
\"
"
,
"stb2_7 1626006833620ms
\"
binary_val.:;,./?|+-=
\"
host=
\"
host0
\"
"
,
"stb2_7 1626006833630ms
\"
binary_val.()[]{}<>
\"
host=
\"
host0
\"
"
"stb2_7 1626006833630ms
\"
binary_val.()[]{}<>
\"
host=
\"
host0
\"
"
};
};
code
=
taos_schemaless_insert
(
taos
,
lines2_7
,
3
,
1
);
code
=
taos_schemaless_insert
(
taos
,
lines2_7
,
3
,
1
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"lines2_7 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"lines2_7 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
@@ -158,7 +158,7 @@ void verify_telnet_insert(TAOS* taos) {
...
@@ -158,7 +158,7 @@ void verify_telnet_insert(TAOS* taos) {
"stb2_8 1626006833610ms L
\"
nchar_val数值一
\"
host=
\"
host0
\"
"
,
"stb2_8 1626006833610ms L
\"
nchar_val数值一
\"
host=
\"
host0
\"
"
,
"stb2_8 1626006833620ms L
\"
nchar_val数值二
\"
host=
\"
host0
\"
"
"stb2_8 1626006833620ms L
\"
nchar_val数值二
\"
host=
\"
host0
\"
"
};
};
code
=
taos_schemaless_insert
(
taos
,
lines2_8
,
2
,
1
);
code
=
taos_schemaless_insert
(
taos
,
lines2_8
,
2
,
1
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"lines2_8 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"lines2_8 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
@@ -169,18 +169,18 @@ void verify_telnet_insert(TAOS* taos) {
...
@@ -169,18 +169,18 @@ 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
);
code
=
taos_schemaless_insert
(
taos
,
lines3_0
,
2
,
1
,
NULL
);
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_schemaless_insert
(
taos
,
lines3_1
,
3
,
1
);
code
=
taos_schemaless_insert
(
taos
,
lines3_1
,
3
,
1
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"lines3_1 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"lines3_1 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
@@ -204,7 +204,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -204,7 +204,7 @@ void verify_json_insert(TAOS* taos) {
char
*
message
[]
=
{
char
*
message
[]
=
{
"{ \
"{ \
\"
metric
\"
:
\"
cpu_load_0
\"
, \
\"
metric
\"
:
\"
cpu_load_0
\"
, \
\"
timestamp
\"
: 1626006833610
123,
\
\"
timestamp
\"
: 1626006833610
,
\
\"
value
\"
: 55.5, \
\"
value
\"
: 55.5, \
\"
tags
\"
: \
\"
tags
\"
: \
{ \
{ \
...
@@ -214,7 +214,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -214,7 +214,7 @@ void verify_json_insert(TAOS* taos) {
} \
} \
}"
};
}"
};
code
=
taos_schemaless_insert
(
taos
,
message
,
0
,
2
);
code
=
taos_schemaless_insert
(
taos
,
message
,
0
,
2
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"payload_0 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"payload_0 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
@@ -223,7 +223,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -223,7 +223,7 @@ void verify_json_insert(TAOS* taos) {
"[ \
"[ \
{ \
{ \
\"
metric
\"
:
\"
cpu_load_1
\"
, \
\"
metric
\"
:
\"
cpu_load_1
\"
, \
\"
timestamp
\"
: 1626006833610
123,
\
\"
timestamp
\"
: 1626006833610
,
\
\"
value
\"
: 55.5, \
\"
value
\"
: 55.5, \
\"
tags
\"
: \
\"
tags
\"
: \
{ \
{ \
...
@@ -234,7 +234,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -234,7 +234,7 @@ void verify_json_insert(TAOS* taos) {
}, \
}, \
{ \
{ \
\"
metric
\"
:
\"
cpu_load_2
\"
, \
\"
metric
\"
:
\"
cpu_load_2
\"
, \
\"
timestamp
\"
: 1626006833610
123,
\
\"
timestamp
\"
: 1626006833610
,
\
\"
value
\"
: 55.5, \
\"
value
\"
: 55.5, \
\"
tags
\"
: \
\"
tags
\"
: \
{ \
{ \
...
@@ -245,7 +245,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -245,7 +245,7 @@ void verify_json_insert(TAOS* taos) {
} \
} \
]"
};
]"
};
code
=
taos_schemaless_insert
(
taos
,
message1
,
0
,
2
);
code
=
taos_schemaless_insert
(
taos
,
message1
,
0
,
2
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"payload_1 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"payload_1 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
@@ -256,8 +256,8 @@ void verify_json_insert(TAOS* taos) {
...
@@ -256,8 +256,8 @@ void verify_json_insert(TAOS* taos) {
\"
metric
\"
:
\"
cpu_load_3
\"
, \
\"
metric
\"
:
\"
cpu_load_3
\"
, \
\"
timestamp
\"
: \
\"
timestamp
\"
: \
{ \
{ \
\"
value
\"
: 1626006833610
123,
\
\"
value
\"
: 1626006833610
,
\
\"
type
\"
:
\"
u
s
\"
\
\"
type
\"
:
\"
m
s
\"
\
}, \
}, \
\"
value
\"
: \
\"
value
\"
: \
{ \
{ \
...
@@ -286,7 +286,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -286,7 +286,7 @@ void verify_json_insert(TAOS* taos) {
}, \
}, \
{ \
{ \
\"
metric
\"
:
\"
cpu_load_4
\"
, \
\"
metric
\"
:
\"
cpu_load_4
\"
, \
\"
timestamp
\"
: 1626006833610
123,
\
\"
timestamp
\"
: 1626006833610
,
\
\"
value
\"
: 66.6, \
\"
value
\"
: 66.6, \
\"
tags
\"
: \
\"
tags
\"
: \
{ \
{ \
...
@@ -296,7 +296,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -296,7 +296,7 @@ void verify_json_insert(TAOS* taos) {
} \
} \
} \
} \
]"
};
]"
};
code
=
taos_schemaless_insert
(
taos
,
message2
,
0
,
2
);
code
=
taos_schemaless_insert
(
taos
,
message2
,
0
,
2
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"payload_2 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"payload_2 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
@@ -309,7 +309,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -309,7 +309,7 @@ void verify_json_insert(TAOS* taos) {
//number
//number
payload
=
cJSON_CreateObject
();
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb0_0"
);
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb0_0"
);
cJSON_AddNumberToObject
(
payload
,
"timestamp"
,
1626006833610
123
);
cJSON_AddNumberToObject
(
payload
,
"timestamp"
,
1626006833610
);
cJSON_AddNumberToObject
(
payload
,
"value"
,
10
);
cJSON_AddNumberToObject
(
payload
,
"value"
,
10
);
tags
=
cJSON_CreateObject
();
tags
=
cJSON_CreateObject
();
cJSON_AddTrueToObject
(
tags
,
"t1"
);
cJSON_AddTrueToObject
(
tags
,
"t1"
);
...
@@ -320,7 +320,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -320,7 +320,7 @@ 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
);
code
=
taos_schemaless_insert
(
taos
,
payload_str
,
0
,
2
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"payload0_0 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"payload0_0 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
@@ -330,7 +330,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -330,7 +330,7 @@ void verify_json_insert(TAOS* taos) {
//true
//true
payload
=
cJSON_CreateObject
();
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb0_1"
);
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb0_1"
);
cJSON_AddNumberToObject
(
payload
,
"timestamp"
,
1626006833610
123
);
cJSON_AddNumberToObject
(
payload
,
"timestamp"
,
1626006833610
);
cJSON_AddTrueToObject
(
payload
,
"value"
);
cJSON_AddTrueToObject
(
payload
,
"value"
);
tags
=
cJSON_CreateObject
();
tags
=
cJSON_CreateObject
();
cJSON_AddTrueToObject
(
tags
,
"t1"
);
cJSON_AddTrueToObject
(
tags
,
"t1"
);
...
@@ -341,7 +341,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -341,7 +341,7 @@ 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
);
code
=
taos_schemaless_insert
(
taos
,
payload_str
,
0
,
2
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"payload0_1 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"payload0_1 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
@@ -351,7 +351,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -351,7 +351,7 @@ void verify_json_insert(TAOS* taos) {
//false
//false
payload
=
cJSON_CreateObject
();
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb0_2"
);
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb0_2"
);
cJSON_AddNumberToObject
(
payload
,
"timestamp"
,
1626006833610
123
);
cJSON_AddNumberToObject
(
payload
,
"timestamp"
,
1626006833610
);
cJSON_AddFalseToObject
(
payload
,
"value"
);
cJSON_AddFalseToObject
(
payload
,
"value"
);
tags
=
cJSON_CreateObject
();
tags
=
cJSON_CreateObject
();
cJSON_AddTrueToObject
(
tags
,
"t1"
);
cJSON_AddTrueToObject
(
tags
,
"t1"
);
...
@@ -362,7 +362,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -362,7 +362,7 @@ 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
);
code
=
taos_schemaless_insert
(
taos
,
payload_str
,
0
,
2
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"payload0_2 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"payload0_2 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
@@ -372,7 +372,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -372,7 +372,7 @@ void verify_json_insert(TAOS* taos) {
//string
//string
payload
=
cJSON_CreateObject
();
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb0_3"
);
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb0_3"
);
cJSON_AddNumberToObject
(
payload
,
"timestamp"
,
1626006833610
123
);
cJSON_AddNumberToObject
(
payload
,
"timestamp"
,
1626006833610
);
cJSON_AddStringToObject
(
payload
,
"value"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddStringToObject
(
payload
,
"value"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
tags
=
cJSON_CreateObject
();
tags
=
cJSON_CreateObject
();
cJSON_AddTrueToObject
(
tags
,
"t1"
);
cJSON_AddTrueToObject
(
tags
,
"t1"
);
...
@@ -383,7 +383,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -383,7 +383,7 @@ 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
);
code
=
taos_schemaless_insert
(
taos
,
payload_str
,
0
,
2
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"payload0_3 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"payload0_3 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
@@ -404,7 +404,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -404,7 +404,7 @@ 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
);
code
=
taos_schemaless_insert
(
taos
,
payload_str
,
0
,
2
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"payload0_4 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"payload0_4 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
@@ -433,7 +433,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -433,7 +433,7 @@ 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
);
code
=
taos_schemaless_insert
(
taos
,
payload_str
,
0
,
2
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"payload1_0 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"payload1_0 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
@@ -459,7 +459,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -459,7 +459,7 @@ 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
);
code
=
taos_schemaless_insert
(
taos
,
payload_str
,
0
,
2
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"payload1_1 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"payload1_1 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
@@ -485,7 +485,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -485,7 +485,7 @@ 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
);
code
=
taos_schemaless_insert
(
taos
,
payload_str
,
0
,
2
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"payload1_2 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"payload1_2 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
@@ -511,7 +511,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -511,7 +511,7 @@ 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
);
code
=
taos_schemaless_insert
(
taos
,
payload_str
,
0
,
2
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"payload1_4 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"payload1_4 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
@@ -543,7 +543,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -543,7 +543,7 @@ 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
);
code
=
taos_schemaless_insert
(
taos
,
payload_str
,
0
,
2
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"payload2_0 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"payload2_0 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
@@ -573,7 +573,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -573,7 +573,7 @@ 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
);
code
=
taos_schemaless_insert
(
taos
,
payload_str
,
0
,
2
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"payload2_1 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"payload2_1 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
@@ -603,7 +603,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -603,7 +603,7 @@ 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
);
code
=
taos_schemaless_insert
(
taos
,
payload_str
,
0
,
2
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"payload2_2 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"payload2_2 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
@@ -633,7 +633,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -633,7 +633,7 @@ 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
);
code
=
taos_schemaless_insert
(
taos
,
payload_str
,
0
,
2
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"payload2_3 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"payload2_3 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
@@ -663,7 +663,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -663,7 +663,7 @@ 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
);
code
=
taos_schemaless_insert
(
taos
,
payload_str
,
0
,
2
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"payload2_4 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"payload2_4 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
@@ -693,7 +693,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -693,7 +693,7 @@ 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
);
code
=
taos_schemaless_insert
(
taos
,
payload_str
,
0
,
2
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"payload2_5 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"payload2_5 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
@@ -723,7 +723,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -723,7 +723,7 @@ 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
);
code
=
taos_schemaless_insert
(
taos
,
payload_str
,
0
,
2
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"payload2_6 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"payload2_6 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
@@ -753,7 +753,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -753,7 +753,7 @@ 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
);
code
=
taos_schemaless_insert
(
taos
,
payload_str
,
0
,
2
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"payload2_7 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"payload2_7 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
@@ -783,7 +783,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -783,7 +783,7 @@ 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
);
code
=
taos_schemaless_insert
(
taos
,
payload_str
,
0
,
2
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"payload2_8 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"payload2_8 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
@@ -863,7 +863,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -863,7 +863,7 @@ 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
);
code
=
taos_schemaless_insert
(
taos
,
payload_str
,
0
,
2
,
NULL
);
if
(
code
)
{
if
(
code
)
{
printf
(
"payload3_0 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"payload3_0 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
...
...
tests/script/general/parser/line_insert.sim
浏览文件 @
b353b162
...
@@ -16,10 +16,10 @@ sql create database $db precision 'us'
...
@@ -16,10 +16,10 @@ sql create database $db precision 'us'
sql use $db
sql use $db
sql create stable $mte (ts timestamp, f int) TAGS(t1 bigint)
sql create stable $mte (ts timestamp, f int) TAGS(t1 bigint)
line_insert st,t1=3i64,t2=4f64,t3="t3" c1=3i64,c3=L"passit",c2=false,c4=4f64 1626006833639000000
ns
line_insert st,t1=3i64,t2=4f64,t3="t3" c1=3i64,c3=L"passit",c2=false,c4=4f64 1626006833639000000
line_insert st,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin",c2=true,c4=5f64,c5=5f64 1626006833640000000
ns
line_insert st,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin",c2=true,c4=5f64,c5=5f64 1626006833640000000
line_insert ste,t2=5f64,t3=L"ste" c1=true,c2=4i64,c3="iam" 1626056811823316532ns
line_insert ste,t2=5f64,t3=L"ste" c1=true,c2=4i64,c3="iam" 1626056811823316532ns
line_insert stf,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000
ns
line_insert stf,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000
sql select * from st
sql select * from st
if $rows != 2 then
if $rows != 2 then
return -1
return -1
...
...
tests/tsim/src/simExe.c
浏览文件 @
b353b162
...
@@ -1084,7 +1084,7 @@ bool simExecuteLineInsertCmd(SScript *script, char *rest) {
...
@@ -1084,7 +1084,7 @@ bool simExecuteLineInsertCmd(SScript *script, char *rest) {
simInfo
(
"script:%s, %s"
,
script
->
fileName
,
rest
);
simInfo
(
"script:%s, %s"
,
script
->
fileName
,
rest
);
simLogSql
(
buf
,
true
);
simLogSql
(
buf
,
true
);
char
*
lines
[]
=
{
rest
};
char
*
lines
[]
=
{
rest
};
int32_t
ret
=
taos_schemaless_insert
(
script
->
taos
,
lines
,
1
,
0
);
int32_t
ret
=
taos_schemaless_insert
(
script
->
taos
,
lines
,
1
,
0
,
"ns"
);
if
(
ret
==
TSDB_CODE_SUCCESS
)
{
if
(
ret
==
TSDB_CODE_SUCCESS
)
{
simDebug
(
"script:%s, taos:%p, %s executed. success."
,
script
->
fileName
,
script
->
taos
,
rest
);
simDebug
(
"script:%s, taos:%p, %s executed. success."
,
script
->
fileName
,
script
->
taos
,
rest
);
script
->
linePos
++
;
script
->
linePos
++
;
...
@@ -1107,7 +1107,7 @@ bool simExecuteLineInsertErrorCmd(SScript *script, char *rest) {
...
@@ -1107,7 +1107,7 @@ bool simExecuteLineInsertErrorCmd(SScript *script, char *rest) {
simInfo
(
"script:%s, %s"
,
script
->
fileName
,
rest
);
simInfo
(
"script:%s, %s"
,
script
->
fileName
,
rest
);
simLogSql
(
buf
,
true
);
simLogSql
(
buf
,
true
);
char
*
lines
[]
=
{
rest
};
char
*
lines
[]
=
{
rest
};
int32_t
ret
=
taos_schemaless_insert
(
script
->
taos
,
lines
,
1
,
0
);
int32_t
ret
=
taos_schemaless_insert
(
script
->
taos
,
lines
,
1
,
0
,
"ns"
);
if
(
ret
==
TSDB_CODE_SUCCESS
)
{
if
(
ret
==
TSDB_CODE_SUCCESS
)
{
sprintf
(
script
->
error
,
"script:%s, taos:%p, %s executed. expect failed, but success."
,
script
->
fileName
,
script
->
taos
,
rest
);
sprintf
(
script
->
error
,
"script:%s, taos:%p, %s executed. expect failed, but success."
,
script
->
fileName
,
script
->
taos
,
rest
);
script
->
linePos
++
;
script
->
linePos
++
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录