Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8f231917
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
8f231917
编写于
11月 02, 2021
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed the syntax error of the specified tag column inserted in multiple tables in stmt mode.
上级
692535c3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
98 addition
and
8 deletion
+98
-8
.gitignore
.gitignore
+4
-0
src/client/src/tscPrepare.c
src/client/src/tscPrepare.c
+48
-5
tests/script/api/batchprepare.c
tests/script/api/batchprepare.c
+46
-3
未找到文件。
.gitignore
浏览文件 @
8f231917
...
...
@@ -81,6 +81,10 @@ tests/comparisonTest/opentsdb/opentsdbtest/.settings/
tests/examples/JDBC/JDBCDemo/.classpath
tests/examples/JDBC/JDBCDemo/.project
tests/examples/JDBC/JDBCDemo/.settings/
tests/script/api/batchprepare
tests/script/api/stmt
tests/script/api/stmtBatchTest
tests/script/api/stmtTest
# Emacs
# -*- mode: gitignore; -*-
...
...
src/client/src/tscPrepare.c
浏览文件 @
8f231917
...
...
@@ -48,12 +48,14 @@ typedef struct SMultiTbStmt {
bool
nameSet
;
bool
tagSet
;
bool
subSet
;
bool
tagColSet
;
uint64_t
currentUid
;
char
*
sqlstr
;
uint32_t
tbNum
;
SStrToken
tbname
;
SStrToken
stbname
;
SStrToken
values
;
SStrToken
tagCols
;
SArray
*
tags
;
STableDataBlocks
*
lastBlock
;
SHashObj
*
pTableHash
;
...
...
@@ -1343,9 +1345,40 @@ int stmtParseInsertTbTags(SSqlObj* pSql, STscStmt* pStmt) {
pStmt
->
mtb
.
stbname
=
sToken
;
sToken
=
tStrGetToken
(
pCmd
->
insertParam
.
sql
,
&
index
,
false
);
if
(
sToken
.
n
<=
0
||
sToken
.
type
!=
TK_TAGS
)
{
tscError
(
"keyword TAGS expected, sql:%s"
,
pCmd
->
insertParam
.
sql
);
return
tscSQLSyntaxErrMsg
(
pCmd
->
payload
,
"keyword TAGS expected"
,
sToken
.
z
?
sToken
.
z
:
pCmd
->
insertParam
.
sql
);
if
(
sToken
.
n
<=
0
||
((
sToken
.
type
!=
TK_TAGS
)
&&
(
sToken
.
type
!=
TK_LP
)))
{
tscError
(
"invalid token, sql:%s"
,
pCmd
->
insertParam
.
sql
);
return
tscSQLSyntaxErrMsg
(
pCmd
->
payload
,
"invalid token"
,
sToken
.
z
?
sToken
.
z
:
pCmd
->
insertParam
.
sql
);
}
// ... (tag_col_list) TAGS(tag_val_list) ...
int32_t
tagColsCnt
=
0
;
if
(
sToken
.
type
==
TK_LP
)
{
pStmt
->
mtb
.
tagColSet
=
true
;
pStmt
->
mtb
.
tagCols
=
sToken
;
int32_t
tagColsStart
=
index
;
while
(
1
)
{
sToken
=
tStrGetToken
(
pCmd
->
insertParam
.
sql
,
&
index
,
false
);
if
(
sToken
.
type
==
TK_ILLEGAL
)
{
return
tscSQLSyntaxErrMsg
(
pCmd
->
payload
,
"unrecognized token"
,
sToken
.
z
);
}
if
(
sToken
.
type
==
TK_ID
)
{
++
tagColsCnt
;
}
if
(
sToken
.
type
==
TK_RP
)
{
break
;
}
}
if
(
tagColsCnt
==
0
)
{
tscError
(
"tag column list expected, sql:%s"
,
pCmd
->
insertParam
.
sql
);
return
tscSQLSyntaxErrMsg
(
pCmd
->
payload
,
"tag column list expected"
,
pCmd
->
insertParam
.
sql
);
}
pStmt
->
mtb
.
tagCols
.
n
=
index
-
tagColsStart
+
1
;
sToken
=
tStrGetToken
(
pCmd
->
insertParam
.
sql
,
&
index
,
false
);
if
(
sToken
.
n
<=
0
||
sToken
.
type
!=
TK_TAGS
)
{
tscError
(
"keyword TAGS expected, sql:%s"
,
pCmd
->
insertParam
.
sql
);
return
tscSQLSyntaxErrMsg
(
pCmd
->
payload
,
"keyword TAGS expected"
,
sToken
.
z
?
sToken
.
z
:
pCmd
->
insertParam
.
sql
);
}
}
sToken
=
tStrGetToken
(
pCmd
->
insertParam
.
sql
,
&
index
,
false
);
...
...
@@ -1385,6 +1418,11 @@ int stmtParseInsertTbTags(SSqlObj* pSql, STscStmt* pStmt) {
return
tscSQLSyntaxErrMsg
(
pCmd
->
payload
,
"no tags"
,
pCmd
->
insertParam
.
sql
);
}
if
(
tagColsCnt
>
0
&&
taosArrayGetSize
(
pStmt
->
mtb
.
tags
)
!=
tagColsCnt
)
{
tscError
(
"not match tags, sql:%s"
,
pCmd
->
insertParam
.
sql
);
return
tscSQLSyntaxErrMsg
(
pCmd
->
payload
,
"not match tags"
,
pCmd
->
insertParam
.
sql
);
}
sToken
=
tStrGetToken
(
pCmd
->
insertParam
.
sql
,
&
index
,
false
);
if
(
sToken
.
n
<=
0
||
(
sToken
.
type
!=
TK_VALUES
&&
sToken
.
type
!=
TK_LP
))
{
tscError
(
"sql error, sql:%s"
,
pCmd
->
insertParam
.
sql
);
...
...
@@ -1407,7 +1445,13 @@ int stmtGenInsertStatement(SSqlObj* pSql, STscStmt* pStmt, const char* name, TAO
int32_t
j
=
0
;
while
(
1
)
{
len
=
(
size_t
)
snprintf
(
str
,
size
-
1
,
"insert into %s using %.*s tags("
,
name
,
pStmt
->
mtb
.
stbname
.
n
,
pStmt
->
mtb
.
stbname
.
z
);
if
(
pStmt
->
mtb
.
tagColSet
)
{
len
=
(
size_t
)
snprintf
(
str
,
size
-
1
,
"insert into %s using %.*s %.*s tags("
,
name
,
pStmt
->
mtb
.
stbname
.
n
,
pStmt
->
mtb
.
stbname
.
z
,
pStmt
->
mtb
.
tagCols
.
n
,
pStmt
->
mtb
.
tagCols
.
z
);
}
else
{
len
=
(
size_t
)
snprintf
(
str
,
size
-
1
,
"insert into %s using %.*s tags("
,
name
,
pStmt
->
mtb
.
stbname
.
n
,
pStmt
->
mtb
.
stbname
.
z
);
}
if
(
len
>=
(
size
-
1
))
{
size
*=
2
;
free
(
str
);
...
...
@@ -1708,7 +1752,6 @@ int taos_stmt_set_tbname_tags(TAOS_STMT* stmt, const char* name, TAOS_BIND* tags
STMT_RET
(
TSDB_CODE_SUCCESS
);
}
if
(
pStmt
->
mtb
.
tagSet
)
{
pStmt
->
mtb
.
tbname
=
tscReplaceStrToken
(
&
pSql
->
sqlstr
,
&
pStmt
->
mtb
.
tbname
,
name
);
}
else
{
...
...
tests/script/api/batchprepare.c
浏览文件 @
8f231917
...
...
@@ -1761,7 +1761,7 @@ int stmt_funcb_autoctb_e1(TAOS_STMT *stmt) {
int
code
=
taos_stmt_prepare
(
stmt
,
sql
,
0
);
if
(
code
!=
0
){
printf
(
"failed to execute taos_stmt_prepare. error:%s
\n
"
,
taos_stmt_errstr
(
stmt
));
return
-
1
;
exit
(
1
)
;
}
int
id
=
0
;
...
...
@@ -1797,9 +1797,44 @@ int stmt_funcb_autoctb_e1(TAOS_STMT *stmt) {
return
0
;
}
int
stmt_multi_insert_check
(
TAOS_STMT
*
stmt
)
{
char
*
sql
;
// The number of tag column list is not equal to the number of tag value list
sql
=
"insert into ? using stb1 (id1) tags(1,?) values(?,?,?,?,?,?,?,?,?,?)"
;
if
(
0
==
taos_stmt_prepare
(
stmt
,
sql
,
0
))
{
printf
(
"failed to check taos_stmt_prepare. sql:%s
\n
"
,
sql
);
exit
(
1
);
}
// The number of column list is not equal to the number of value list
sql
=
"insert into ? using stb1 tags(1,?,2,?,4,?,6.0,?,'b') "
"(ts, b, v1, v2, v4, v8, f4, f8, bin) values(?,?,?,?,?,?,?,?,?,?)"
;
if
(
0
==
taos_stmt_prepare
(
stmt
,
sql
,
0
))
{
printf
(
"failed to check taos_stmt_prepare. sql:%s
\n
"
,
sql
);
exit
(
1
);
}
sql
=
"insert into ? using stb1 () tags(1,?) values(?,?,?,?,?,?,?,?,?,?)"
;
if
(
0
==
taos_stmt_prepare
(
stmt
,
sql
,
0
))
{
printf
(
"failed to check taos_stmt_prepare. sql:%s
\n
"
,
sql
);
exit
(
1
);
}
sql
=
"insert into ? using stb1 ( tags(1,?) values(?,?,?,?,?,?,?,?,?,?)"
;
if
(
0
==
taos_stmt_prepare
(
stmt
,
sql
,
0
))
{
printf
(
"failed to check taos_stmt_prepare. sql:%s
\n
"
,
sql
);
exit
(
1
);
}
sql
=
"insert into ? using stb1 ) tags(1,?) values(?,?,?,?,?,?,?,?,?,?)"
;
if
(
0
==
taos_stmt_prepare
(
stmt
,
sql
,
0
))
{
printf
(
"failed to check taos_stmt_prepare. sql:%s
\n
"
,
sql
);
exit
(
1
);
}
return
0
;
}
//1 tables 10 records
int
stmt_funcb_autoctb_e2
(
TAOS_STMT
*
stmt
)
{
...
...
@@ -4505,7 +4540,6 @@ void* runcase(void *par) {
(
void
)
idx
;
#if 1
prepare
(
taos
,
1
,
1
);
...
...
@@ -4819,6 +4853,16 @@ void* runcase(void *par) {
#endif
#if 1
prepare
(
taos
,
1
,
0
);
stmt
=
taos_stmt_init
(
taos
);
printf
(
"stmt_multi_insert_check start
\n
"
);
stmt_multi_insert_check
(
stmt
);
printf
(
"stmt_multi_insert_check end
\n
"
);
taos_stmt_close
(
stmt
);
#endif
#if 1
prepare
(
taos
,
1
,
1
);
...
...
@@ -5007,7 +5051,6 @@ void* runcase(void *par) {
printf
(
"check result end
\n
"
);
#endif
#if 1
preparem
(
taos
,
0
,
idx
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录