Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
c8f1f7ca
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
c8f1f7ca
编写于
7月 14, 2021
作者:
H
Haojun Liao
提交者:
GitHub
7月 14, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6846 from taosdata/feature/szhou/sync_home_office
Feature/szhou/sync home office
上级
9d475061
6b404cd1
变更
10
展开全部
隐藏空白更改
内联
并排
Showing
10 changed file
with
1419 addition
and
4 deletion
+1419
-4
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+1
-0
src/client/src/tscParseLineProtocol.c
src/client/src/tscParseLineProtocol.c
+1214
-0
src/client/src/tscPrepare.c
src/client/src/tscPrepare.c
+9
-2
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+1
-0
src/inc/taos.h
src/inc/taos.h
+2
-0
tests/examples/c/apitest.c
tests/examples/c/apitest.c
+40
-2
tests/script/general/parser/line_insert.sim
tests/script/general/parser/line_insert.sim
+54
-0
tests/tsim/inc/sim.h
tests/tsim/inc/sim.h
+4
-0
tests/tsim/src/simExe.c
tests/tsim/src/simExe.c
+46
-0
tests/tsim/src/simParse.c
tests/tsim/src/simParse.c
+48
-0
未找到文件。
src/client/src/tscParseInsert.c
浏览文件 @
c8f1f7ca
...
...
@@ -1129,6 +1129,7 @@ int tsParseInsertSql(SSqlObj *pSql) {
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SInsertStatementParam
*
pInsertParam
=
&
pCmd
->
insertParam
;
pInsertParam
->
objectId
=
pSql
->
self
;
char
*
str
=
pInsertParam
->
sql
;
int32_t
totalNum
=
0
;
...
...
src/client/src/tscParseLineProtocol.c
0 → 100644
浏览文件 @
c8f1f7ca
此差异已折叠。
点击以展开。
src/client/src/tscPrepare.c
浏览文件 @
c8f1f7ca
...
...
@@ -1200,9 +1200,11 @@ static int insertBatchStmtExecute(STscStmt* pStmt) {
// wait for the callback function to post the semaphore
tsem_wait
(
&
pStmt
->
pSql
->
rspSem
);
code
=
pStmt
->
pSql
->
res
.
code
;
insertBatchClean
(
pStmt
);
return
pStmt
->
pSql
->
res
.
code
;
return
code
;
}
int
stmtParseInsertTbTags
(
SSqlObj
*
pSql
,
STscStmt
*
pStmt
)
{
...
...
@@ -1470,6 +1472,7 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) {
pSql
->
fetchFp
=
waitForQueryRsp
;
pCmd
->
insertParam
.
insertType
=
TSDB_QUERY_TYPE_STMT_INSERT
;
pCmd
->
insertParam
.
objectId
=
pSql
->
self
;
pSql
->
sqlstr
=
realloc
(
pSql
->
sqlstr
,
sqlLen
+
1
);
...
...
@@ -1646,7 +1649,11 @@ int taos_stmt_close(TAOS_STMT* stmt) {
}
else
{
if
(
pStmt
->
multiTbInsert
)
{
taosHashCleanup
(
pStmt
->
mtb
.
pTableHash
);
pStmt
->
mtb
.
pTableBlockHashList
=
tscDestroyBlockHashTable
(
pStmt
->
mtb
.
pTableBlockHashList
,
false
);
bool
rmMeta
=
false
;
if
(
pStmt
->
pSql
&&
pStmt
->
pSql
->
res
.
code
!=
0
)
{
rmMeta
=
true
;
}
pStmt
->
mtb
.
pTableBlockHashList
=
tscDestroyBlockHashTable
(
pStmt
->
mtb
.
pTableBlockHashList
,
rmMeta
);
taosHashCleanup
(
pStmt
->
pSql
->
cmd
.
insertParam
.
pTableBlockHashList
);
pStmt
->
pSql
->
cmd
.
insertParam
.
pTableBlockHashList
=
NULL
;
taosArrayDestroy
(
pStmt
->
mtb
.
tags
);
...
...
src/client/src/tscUtil.c
浏览文件 @
c8f1f7ca
...
...
@@ -3342,6 +3342,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, __async_cb_func_t
pnCmd
->
insertParam
.
numOfTables
=
0
;
pnCmd
->
insertParam
.
pTableNameList
=
NULL
;
pnCmd
->
insertParam
.
pTableBlockHashList
=
NULL
;
pnCmd
->
insertParam
.
objectId
=
pNew
->
self
;
memset
(
&
pnCmd
->
insertParam
.
tagData
,
0
,
sizeof
(
STagData
));
...
...
src/inc/taos.h
浏览文件 @
c8f1f7ca
...
...
@@ -169,6 +169,8 @@ 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_insert_lines
(
TAOS
*
taos
,
char
*
lines
[],
int
numLines
);
#ifdef __cplusplus
}
#endif
...
...
tests/examples/c/apitest.c
浏览文件 @
c8f1f7ca
...
...
@@ -12,7 +12,7 @@ static void prepare_data(TAOS* taos) {
result
=
taos_query
(
taos
,
"drop database if exists test;"
);
taos_free_result
(
result
);
usleep
(
100000
);
result
=
taos_query
(
taos
,
"create database test;"
);
result
=
taos_query
(
taos
,
"create database test
precision 'us'
;"
);
taos_free_result
(
result
);
usleep
(
100000
);
taos_select_db
(
taos
,
"test"
);
...
...
@@ -949,13 +949,45 @@ void verify_stream(TAOS* taos) {
taos_close_stream
(
strm
);
}
int32_t
verify_schema_less
(
TAOS
*
taos
)
{
TAOS_RES
*
result
;
result
=
taos_query
(
taos
,
"drop database if exists test;"
);
taos_free_result
(
result
);
usleep
(
100000
);
result
=
taos_query
(
taos
,
"create database test precision 'us';"
);
taos_free_result
(
result
);
usleep
(
100000
);
taos_select_db
(
taos
,
"test"
);
result
=
taos_query
(
taos
,
"create stable ste(ts timestamp, f int) tags(t1 bigint)"
);
taos_free_result
(
result
);
usleep
(
100000
);
char
*
lines
[]
=
{
"st,t1=3i,t2=4,t3=
\"
t3
\"
c1=3i,c3=L
\"
passit
\"
,c2=false,c4=4 1626006833639000000"
,
"st,t1=4i,t3=
\"
t4
\"
,t2=5,t4=5 c1=3i,c3=L
\"
passitagin
\"
,c2=true,c4=5,c5=5 1626006833640000000"
,
"ste,t2=5,t3=L
\"
ste
\"
c1=true,c2=4,c3=
\"
iam
\"
1626056811823316532"
,
"st,t1=4i,t2=5,t3=
\"
t4
\"
c1=3i,c3=L
\"
passitagain
\"
,c2=true,c4=5 1626006833642000000"
,
"ste,t2=5,t3=L
\"
ste2
\"
c3=
\"
iamszhou
\"
,c4=false 1626056811843316532"
,
"ste,t2=5,t3=L
\"
ste2
\"
c3=
\"
iamszhou
\"
,c4=false,c5=32b,c6=64s,c7=32w,c8=88.88f 1626056812843316532"
,
"st,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,t3=
\"
t4
\"
,t2=5,t4=5 c1=3i,c3=L
\"
passitagin
\"
,c2=true,c4=5,c5=5,c6=7u 1626006933640000000"
,
"stf,t1=4i,t3=
\"
t4
\"
,t2=5,t4=5 c1=3i,c3=L
\"
passitagin_stf
\"
,c2=false,c5=5,c6=7u 1626006933641a"
};
// int code = taos_insert_lines(taos, lines , sizeof(lines)/sizeof(char*));
int
code
=
taos_insert_lines
(
taos
,
&
lines
[
0
],
1
);
code
=
taos_insert_lines
(
taos
,
&
lines
[
1
],
1
);
return
code
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
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
));
...
...
@@ -967,6 +999,12 @@ int main(int argc, char *argv[]) {
info
=
taos_get_client_info
(
taos
);
printf
(
"client info: %s
\n
"
,
info
);
printf
(
"************ verify shemaless *************
\n
"
);
int
code
=
verify_schema_less
(
taos
);
if
(
code
==
0
)
{
return
code
;
}
printf
(
"************ verify query *************
\n
"
);
verify_query
(
taos
);
...
...
tests/script/general/parser/line_insert.sim
0 → 100644
浏览文件 @
c8f1f7ca
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/exec.sh -n dnode1 -s start
sleep 2000
sql connect
print =============== step1
$db = testlp
$mte = ste
$mt = st
sql drop database $db -x step1
step1:
sql create database $db precision 'us'
sql use $db
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=4i,t3="t41",t2=5 c1=3i,c3=L"passiT",c2=true,c4=5 1626006833640000000
line_insert stf,t1=4i,t2=5,t3="t4" c1=3i,c3=L"passitagain",c2=true,c4=5 1626006833642000000
line_insert ste,t2=5,t3=L"ste" c1=true,c2=4,c3="iam" 1626056811823316532
sql select * from st
if $rows != 2 then
return -1
endi
if $data00 != @21-07-11 20:33:53.639000@ then
return -1
endi
if $data03 != @passit@ then
return -1
endi
sql select * from stf
if $rows != 1 then
return -1
endi
sql select * from ste
if $rows != 1 then
return -1
endi
#print =============== clear
sql drop database $db
sql show databases
if $rows != 0 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/tsim/inc/sim.h
浏览文件 @
c8f1f7ca
...
...
@@ -87,6 +87,8 @@ enum {
SIM_CMD_RESTFUL
,
SIM_CMD_TEST
,
SIM_CMD_RETURN
,
SIM_CMD_LINE_INSERT
,
SIM_CMD_LINE_INSERT_ERROR
,
SIM_CMD_END
};
...
...
@@ -172,6 +174,8 @@ bool simExecuteSqlCmd(SScript *script, char *option);
bool
simExecuteSqlErrorCmd
(
SScript
*
script
,
char
*
rest
);
bool
simExecuteSqlSlowCmd
(
SScript
*
script
,
char
*
option
);
bool
simExecuteRestfulCmd
(
SScript
*
script
,
char
*
rest
);
bool
simExecuteLineInsertCmd
(
SScript
*
script
,
char
*
option
);
bool
simExecuteLineInsertErrorCmd
(
SScript
*
script
,
char
*
option
);
void
simVisuallizeOption
(
SScript
*
script
,
char
*
src
,
char
*
dst
);
#endif
\ No newline at end of file
tests/tsim/src/simExe.c
浏览文件 @
c8f1f7ca
...
...
@@ -1067,3 +1067,49 @@ bool simExecuteSqlErrorCmd(SScript *script, char *rest) {
return
false
;
}
bool
simExecuteLineInsertCmd
(
SScript
*
script
,
char
*
rest
)
{
char
buf
[
TSDB_MAX_BINARY_LEN
];
simVisuallizeOption
(
script
,
rest
,
buf
);
rest
=
buf
;
SCmdLine
*
line
=
&
script
->
lines
[
script
->
linePos
];
simInfo
(
"script:%s, %s"
,
script
->
fileName
,
rest
);
simLogSql
(
buf
,
true
);
char
*
lines
[]
=
{
rest
};
int32_t
ret
=
taos_insert_lines
(
script
->
taos
,
lines
,
1
);
if
(
ret
==
TSDB_CODE_SUCCESS
)
{
simDebug
(
"script:%s, taos:%p, %s executed. success."
,
script
->
fileName
,
script
->
taos
,
rest
);
script
->
linePos
++
;
return
true
;
}
else
{
sprintf
(
script
->
error
,
"lineNum: %d. line: %s failed, ret:%d:%s"
,
line
->
lineNum
,
rest
,
ret
&
0XFFFF
,
tstrerror
(
ret
));
return
false
;
}
}
bool
simExecuteLineInsertErrorCmd
(
SScript
*
script
,
char
*
rest
)
{
char
buf
[
TSDB_MAX_BINARY_LEN
];
simVisuallizeOption
(
script
,
rest
,
buf
);
rest
=
buf
;
SCmdLine
*
line
=
&
script
->
lines
[
script
->
linePos
];
simInfo
(
"script:%s, %s"
,
script
->
fileName
,
rest
);
simLogSql
(
buf
,
true
);
char
*
lines
[]
=
{
rest
};
int32_t
ret
=
taos_insert_lines
(
script
->
taos
,
lines
,
1
);
if
(
ret
==
TSDB_CODE_SUCCESS
)
{
sprintf
(
script
->
error
,
"script:%s, taos:%p, %s executed. expect failed, but success."
,
script
->
fileName
,
script
->
taos
,
rest
);
script
->
linePos
++
;
return
false
;
}
else
{
simDebug
(
"lineNum: %d. line: %s failed, ret:%d:%s. Expect failed, so success"
,
line
->
lineNum
,
rest
,
ret
&
0XFFFF
,
tstrerror
(
ret
));
return
true
;
}
}
tests/tsim/src/simParse.c
浏览文件 @
c8f1f7ca
...
...
@@ -838,6 +838,38 @@ bool simParseRunBackCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
return
true
;
}
bool
simParseLineInsertCmd
(
char
*
rest
,
SCommand
*
pCmd
,
int32_t
lineNum
)
{
int32_t
expLen
;
rest
++
;
cmdLine
[
numOfLines
].
cmdno
=
SIM_CMD_LINE_INSERT
;
cmdLine
[
numOfLines
].
lineNum
=
lineNum
;
cmdLine
[
numOfLines
].
optionOffset
=
optionOffset
;
expLen
=
(
int32_t
)
strlen
(
rest
);
memcpy
(
optionBuffer
+
optionOffset
,
rest
,
expLen
);
optionOffset
+=
expLen
+
1
;
*
(
optionBuffer
+
optionOffset
-
1
)
=
0
;
numOfLines
++
;
return
true
;
}
bool
simParseLineInsertErrorCmd
(
char
*
rest
,
SCommand
*
pCmd
,
int32_t
lineNum
)
{
int32_t
expLen
;
rest
++
;
cmdLine
[
numOfLines
].
cmdno
=
SIM_CMD_LINE_INSERT
;
cmdLine
[
numOfLines
].
lineNum
=
lineNum
;
cmdLine
[
numOfLines
].
optionOffset
=
optionOffset
;
expLen
=
(
int32_t
)
strlen
(
rest
);
memcpy
(
optionBuffer
+
optionOffset
,
rest
,
expLen
);
optionOffset
+=
expLen
+
1
;
*
(
optionBuffer
+
optionOffset
-
1
)
=
0
;
numOfLines
++
;
return
true
;
}
void
simInitsimCmdList
()
{
int32_t
cmdno
;
memset
(
simCmdList
,
0
,
SIM_CMD_END
*
sizeof
(
SCommand
));
...
...
@@ -1049,4 +1081,20 @@ void simInitsimCmdList() {
simCmdList
[
cmdno
].
parseCmd
=
simParseReturnCmd
;
simCmdList
[
cmdno
].
executeCmd
=
simExecuteReturnCmd
;
simAddCmdIntoHash
(
&
(
simCmdList
[
cmdno
]));
cmdno
=
SIM_CMD_LINE_INSERT
;
simCmdList
[
cmdno
].
cmdno
=
cmdno
;
strcpy
(
simCmdList
[
cmdno
].
name
,
"line_insert"
);
simCmdList
[
cmdno
].
nlen
=
(
int16_t
)
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
parseCmd
=
simParseLineInsertCmd
;
simCmdList
[
cmdno
].
executeCmd
=
simExecuteLineInsertCmd
;
simAddCmdIntoHash
(
&
(
simCmdList
[
cmdno
]));
cmdno
=
SIM_CMD_LINE_INSERT_ERROR
;
simCmdList
[
cmdno
].
cmdno
=
cmdno
;
strcpy
(
simCmdList
[
cmdno
].
name
,
"line_insert_error"
);
simCmdList
[
cmdno
].
nlen
=
(
int16_t
)
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
parseCmd
=
simParseLineInsertErrorCmd
;
simCmdList
[
cmdno
].
executeCmd
=
simExecuteLineInsertErrorCmd
;
simAddCmdIntoHash
(
&
(
simCmdList
[
cmdno
]));
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录