Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f0154c03
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看板
提交
f0154c03
编写于
5月 09, 2022
作者:
D
dapan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
stmt auto create table
上级
6621ee69
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
95 addition
and
18 deletion
+95
-18
source/client/src/clientStmt.c
source/client/src/clientStmt.c
+7
-2
source/libs/parser/src/parInsert.c
source/libs/parser/src/parInsert.c
+9
-0
tests/script/api/batchprepare.c
tests/script/api/batchprepare.c
+79
-16
未找到文件。
source/client/src/clientStmt.c
浏览文件 @
f0154c03
...
...
@@ -29,6 +29,11 @@ int32_t stmtSwitchStatus(STscStmt* pStmt, STMT_STATUS newStatus) {
if
(
STMT_STATUS_EQ
(
INIT
)
||
STMT_STATUS_EQ
(
BIND_COL
))
{
code
=
TSDB_CODE_TSC_STMT_API_ERROR
;
}
/*
if ((pStmt->sql.type == STMT_TYPE_MULTI_INSERT) && ()) {
code = TSDB_CODE_TSC_STMT_API_ERROR;
}
*/
break
;
case
STMT_BIND_COL
:
if
(
STMT_STATUS_EQ
(
INIT
)
||
STMT_STATUS_EQ
(
BIND
))
{
...
...
@@ -513,8 +518,6 @@ int32_t stmtFetchColFields(STscStmt* pStmt, int32_t *fieldNum, TAOS_FIELD** fiel
int
stmtBindBatch
(
TAOS_STMT
*
stmt
,
TAOS_MULTI_BIND
*
bind
,
int32_t
colIdx
)
{
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
STMT_ERR_RET
(
stmtSwitchStatus
(
pStmt
,
STMT_BIND
));
if
(
pStmt
->
bInfo
.
needParse
&&
pStmt
->
sql
.
runTimes
&&
pStmt
->
sql
.
type
>
0
&&
STMT_TYPE_MULTI_INSERT
!=
pStmt
->
sql
.
type
)
{
pStmt
->
bInfo
.
needParse
=
false
;
}
...
...
@@ -532,6 +535,8 @@ int stmtBindBatch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind, int32_t colIdx) {
STMT_ERR_RET
(
stmtParseSql
(
pStmt
));
}
STMT_ERR_RET
(
stmtSwitchStatus
(
pStmt
,
STMT_BIND
));
if
(
STMT_TYPE_QUERY
==
pStmt
->
sql
.
type
)
{
if
(
NULL
==
pStmt
->
sql
.
pQueryPlan
)
{
STMT_ERR_RET
(
getQueryPlan
(
pStmt
->
exec
.
pRequest
,
pStmt
->
sql
.
pQuery
,
&
pStmt
->
sql
.
nodeList
));
...
...
source/libs/parser/src/parInsert.c
浏览文件 @
f0154c03
...
...
@@ -241,6 +241,15 @@ static int32_t getTableMetaImpl(SInsertParseContext* pCxt, SToken* pTname, bool
SParseContext
*
pBasicCtx
=
pCxt
->
pComCxt
;
SName
name
=
{
0
};
createSName
(
&
name
,
pTname
,
pBasicCtx
->
acctId
,
pBasicCtx
->
db
,
&
pCxt
->
msg
);
char
dbFname
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
tNameGetFullDbName
(
&
name
,
dbFname
);
bool
pass
=
false
;
CHECK_CODE
(
catalogChkAuth
(
pBasicCtx
->
pCatalog
,
pBasicCtx
->
pTransporter
,
&
pBasicCtx
->
mgmtEpSet
,
pBasicCtx
->
pUser
,
dbFname
,
AUTH_TYPE_WRITE
,
&
pass
));
if
(
!
pass
)
{
return
TSDB_CODE_PAR_PERMISSION_DENIED
;
}
if
(
isStb
)
{
CHECK_CODE
(
catalogGetSTableMeta
(
pBasicCtx
->
pCatalog
,
pBasicCtx
->
pTransporter
,
&
pBasicCtx
->
mgmtEpSet
,
&
name
,
&
pCxt
->
pTableMeta
));
...
...
tests/script/api/batchprepare.c
浏览文件 @
f0154c03
...
...
@@ -104,7 +104,7 @@ typedef struct {
int32_t
colNum
;
int32_t
*
colList
;
// full table column list
int32_t
testType
;
bool
prepareStb
;
bool
autoCreateTbl
;
bool
fullCol
;
int32_t
(
*
runFn
)(
TAOS_STMT
*
,
TAOS
*
);
int32_t
tblNum
;
...
...
@@ -118,8 +118,8 @@ typedef struct {
}
CaseCfg
;
CaseCfg
gCase
[]
=
{
{
"insert:MBSE
1
-FULL"
,
tListLen
(
shortColList
),
shortColList
,
TTYPE_INSERT
,
false
,
true
,
insertMBSETest1
,
1
,
10
,
10
,
0
,
0
,
0
,
1
,
-
1
},
{
"insert:MBSE
1
-FULL"
,
tListLen
(
shortColList
),
shortColList
,
TTYPE_INSERT
,
false
,
true
,
insertMBSETest1
,
10
,
100
,
10
,
0
,
0
,
0
,
1
,
-
1
},
{
"insert:MBSE
0
-FULL"
,
tListLen
(
shortColList
),
shortColList
,
TTYPE_INSERT
,
false
,
true
,
insertMBSETest1
,
1
,
10
,
10
,
0
,
0
,
0
,
1
,
-
1
},
{
"insert:MBSE
0
-FULL"
,
tListLen
(
shortColList
),
shortColList
,
TTYPE_INSERT
,
false
,
true
,
insertMBSETest1
,
10
,
100
,
10
,
0
,
0
,
0
,
1
,
-
1
},
{
"insert:MBSE1-FULL"
,
tListLen
(
fullColList
),
fullColList
,
TTYPE_INSERT
,
false
,
true
,
insertMBSETest1
,
10
,
10
,
2
,
0
,
0
,
0
,
1
,
-
1
},
{
"insert:MBSE1-C012"
,
tListLen
(
fullColList
),
fullColList
,
TTYPE_INSERT
,
false
,
false
,
insertMBSETest1
,
10
,
10
,
2
,
12
,
0
,
0
,
1
,
-
1
},
...
...
@@ -166,6 +166,7 @@ typedef struct {
bool
printCreateTblSql
;
bool
printQuerySql
;
bool
printStmtSql
;
bool
autoCreateTbl
;
int32_t
rowNum
;
//row num for one table
int32_t
bindColNum
;
int32_t
bindTagNum
;
...
...
@@ -189,6 +190,35 @@ CaseCtrl gCaseCtrl = { // default
.printCreateTblSql = false,
.printQuerySql = true,
.printStmtSql = true,
.autoCreateTbl = false,
.rowNum = 0,
.bindColNum = 0,
.bindTagNum = 0,
.bindRowNum = 0,
.bindColTypeNum = 0,
.bindColTypeList = NULL,
.bindTagTypeNum = 0,
.bindTagTypeList = NULL,
.optrIdxListNum = 0,
.optrIdxList = NULL,
.checkParamNum = false,
.printRes = true,
.runTimes = 0,
.caseIdx = -1,
.caseNum = -1,
.caseRunIdx = -1,
.caseRunNum = -1,
};
#endif
#if 1
CaseCtrl
gCaseCtrl
=
{
// default
.
bindNullNum
=
0
,
.
printCreateTblSql
=
true
,
.
printQuerySql
=
true
,
.
printStmtSql
=
true
,
.
autoCreateTbl
=
false
,
.
rowNum
=
0
,
.
bindColNum
=
0
,
.
bindTagNum
=
0
,
...
...
@@ -236,12 +266,13 @@ CaseCtrl gCaseCtrl = { // query case with specified col&oper
};
#endif
#if
1
#if
0
CaseCtrl gCaseCtrl = { // query case with specified col&oper
.bindNullNum = 0,
.printCreateTblSql = true,
.printQuerySql = true,
.printStmtSql = true,
.autoCreateTbl = true,
.rowNum = 0,
.bindColNum = 0,
.bindTagNum = 0,
...
...
@@ -1237,6 +1268,15 @@ void bpCheckQueryResult(TAOS_STMT *stmt, TAOS *taos, char *stmtSql, TAOS_MULTI_B
printf
(
"***sql res num match stmt res num %d
\n
"
,
stmtResNum
);
}
int32_t
bpSetTableNameTags
(
BindData
*
data
,
int32_t
tblIdx
,
char
*
tblName
,
TAOS_STMT
*
stmt
)
{
if
(
gCurCase
->
bindTagNum
>
0
)
{
return
taos_stmt_set_tbname_tags
(
stmt
,
tblName
,
data
->
pTags
+
tblIdx
*
gCurCase
->
bindTagNum
);
}
else
{
return
taos_stmt_set_tbname
(
stmt
,
tblName
);
}
}
/* prepare [settbname [bind add]] exec */
int
insertMBSETest1
(
TAOS_STMT
*
stmt
,
TAOS
*
taos
)
{
BindData
data
=
{
0
};
...
...
@@ -1255,7 +1295,7 @@ int insertMBSETest1(TAOS_STMT *stmt, TAOS *taos) {
if
(
gCurCase
->
tblNum
>
1
)
{
char
buf
[
32
];
sprintf
(
buf
,
"t%d"
,
t
);
code
=
taos_stmt_set_tbname
(
stmt
,
buf
);
code
=
bpSetTableNameTags
(
&
data
,
t
,
buf
,
stmt
);
if
(
code
!=
0
){
printf
(
"!!!taos_stmt_set_tbname error:%s
\n
"
,
taos_stmt_errstr
(
stmt
));
exit
(
1
);
...
...
@@ -1312,7 +1352,7 @@ int insertMBSETest2(TAOS_STMT *stmt, TAOS *taos) {
if
(
gCurCase
->
tblNum
>
1
)
{
char
buf
[
32
];
sprintf
(
buf
,
"t%d"
,
t
);
code
=
taos_stmt_set_tbname
(
stmt
,
buf
);
code
=
bpSetTableNameTags
(
&
data
,
t
,
buf
,
stmt
);
if
(
code
!=
0
){
printf
(
"!!!taos_stmt_set_tbname error:%s
\n
"
,
taos_stmt_errstr
(
stmt
));
exit
(
1
);
...
...
@@ -1365,7 +1405,7 @@ int insertMBMETest1(TAOS_STMT *stmt, TAOS *taos) {
if
(
gCurCase
->
tblNum
>
1
)
{
char
buf
[
32
];
sprintf
(
buf
,
"t%d"
,
t
);
code
=
taos_stmt_set_tbname
(
stmt
,
buf
);
code
=
bpSetTableNameTags
(
&
data
,
t
,
buf
,
stmt
);
if
(
code
!=
0
){
printf
(
"!!!taos_stmt_set_tbname error:%s
\n
"
,
taos_stmt_errstr
(
stmt
));
exit
(
1
);
...
...
@@ -1419,7 +1459,7 @@ int insertMBMETest2(TAOS_STMT *stmt, TAOS *taos) {
if
(
gCurCase
->
tblNum
>
1
)
{
char
buf
[
32
];
sprintf
(
buf
,
"t%d"
,
t
);
code
=
taos_stmt_set_tbname
(
stmt
,
buf
);
code
=
bpSetTableNameTags
(
&
data
,
t
,
buf
,
stmt
);
if
(
code
!=
0
){
printf
(
"!!!taos_stmt_set_tbname error:%s
\n
"
,
taos_stmt_errstr
(
stmt
));
exit
(
1
);
...
...
@@ -1473,7 +1513,7 @@ int insertMBMETest3(TAOS_STMT *stmt, TAOS *taos) {
if
(
gCurCase
->
tblNum
>
1
)
{
char
buf
[
32
];
sprintf
(
buf
,
"t%d"
,
t
);
code
=
taos_stmt_set_tbname
(
stmt
,
buf
);
code
=
bpSetTableNameTags
(
&
data
,
t
,
buf
,
stmt
);
if
(
code
!=
0
){
printf
(
"!!!taos_stmt_set_tbname error:%s
\n
"
,
taos_stmt_errstr
(
stmt
));
exit
(
1
);
...
...
@@ -1488,7 +1528,7 @@ int insertMBMETest3(TAOS_STMT *stmt, TAOS *taos) {
if
(
gCurCase
->
tblNum
>
1
)
{
char
buf
[
32
];
sprintf
(
buf
,
"t%d"
,
t
);
code
=
taos_stmt_set_tbname
(
stmt
,
buf
);
code
=
bpSetTableNameTags
(
&
data
,
t
,
buf
,
stmt
);
if
(
code
!=
0
){
printf
(
"!!!taos_stmt_set_tbname error:%s
\n
"
,
taos_stmt_errstr
(
stmt
));
exit
(
1
);
...
...
@@ -1540,7 +1580,7 @@ int insertMBMETest4(TAOS_STMT *stmt, TAOS *taos) {
if
(
gCurCase
->
tblNum
>
1
)
{
char
buf
[
32
];
sprintf
(
buf
,
"t%d"
,
t
);
code
=
taos_stmt_set_tbname
(
stmt
,
buf
);
code
=
bpSetTableNameTags
(
&
data
,
t
,
buf
,
stmt
);
if
(
code
!=
0
){
printf
(
"!!!taos_stmt_set_tbname error:%s
\n
"
,
taos_stmt_errstr
(
stmt
));
exit
(
1
);
...
...
@@ -1596,7 +1636,7 @@ int insertMPMETest1(TAOS_STMT *stmt, TAOS *taos) {
if
(
gCurCase
->
tblNum
>
1
)
{
char
buf
[
32
];
sprintf
(
buf
,
"t%d"
,
t
);
code
=
taos_stmt_set_tbname
(
stmt
,
buf
);
code
=
bpSetTableNameTags
(
&
data
,
t
,
buf
,
stmt
);
if
(
code
!=
0
){
printf
(
"!!!taos_stmt_set_tbname error:%s
\n
"
,
taos_stmt_errstr
(
stmt
));
exit
(
1
);
...
...
@@ -1640,11 +1680,12 @@ int insertMPMETest1(TAOS_STMT *stmt, TAOS *taos) {
return
0
;
}
/* [prepare [settbnametag [bind add] exec]] */
int
insertAUTOTest1
(
TAOS_STMT
*
stmt
,
TAOS
*
taos
)
{
int32_t
loop
=
0
;
while
(
gCurCase
->
bind
ColNum
>=
2
)
{
while
(
gCurCase
->
bind
TagNum
>
0
&&
gCurCase
->
bindColNum
>
0
)
{
BindData
data
=
{
0
};
prepareInsertData
(
&
data
);
...
...
@@ -3316,10 +3357,23 @@ int32_t runCase(TAOS *taos, int32_t caseIdx, int32_t caseRunIdx, bool silent) {
if
(
gCaseCtrl
.
rowNum
)
{
gCurCase
->
rowNum
=
gCaseCtrl
.
rowNum
;
}
if
(
gCaseCtrl
.
autoCreateTbl
)
{
if
(
gCurCase
->
testType
==
TTYPE_INSERT
&&
gCurCase
->
tblNum
>
1
)
{
gCurCase
->
autoCreateTbl
=
true
;
if
(
gCurCase
->
bindTagNum
<=
0
)
{
gCurCase
->
bindTagNum
=
gCurCase
->
colNum
;
}
}
else
{
return
1
;
}
}
if
(
gCurCase
->
fullCol
)
{
gCurCase
->
bindColNum
=
gCurCase
->
colNum
;
gCurCase
->
bindTagNum
=
gCurCase
->
colNum
;
if
(
gCurCase
->
autoCreateTbl
)
{
gCurCase
->
bindTagNum
=
gCurCase
->
colNum
;
}
}
gCurCase
->
bindNullNum
=
gCaseCtrl
.
bindNullNum
;
...
...
@@ -3350,7 +3404,7 @@ int32_t runCase(TAOS *taos, int32_t caseIdx, int32_t caseRunIdx, bool silent) {
totalUs
=
0
;
for
(
int32_t
n
=
0
;
n
<
gCurCase
->
runTimes
;
++
n
)
{
if
(
gCurCase
->
preCaseIdx
<
0
)
{
prepare
(
taos
,
gCurCase
->
colNum
,
gCurCase
->
colList
,
gCurCase
->
prepareStb
);
prepare
(
taos
,
gCurCase
->
colNum
,
gCurCase
->
colList
,
gCurCase
->
autoCreateTbl
);
}
beginUs
=
taosGetTimestampUs
();
...
...
@@ -3411,10 +3465,18 @@ void* runCaseList(TAOS *taos) {
}
void
runAll
(
TAOS
*
taos
)
{
/*
strcpy(gCaseCtrl.caseCatalog, "Normal Test");
printf("%s Begin\n", gCaseCtrl.caseCatalog);
runCaseList(taos);
*/
strcpy
(
gCaseCtrl
.
caseCatalog
,
"Auto Create Table Test"
);
gCaseCtrl
.
autoCreateTbl
=
true
;
printf
(
"%s Begin
\n
"
,
gCaseCtrl
.
caseCatalog
);
runCaseList
(
taos
);
gCaseCtrl
.
autoCreateTbl
=
false
;
/*
strcpy(gCaseCtrl.caseCatalog, "Null Test");
printf("%s Begin\n", gCaseCtrl.caseCatalog);
gCaseCtrl.bindNullNum = 1;
...
...
@@ -3458,7 +3520,8 @@ void runAll(TAOS *taos) {
gCaseCtrl.bindColTypeNum = tListLen(bindColTypeList);
gCaseCtrl.bindColTypeList = bindColTypeList;
runCaseList(taos);
*/
printf
(
"All Test End
\n
"
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录