Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1aa22beb
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看板
提交
1aa22beb
编写于
4月 27, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
stmt query
上级
4d595938
变更
14
展开全部
隐藏空白更改
内联
并排
Showing
14 changed file
with
681 addition
and
237 deletion
+681
-237
include/libs/nodes/plannodes.h
include/libs/nodes/plannodes.h
+1
-1
include/libs/parser/parser.h
include/libs/parser/parser.h
+1
-0
include/libs/planner/planner.h
include/libs/planner/planner.h
+1
-1
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+2
-1
source/client/src/clientStmt.c
source/client/src/clientStmt.c
+1
-1
source/libs/nodes/src/nodesTraverseFuncs.c
source/libs/nodes/src/nodesTraverseFuncs.c
+4
-4
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+2
-2
source/libs/parser/src/parAstParser.c
source/libs/parser/src/parAstParser.c
+1
-0
source/libs/parser/src/parInsert.c
source/libs/parser/src/parInsert.c
+4
-5
source/libs/planner/src/planner.c
source/libs/planner/src/planner.c
+12
-18
source/libs/scalar/inc/sclInt.h
source/libs/scalar/inc/sclInt.h
+1
-1
source/libs/scalar/src/filter.c
source/libs/scalar/src/filter.c
+7
-2
source/libs/scalar/src/scalar.c
source/libs/scalar/src/scalar.c
+3
-2
tests/script/api/batchprepare.c
tests/script/api/batchprepare.c
+641
-199
未找到文件。
include/libs/nodes/plannodes.h
浏览文件 @
1aa22beb
...
...
@@ -351,7 +351,7 @@ typedef struct SQueryPlan {
int32_t
numOfSubplans
;
SNodeList
*
pSubplans
;
// Element is SNodeListNode. The execution level of subplan, starting from 0.
SExplainInfo
explainInfo
;
S
NodeList
*
pPlaceholderValues
;
S
Array
*
pPlaceholderValues
;
}
SQueryPlan
;
void
nodesWalkPhysiPlan
(
SNode
*
pNode
,
FNodeWalker
walker
,
void
*
pContext
);
...
...
include/libs/parser/parser.h
浏览文件 @
1aa22beb
...
...
@@ -73,6 +73,7 @@ typedef struct SQuery {
SArray
*
pDbList
;
SArray
*
pTableList
;
bool
showRewrite
;
int32_t
placeholderNum
;
}
SQuery
;
int32_t
qParseQuerySql
(
SParseContext
*
pCxt
,
SQuery
**
pQuery
);
...
...
include/libs/planner/planner.h
浏览文件 @
1aa22beb
...
...
@@ -34,7 +34,7 @@ typedef struct SPlanContext {
bool
showRewrite
;
int8_t
triggerType
;
int64_t
watermark
;
bool
isStmtQuery
;
int32_t
placeholderNum
;
void
*
pTransporter
;
struct
SCatalog
*
pCatalog
;
char
*
pMsg
;
...
...
source/client/src/clientImpl.c
浏览文件 @
1aa22beb
...
...
@@ -233,7 +233,8 @@ int32_t getPlan(SRequestObj* pRequest, SQuery* pQuery, SQueryPlan** pPlan, SArra
.
showRewrite
=
pQuery
->
showRewrite
,
.
pTransporter
=
pRequest
->
pTscObj
->
pAppInfo
->
pTransporter
,
.
pMsg
=
pRequest
->
msgBuf
,
.
msgLen
=
ERROR_MSG_BUF_DEFAULT_SIZE
};
.
msgLen
=
ERROR_MSG_BUF_DEFAULT_SIZE
,
.
placeholderNum
=
pQuery
->
placeholderNum
};
int32_t
code
=
catalogGetHandle
(
pRequest
->
pTscObj
->
pAppInfo
->
clusterId
,
&
cxt
.
pCatalog
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
qCreateQueryPlan
(
&
cxt
,
pPlan
,
pNodeList
);
...
...
source/client/src/clientStmt.c
浏览文件 @
1aa22beb
...
...
@@ -601,7 +601,7 @@ int stmtGetParamNum(TAOS_STMT *stmt, int *nums) {
pStmt
->
exec
.
pRequest
->
body
.
pDag
=
NULL
;
}
*
nums
=
(
pStmt
->
sql
.
pQueryPlan
->
pPlaceholderValues
)
?
pStmt
->
sql
.
pQueryPlan
->
pPlaceholderValues
->
length
:
0
;
*
nums
=
taosArrayGetSize
(
pStmt
->
sql
.
pQueryPlan
->
pPlaceholderValues
)
;
}
else
{
STMT_ERR_RET
(
stmtFetchColFields
(
stmt
,
nums
,
NULL
));
}
...
...
source/libs/nodes/src/nodesTraverseFuncs.c
浏览文件 @
1aa22beb
...
...
@@ -423,6 +423,9 @@ static EDealRes dispatchPhysiPlan(SNode* pNode, ETraversalOrder order, FNodeWalk
EDealRes
res
=
DEAL_RES_CONTINUE
;
switch
(
nodeType
(
pNode
))
{
case
QUERY_NODE_NODE_LIST
:
res
=
walkPhysiPlans
(((
SNodeListNode
*
)
pNode
)
->
pNodeList
,
order
,
walker
,
pContext
);
break
;
case
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN
:
res
=
walkScanPhysi
((
SScanPhysiNode
*
)
pNode
,
order
,
walker
,
pContext
);
break
;
...
...
@@ -534,10 +537,7 @@ static EDealRes dispatchPhysiPlan(SNode* pNode, ETraversalOrder order, FNodeWalk
break
;
case
QUERY_NODE_PHYSICAL_SUBPLAN
:
{
SSubplan
*
pSubplan
=
(
SSubplan
*
)
pNode
;
res
=
walkPhysiNode
((
SPhysiNode
*
)
pNode
,
order
,
walker
,
pContext
);
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walkPhysiPlans
(
pSubplan
->
pChildren
,
order
,
walker
,
pContext
);
}
res
=
walkPhysiPlans
(
pSubplan
->
pChildren
,
order
,
walker
,
pContext
);
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walkPhysiPlan
((
SNode
*
)
pSubplan
->
pNode
,
order
,
walker
,
pContext
);
}
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
1aa22beb
...
...
@@ -44,7 +44,7 @@ void initAstCreateContext(SParseContext* pParseCxt, SAstCreateContext* pCxt) {
pCxt
->
notSupport
=
false
;
pCxt
->
valid
=
true
;
pCxt
->
pRootNode
=
NULL
;
pCxt
->
placeholderNo
=
1
;
pCxt
->
placeholderNo
=
0
;
}
static
void
trimEscape
(
SToken
*
pName
)
{
...
...
@@ -309,7 +309,7 @@ SNode* createPlaceholderValueNode(SAstCreateContext* pCxt, const SToken* pLitera
CHECK_OUT_OF_MEM
(
val
);
val
->
literal
=
strndup
(
pLiteral
->
z
,
pLiteral
->
n
);
CHECK_OUT_OF_MEM
(
val
->
literal
);
val
->
placeholderNo
=
pCxt
->
placeholderNo
++
;
val
->
placeholderNo
=
++
pCxt
->
placeholderNo
;
return
(
SNode
*
)
val
;
}
...
...
source/libs/parser/src/parAstParser.c
浏览文件 @
1aa22beb
...
...
@@ -80,6 +80,7 @@ abort_parse:
return
TSDB_CODE_OUT_OF_MEMORY
;
}
(
*
pQuery
)
->
pRoot
=
cxt
.
pRootNode
;
(
*
pQuery
)
->
placeholderNum
=
cxt
.
placeholderNo
;
}
return
cxt
.
valid
?
TSDB_CODE_SUCCESS
:
TSDB_CODE_FAILED
;
}
source/libs/parser/src/parInsert.c
浏览文件 @
1aa22beb
...
...
@@ -1068,7 +1068,6 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
if
(
TSDB_QUERY_HAS_TYPE
(
pCxt
->
pOutput
->
insertType
,
TSDB_QUERY_TYPE_STMT_INSERT
)
&&
tbNum
>
0
)
{
return
buildInvalidOperationMsg
(
&
pCxt
->
msg
,
"single table allowed in one stmt"
);
;
}
destroyInsertParseContextForTable
(
pCxt
);
...
...
@@ -1328,10 +1327,6 @@ int32_t qBindStmtColsValue(void *pBlock, TAOS_MULTI_BIND *bind, char *msgBuf, in
for
(
int
c
=
0
;
c
<
spd
->
numOfBound
;
++
c
)
{
SSchema
*
pColSchema
=
&
pSchema
[
spd
->
boundColumns
[
c
]
-
1
];
if
(
bind
[
c
].
buffer_type
!=
pColSchema
->
type
)
{
return
buildInvalidOperationMsg
(
&
pBuf
,
"column type mis-match with buffer type"
);
}
if
(
bind
[
c
].
num
!=
rowNum
)
{
return
buildInvalidOperationMsg
(
&
pBuf
,
"row number in each bind param should be the same"
);
}
...
...
@@ -1346,6 +1341,10 @@ int32_t qBindStmtColsValue(void *pBlock, TAOS_MULTI_BIND *bind, char *msgBuf, in
CHECK_CODE
(
MemRowAppend
(
&
pBuf
,
NULL
,
0
,
&
param
));
}
else
{
if
(
bind
[
c
].
buffer_type
!=
pColSchema
->
type
)
{
return
buildInvalidOperationMsg
(
&
pBuf
,
"column type mis-match with buffer type"
);
}
int32_t
colLen
=
pColSchema
->
bytes
;
if
(
IS_VAR_DATA_TYPE
(
pColSchema
->
type
))
{
colLen
=
bind
[
c
].
length
[
r
];
...
...
source/libs/planner/src/planner.c
浏览文件 @
1aa22beb
...
...
@@ -19,26 +19,23 @@
typedef
struct
SCollectPlaceholderValuesCxt
{
int32_t
errCode
;
S
NodeList
*
pValues
;
S
Array
*
pValues
;
}
SCollectPlaceholderValuesCxt
;
static
EDealRes
collectPlaceholderValuesImpl
(
SNode
*
pNode
,
void
*
pContext
)
{
if
(
QUERY_NODE_VALUE
==
nodeType
(
pNode
)
&&
((
SValueNode
*
)
pNode
)
->
placeholderNo
>
0
)
{
SCollectPlaceholderValuesCxt
*
pCxt
=
pContext
;
pCxt
->
errCode
=
nodesListMakeAppend
(
&
pCxt
->
pValues
,
pNode
);
taosArrayInsert
(
pCxt
->
pValues
,
((
SValueNode
*
)
pNode
)
->
placeholderNo
-
1
,
&
pNode
);
return
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
?
DEAL_RES_IGNORE_CHILD
:
DEAL_RES_ERROR
;
}
return
DEAL_RES_CONTINUE
;
}
static
int32_t
collectPlaceholderValues
(
SPlanContext
*
pCxt
,
SQueryPlan
*
pPlan
)
{
SCollectPlaceholderValuesCxt
cxt
=
{.
errCode
=
TSDB_CODE_SUCCESS
,
.
pValues
=
NULL
};
pPlan
->
pPlaceholderValues
=
taosArrayInit
(
TARRAY_MIN_SIZE
,
POINTER_BYTES
);
SCollectPlaceholderValuesCxt
cxt
=
{.
errCode
=
TSDB_CODE_SUCCESS
,
.
pValues
=
pPlan
->
pPlaceholderValues
};
nodesWalkPhysiPlan
((
SNode
*
)
pPlan
,
collectPlaceholderValuesImpl
,
&
cxt
);
if
(
TSDB_CODE_SUCCESS
==
cxt
.
errCode
)
{
pPlan
->
pPlaceholderValues
=
cxt
.
pValues
;
}
else
{
nodesDestroyList
(
cxt
.
pValues
);
}
return
cxt
.
errCode
;
}
...
...
@@ -60,7 +57,7 @@ int32_t qCreateQueryPlan(SPlanContext* pCxt, SQueryPlan** pPlan, SArray* pExecNo
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createPhysiPlan
(
pCxt
,
pLogicPlan
,
pPlan
,
pExecNodeList
);
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
pCxt
->
isStmtQuery
)
{
if
(
TSDB_CODE_SUCCESS
==
code
&&
pCxt
->
placeholderNum
>
0
)
{
code
=
collectPlaceholderValues
(
pCxt
,
*
pPlan
);
}
...
...
@@ -108,7 +105,7 @@ static int32_t setValueByBindParam(SValueNode* pVal, TAOS_MULTI_BIND* pParam) {
return
TSDB_CODE_SUCCESS
;
}
pVal
->
node
.
resType
.
type
=
pParam
->
buffer_type
;
pVal
->
node
.
resType
.
bytes
=
*
(
pParam
->
length
)
;
pVal
->
node
.
resType
.
bytes
=
NULL
!=
pParam
->
length
?
*
(
pParam
->
length
)
:
tDataTypes
[
pParam
->
buffer_type
].
bytes
;
switch
(
pParam
->
buffer_type
)
{
case
TSDB_DATA_TYPE_BOOL
:
pVal
->
datum
.
b
=
*
((
bool
*
)
pParam
->
buffer
);
...
...
@@ -133,6 +130,7 @@ static int32_t setValueByBindParam(SValueNode* pVal, TAOS_MULTI_BIND* pParam) {
break
;
case
TSDB_DATA_TYPE_VARCHAR
:
case
TSDB_DATA_TYPE_VARBINARY
:
case
TSDB_DATA_TYPE_NCHAR
:
pVal
->
datum
.
p
=
taosMemoryCalloc
(
1
,
pVal
->
node
.
resType
.
bytes
+
VARSTR_HEADER_SIZE
+
1
);
if
(
NULL
==
pVal
->
datum
.
p
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -155,7 +153,6 @@ static int32_t setValueByBindParam(SValueNode* pVal, TAOS_MULTI_BIND* pParam) {
case
TSDB_DATA_TYPE_UBIGINT
:
pVal
->
datum
.
u
=
*
((
uint64_t
*
)
pParam
->
buffer
);
break
;
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_JSON
:
case
TSDB_DATA_TYPE_DECIMAL
:
case
TSDB_DATA_TYPE_BLOB
:
...
...
@@ -170,15 +167,12 @@ static int32_t setValueByBindParam(SValueNode* pVal, TAOS_MULTI_BIND* pParam) {
int32_t
qStmtBindParam
(
SQueryPlan
*
pPlan
,
TAOS_MULTI_BIND
*
pParams
,
int32_t
colIdx
)
{
if
(
colIdx
<
0
)
{
int32_t
index
=
0
;
SNode
*
pNode
=
NULL
;
FOREACH
(
pNode
,
pPlan
->
pPlaceholderValues
)
{
setValueByBindParam
((
SValueNode
*
)
pNode
,
pParams
+
index
);
++
index
;
int32_t
size
=
taosArrayGetSize
(
pPlan
->
pPlaceholderValues
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
setValueByBindParam
((
SValueNode
*
)
taosArrayGetP
(
pPlan
->
pPlaceholderValues
,
i
),
pParams
+
i
);
}
}
else
{
setValueByBindParam
((
SValueNode
*
)
nodesListGetNode
(
pPlan
->
pPlaceholderValues
,
colIdx
),
pParams
);
setValueByBindParam
((
SValueNode
*
)
taosArrayGetP
(
pPlan
->
pPlaceholderValues
,
colIdx
),
pParams
);
}
return
TSDB_CODE_SUCCESS
;
}
...
...
source/libs/scalar/inc/sclInt.h
浏览文件 @
1aa22beb
...
...
@@ -34,7 +34,7 @@ typedef struct SScalarCtx {
#define SCL_IS_CONST_NODE(_node) ((NULL == (_node)) || (QUERY_NODE_VALUE == (_node)->type) || (QUERY_NODE_NODE_LIST == (_node)->type))
#define SCL_IS_CONST_CALC(_ctx) (NULL == (_ctx)->pBlockList)
#define SCL_IS_NULL_VALUE_NODE(_node) ((QUERY_NODE_VALUE == nodeType(_node)) && (TSDB_DATA_TYPE_NULL == ((SValueNode *)_node)->node.resType.type))
#define SCL_IS_NULL_VALUE_NODE(_node) ((QUERY_NODE_VALUE == nodeType(_node)) && (TSDB_DATA_TYPE_NULL == ((SValueNode *)_node)->node.resType.type)
&& (((SValueNode *)_node)->placeholderNo <= 0)
)
#define sclFatal(...) qFatal(__VA_ARGS__)
#define sclError(...) qError(__VA_ARGS__)
...
...
source/libs/scalar/src/filter.c
浏览文件 @
1aa22beb
...
...
@@ -3541,11 +3541,16 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) {
}
if
(
QUERY_NODE_VALUE
==
nodeType
(
*
pNode
))
{
SValueNode
*
valueNode
=
(
SValueNode
*
)
*
pNode
;
if
(
valueNode
->
placeholderNo
>=
1
)
{
stat
->
scalarMode
=
true
;
return
DEAL_RES_CONTINUE
;
}
if
(
!
FILTER_GET_FLAG
(
stat
->
info
->
options
,
FLT_OPTION_TIMESTAMP
))
{
return
DEAL_RES_CONTINUE
;
}
SValueNode
*
valueNode
=
(
SValueNode
*
)
*
pNode
;
if
(
TSDB_DATA_TYPE_BINARY
!=
valueNode
->
node
.
resType
.
type
&&
TSDB_DATA_TYPE_NCHAR
!=
valueNode
->
node
.
resType
.
type
)
{
return
DEAL_RES_CONTINUE
;
}
...
...
@@ -3587,7 +3592,7 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) {
return
DEAL_RES_CONTINUE
;
}
if
(
node
->
opType
==
OP_TYPE_NOT_IN
||
node
->
opType
==
OP_TYPE_NOT_LIKE
||
node
->
opType
>
OP_TYPE_IS_NOT_NULL
)
{
if
(
node
->
opType
==
OP_TYPE_NOT_IN
||
node
->
opType
==
OP_TYPE_NOT_LIKE
||
node
->
opType
>
OP_TYPE_IS_NOT_NULL
||
node
->
opType
==
OP_TYPE_NOT_EQUAL
)
{
stat
->
scalarMode
=
true
;
return
DEAL_RES_CONTINUE
;
}
...
...
source/libs/scalar/src/scalar.c
浏览文件 @
1aa22beb
...
...
@@ -505,6 +505,7 @@ EDealRes sclRewriteBasedOnOptr(SNode** pNode, SScalarCtx *ctx, EOperatorType opT
}
res
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_BOOL
;
res
->
node
.
resType
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_BOOL
].
bytes
;
res
->
datum
.
b
=
false
;
nodesDestroyNode
(
*
pNode
);
...
...
@@ -520,14 +521,14 @@ EDealRes sclRewriteOperatorForNullValue(SNode** pNode, SScalarCtx *ctx) {
if
(
node
->
pLeft
&&
(
QUERY_NODE_VALUE
==
nodeType
(
node
->
pLeft
)))
{
SValueNode
*
valueNode
=
(
SValueNode
*
)
node
->
pLeft
;
if
(
TSDB_DATA_TYPE_NULL
==
valueNode
->
node
.
resType
.
type
&&
(
node
->
opType
!=
OP_TYPE_IS_NULL
&&
node
->
opType
!=
OP_TYPE_IS_NOT_NULL
))
{
if
(
SCL_IS_NULL_VALUE_NODE
(
valueNode
)
&&
(
node
->
opType
!=
OP_TYPE_IS_NULL
&&
node
->
opType
!=
OP_TYPE_IS_NOT_NULL
))
{
return
sclRewriteBasedOnOptr
(
pNode
,
ctx
,
node
->
opType
);
}
}
if
(
node
->
pRight
&&
(
QUERY_NODE_VALUE
==
nodeType
(
node
->
pRight
)))
{
SValueNode
*
valueNode
=
(
SValueNode
*
)
node
->
pRight
;
if
(
TSDB_DATA_TYPE_NULL
==
valueNode
->
node
.
resType
.
type
&&
(
node
->
opType
!=
OP_TYPE_IS_NULL
&&
node
->
opType
!=
OP_TYPE_IS_NOT_NULL
))
{
if
(
SCL_IS_NULL_VALUE_NODE
(
valueNode
)
&&
(
node
->
opType
!=
OP_TYPE_IS_NULL
&&
node
->
opType
!=
OP_TYPE_IS_NOT_NULL
))
{
return
sclRewriteBasedOnOptr
(
pNode
,
ctx
,
node
->
opType
);
}
}
...
...
tests/script/api/batchprepare.c
浏览文件 @
1aa22beb
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录