Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
945ac571
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看板
未验证
提交
945ac571
编写于
5月 30, 2022
作者:
X
Xiaoyu Wang
提交者:
GitHub
5月 30, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #13239 from taosdata/feature/3.0_wxy
fix: problems of some function parameters with negative numbers
上级
42675a3d
a37782e4
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
73 addition
and
42 deletion
+73
-42
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+35
-34
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+22
-8
source/libs/parser/test/parSelectTest.cpp
source/libs/parser/test/parSelectTest.cpp
+8
-0
source/libs/planner/test/planSTableTest.cpp
source/libs/planner/test/planSTableTest.cpp
+8
-0
未找到文件。
source/libs/executor/src/executorimpl.c
浏览文件 @
945ac571
...
@@ -2767,7 +2767,7 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SEx
...
@@ -2767,7 +2767,7 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SEx
code
=
setSDataBlockFromFetchRsp
(
pExchangeInfo
->
pResult
,
pLoadInfo
,
pTableRsp
->
numOfRows
,
pTableRsp
->
data
,
code
=
setSDataBlockFromFetchRsp
(
pExchangeInfo
->
pResult
,
pLoadInfo
,
pTableRsp
->
numOfRows
,
pTableRsp
->
data
,
pTableRsp
->
compLen
,
pTableRsp
->
numOfCols
,
startTs
,
&
pDataInfo
->
totalRows
,
NULL
);
pTableRsp
->
compLen
,
pTableRsp
->
numOfCols
,
startTs
,
&
pDataInfo
->
totalRows
,
NULL
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
taosMemoryFreeClear
(
pDataInfo
->
pRsp
);
taosMemoryFreeClear
(
pDataInfo
->
pRsp
);
goto
_error
;
goto
_error
;
}
}
...
@@ -2788,7 +2788,7 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SEx
...
@@ -2788,7 +2788,7 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SEx
pDataInfo
->
status
=
EX_SOURCE_DATA_NOT_READY
;
pDataInfo
->
status
=
EX_SOURCE_DATA_NOT_READY
;
code
=
doSendFetchDataRequest
(
pExchangeInfo
,
pTaskInfo
,
i
);
code
=
doSendFetchDataRequest
(
pExchangeInfo
,
pTaskInfo
,
i
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
taosMemoryFreeClear
(
pDataInfo
->
pRsp
);
taosMemoryFreeClear
(
pDataInfo
->
pRsp
);
goto
_error
;
goto
_error
;
}
}
}
}
...
@@ -2895,7 +2895,7 @@ static SSDataBlock* seqLoadRemoteData(SOperatorInfo* pOperator) {
...
@@ -2895,7 +2895,7 @@ static SSDataBlock* seqLoadRemoteData(SOperatorInfo* pOperator) {
pDataInfo
->
totalRows
,
pLoadInfo
->
totalRows
);
pDataInfo
->
totalRows
,
pLoadInfo
->
totalRows
);
pDataInfo
->
status
=
EX_SOURCE_DATA_EXHAUSTED
;
pDataInfo
->
status
=
EX_SOURCE_DATA_EXHAUSTED
;
pExchangeInfo
->
current
+=
1
;
pExchangeInfo
->
current
+=
1
;
taosMemoryFreeClear
(
pDataInfo
->
pRsp
);
taosMemoryFreeClear
(
pDataInfo
->
pRsp
);
continue
;
continue
;
}
}
...
@@ -2922,7 +2922,7 @@ static SSDataBlock* seqLoadRemoteData(SOperatorInfo* pOperator) {
...
@@ -2922,7 +2922,7 @@ static SSDataBlock* seqLoadRemoteData(SOperatorInfo* pOperator) {
}
}
pOperator
->
resultInfo
.
totalRows
+=
pRes
->
info
.
rows
;
pOperator
->
resultInfo
.
totalRows
+=
pRes
->
info
.
rows
;
taosMemoryFreeClear
(
pDataInfo
->
pRsp
);
taosMemoryFreeClear
(
pDataInfo
->
pRsp
);
return
pExchangeInfo
->
pResult
;
return
pExchangeInfo
->
pResult
;
}
}
}
}
...
@@ -3384,7 +3384,7 @@ int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t* order, int32_t* scan
...
@@ -3384,7 +3384,7 @@ int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t* order, int32_t* scan
// todo add more information about exchange operation
// todo add more information about exchange operation
int32_t
type
=
pOperator
->
operatorType
;
int32_t
type
=
pOperator
->
operatorType
;
if
(
type
==
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
||
type
==
QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN
||
if
(
type
==
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
||
type
==
QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN
||
type
==
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN
)
{
type
==
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN
||
type
==
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN
)
{
*
order
=
TSDB_ORDER_ASC
;
*
order
=
TSDB_ORDER_ASC
;
*
scanFlag
=
MAIN_SCAN
;
*
scanFlag
=
MAIN_SCAN
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -3499,14 +3499,15 @@ static SSDataBlock* getAggregateResult(SOperatorInfo* pOperator) {
...
@@ -3499,14 +3499,15 @@ static SSDataBlock* getAggregateResult(SOperatorInfo* pOperator) {
}
}
int32_t
aggEncodeResultRow
(
SOperatorInfo
*
pOperator
,
char
**
result
,
int32_t
*
length
)
{
int32_t
aggEncodeResultRow
(
SOperatorInfo
*
pOperator
,
char
**
result
,
int32_t
*
length
)
{
if
(
result
==
NULL
||
length
==
NULL
)
{
if
(
result
==
NULL
||
length
==
NULL
)
{
return
TSDB_CODE_TSC_INVALID_INPUT
;
return
TSDB_CODE_TSC_INVALID_INPUT
;
}
}
SOptrBasicInfo
*
pInfo
=
(
SOptrBasicInfo
*
)(
pOperator
->
info
);
SOptrBasicInfo
*
pInfo
=
(
SOptrBasicInfo
*
)(
pOperator
->
info
);
SAggSupporter
*
pSup
=
(
SAggSupporter
*
)
POINTER_SHIFT
(
pOperator
->
info
,
sizeof
(
SOptrBasicInfo
));
SAggSupporter
*
pSup
=
(
SAggSupporter
*
)
POINTER_SHIFT
(
pOperator
->
info
,
sizeof
(
SOptrBasicInfo
));
int32_t
size
=
taosHashGetSize
(
pSup
->
pResultRowHashTable
);
int32_t
size
=
taosHashGetSize
(
pSup
->
pResultRowHashTable
);
size_t
keyLen
=
sizeof
(
uint64_t
)
*
2
;
// estimate the key length
size_t
keyLen
=
sizeof
(
uint64_t
)
*
2
;
// estimate the key length
int32_t
totalSize
=
sizeof
(
int32_t
)
+
sizeof
(
int32_t
)
+
size
*
(
sizeof
(
int32_t
)
+
keyLen
+
sizeof
(
int32_t
)
+
pSup
->
resultRowSize
);
int32_t
totalSize
=
sizeof
(
int32_t
)
+
sizeof
(
int32_t
)
+
size
*
(
sizeof
(
int32_t
)
+
keyLen
+
sizeof
(
int32_t
)
+
pSup
->
resultRowSize
);
*
result
=
(
char
*
)
taosMemoryCalloc
(
1
,
totalSize
);
*
result
=
(
char
*
)
taosMemoryCalloc
(
1
,
totalSize
);
if
(
*
result
==
NULL
)
{
if
(
*
result
==
NULL
)
{
...
@@ -3568,11 +3569,11 @@ int32_t aggEncodeResultRow(SOperatorInfo* pOperator, char** result, int32_t* len
...
@@ -3568,11 +3569,11 @@ int32_t aggEncodeResultRow(SOperatorInfo* pOperator, char** result, int32_t* len
}
}
int32_t
aggDecodeResultRow
(
SOperatorInfo
*
pOperator
,
char
*
result
)
{
int32_t
aggDecodeResultRow
(
SOperatorInfo
*
pOperator
,
char
*
result
)
{
if
(
result
==
NULL
)
{
if
(
result
==
NULL
)
{
return
TSDB_CODE_TSC_INVALID_INPUT
;
return
TSDB_CODE_TSC_INVALID_INPUT
;
}
}
SOptrBasicInfo
*
pInfo
=
(
SOptrBasicInfo
*
)(
pOperator
->
info
);
SOptrBasicInfo
*
pInfo
=
(
SOptrBasicInfo
*
)(
pOperator
->
info
);
SAggSupporter
*
pSup
=
(
SAggSupporter
*
)
POINTER_SHIFT
(
pOperator
->
info
,
sizeof
(
SOptrBasicInfo
));
SAggSupporter
*
pSup
=
(
SAggSupporter
*
)
POINTER_SHIFT
(
pOperator
->
info
,
sizeof
(
SOptrBasicInfo
));
// int32_t size = taosHashGetSize(pSup->pResultRowHashTable);
// int32_t size = taosHashGetSize(pSup->pResultRowHashTable);
int32_t
length
=
*
(
int32_t
*
)(
result
);
int32_t
length
=
*
(
int32_t
*
)(
result
);
...
@@ -4512,8 +4513,8 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
...
@@ -4512,8 +4513,8 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN
==
type
)
{
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN
==
type
)
{
SScanPhysiNode
*
pScanPhyNode
=
(
SScanPhysiNode
*
)
pPhyNode
;
// simple child table.
SScanPhysiNode
*
pScanPhyNode
=
(
SScanPhysiNode
*
)
pPhyNode
;
// simple child table.
STableScanPhysiNode
*
pTableScanNode
=
(
STableScanPhysiNode
*
)
pPhyNode
;
STableScanPhysiNode
*
pTableScanNode
=
(
STableScanPhysiNode
*
)
pPhyNode
;
STimeWindowAggSupp
twSup
=
{.
waterMark
=
pTableScanNode
->
watermark
,
STimeWindowAggSupp
twSup
=
{
.
calTrigger
=
pTableScanNode
->
triggerType
,
.
maxTs
=
INT64_MIN
};
.
waterMark
=
pTableScanNode
->
watermark
,
.
calTrigger
=
pTableScanNode
->
triggerType
,
.
maxTs
=
INT64_MIN
};
tsdbReaderT
pDataReader
=
NULL
;
tsdbReaderT
pDataReader
=
NULL
;
if
(
pHandle
->
vnode
)
{
if
(
pHandle
->
vnode
)
{
pDataReader
=
doCreateDataReader
(
pTableScanNode
,
pHandle
,
pTableListInfo
,
(
uint64_t
)
queryId
,
taskId
,
pTagCond
);
pDataReader
=
doCreateDataReader
(
pTableScanNode
,
pHandle
,
pTableListInfo
,
(
uint64_t
)
queryId
,
taskId
,
pTagCond
);
...
@@ -4527,9 +4528,9 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
...
@@ -4527,9 +4528,9 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
}
else
{
}
else
{
qDebug
(
"%s pDataReader is not NULL"
,
GET_TASKID
(
pTaskInfo
));
qDebug
(
"%s pDataReader is not NULL"
,
GET_TASKID
(
pTaskInfo
));
}
}
SArray
*
tableIdList
=
extractTableIdList
(
pTableListInfo
);
SArray
*
tableIdList
=
extractTableIdList
(
pTableListInfo
);
SOperatorInfo
*
pOperator
=
createStreamScanOperatorInfo
(
pDataReader
,
pHandle
,
SOperatorInfo
*
pOperator
=
createStreamScanOperatorInfo
(
pDataReader
,
pHandle
,
tableIdList
,
pTableScanNode
,
tableIdList
,
pTableScanNode
,
pTaskInfo
,
&
twSup
,
pTableScanNode
->
tsColId
);
pTaskInfo
,
&
twSup
,
pTableScanNode
->
tsColId
);
taosArrayDestroy
(
tableIdList
);
taosArrayDestroy
(
tableIdList
);
return
pOperator
;
return
pOperator
;
...
@@ -4996,25 +4997,25 @@ _error:
...
@@ -4996,25 +4997,25 @@ _error:
return
NULL
;
return
NULL
;
}
}
int32_t
encodeOperator
(
SOperatorInfo
*
ops
,
char
**
result
,
int32_t
*
length
)
{
int32_t
encodeOperator
(
SOperatorInfo
*
ops
,
char
**
result
,
int32_t
*
length
)
{
int32_t
code
=
TDB_CODE_SUCCESS
;
int32_t
code
=
TDB_CODE_SUCCESS
;
char
*
pCurrent
=
NULL
;
char
*
pCurrent
=
NULL
;
int32_t
currLength
=
0
;
int32_t
currLength
=
0
;
if
(
ops
->
fpSet
.
encodeResultRow
)
{
if
(
ops
->
fpSet
.
encodeResultRow
)
{
if
(
result
==
NULL
||
length
==
NULL
)
{
if
(
result
==
NULL
||
length
==
NULL
)
{
return
TSDB_CODE_TSC_INVALID_INPUT
;
return
TSDB_CODE_TSC_INVALID_INPUT
;
}
}
code
=
ops
->
fpSet
.
encodeResultRow
(
ops
,
&
pCurrent
,
&
currLength
);
code
=
ops
->
fpSet
.
encodeResultRow
(
ops
,
&
pCurrent
,
&
currLength
);
if
(
code
!=
TDB_CODE_SUCCESS
)
{
if
(
code
!=
TDB_CODE_SUCCESS
)
{
if
(
*
result
!=
NULL
)
{
if
(
*
result
!=
NULL
)
{
taosMemoryFree
(
*
result
);
taosMemoryFree
(
*
result
);
*
result
=
NULL
;
*
result
=
NULL
;
}
}
return
code
;
return
code
;
}
}
if
(
*
result
==
NULL
)
{
if
(
*
result
==
NULL
)
{
*
result
=
(
char
*
)
taosMemoryCalloc
(
1
,
currLength
+
sizeof
(
int32_t
));
*
result
=
(
char
*
)
taosMemoryCalloc
(
1
,
currLength
+
sizeof
(
int32_t
));
if
(
*
result
==
NULL
)
{
if
(
*
result
==
NULL
)
{
taosMemoryFree
(
pCurrent
);
taosMemoryFree
(
pCurrent
);
...
@@ -5022,9 +5023,9 @@ int32_t encodeOperator(SOperatorInfo* ops, char** result, int32_t *length){
...
@@ -5022,9 +5023,9 @@ int32_t encodeOperator(SOperatorInfo* ops, char** result, int32_t *length){
}
}
memcpy
(
*
result
+
sizeof
(
int32_t
),
pCurrent
,
currLength
);
memcpy
(
*
result
+
sizeof
(
int32_t
),
pCurrent
,
currLength
);
*
(
int32_t
*
)(
*
result
)
=
currLength
+
sizeof
(
int32_t
);
*
(
int32_t
*
)(
*
result
)
=
currLength
+
sizeof
(
int32_t
);
}
else
{
}
else
{
int32_t
sizePre
=
*
(
int32_t
*
)(
*
result
);
int32_t
sizePre
=
*
(
int32_t
*
)(
*
result
);
char
*
tmp
=
(
char
*
)
taosMemoryRealloc
(
*
result
,
sizePre
+
currLength
);
char
*
tmp
=
(
char
*
)
taosMemoryRealloc
(
*
result
,
sizePre
+
currLength
);
if
(
tmp
==
NULL
)
{
if
(
tmp
==
NULL
)
{
taosMemoryFree
(
pCurrent
);
taosMemoryFree
(
pCurrent
);
taosMemoryFree
(
*
result
);
taosMemoryFree
(
*
result
);
...
@@ -5041,33 +5042,33 @@ int32_t encodeOperator(SOperatorInfo* ops, char** result, int32_t *length){
...
@@ -5041,33 +5042,33 @@ int32_t encodeOperator(SOperatorInfo* ops, char** result, int32_t *length){
for
(
int32_t
i
=
0
;
i
<
ops
->
numOfDownstream
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
ops
->
numOfDownstream
;
++
i
)
{
code
=
encodeOperator
(
ops
->
pDownstream
[
i
],
result
,
length
);
code
=
encodeOperator
(
ops
->
pDownstream
[
i
],
result
,
length
);
if
(
code
!=
TDB_CODE_SUCCESS
)
{
if
(
code
!=
TDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
}
}
}
return
TDB_CODE_SUCCESS
;
return
TDB_CODE_SUCCESS
;
}
}
int32_t
decodeOperator
(
SOperatorInfo
*
ops
,
char
*
result
,
int32_t
length
){
int32_t
decodeOperator
(
SOperatorInfo
*
ops
,
char
*
result
,
int32_t
length
)
{
int32_t
code
=
TDB_CODE_SUCCESS
;
int32_t
code
=
TDB_CODE_SUCCESS
;
if
(
ops
->
fpSet
.
decodeResultRow
)
{
if
(
ops
->
fpSet
.
decodeResultRow
)
{
if
(
result
==
NULL
)
{
if
(
result
==
NULL
)
{
return
TSDB_CODE_TSC_INVALID_INPUT
;
return
TSDB_CODE_TSC_INVALID_INPUT
;
}
}
ASSERT
(
length
==
*
(
int32_t
*
)
result
);
ASSERT
(
length
==
*
(
int32_t
*
)
result
);
char
*
data
=
result
+
sizeof
(
int32_t
);
char
*
data
=
result
+
sizeof
(
int32_t
);
code
=
ops
->
fpSet
.
decodeResultRow
(
ops
,
data
);
code
=
ops
->
fpSet
.
decodeResultRow
(
ops
,
data
);
if
(
code
!=
TDB_CODE_SUCCESS
)
{
if
(
code
!=
TDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
}
int32_t
totalLength
=
*
(
int32_t
*
)
result
;
int32_t
totalLength
=
*
(
int32_t
*
)
result
;
int32_t
dataLength
=
*
(
int32_t
*
)
data
;
int32_t
dataLength
=
*
(
int32_t
*
)
data
;
if
(
totalLength
==
dataLength
+
sizeof
(
int32_t
))
{
// the last data
if
(
totalLength
==
dataLength
+
sizeof
(
int32_t
))
{
// the last data
result
=
NULL
;
result
=
NULL
;
length
=
0
;
length
=
0
;
}
else
{
}
else
{
result
+=
dataLength
;
result
+=
dataLength
;
*
(
int32_t
*
)(
result
)
=
totalLength
-
dataLength
;
*
(
int32_t
*
)(
result
)
=
totalLength
-
dataLength
;
length
=
totalLength
-
dataLength
;
length
=
totalLength
-
dataLength
;
...
@@ -5076,7 +5077,7 @@ int32_t decodeOperator(SOperatorInfo* ops, char* result, int32_t length){
...
@@ -5076,7 +5077,7 @@ int32_t decodeOperator(SOperatorInfo* ops, char* result, int32_t length){
for
(
int32_t
i
=
0
;
i
<
ops
->
numOfDownstream
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
ops
->
numOfDownstream
;
++
i
)
{
code
=
decodeOperator
(
ops
->
pDownstream
[
i
],
result
,
length
);
code
=
decodeOperator
(
ops
->
pDownstream
[
i
],
result
,
length
);
if
(
code
!=
TDB_CODE_SUCCESS
)
{
if
(
code
!=
TDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
}
}
}
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
945ac571
...
@@ -752,18 +752,30 @@ static bool isMultiResFunc(SNode* pNode) {
...
@@ -752,18 +752,30 @@ static bool isMultiResFunc(SNode* pNode) {
return
(
QUERY_NODE_COLUMN
==
nodeType
(
pParam
)
?
0
==
strcmp
(((
SColumnNode
*
)
pParam
)
->
colName
,
"*"
)
:
false
);
return
(
QUERY_NODE_COLUMN
==
nodeType
(
pParam
)
?
0
==
strcmp
(((
SColumnNode
*
)
pParam
)
->
colName
,
"*"
)
:
false
);
}
}
static
EDealRes
translateUnaryOperator
(
STranslateContext
*
pCxt
,
SOperatorNode
*
pOp
)
{
static
int32_t
rewriteNegativeOperator
(
SNode
**
pOp
)
{
SNode
*
pRes
=
NULL
;
int32_t
code
=
scalarCalculateConstants
(
*
pOp
,
&
pRes
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pOp
=
pRes
;
}
return
code
;
}
static
EDealRes
translateUnaryOperator
(
STranslateContext
*
pCxt
,
SOperatorNode
**
pOpRef
)
{
SOperatorNode
*
pOp
=
*
pOpRef
;
if
(
OP_TYPE_MINUS
==
pOp
->
opType
)
{
if
(
OP_TYPE_MINUS
==
pOp
->
opType
)
{
if
(
!
IS_MATHABLE_TYPE
(((
SExprNode
*
)(
pOp
->
pLeft
))
->
resType
.
type
))
{
if
(
!
IS_MATHABLE_TYPE
(((
SExprNode
*
)(
pOp
->
pLeft
))
->
resType
.
type
))
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
((
SExprNode
*
)(
pOp
->
pLeft
))
->
aliasName
);
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
((
SExprNode
*
)(
pOp
->
pLeft
))
->
aliasName
);
}
}
pOp
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_DOUBLE
;
pOp
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_DOUBLE
;
pOp
->
node
.
resType
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_DOUBLE
].
bytes
;
pOp
->
node
.
resType
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_DOUBLE
].
bytes
;
pCxt
->
errCode
=
rewriteNegativeOperator
((
SNode
**
)
pOpRef
);
}
else
{
}
else
{
pOp
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_BOOL
;
pOp
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_BOOL
;
pOp
->
node
.
resType
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_BOOL
].
bytes
;
pOp
->
node
.
resType
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_BOOL
].
bytes
;
}
}
return
DEAL_RES_CONTINUE
;
return
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
?
DEAL_RES_CONTINUE
:
DEAL_RES_ERROR
;
}
}
static
EDealRes
translateArithmeticOperator
(
STranslateContext
*
pCxt
,
SOperatorNode
*
pOp
)
{
static
EDealRes
translateArithmeticOperator
(
STranslateContext
*
pCxt
,
SOperatorNode
*
pOp
)
{
...
@@ -824,7 +836,9 @@ static EDealRes translateJsonOperator(STranslateContext* pCxt, SOperatorNode* pO
...
@@ -824,7 +836,9 @@ static EDealRes translateJsonOperator(STranslateContext* pCxt, SOperatorNode* pO
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
}
}
static
EDealRes
translateOperator
(
STranslateContext
*
pCxt
,
SOperatorNode
*
pOp
)
{
static
EDealRes
translateOperator
(
STranslateContext
*
pCxt
,
SOperatorNode
**
pOpRef
)
{
SOperatorNode
*
pOp
=
*
pOpRef
;
if
(
isMultiResFunc
(
pOp
->
pLeft
))
{
if
(
isMultiResFunc
(
pOp
->
pLeft
))
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
((
SExprNode
*
)(
pOp
->
pLeft
))
->
aliasName
);
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
((
SExprNode
*
)(
pOp
->
pLeft
))
->
aliasName
);
}
}
...
@@ -833,7 +847,7 @@ static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) {
...
@@ -833,7 +847,7 @@ static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) {
}
}
if
(
nodesIsUnaryOp
(
pOp
))
{
if
(
nodesIsUnaryOp
(
pOp
))
{
return
translateUnaryOperator
(
pCxt
,
pOp
);
return
translateUnaryOperator
(
pCxt
,
pOp
Ref
);
}
else
if
(
nodesIsArithmeticOp
(
pOp
))
{
}
else
if
(
nodesIsArithmeticOp
(
pOp
))
{
return
translateArithmeticOperator
(
pCxt
,
pOp
);
return
translateArithmeticOperator
(
pCxt
,
pOp
);
}
else
if
(
nodesIsComparisonOp
(
pOp
))
{
}
else
if
(
nodesIsComparisonOp
(
pOp
))
{
...
@@ -992,7 +1006,7 @@ static EDealRes doTranslateExpr(SNode** pNode, void* pContext) {
...
@@ -992,7 +1006,7 @@ static EDealRes doTranslateExpr(SNode** pNode, void* pContext) {
case
QUERY_NODE_VALUE
:
case
QUERY_NODE_VALUE
:
return
translateValue
(
pCxt
,
(
SValueNode
*
)
*
pNode
);
return
translateValue
(
pCxt
,
(
SValueNode
*
)
*
pNode
);
case
QUERY_NODE_OPERATOR
:
case
QUERY_NODE_OPERATOR
:
return
translateOperator
(
pCxt
,
(
SOperatorNode
*
)
*
pNode
);
return
translateOperator
(
pCxt
,
(
SOperatorNode
*
*
)
pNode
);
case
QUERY_NODE_FUNCTION
:
case
QUERY_NODE_FUNCTION
:
return
translateFunction
(
pCxt
,
(
SFunctionNode
*
)
*
pNode
);
return
translateFunction
(
pCxt
,
(
SFunctionNode
*
)
*
pNode
);
case
QUERY_NODE_LOGIC_CONDITION
:
case
QUERY_NODE_LOGIC_CONDITION
:
...
@@ -1891,9 +1905,9 @@ static int32_t translatePartitionBy(STranslateContext* pCxt, SNodeList* pPartiti
...
@@ -1891,9 +1905,9 @@ static int32_t translatePartitionBy(STranslateContext* pCxt, SNodeList* pPartiti
return
translateExprList
(
pCxt
,
pPartitionByList
);
return
translateExprList
(
pCxt
,
pPartitionByList
);
}
}
static
int32_t
translateWhere
(
STranslateContext
*
pCxt
,
SNode
*
pWhere
)
{
static
int32_t
translateWhere
(
STranslateContext
*
pCxt
,
SNode
*
*
pWhere
)
{
pCxt
->
currClause
=
SQL_CLAUSE_WHERE
;
pCxt
->
currClause
=
SQL_CLAUSE_WHERE
;
return
translateExpr
(
pCxt
,
&
pWhere
);
return
translateExpr
(
pCxt
,
pWhere
);
}
}
static
int32_t
translateFrom
(
STranslateContext
*
pCxt
,
SSelectStmt
*
pSelect
)
{
static
int32_t
translateFrom
(
STranslateContext
*
pCxt
,
SSelectStmt
*
pSelect
)
{
...
@@ -1964,7 +1978,7 @@ static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) {
...
@@ -1964,7 +1978,7 @@ static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) {
pCxt
->
pCurrStmt
=
pSelect
;
pCxt
->
pCurrStmt
=
pSelect
;
int32_t
code
=
translateFrom
(
pCxt
,
pSelect
);
int32_t
code
=
translateFrom
(
pCxt
,
pSelect
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
translateWhere
(
pCxt
,
pSelect
->
pWhere
);
code
=
translateWhere
(
pCxt
,
&
pSelect
->
pWhere
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
translatePartitionBy
(
pCxt
,
pSelect
->
pPartitionByList
);
code
=
translatePartitionBy
(
pCxt
,
pSelect
->
pPartitionByList
);
...
...
source/libs/parser/test/parSelectTest.cpp
浏览文件 @
945ac571
...
@@ -44,6 +44,8 @@ TEST_F(ParserSelectTest, constant) {
...
@@ -44,6 +44,8 @@ TEST_F(ParserSelectTest, constant) {
"timestamp '2022-02-09 17:30:20', true, false, 15s FROM t1"
);
"timestamp '2022-02-09 17:30:20', true, false, 15s FROM t1"
);
run
(
"SELECT 123 + 45 FROM t1 WHERE 2 - 1"
);
run
(
"SELECT 123 + 45 FROM t1 WHERE 2 - 1"
);
run
(
"SELECT * FROM t1 WHERE -2"
);
}
}
TEST_F
(
ParserSelectTest
,
expression
)
{
TEST_F
(
ParserSelectTest
,
expression
)
{
...
@@ -76,6 +78,12 @@ TEST_F(ParserSelectTest, pseudoColumnSemanticCheck) {
...
@@ -76,6 +78,12 @@ TEST_F(ParserSelectTest, pseudoColumnSemanticCheck) {
run
(
"SELECT TBNAME FROM (SELECT * FROM st1s1)"
,
TSDB_CODE_PAR_INVALID_TBNAME
,
PARSER_STAGE_TRANSLATE
);
run
(
"SELECT TBNAME FROM (SELECT * FROM st1s1)"
,
TSDB_CODE_PAR_INVALID_TBNAME
,
PARSER_STAGE_TRANSLATE
);
}
}
TEST_F
(
ParserSelectTest
,
aggFunc
)
{
useDb
(
"root"
,
"test"
);
run
(
"SELECT LEASTSQUARES(c1, -1, 1) FROM t1"
);
}
TEST_F
(
ParserSelectTest
,
multiResFunc
)
{
TEST_F
(
ParserSelectTest
,
multiResFunc
)
{
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
...
...
source/libs/planner/test/planSTableTest.cpp
浏览文件 @
945ac571
...
@@ -27,6 +27,14 @@ TEST_F(PlanSuperTableTest, pseudoCol) {
...
@@ -27,6 +27,14 @@ TEST_F(PlanSuperTableTest, pseudoCol) {
run
(
"SELECT TBNAME, tag1, tag2 FROM st1"
);
run
(
"SELECT TBNAME, tag1, tag2 FROM st1"
);
}
}
TEST_F
(
PlanSuperTableTest
,
pseudoColOnChildTable
)
{
useDb
(
"root"
,
"test"
);
run
(
"SELECT TBNAME FROM st1s1"
);
run
(
"SELECT TBNAME, tag1, tag2 FROM st1s1"
);
}
TEST_F
(
PlanSuperTableTest
,
orderBy
)
{
TEST_F
(
PlanSuperTableTest
,
orderBy
)
{
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录