Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ce3b4b31
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ce3b4b31
编写于
5月 13, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
stmt query
上级
997f07a0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
59 addition
and
19 deletion
+59
-19
source/client/src/clientStmt.c
source/client/src/clientStmt.c
+17
-3
source/libs/parser/src/parInsert.c
source/libs/parser/src/parInsert.c
+8
-4
source/libs/parser/src/parser.c
source/libs/parser/src/parser.c
+1
-0
tests/script/api/batchprepare.c
tests/script/api/batchprepare.c
+33
-12
未找到文件。
source/client/src/clientStmt.c
浏览文件 @
ce3b4b31
...
...
@@ -226,7 +226,6 @@ int32_t stmtParseSql(STscStmt* pStmt) {
break
;
case
QUERY_NODE_SELECT_STMT
:
pStmt
->
sql
.
type
=
STMT_TYPE_QUERY
;
STMT_ERR_RET
(
stmtBackupQueryFields
(
pStmt
));
break
;
default:
tscError
(
"not supported stmt type %d"
,
nodeType
(
pStmt
->
sql
.
pQuery
->
pRoot
));
...
...
@@ -616,8 +615,6 @@ int stmtBindBatch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int32_t colIdx) {
if
(
pStmt
->
bInfo
.
needParse
)
{
STMT_ERR_RET
(
stmtParseSql
(
pStmt
));
}
else
if
(
STMT_TYPE_QUERY
==
pStmt
->
sql
.
type
)
{
STMT_ERR_RET
(
stmtRestoreQueryFields
(
pStmt
));
}
if
(
STMT_TYPE_QUERY
==
pStmt
->
sql
.
type
)
{
...
...
@@ -634,8 +631,25 @@ int stmtBindBatch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int32_t colIdx) {
.
pTransporter
=
pStmt
->
taos
->
pAppInfo
->
pTransporter
,
.
pStmtCb
=
NULL
,
.
pUser
=
pStmt
->
taos
->
user
};
ctx
.
mgmtEpSet
=
getEpSet_s
(
&
pStmt
->
taos
->
pAppInfo
->
mgmtEp
);
STMT_ERR_RET
(
catalogGetHandle
(
pStmt
->
taos
->
pAppInfo
->
clusterId
,
&
ctx
.
pCatalog
));
STMT_ERR_RET
(
qStmtParseQuerySql
(
&
ctx
,
pStmt
->
sql
.
pQuery
));
if
(
pStmt
->
sql
.
pQuery
->
haveResultSet
)
{
setResSchemaInfo
(
&
pStmt
->
exec
.
pRequest
->
body
.
resInfo
,
pStmt
->
sql
.
pQuery
->
pResSchema
,
pStmt
->
sql
.
pQuery
->
numOfResCols
);
setResPrecision
(
&
pStmt
->
exec
.
pRequest
->
body
.
resInfo
,
pStmt
->
sql
.
pQuery
->
precision
);
}
TSWAP
(
pStmt
->
exec
.
pRequest
->
dbList
,
pStmt
->
sql
.
pQuery
->
pDbList
);
TSWAP
(
pStmt
->
exec
.
pRequest
->
tableList
,
pStmt
->
sql
.
pQuery
->
pTableList
);
//if (STMT_TYPE_QUERY == pStmt->sql.queryRes) {
// STMT_ERR_RET(stmtRestoreQueryFields(pStmt));
//}
//STMT_ERR_RET(stmtBackupQueryFields(pStmt));
return
TSDB_CODE_SUCCESS
;
}
...
...
source/libs/parser/src/parInsert.c
浏览文件 @
ce3b4b31
...
...
@@ -1227,16 +1227,20 @@ int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery) {
if
(
NULL
==
*
pQuery
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
(
*
pQuery
)
->
pTableList
=
taosArrayInit
(
taosHashGetSize
(
context
.
pTableNameHashObj
),
sizeof
(
SName
));
if
(
NULL
==
(
*
pQuery
)
->
pTableList
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
(
*
pQuery
)
->
execMode
=
QUERY_EXEC_MODE_SCHEDULE
;
(
*
pQuery
)
->
haveResultSet
=
false
;
(
*
pQuery
)
->
msgType
=
TDMT_VND_SUBMIT
;
(
*
pQuery
)
->
pRoot
=
(
SNode
*
)
context
.
pOutput
;
}
if
(
NULL
==
(
*
pQuery
)
->
pTableList
)
{
(
*
pQuery
)
->
pTableList
=
taosArrayInit
(
taosHashGetSize
(
context
.
pTableNameHashObj
),
sizeof
(
SName
));
if
(
NULL
==
(
*
pQuery
)
->
pTableList
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
context
.
pOutput
->
payloadType
=
PAYLOAD_TYPE_KV
;
int32_t
code
=
skipInsertInto
(
&
context
);
...
...
source/libs/parser/src/parser.c
浏览文件 @
ce3b4b31
...
...
@@ -184,5 +184,6 @@ int32_t qStmtParseQuerySql(SParseContext* pCxt, SQuery* pQuery) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
calculateConstant
(
pCxt
,
pQuery
);
}
return
code
;
}
tests/script/api/batchprepare.c
浏览文件 @
ce3b4b31
...
...
@@ -9,10 +9,12 @@
#include <unistd.h>
#include "../../../include/client/taos.h"
#define FUNCTION_TEST_IDX 1
int32_t
shortColList
[]
=
{
TSDB_DATA_TYPE_TIMESTAMP
,
TSDB_DATA_TYPE_INT
};
int32_t
fullColList
[]
=
{
TSDB_DATA_TYPE_TIMESTAMP
,
TSDB_DATA_TYPE_BOOL
,
TSDB_DATA_TYPE_TINYINT
,
TSDB_DATA_TYPE_UTINYINT
,
TSDB_DATA_TYPE_SMALLINT
,
TSDB_DATA_TYPE_USMALLINT
,
TSDB_DATA_TYPE_INT
,
TSDB_DATA_TYPE_UINT
,
TSDB_DATA_TYPE_BIGINT
,
TSDB_DATA_TYPE_UBIGINT
,
TSDB_DATA_TYPE_FLOAT
,
TSDB_DATA_TYPE_DOUBLE
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DATA_TYPE_NCHAR
};
int32_t
bindColTypeList
[]
=
{
TSDB_DATA_TYPE_TIMESTAMP
,
TSDB_DATA_TYPE_
NCHAR
};
int32_t
optrIdxList
[]
=
{
0
,
9
};
int32_t
bindColTypeList
[]
=
{
TSDB_DATA_TYPE_TIMESTAMP
,
TSDB_DATA_TYPE_
INT
};
int32_t
optrIdxList
[]
=
{
0
,
1
};
typedef
struct
{
char
*
oper
;
...
...
@@ -53,7 +55,6 @@ FuncInfo funcInfo[] = {
{
"count"
,
1
},
{
"sum"
,
1
},
{
"min"
,
1
},
{
"sin"
,
1
},
};
char
*
bpStbPrefix
=
"st"
;
...
...
@@ -66,6 +67,10 @@ int32_t bpDefaultStbId = 1;
//char *varoperatorList[] = {">", ">=", "<", "<=", "=", "<>", "in", "not in", "like", "not like", "match", "nmatch"};
#define tListLen(x) (sizeof(x) / sizeof((x)[0]))
#define IS_SIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_TINYINT && (_t) <= TSDB_DATA_TYPE_BIGINT)
#define IS_UNSIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_UTINYINT && (_t) <= TSDB_DATA_TYPE_UBIGINT)
#define IS_FLOAT_TYPE(_t) ((_t) == TSDB_DATA_TYPE_FLOAT || (_t) == TSDB_DATA_TYPE_DOUBLE)
#define IS_NUMERIC_TYPE(_t) ((IS_SIGNED_NUMERIC_TYPE(_t)) || (IS_UNSIGNED_NUMERIC_TYPE(_t)) || (IS_FLOAT_TYPE(_t)))
typedef
struct
{
int64_t
*
tsData
;
...
...
@@ -166,7 +171,7 @@ CaseCfg gCase[] = {
{
"insert:AUTO1-FULL"
,
tListLen
(
fullColList
),
fullColList
,
TTYPE_INSERT
,
true
,
true
,
insertAUTOTest1
,
10
,
10
,
2
,
0
,
0
,
0
,
1
,
-
1
},
{
"query:SUBT-COLUMN"
,
tListLen
(
fullColList
),
fullColList
,
TTYPE_QUERY
,
false
,
false
,
queryColumnTest
,
10
,
10
,
1
,
3
,
0
,
0
,
1
,
2
},
{
"query:SUBT-MISC"
,
tListLen
(
fullColList
),
fullColList
,
TTYPE_QUERY
,
false
,
false
,
queryMiscTest
,
2
,
10
,
1
,
3
,
0
,
0
,
1
,
2
},
{
"query:SUBT-MISC"
,
tListLen
(
fullColList
),
fullColList
,
TTYPE_QUERY
,
false
,
false
,
queryMiscTest
,
2
,
10
,
1
,
1
,
0
,
0
,
1
,
2
},
};
...
...
@@ -181,6 +186,7 @@ typedef struct {
bool
printQuerySql
;
bool
printStmtSql
;
bool
autoCreateTbl
;
bool
numericParam
;
int32_t
rowNum
;
//row num for one table
int32_t
bindColNum
;
int32_t
bindTagNum
;
...
...
@@ -207,6 +213,7 @@ CaseCtrl gCaseCtrl = { // default
.printQuerySql = true,
.printStmtSql = true,
.autoCreateTbl = false,
.numericParam = false,
.rowNum = 0,
.bindColNum = 0,
.bindTagNum = 0,
...
...
@@ -303,11 +310,11 @@ CaseCtrl gCaseCtrl = { // query case with specified col&oper
.printRes = true,
.runTimes = 0,
.caseRunIdx = -1,
//
.optrIdxListNum = tListLen(optrIdxList),
//
.optrIdxList = optrIdxList,
//
.bindColTypeNum = tListLen(bindColTypeList),
//
.bindColTypeList = bindColTypeList,
.caseIdx = 2
2
,
.optrIdxListNum = tListLen(optrIdxList),
.optrIdxList = optrIdxList,
.bindColTypeNum = tListLen(bindColTypeList),
.bindColTypeList = bindColTypeList,
.caseIdx = 2
4
,
.caseNum = 1,
.caseRunNum = 1,
};
...
...
@@ -661,11 +668,11 @@ void bpGenerateConstInFuncSQL(BindData *data, int32_t tblIdx) {
void
generateQueryMiscSQL
(
BindData
*
data
,
int32_t
tblIdx
)
{
switch
(
tblIdx
)
{
case
0
:
bpGenerateConstInOpSQL
(
data
,
tblIdx
);
break
;
case
1
:
//TODO FILL TEST
default:
bpGenerateConstInOpSQL
(
data
,
tblIdx
);
break
;
case
FUNCTION_TEST_IDX
:
bpGenerateConstInFuncSQL
(
data
,
tblIdx
);
break
;
}
...
...
@@ -709,6 +716,16 @@ void generateColDataType(BindData *data, int32_t bindIdx, int32_t colIdx, int32_
}
else
if
(
gCurCase
->
fullCol
)
{
*
dataType
=
gCurCase
->
colList
[
bindIdx
];
return
;
}
else
if
(
gCaseCtrl
.
numericParam
)
{
while
(
true
)
{
*
dataType
=
rand
()
%
(
TSDB_DATA_TYPE_MAX
-
1
)
+
1
;
if
(
!
IS_NUMERIC_TYPE
(
*
dataType
))
{
continue
;
}
break
;
}
return
;
}
else
if
(
0
==
colIdx
)
{
*
dataType
=
TSDB_DATA_TYPE_TIMESTAMP
;
return
;
...
...
@@ -1046,6 +1063,10 @@ int32_t prepareQueryMiscData(BindData *data, int32_t tblIdx) {
data
->
binaryLen
[
i
]
=
gVarCharLen
;
}
if
(
tblIdx
==
FUNCTION_TEST_IDX
)
{
gCaseCtrl
.
numericParam
=
true
;
}
for
(
int
b
=
0
;
b
<
bindNum
;
b
++
)
{
for
(
int
c
=
0
;
c
<
gCurCase
->
bindColNum
;
++
c
)
{
prepareColData
(
BP_BIND_COL
,
data
,
b
*
gCurCase
->
bindColNum
+
c
,
b
*
gCurCase
->
bindRowNum
,
c
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录