Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ae650216
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ae650216
编写于
7月 22, 2021
作者:
haoranc
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' into fix/TD-5454
上级
ec7bfe5d
30ea017b
变更
18
展开全部
隐藏空白更改
内联
并排
Showing
18 changed file
with
2740 addition
and
1795 deletion
+2740
-1795
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+1
-0
src/client/src/TSDBJNIConnector.c
src/client/src/TSDBJNIConnector.c
+31
-0
src/client/src/tscParseLineProtocol.c
src/client/src/tscParseLineProtocol.c
+944
-331
src/client/src/tscPrepare.c
src/client/src/tscPrepare.c
+2
-0
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+1
-10
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
...dbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
+9
-0
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBJNIConnectorTest.java
...src/test/java/com/taosdata/jdbc/TSDBJNIConnectorTest.java
+4
-0
src/connector/python/taos/cinterface.py
src/connector/python/taos/cinterface.py
+14
-0
src/connector/python/taos/connection.py
src/connector/python/taos/connection.py
+8
-0
src/inc/taoserror.h
src/inc/taoserror.h
+1
-0
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+1440
-1432
tests/examples/c/CMakeLists.txt
tests/examples/c/CMakeLists.txt
+2
-0
tests/examples/c/apitest.c
tests/examples/c/apitest.c
+24
-16
tests/examples/c/schemaless.c
tests/examples/c/schemaless.c
+161
-0
tests/pytest/fulltest.sh
tests/pytest/fulltest.sh
+1
-0
tests/pytest/insert/line_insert.py
tests/pytest/insert/line_insert.py
+91
-0
tests/script/fullGeneralSuite.sim
tests/script/fullGeneralSuite.sim
+1
-0
tests/script/general/parser/line_insert.sim
tests/script/general/parser/line_insert.sim
+5
-6
未找到文件。
src/client/inc/tsclient.h
浏览文件 @
ae650216
...
@@ -412,6 +412,7 @@ int32_t tscSQLSyntaxErrMsg(char* msg, const char* additionalInfo, const char* s
...
@@ -412,6 +412,7 @@ int32_t tscSQLSyntaxErrMsg(char* msg, const char* additionalInfo, const char* s
int32_t
tscValidateSqlInfo
(
SSqlObj
*
pSql
,
struct
SSqlInfo
*
pInfo
);
int32_t
tscValidateSqlInfo
(
SSqlObj
*
pSql
,
struct
SSqlInfo
*
pInfo
);
int32_t
tsSetBlockInfo
(
SSubmitBlk
*
pBlocks
,
const
STableMeta
*
pTableMeta
,
int32_t
numOfRows
);
extern
int32_t
sentinel
;
extern
int32_t
sentinel
;
extern
SHashObj
*
tscVgroupMap
;
extern
SHashObj
*
tscVgroupMap
;
extern
SHashObj
*
tscTableMetaInfo
;
extern
SHashObj
*
tscTableMetaInfo
;
...
...
src/client/src/TSDBJNIConnector.c
浏览文件 @
ae650216
...
@@ -946,3 +946,34 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setTableNameTagsI
...
@@ -946,3 +946,34 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setTableNameTagsI
return
JNI_SUCCESS
;
return
JNI_SUCCESS
;
}
}
JNIEXPORT
jlong
JNICALL
Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp
(
JNIEnv
*
env
,
jobject
jobj
,
jobjectArray
lines
,
jlong
conn
)
{
TAOS
*
taos
=
(
TAOS
*
)
conn
;
if
(
taos
==
NULL
)
{
jniError
(
"jobj:%p, connection already closed"
,
jobj
);
return
JNI_CONNECTION_NULL
;
}
int
numLines
=
(
*
env
)
->
GetArrayLength
(
env
,
lines
);
char
**
c_lines
=
calloc
(
numLines
,
sizeof
(
char
*
));
for
(
int
i
=
0
;
i
<
numLines
;
++
i
)
{
jstring
line
=
(
jstring
)
((
*
env
)
->
GetObjectArrayElement
(
env
,
lines
,
i
));
c_lines
[
i
]
=
(
char
*
)(
*
env
)
->
GetStringUTFChars
(
env
,
line
,
0
);
}
int
code
=
taos_insert_lines
(
taos
,
c_lines
,
numLines
);
for
(
int
i
=
0
;
i
<
numLines
;
++
i
)
{
jstring
line
=
(
jstring
)
((
*
env
)
->
GetObjectArrayElement
(
env
,
lines
,
i
));
(
*
env
)
->
ReleaseStringUTFChars
(
env
,
line
,
c_lines
[
i
]);
}
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
jniError
(
"jobj:%p, conn:%p, code:%s"
,
jobj
,
taos
,
tstrerror
(
code
));
return
JNI_TDENGINE_ERROR
;
}
return
code
;
}
\ No newline at end of file
src/client/src/tscParseLineProtocol.c
浏览文件 @
ae650216
此差异已折叠。
点击以展开。
src/client/src/tscPrepare.c
浏览文件 @
ae650216
...
@@ -1617,6 +1617,8 @@ int taos_stmt_set_tbname_tags(TAOS_STMT* stmt, const char* name, TAOS_BIND* tags
...
@@ -1617,6 +1617,8 @@ int taos_stmt_set_tbname_tags(TAOS_STMT* stmt, const char* name, TAOS_BIND* tags
(
*
t1
)
->
prevTS
=
INT64_MIN
;
(
*
t1
)
->
prevTS
=
INT64_MIN
;
}
}
tsSetBlockInfo
(
pBlk
,
(
*
t1
)
->
pTableMeta
,
pBlk
->
numOfRows
);
taosHashPut
(
pCmd
->
insertParam
.
pTableBlockHashList
,
(
void
*
)
&
pStmt
->
mtb
.
currentUid
,
sizeof
(
pStmt
->
mtb
.
currentUid
),
(
void
*
)
t1
,
POINTER_BYTES
);
taosHashPut
(
pCmd
->
insertParam
.
pTableBlockHashList
,
(
void
*
)
&
pStmt
->
mtb
.
currentUid
,
sizeof
(
pStmt
->
mtb
.
currentUid
),
(
void
*
)
t1
,
POINTER_BYTES
);
tscDebug
(
"0x%"
PRIx64
" table:%s is already prepared, uid:%"
PRIu64
,
pSql
->
self
,
name
,
pStmt
->
mtb
.
currentUid
);
tscDebug
(
"0x%"
PRIx64
" table:%s is already prepared, uid:%"
PRIu64
,
pSql
->
self
,
name
,
pStmt
->
mtb
.
currentUid
);
...
...
src/client/src/tscUtil.c
浏览文件 @
ae650216
...
@@ -4770,15 +4770,6 @@ static void freeContent(void* p) {
...
@@ -4770,15 +4770,6 @@ static void freeContent(void* p) {
tfree
(
ptr
);
tfree
(
ptr
);
}
}
static
int32_t
contCompare
(
const
void
*
p1
,
const
void
*
p2
)
{
int32_t
ret
=
strcmp
(
p1
,
p2
);
if
(
ret
==
0
)
{
return
0
;
}
else
{
return
ret
>
0
?
1
:-
1
;
}
}
int
tscTransferTableNameList
(
SSqlObj
*
pSql
,
const
char
*
pNameList
,
int32_t
length
,
SArray
*
pNameArray
)
{
int
tscTransferTableNameList
(
SSqlObj
*
pSql
,
const
char
*
pNameList
,
int32_t
length
,
SArray
*
pNameArray
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
...
@@ -4826,7 +4817,7 @@ int tscTransferTableNameList(SSqlObj *pSql, const char *pNameList, int32_t lengt
...
@@ -4826,7 +4817,7 @@ int tscTransferTableNameList(SSqlObj *pSql, const char *pNameList, int32_t lengt
}
}
taosArraySort
(
pNameArray
,
nameComparFn
);
taosArraySort
(
pNameArray
,
nameComparFn
);
taosArrayRemoveDuplicate
(
pNameArray
,
contCompare
,
freeContent
);
taosArrayRemoveDuplicate
(
pNameArray
,
nameComparFn
,
freeContent
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
浏览文件 @
ae650216
...
@@ -348,4 +348,13 @@ public class TSDBJNIConnector {
...
@@ -348,4 +348,13 @@ public class TSDBJNIConnector {
}
}
private
native
int
closeStmt
(
long
stmt
,
long
con
);
private
native
int
closeStmt
(
long
stmt
,
long
con
);
public
void
insertLines
(
String
[]
lines
)
throws
SQLException
{
int
code
=
insertLinesImp
(
lines
,
this
.
taos
);
if
(
code
!=
TSDBConstants
.
JNI_SUCCESS
)
{
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_UNKNOWN
,
"failed to insertLines"
);
}
}
private
native
int
insertLinesImp
(
String
[]
lines
,
long
conn
);
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBJNIConnectorTest.java
浏览文件 @
ae650216
...
@@ -114,6 +114,10 @@ public class TSDBJNIConnectorTest {
...
@@ -114,6 +114,10 @@ public class TSDBJNIConnectorTest {
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_JNI_RESULT_SET_NULL
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_JNI_RESULT_SET_NULL
);
}
}
// close statement
// close statement
connector
.
executeQuery
(
"use d"
);
String
[]
lines
=
new
String
[]
{
"st,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000ns"
,
"st,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000ns"
};
connector
.
insertLines
(
lines
);
// close connection
// close connection
connector
.
closeConnection
();
connector
.
closeConnection
();
...
...
src/connector/python/taos/cinterface.py
浏览文件 @
ae650216
...
@@ -403,6 +403,20 @@ class CTaosInterface(object):
...
@@ -403,6 +403,20 @@ class CTaosInterface(object):
"""
"""
return
CTaosInterface
.
libtaos
.
taos_affected_rows
(
result
)
return
CTaosInterface
.
libtaos
.
taos_affected_rows
(
result
)
@
staticmethod
def
insertLines
(
connection
,
lines
):
'''
insert through lines protocol
@lines: list of str
@rtype: tsdb error codes
'''
numLines
=
len
(
lines
)
c_lines_type
=
ctypes
.
c_char_p
*
numLines
c_lines
=
c_lines_type
()
for
i
in
range
(
numLines
):
c_lines
[
i
]
=
ctypes
.
c_char_p
(
lines
[
i
].
encode
(
'utf-8'
))
return
CTaosInterface
.
libtaos
.
taos_insert_lines
(
connection
,
c_lines
,
ctypes
.
c_int
(
numLines
))
@
staticmethod
@
staticmethod
def
subscribe
(
connection
,
restart
,
topic
,
sql
,
interval
):
def
subscribe
(
connection
,
restart
,
topic
,
sql
,
interval
):
"""Create a subscription
"""Create a subscription
...
...
src/connector/python/taos/connection.py
浏览文件 @
ae650216
...
@@ -66,6 +66,14 @@ class TDengineConnection(object):
...
@@ -66,6 +66,14 @@ class TDengineConnection(object):
self
.
_conn
,
restart
,
topic
,
sql
,
interval
)
self
.
_conn
,
restart
,
topic
,
sql
,
interval
)
return
TDengineSubscription
(
sub
)
return
TDengineSubscription
(
sub
)
def
insertLines
(
self
,
lines
):
"""
insert lines through line protocol
"""
if
self
.
_conn
is
None
:
return
None
return
CTaosInterface
.
insertLines
(
self
.
_conn
,
lines
)
def
cursor
(
self
):
def
cursor
(
self
):
"""Return a new Cursor object using the connection.
"""Return a new Cursor object using the connection.
"""
"""
...
...
src/inc/taoserror.h
浏览文件 @
ae650216
...
@@ -101,6 +101,7 @@ int32_t* taosGetErrno();
...
@@ -101,6 +101,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_TSC_INVALID_TABLE_NAME TAOS_DEF_ERROR_CODE(0, 0x0218) //"Table does not exist")
#define TSDB_CODE_TSC_INVALID_TABLE_NAME TAOS_DEF_ERROR_CODE(0, 0x0218) //"Table does not exist")
#define TSDB_CODE_TSC_EXCEED_SQL_LIMIT TAOS_DEF_ERROR_CODE(0, 0x0219) //"SQL statement too long check maxSQLLength config")
#define TSDB_CODE_TSC_EXCEED_SQL_LIMIT TAOS_DEF_ERROR_CODE(0, 0x0219) //"SQL statement too long check maxSQLLength config")
#define TSDB_CODE_TSC_FILE_EMPTY TAOS_DEF_ERROR_CODE(0, 0x021A) //"File is empty")
#define TSDB_CODE_TSC_FILE_EMPTY TAOS_DEF_ERROR_CODE(0, 0x021A) //"File is empty")
#define TSDB_CODE_TSC_LINE_SYNTAX_ERROR TAOS_DEF_ERROR_CODE(0, 0x021B) //"Syntax error in Line")
// 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/kit/taosdemo/taosdemo.c
浏览文件 @
ae650216
此差异已折叠。
点击以展开。
tests/examples/c/CMakeLists.txt
浏览文件 @
ae650216
...
@@ -5,6 +5,8 @@ IF (TD_LINUX)
...
@@ -5,6 +5,8 @@ IF (TD_LINUX)
AUX_SOURCE_DIRECTORY
(
. SRC
)
AUX_SOURCE_DIRECTORY
(
. SRC
)
ADD_EXECUTABLE
(
demo apitest.c
)
ADD_EXECUTABLE
(
demo apitest.c
)
TARGET_LINK_LIBRARIES
(
demo taos_static trpc tutil pthread
)
TARGET_LINK_LIBRARIES
(
demo taos_static trpc tutil pthread
)
ADD_EXECUTABLE
(
sml schemaless.c
)
TARGET_LINK_LIBRARIES
(
sml taos_static trpc tutil pthread
)
ADD_EXECUTABLE
(
subscribe subscribe.c
)
ADD_EXECUTABLE
(
subscribe subscribe.c
)
TARGET_LINK_LIBRARIES
(
subscribe taos_static trpc tutil pthread
)
TARGET_LINK_LIBRARIES
(
subscribe taos_static trpc tutil pthread
)
ADD_EXECUTABLE
(
epoll epoll.c
)
ADD_EXECUTABLE
(
epoll epoll.c
)
...
...
tests/examples/c/apitest.c
浏览文件 @
ae650216
...
@@ -964,21 +964,31 @@ int32_t verify_schema_less(TAOS* taos) {
...
@@ -964,21 +964,31 @@ int32_t verify_schema_less(TAOS* taos) {
usleep
(
100000
);
usleep
(
100000
);
char
*
lines
[]
=
{
char
*
lines
[]
=
{
"st,t1=3i
,t2=4,t3=
\"
t3
\"
c1=3i,c3=L
\"
passit
\"
,c2=false,c4=4 1626006833639000000
"
,
"st,t1=3i
64,t2=4f64,t3=
\"
t3
\"
c1=3i64,c3=L
\"
passit
\"
,c2=false,c4=4f64 1626006833639000000ns
"
,
"st,t1=4i
,t3=
\"
t4
\"
,t2=5,t4=5 c1=3i,c3=L
\"
passitagin
\"
,c2=true,c4=5,c5=5 1626006833640000000
"
,
"st,t1=4i
64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64 1626006833640000000ns
"
,
"ste,t2=5
,t3=L
\"
ste
\"
c1=true,c2=4,c3=
\"
iam
\"
1626056811823316532
"
,
"ste,t2=5
f64,t3=L
\"
ste
\"
c1=true,c2=4i64,c3=
\"
iam
\"
1626056811823316532ns
"
,
"st,t1=4i
,t2=5,t3=
\"
t4
\"
c1=3i,c3=L
\"
passitagain
\"
,c2=true,c4=5 1626006833642000000
"
,
"st,t1=4i
64,t2=5f64,t3=
\"
t4
\"
c1=3i64,c3=L
\"
passitagain
\"
,c2=true,c4=5f64 1626006833642000000ns
"
,
"ste,t2=5
,t3=L
\"
ste2
\"
c3=
\"
iamszhou
\"
,c4=false 1626056811843316532
"
,
"ste,t2=5
f64,t3=L
\"
ste2
\"
c3=
\"
iamszhou
\"
,c4=false 1626056811843316532ns
"
,
"ste,t2=5
,t3=L
\"
ste2
\"
c3=
\"
iamszhou
\"
,c4=false,c5=32b,c6=64s,c7=32w,c8=88.88f 1626056812843316532
"
,
"ste,t2=5
f64,t3=L
\"
ste2
\"
c3=
\"
iamszhou
\"
,c4=false,c5=32i8,c6=64i16,c7=32i32,c8=88.88f32 1626056812843316532ns
"
,
"st,t1=4i
,t3=
\"
t4
\"
,t2=5,t4=5 c1=3i,c3=L
\"
passitagin
\"
,c2=true,c4=5,c5=5,c6=7u 1626006933640000000
"
,
"st,t1=4i
64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000ns
"
,
"stf,t1=4i
,t3=
\"
t4
\"
,t2=5,t4=5 c1=3i,c3=L
\"
passitagin
\"
,c2=true,c4=5,c5=5,c6=7u 1626006933640000000
"
,
"stf,t1=4i
64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000ns
"
,
"stf,t1=4i
,t3=
\"
t4
\"
,t2=5,t4=5 c1=3i,c3=L
\"
passitagin_stf
\"
,c2=false,c5=5,c6=7u 1626006933641a
"
"stf,t1=4i
64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin_stf
\"
,c2=false,c5=5f64,c6=7u64 1626006933641000000ns
"
};
};
// int code = taos_insert_lines(taos, lines , sizeof(lines)/sizeof(char*));
int
code
=
0
;
int
code
=
taos_insert_lines
(
taos
,
&
lines
[
0
],
1
);
code
=
taos_insert_lines
(
taos
,
lines
,
sizeof
(
lines
)
/
sizeof
(
char
*
));
code
=
taos_insert_lines
(
taos
,
&
lines
[
1
],
1
);
char
*
lines2
[]
=
{
"stg,t1=3i64,t2=4f64,t3=
\"
t3
\"
c1=3i64,c3=L
\"
passit
\"
,c2=false,c4=4f64 1626006833639000000ns"
,
"stg,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64 1626006833640000000ns"
};
code
=
taos_insert_lines
(
taos
,
&
lines2
[
0
],
1
);
code
=
taos_insert_lines
(
taos
,
&
lines2
[
1
],
1
);
char
*
lines3
[]
=
{
"sth,t1=4i64,t2=5f64,t4=5f64,ID=
\"
childtable
\"
c1=3i64,c3=L
\"
passitagin_stf
\"
,c2=false,c5=5f64,c6=7u64 1626006933641ms"
,
"sth,t1=4i64,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin_stf
\"
,c2=false,c5=5f64,c6=7u64 1626006933654ms"
};
code
=
taos_insert_lines
(
taos
,
lines3
,
2
);
return
code
;
return
code
;
}
}
...
@@ -1000,10 +1010,8 @@ int main(int argc, char *argv[]) {
...
@@ -1000,10 +1010,8 @@ int main(int argc, char *argv[]) {
printf
(
"client info: %s
\n
"
,
info
);
printf
(
"client info: %s
\n
"
,
info
);
printf
(
"************ verify shemaless *************
\n
"
);
printf
(
"************ verify shemaless *************
\n
"
);
int
code
=
verify_schema_less
(
taos
);
verify_schema_less
(
taos
);
if
(
code
==
0
)
{
return
code
;
}
printf
(
"************ verify query *************
\n
"
);
printf
(
"************ verify query *************
\n
"
);
verify_query
(
taos
);
verify_query
(
taos
);
...
...
tests/examples/c/schemaless.c
0 → 100644
浏览文件 @
ae650216
#include "taos.h"
#include "taoserror.h"
#include "os.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
int
numSuperTables
=
8
;
int
numChildTables
=
1024
;
int
numRowsPerChildTable
=
128
;
void
shuffle
(
char
**
lines
,
size_t
n
)
{
if
(
n
>
1
)
{
size_t
i
;
for
(
i
=
0
;
i
<
n
-
1
;
i
++
)
{
size_t
j
=
i
+
rand
()
/
(
RAND_MAX
/
(
n
-
i
)
+
1
);
char
*
t
=
lines
[
j
];
lines
[
j
]
=
lines
[
i
];
lines
[
i
]
=
t
;
}
}
}
static
int64_t
getTimeInUs
()
{
struct
timeval
systemTime
;
gettimeofday
(
&
systemTime
,
NULL
);
return
(
int64_t
)
systemTime
.
tv_sec
*
1000000L
+
(
int64_t
)
systemTime
.
tv_usec
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
TAOS_RES
*
result
;
const
char
*
host
=
"127.0.0.1"
;
const
char
*
user
=
"root"
;
const
char
*
passwd
=
"taosdata"
;
taos_options
(
TSDB_OPTION_TIMEZONE
,
"GMT-8"
);
TAOS
*
taos
=
taos_connect
(
host
,
user
,
passwd
,
""
,
0
);
if
(
taos
==
NULL
)
{
printf
(
"
\033
[31mfailed to connect to db, reason:%s
\033
[0m
\n
"
,
taos_errstr
(
taos
));
exit
(
1
);
}
char
*
info
=
taos_get_server_info
(
taos
);
printf
(
"server info: %s
\n
"
,
info
);
info
=
taos_get_client_info
(
taos
);
printf
(
"client info: %s
\n
"
,
info
);
result
=
taos_query
(
taos
,
"drop database if exists db;"
);
taos_free_result
(
result
);
usleep
(
100000
);
result
=
taos_query
(
taos
,
"create database db precision 'ms';"
);
taos_free_result
(
result
);
usleep
(
100000
);
(
void
)
taos_select_db
(
taos
,
"db"
);
time_t
ct
=
time
(
0
);
int64_t
ts
=
ct
*
1000
;
char
*
lineFormat
=
"sta%d,t0=true,t1=127i8,t2=32767i16,t3=%di32,t4=9223372036854775807i64,t9=11.12345f32,t10=22.123456789f64,t11=
\"
binaryTagValue
\"
,t12=L
\"
ncharTagValue
\"
c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=255u8,c6=32770u16,c7=2147483699u32,c8=9223372036854775899u64,c9=11.12345f32,c10=22.123456789f64,c11=
\"
binaryValue
\"
,c12=L
\"
ncharValue
\"
%lldms"
;
char
**
lines
=
calloc
(
numSuperTables
*
numChildTables
*
numRowsPerChildTable
,
sizeof
(
char
*
));
int
l
=
0
;
for
(
int
i
=
0
;
i
<
numSuperTables
;
++
i
)
{
for
(
int
j
=
0
;
j
<
numChildTables
;
++
j
)
{
for
(
int
k
=
0
;
k
<
numRowsPerChildTable
;
++
k
)
{
char
*
line
=
calloc
(
512
,
1
);
snprintf
(
line
,
512
,
lineFormat
,
i
,
j
,
ts
+
10
*
l
);
lines
[
l
]
=
line
;
++
l
;
}
}
}
shuffle
(
lines
,
numSuperTables
*
numChildTables
*
numRowsPerChildTable
);
printf
(
"%s
\n
"
,
"begin taos_insert_lines"
);
int64_t
begin
=
getTimeInUs
();
int32_t
code
=
taos_insert_lines
(
taos
,
lines
,
numSuperTables
*
numChildTables
*
numRowsPerChildTable
);
int64_t
end
=
getTimeInUs
();
printf
(
"code: %d, %s. time used: %"
PRId64
"
\n
"
,
code
,
tstrerror
(
code
),
end
-
begin
);
char
*
lines_000_0
[]
=
{
"sta1,id=sta1_1,t0=true,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=255u8,t6=32770u16,t7=2147483699u32,t8=9223372036854775899u64,t9=11.12345f32,t10=22.123456789f64,t11=
\"
binaryTagValue
\"
,t12=L
\"
ncharTagValue
\"
c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=255u8,c6=32770u16,c7=2147483699u32,c8=9223372036854775899u64,c9=11.12345f32,c10=22.123456789f64,c11=
\"
binaryValue
\"
,c12=L
\"
ncharValue
\"
1626006833639000us"
};
code
=
taos_insert_lines
(
taos
,
lines_000_0
,
sizeof
(
lines_000_0
)
/
sizeof
(
char
*
));
if
(
0
==
code
)
{
printf
(
"taos_insert_lines() lines_000_0 should return error
\n
"
);
return
-
1
;
}
char
*
lines_000_1
[]
=
{
"sta2,id=
\"
sta2_1
\"
,t0=true,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=255u8,t6=32770u16,t7=2147483699u32,t8=9223372036854775899u64,t9=11.12345f32,t10=22.123456789f64,t11=
\"
binaryTagValue
\"
,t12=L
\"
ncharTagValue
\"
c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=255u8,c6=32770u16,c7=2147483699u32,c8=9223372036854775899u64,c9=11.12345f32,c10=22.123456789f64,c11=
\"
binaryValue
\"
,c12=L
\"
ncharValue
\"
1626006833639001"
};
code
=
taos_insert_lines
(
taos
,
lines_000_1
,
sizeof
(
lines_000_1
)
/
sizeof
(
char
*
));
if
(
0
==
code
)
{
printf
(
"taos_insert_lines() lines_000_1 should return error
\n
"
);
return
-
1
;
}
char
*
lines_000_2
[]
=
{
"sta3,id=
\"
sta3_1
\"
,t0=true,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t9=11.12345f32,t10=22.123456789f64,t11=
\"
binaryTagValue
\"
,t12=L
\"
ncharTagValue
\"
c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=255u8,c6=32770u16,c7=2147483699u32,c8=9223372036854775899u64,c9=11.12345f32,c10=22.123456789f64,c11=
\"
binaryValue
\"
,c12=L
\"
ncharValue
\"
0"
};
code
=
taos_insert_lines
(
taos
,
lines_000_2
,
sizeof
(
lines_000_2
)
/
sizeof
(
char
*
));
if
(
0
!=
code
)
{
printf
(
"taos_insert_lines() lines_000_2 return code:%d (%s)
\n
"
,
code
,
(
char
*
)
tstrerror
(
code
));
return
-
1
;
}
char
*
lines_001_0
[]
=
{
"sta4,t0=true,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t9=11.12345f32,t10=22.123456789f64,t11=
\"
binaryTagValue
\"
,t12=L
\"
ncharTagValue
\"
c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c9=11.12345f32,c10=22.123456789f64,c11=
\"
binaryValue
\"
,c12=L
\"
ncharValue
\"
1626006833639000us"
,
};
code
=
taos_insert_lines
(
taos
,
lines_001_0
,
sizeof
(
lines_001_0
)
/
sizeof
(
char
*
));
if
(
0
!=
code
)
{
printf
(
"taos_insert_lines() lines_001_0 return code:%d (%s)
\n
"
,
code
,
(
char
*
)
tstrerror
(
code
));
return
-
1
;
}
char
*
lines_001_1
[]
=
{
"sta5,id=
\"
sta5_1
\"
,t0=true,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t9=11.12345f32,t10=22.123456789f64,t11=
\"
binaryTagValue
\"
,t12=L
\"
ncharTagValue
\"
c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c9=11.12345f32,c10=22.123456789f64,c11=
\"
binaryValue
\"
,c12=L
\"
ncharValue
\"
1626006833639001"
};
code
=
taos_insert_lines
(
taos
,
lines_001_1
,
sizeof
(
lines_001_1
)
/
sizeof
(
char
*
));
if
(
0
!=
code
)
{
printf
(
"taos_insert_lines() lines_001_1 return code:%d (%s)
\n
"
,
code
,
(
char
*
)
tstrerror
(
code
));
return
-
1
;
}
char
*
lines_001_2
[]
=
{
"sta6,id=
\"
sta6_1
\"
,t0=true,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t9=11.12345f32,t10=22.123456789f64,t11=
\"
binaryTagValue
\"
,t12=L
\"
ncharTagValue
\"
c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c9=11.12345f32,c10=22.123456789f64,c11=
\"
binaryValue
\"
,c12=L
\"
ncharValue
\"
0"
};
code
=
taos_insert_lines
(
taos
,
lines_001_2
,
sizeof
(
lines_001_2
)
/
sizeof
(
char
*
));
if
(
0
!=
code
)
{
printf
(
"taos_insert_lines() lines_001_2 return code:%d (%s)
\n
"
,
code
,
(
char
*
)
tstrerror
(
code
));
return
-
1
;
}
char
*
lines_002
[]
=
{
"stb,id=
\"
stb_1
\"
,t20=t,t21=T,t22=true,t23=True,t24=TRUE,t25=f,t26=F,t27=false,t28=False,t29=FALSE,t10=33.12345,t11=
\"
binaryTagValue
\"
,t12=L
\"
ncharTagValue
\"
c20=t,c21=T,c22=true,c23=True,c24=TRUE,c25=f,c26=F,c27=false,c28=False,c29=FALSE,c10=33.12345,c11=
\"
binaryValue
\"
,c12=L
\"
ncharValue
\"
1626006833639000000ns"
,
"stc,id=
\"
stc_1
\"
,t20=t,t21=T,t22=true,t23=True,t24=TRUE,t25=f,t26=F,t27=false,t28=False,t29=FALSE,t10=33.12345,t11=
\"
binaryTagValue
\"
,t12=L
\"
ncharTagValue
\"
c20=t,c21=T,c22=true,c23=True,c24=TRUE,c25=f,c26=F,c27=false,c28=False,c29=FALSE,c10=33.12345,c11=
\"
binaryValue
\"
,c12=L
\"
ncharValue
\"
1626006833639019us"
,
"stc,id=
\"
stc_1
\"
,t20=t,t21=T,t22=true,t23=True,t24=TRUE,t25=f,t26=F,t27=false,t28=False,t29=FALSE,t10=33.12345,t11=
\"
binaryTagValue
\"
,t12=L
\"
ncharTagValue
\"
c20=t,c21=T,c22=true,c23=True,c24=TRUE,c25=f,c26=F,c27=false,c28=False,c29=FALSE,c10=33.12345,c11=
\"
binaryValue
\"
,c12=L
\"
ncharValue
\"
1626006833640ms"
,
"stc,id=
\"
stc_1
\"
,t20=t,t21=T,t22=true,t23=True,t24=TRUE,t25=f,t26=F,t27=false,t28=False,t29=FALSE,t10=33.12345,t11=
\"
binaryTagValue
\"
,t12=L
\"
ncharTagValue
\"
c20=t,c21=T,c22=true,c23=True,c24=TRUE,c25=f,c26=F,c27=false,c28=False,c29=FALSE,c10=33.12345,c11=
\"
binaryValue
\"
,c12=L
\"
ncharValue
\"
1626006834s"
};
code
=
taos_insert_lines
(
taos
,
lines_002
,
sizeof
(
lines_002
)
/
sizeof
(
char
*
));
if
(
0
!=
code
)
{
printf
(
"taos_insert_lines() lines_002 return code:%d (%s)
\n
"
,
code
,
(
char
*
)
tstrerror
(
code
));
return
-
1
;
}
return
0
;
}
tests/pytest/fulltest.sh
浏览文件 @
ae650216
...
@@ -27,6 +27,7 @@ python3 ./test.py -f insert/bug3654.py
...
@@ -27,6 +27,7 @@ python3 ./test.py -f insert/bug3654.py
python3 ./test.py
-f
insert/insertDynamicColBeforeVal.py
python3 ./test.py
-f
insert/insertDynamicColBeforeVal.py
python3 ./test.py
-f
insert/in_function.py
python3 ./test.py
-f
insert/in_function.py
python3 ./test.py
-f
insert/modify_column.py
python3 ./test.py
-f
insert/modify_column.py
python3 ./test.py
-f
insert/line_insert.py
#table
#table
python3 ./test.py
-f
table/alter_wal0.py
python3 ./test.py
-f
table/alter_wal0.py
...
...
tests/pytest/insert/line_insert.py
0 → 100644
浏览文件 @
ae650216
###################################################################
# Copyright (c) 2021 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
(),
logSql
)
self
.
_conn
=
conn
def
run
(
self
):
print
(
"running {}"
.
format
(
__file__
))
tdSql
.
execute
(
"drop database if exists test"
)
tdSql
.
execute
(
"create database if not exists test precision 'us'"
)
tdSql
.
execute
(
'use test'
)
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 1626006833639000000ns"
,
"st,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64 1626006833640000000ns"
,
"ste,t2=5f64,t3=L
\"
ste
\"
c1=true,c2=4i64,c3=
\"
iam
\"
1626056811823316532ns"
,
"stf,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000ns"
,
"st,t1=4i64,t2=5f64,t3=
\"
t4
\"
c1=3i64,c3=L
\"
passitagain
\"
,c2=true,c4=5f64 1626006833642000000ns"
,
"ste,t2=5f64,t3=L
\"
ste2
\"
c3=
\"
iamszhou
\"
,c4=false 1626056811843316532ns"
,
"ste,t2=5f64,t3=L
\"
ste2
\"
c3=
\"
iamszhou
\"
,c4=false,c5=32i8,c6=64i16,c7=32i32,c8=88.88f32 1626056812843316532ns"
,
"st,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000ns"
,
"stf,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin_stf
\"
,c2=false,c5=5f64,c6=7u64 1626006933641000000ns"
]
code
=
self
.
_conn
.
insertLines
(
lines
)
print
(
"insertLines result {}"
.
format
(
code
))
lines2
=
[
"stg,t1=3i64,t2=4f64,t3=
\"
t3
\"
c1=3i64,c3=L
\"
passit
\"
,c2=false,c4=4f64 1626006833639000000ns"
,
"stg,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64 1626006833640000000ns"
]
code
=
self
.
_conn
.
insertLines
([
lines2
[
0
]
])
print
(
"insertLines result {}"
.
format
(
code
))
self
.
_conn
.
insertLines
([
lines2
[
1
]
])
print
(
"insertLines result {}"
.
format
(
code
))
tdSql
.
query
(
"select * from st"
)
tdSql
.
checkRows
(
4
)
tdSql
.
query
(
"select * from ste"
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select * from stf"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select * from stg"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"show tables"
)
tdSql
.
checkRows
(
8
)
tdSql
.
query
(
"describe stf"
)
tdSql
.
checkData
(
2
,
2
,
14
)
self
.
_conn
.
insertLines
([
"sth,t1=4i64,t2=5f64,t4=5f64,ID=
\"
childtable
\"
c1=3i64,c3=L
\"
passitagin_stf
\"
,c2=false,c5=5f64,c6=7u64 1626006933641ms"
,
"sth,t1=4i64,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin_stf
\"
,c2=false,c5=5f64,c6=7u64 1626006933654ms"
])
tdSql
.
query
(
'select tbname, * from sth'
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
'select tbname, * from childtable'
)
tdSql
.
checkRows
(
1
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/script/fullGeneralSuite.sim
浏览文件 @
ae650216
...
@@ -105,6 +105,7 @@ run general/parser/import_commit2.sim
...
@@ -105,6 +105,7 @@ run general/parser/import_commit2.sim
run general/parser/import_commit3.sim
run general/parser/import_commit3.sim
run general/parser/insert_tb.sim
run general/parser/insert_tb.sim
run general/parser/first_last.sim
run general/parser/first_last.sim
run general/parser/line_insert.sim
#unsupport run general/parser/import_file.sim
#unsupport run general/parser/import_file.sim
run general/parser/lastrow.sim
run general/parser/lastrow.sim
run general/parser/nchar.sim
run general/parser/nchar.sim
...
...
tests/script/general/parser/line_insert.sim
浏览文件 @
ae650216
...
@@ -16,11 +16,10 @@ sql create database $db precision 'us'
...
@@ -16,11 +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=3i,t2=4,t3="t3" c1=3i,c3=L"passit",c2=false,c4=4 1626006833639000000
line_insert st,t1=3i64,t2=4f64,t3="t3" c1=3i64,c3=L"passit",c2=false,c4=4f64 1626006833639000000ns
line_insert st,t1=4i,t3="t41",t2=5 c1=3i,c3=L"passiT",c2=true,c4=5 1626006833640000000
line_insert st,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin",c2=true,c4=5f64,c5=5f64 1626006833640000000ns
line_insert stf,t1=4i,t2=5,t3="t4" c1=3i,c3=L"passitagain",c2=true,c4=5 1626006833642000000
line_insert ste,t2=5f64,t3=L"ste" c1=true,c2=4i64,c3="iam" 1626056811823316532ns
line_insert ste,t2=5,t3=L"ste" c1=true,c2=4,c3="iam" 1626056811823316532
line_insert stf,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000ns
sql select * from st
sql select * from st
if $rows != 2 then
if $rows != 2 then
return -1
return -1
...
@@ -30,7 +29,7 @@ if $data00 != @21-07-11 20:33:53.639000@ then
...
@@ -30,7 +29,7 @@ if $data00 != @21-07-11 20:33:53.639000@ then
return -1
return -1
endi
endi
if $data0
3
!= @passit@ then
if $data0
2
!= @passit@ then
return -1
return -1
endi
endi
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录