Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
aace9c4c
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
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看板
提交
aace9c4c
编写于
7月 05, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'fix/mnode' into fix/tsim
上级
f2494994
93962a8c
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
130 addition
and
115 deletion
+130
-115
source/dnode/mgmt/mgmt_vnode/src/vmFile.c
source/dnode/mgmt/mgmt_vnode/src/vmFile.c
+1
-2
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
+4
-3
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
+15
-24
source/dnode/mgmt/node_mgmt/src/dmTransport.c
source/dnode/mgmt/node_mgmt/src/dmTransport.c
+5
-4
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+32
-33
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+9
-0
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+17
-17
source/libs/parser/src/parUtil.c
source/libs/parser/src/parUtil.c
+3
-19
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+7
-0
source/libs/planner/src/planSpliter.c
source/libs/planner/src/planSpliter.c
+2
-1
source/libs/planner/test/planBasicTest.cpp
source/libs/planner/test/planBasicTest.cpp
+6
-0
source/libs/planner/test/planOtherTest.cpp
source/libs/planner/test/planOtherTest.cpp
+0
-7
source/libs/planner/test/planTestMain.cpp
source/libs/planner/test/planTestMain.cpp
+4
-0
source/libs/planner/test/planTestUtil.cpp
source/libs/planner/test/planTestUtil.cpp
+19
-0
source/libs/planner/test/planTestUtil.h
source/libs/planner/test/planTestUtil.h
+1
-0
tests/script/tsim/stable/tag_modify.sim
tests/script/tsim/stable/tag_modify.sim
+2
-2
tests/script/tsim/stable/tag_rename.sim
tests/script/tsim/stable/tag_rename.sim
+3
-3
未找到文件。
source/dnode/mgmt/mgmt_vnode/src/vmFile.c
浏览文件 @
aace9c4c
...
...
@@ -32,8 +32,7 @@ SVnodeObj **vmGetVnodeListFromHash(SVnodeMgmt *pMgmt, int32_t *numOfVnodes) {
if
(
pVnode
&&
num
<
size
)
{
int32_t
refCount
=
atomic_add_fetch_32
(
&
pVnode
->
refCount
,
1
);
// dTrace("vgId:%d, acquire vnode, refCount:%d", pVnode->vgId, refCount);
pVnodes
[
num
]
=
(
*
ppVnode
);
num
++
;
pVnodes
[
num
++
]
=
(
*
ppVnode
);
pIter
=
taosHashIterate
(
pMgmt
->
hash
,
pIter
);
}
else
{
taosHashCancelIterate
(
pMgmt
->
hash
,
pIter
);
...
...
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
浏览文件 @
aace9c4c
...
...
@@ -88,7 +88,7 @@ void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
while
(
!
taosQueueEmpty
(
pVnode
->
pApplyQ
))
taosMsleep
(
10
);
while
(
!
taosQueueEmpty
(
pVnode
->
pQueryQ
))
taosMsleep
(
10
);
while
(
!
taosQueueEmpty
(
pVnode
->
pFetchQ
))
taosMsleep
(
10
);
dTrace
(
"vgId:%d, vnode
-fetch
queue is empty"
,
pVnode
->
vgId
);
dTrace
(
"vgId:%d, vnode queue is empty"
,
pVnode
->
vgId
);
vmFreeQueue
(
pMgmt
,
pVnode
);
vnodeClose
(
pVnode
->
pImpl
);
...
...
@@ -140,7 +140,7 @@ static void *vmOpenVnodeInThread(void *param) {
}
static
int32_t
vmOpenVnodes
(
SVnodeMgmt
*
pMgmt
)
{
pMgmt
->
hash
=
taosHashInit
(
TSDB_MIN_VNODES
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
HASH_
NO
_LOCK
);
pMgmt
->
hash
=
taosHashInit
(
TSDB_MIN_VNODES
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
HASH_
ENTRY
_LOCK
);
if
(
pMgmt
->
hash
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
dError
(
"failed to init vnode hash since %s"
,
terrstr
());
...
...
@@ -156,7 +156,8 @@ static int32_t vmOpenVnodes(SVnodeMgmt *pMgmt) {
pMgmt
->
state
.
totalVnodes
=
numOfVnodes
;
int32_t
threadNum
=
1
;
int32_t
threadNum
=
tsNumOfCores
/
2
;
if
(
threadNum
<
1
)
threadNum
=
1
;
int32_t
vnodesPerThread
=
numOfVnodes
/
threadNum
+
1
;
SVnodeThread
*
threads
=
taosMemoryCalloc
(
threadNum
,
sizeof
(
SVnodeThread
));
...
...
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
浏览文件 @
aace9c4c
...
...
@@ -114,28 +114,6 @@ static void vmProcessSyncQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOf
}
}
static
void
vmProcessMergeQueue
(
SQueueInfo
*
pInfo
,
STaosQall
*
qall
,
int32_t
numOfMsgs
)
{
SVnodeObj
*
pVnode
=
pInfo
->
ahandle
;
SRpcMsg
*
pMsg
=
NULL
;
for
(
int32_t
i
=
0
;
i
<
numOfMsgs
;
++
i
)
{
if
(
taosGetQitem
(
qall
,
(
void
**
)
&
pMsg
)
==
0
)
continue
;
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
dGTrace
(
"vgId:%d, msg:%p get from vnode-merge queue"
,
pVnode
->
vgId
,
pMsg
);
int32_t
code
=
vnodeProcessFetchMsg
(
pVnode
->
pImpl
,
pMsg
,
pInfo
);
if
(
code
!=
0
)
{
if
(
terrno
!=
0
)
code
=
terrno
;
dGError
(
"vgId:%d, msg:%p failed to merge since %s"
,
pVnode
->
vgId
,
pMsg
,
terrstr
());
vmSendRsp
(
pMsg
,
code
);
}
dGTrace
(
"msg:%p, is freed, code:0x%x"
,
pMsg
,
code
);
rpcFreeCont
(
pMsg
->
pCont
);
taosFreeQitem
(
pMsg
);
}
}
static
int32_t
vmPutMsgToQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
,
EQueueType
qtype
)
{
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
SMsgHead
*
pHead
=
pMsg
->
pCont
;
...
...
@@ -207,7 +185,11 @@ int32_t vmPutMsgToMonitorQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
int32_t
vmPutRpcMsgToQueue
(
SVnodeMgmt
*
pMgmt
,
EQueueType
qtype
,
SRpcMsg
*
pRpc
)
{
SRpcMsg
*
pMsg
=
taosAllocateQitem
(
sizeof
(
SRpcMsg
),
RPC_QITEM
);
if
(
pMsg
==
NULL
)
return
-
1
;
if
(
pMsg
==
NULL
)
{
rpcFreeCont
(
pMsg
->
pCont
);
pRpc
->
pCont
=
NULL
;
return
-
1
;
}
SMsgHead
*
pHead
=
pRpc
->
pCont
;
dTrace
(
"vgId:%d, msg:%p is created, type:%s"
,
pHead
->
vgId
,
pMsg
,
TMSG_INFO
(
pRpc
->
msgType
));
...
...
@@ -215,7 +197,16 @@ int32_t vmPutRpcMsgToQueue(SVnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
pHead
->
contLen
=
htonl
(
pHead
->
contLen
);
pHead
->
vgId
=
htonl
(
pHead
->
vgId
);
memcpy
(
pMsg
,
pRpc
,
sizeof
(
SRpcMsg
));
return
vmPutMsgToQueue
(
pMgmt
,
pMsg
,
qtype
);
int32_t
code
=
vmPutMsgToQueue
(
pMgmt
,
pMsg
,
qtype
);
if
(
code
!=
0
)
{
dTrace
(
"msg:%p, is freed"
,
pMsg
);
taosFreeQitem
(
pMsg
);
rpcFreeCont
(
pMsg
->
pCont
);
pRpc
->
pCont
=
NULL
;
}
return
code
;
}
int32_t
vmGetQueueSize
(
SVnodeMgmt
*
pMgmt
,
int32_t
vgId
,
EQueueType
qtype
)
{
...
...
source/dnode/mgmt/node_mgmt/src/dmTransport.c
浏览文件 @
aace9c4c
...
...
@@ -71,9 +71,9 @@ int32_t dmProcessNodeMsg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg) {
}
static
void
dmProcessRpcMsg
(
SDnode
*
pDnode
,
SRpcMsg
*
pRpc
,
SEpSet
*
pEpSet
)
{
SDnodeTrans
*
pTrans
=
&
pDnode
->
trans
;
SDnodeTrans
*
pTrans
=
&
pDnode
->
trans
;
int32_t
code
=
-
1
;
SRpcMsg
*
pMsg
=
NULL
;
SRpcMsg
*
pMsg
=
NULL
;
SMgmtWrapper
*
pWrapper
=
NULL
;
SDnodeHandle
*
pHandle
=
&
pTrans
->
msgHandles
[
TMSG_INDEX
(
pRpc
->
msgType
)];
...
...
@@ -185,6 +185,7 @@ _OVER:
taosFreeQitem
(
pMsg
);
}
rpcFreeCont
(
pRpc
->
pCont
);
pRpc
->
pCont
=
NULL
;
}
dmReleaseWrapper
(
pWrapper
);
...
...
@@ -195,11 +196,11 @@ int32_t dmInitMsgHandle(SDnode *pDnode) {
for
(
EDndNodeType
ntype
=
DNODE
;
ntype
<
NODE_END
;
++
ntype
)
{
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
ntype
];
SArray
*
pArray
=
(
*
pWrapper
->
func
.
getHandlesFp
)();
SArray
*
pArray
=
(
*
pWrapper
->
func
.
getHandlesFp
)();
if
(
pArray
==
NULL
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pArray
);
++
i
)
{
SMgmtHandle
*
pMgmt
=
taosArrayGet
(
pArray
,
i
);
SMgmtHandle
*
pMgmt
=
taosArrayGet
(
pArray
,
i
);
SDnodeHandle
*
pHandle
=
&
pTrans
->
msgHandles
[
TMSG_INDEX
(
pMgmt
->
msgType
)];
if
(
pMgmt
->
needCheckVgId
)
{
pHandle
->
needCheckVgId
=
pMgmt
->
needCheckVgId
;
...
...
source/libs/function/src/builtins.c
浏览文件 @
aace9c4c
...
...
@@ -15,10 +15,10 @@
#include "builtins.h"
#include "builtinsimpl.h"
#include "cJSON.h"
#include "querynodes.h"
#include "scalar.h"
#include "taoserror.h"
#include "cJSON.h"
static
int32_t
buildFuncErrMsg
(
char
*
pErrBuf
,
int32_t
len
,
int32_t
errCode
,
const
char
*
pFormat
,
...)
{
va_list
vArgList
;
...
...
@@ -40,7 +40,7 @@ static int32_t invaildFuncParaValueErrMsg(char* pErrBuf, int32_t len, const char
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_PARA_VALUE
,
"Invalid parameter value : %s"
,
pFuncName
);
}
#define TIME_UNIT_INVALID 1
#define TIME_UNIT_INVALID
1
#define TIME_UNIT_TOO_SMALL 2
static
int32_t
validateTimeUnitParam
(
uint8_t
dbPrec
,
const
SValueNode
*
pVal
)
{
...
...
@@ -52,10 +52,9 @@ static int32_t validateTimeUnitParam(uint8_t dbPrec, const SValueNode* pVal) {
return
TIME_UNIT_TOO_SMALL
;
}
if
(
pVal
->
literal
[
0
]
!=
'1'
||
(
pVal
->
literal
[
1
]
!=
'u'
&&
pVal
->
literal
[
1
]
!=
'a'
&&
pVal
->
literal
[
1
]
!=
's'
&&
pVal
->
literal
[
1
]
!=
'm'
&&
pVal
->
literal
[
1
]
!=
'h'
&&
pVal
->
literal
[
1
]
!=
'd'
&&
pVal
->
literal
[
1
]
!=
'w'
))
{
if
(
pVal
->
literal
[
0
]
!=
'1'
||
(
pVal
->
literal
[
1
]
!=
'u'
&&
pVal
->
literal
[
1
]
!=
'a'
&&
pVal
->
literal
[
1
]
!=
's'
&&
pVal
->
literal
[
1
]
!=
'm'
&&
pVal
->
literal
[
1
]
!=
'h'
&&
pVal
->
literal
[
1
]
!=
'd'
&&
pVal
->
literal
[
1
]
!=
'w'
))
{
return
TIME_UNIT_INVALID
;
}
...
...
@@ -696,13 +695,14 @@ static int32_t translateElapsed(SFunctionNode* pFunc, char* pErrBuf, int32_t len
uint8_t
dbPrec
=
pFunc
->
node
.
resType
.
precision
;
int32_t
ret
=
validateTimeUnitParam
(
dbPrec
,
(
SValueNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
1
));
int32_t
ret
=
validateTimeUnitParam
(
dbPrec
,
(
SValueNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
1
));
if
(
ret
==
TIME_UNIT_TOO_SMALL
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"ELAPSED function time unit parameter should be greater than db precision"
);
}
else
if
(
ret
==
TIME_UNIT_INVALID
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"ELAPSED function time unit parameter should be one of the following: [1u, 1a, 1s, 1m, 1h, 1d, 1w]"
);
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"ELAPSED function time unit parameter should be one of the following: [1u, 1a, 1s, 1m, 1h, 1d, 1w]"
);
}
}
...
...
@@ -815,13 +815,13 @@ static int8_t validateHistogramBinType(char* binTypeStr) {
}
static
bool
validateHistogramBinDesc
(
char
*
binDescStr
,
int8_t
binType
,
char
*
errMsg
,
int32_t
msgLen
)
{
const
char
*
msg1
=
"HISTOGRAM function requires four parameters"
;
const
char
*
msg3
=
"HISTOGRAM function invalid format for binDesc parameter"
;
const
char
*
msg4
=
"HISTOGRAM function binDesc parameter
\"
count
\"
should be in range [1, 1000]"
;
const
char
*
msg5
=
"HISTOGRAM function bin/parameter should be in range [-DBL_MAX, DBL_MAX]"
;
const
char
*
msg6
=
"HISTOGRAM function binDesc parameter
\"
width
\"
cannot be 0"
;
const
char
*
msg7
=
"HISTOGRAM function binDesc parameter
\"
start
\"
cannot be 0 with
\"
log_bin
\"
type"
;
const
char
*
msg8
=
"HISTOGRAM function binDesc parameter
\"
factor
\"
cannot be negative or equal to 0/1"
;
const
char
*
msg1
=
"HISTOGRAM function requires four parameters"
;
const
char
*
msg3
=
"HISTOGRAM function invalid format for binDesc parameter"
;
const
char
*
msg4
=
"HISTOGRAM function binDesc parameter
\"
count
\"
should be in range [1, 1000]"
;
const
char
*
msg5
=
"HISTOGRAM function bin/parameter should be in range [-DBL_MAX, DBL_MAX]"
;
const
char
*
msg6
=
"HISTOGRAM function binDesc parameter
\"
width
\"
cannot be 0"
;
const
char
*
msg7
=
"HISTOGRAM function binDesc parameter
\"
start
\"
cannot be 0 with
\"
log_bin
\"
type"
;
const
char
*
msg8
=
"HISTOGRAM function binDesc parameter
\"
factor
\"
cannot be negative or equal to 0/1"
;
cJSON
*
binDesc
=
cJSON_Parse
(
binDescStr
);
int32_t
numOfBins
;
...
...
@@ -1004,8 +1004,8 @@ static int32_t translateHistogram(SFunctionNode* pFunc, char* pErrBuf, int32_t l
}
if
(
i
==
3
&&
pValue
->
datum
.
i
!=
1
&&
pValue
->
datum
.
i
!=
0
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"HISTOGRAM function normalized parameter should be 0/1"
);
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"HISTOGRAM function normalized parameter should be 0/1"
);
}
}
...
...
@@ -1062,8 +1062,8 @@ static int32_t translateHistogramImpl(SFunctionNode* pFunc, char* pErrBuf, int32
}
if
(
i
==
3
&&
pValue
->
datum
.
i
!=
1
&&
pValue
->
datum
.
i
!=
0
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"HISTOGRAM function normalized parameter should be 0/1"
);
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"HISTOGRAM function normalized parameter should be 0/1"
);
}
}
...
...
@@ -1218,13 +1218,14 @@ static int32_t translateStateDuration(SFunctionNode* pFunc, char* pErrBuf, int32
if
(
numOfParams
==
4
)
{
uint8_t
dbPrec
=
pFunc
->
node
.
resType
.
precision
;
int32_t
ret
=
validateTimeUnitParam
(
dbPrec
,
(
SValueNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
3
));
int32_t
ret
=
validateTimeUnitParam
(
dbPrec
,
(
SValueNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
3
));
if
(
ret
==
TIME_UNIT_TOO_SMALL
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"STATEDURATION function time unit parameter should be greater than db precision"
);
}
else
if
(
ret
==
TIME_UNIT_INVALID
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"STATEDURATION function time unit parameter should be one of the following: [1u, 1a, 1s, 1m, 1h, 1d, 1w]"
);
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"STATEDURATION function time unit parameter should be one of the following: [1u, 1a, 1s, 1m, 1h, 1d, 1w]"
);
}
}
...
...
@@ -1432,10 +1433,6 @@ static int32_t translateFirstLast(SFunctionNode* pFunc, char* pErrBuf, int32_t l
static
int32_t
translateFirstLastImpl
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
,
bool
isPartial
)
{
// first(col_list) will be rewritten as first(col)
if
(
2
!=
LIST_LENGTH
(
pFunc
->
pParameterList
))
{
// input has two params c0,ts, is this a bug?
return
TSDB_CODE_SUCCESS
;
}
SNode
*
pPara
=
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
uint8_t
paraType
=
((
SExprNode
*
)
pPara
)
->
resType
.
type
;
int32_t
paraBytes
=
((
SExprNode
*
)
pPara
)
->
resType
.
bytes
;
...
...
@@ -1733,13 +1730,14 @@ static int32_t translateTimeTruncate(SFunctionNode* pFunc, char* pErrBuf, int32_
// add database precision as param
uint8_t
dbPrec
=
pFunc
->
node
.
resType
.
precision
;
int32_t
ret
=
validateTimeUnitParam
(
dbPrec
,
(
SValueNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
1
));
int32_t
ret
=
validateTimeUnitParam
(
dbPrec
,
(
SValueNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
1
));
if
(
ret
==
TIME_UNIT_TOO_SMALL
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"TIMETRUNCATE function time unit parameter should be greater than db precision"
);
}
else
if
(
ret
==
TIME_UNIT_INVALID
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"TIMETRUNCATE function time unit parameter should be one of the following: [1u, 1a, 1s, 1m, 1h, 1d, 1w]"
);
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"TIMETRUNCATE function time unit parameter should be one of the following: [1u, 1a, 1s, 1m, 1h, 1d, 1w]"
);
}
addDbPrecisonParam
(
&
pFunc
->
pParameterList
,
dbPrec
);
...
...
@@ -1772,13 +1770,14 @@ static int32_t translateTimeDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t le
uint8_t
dbPrec
=
pFunc
->
node
.
resType
.
precision
;
if
(
3
==
numOfParams
)
{
int32_t
ret
=
validateTimeUnitParam
(
dbPrec
,
(
SValueNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
2
));
int32_t
ret
=
validateTimeUnitParam
(
dbPrec
,
(
SValueNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
2
));
if
(
ret
==
TIME_UNIT_TOO_SMALL
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"TIMEDIFF function time unit parameter should be greater than db precision"
);
}
else
if
(
ret
==
TIME_UNIT_INVALID
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"TIMEDIFF function time unit parameter should be one of the following: [1u, 1a, 1s, 1m, 1h, 1d, 1w]"
);
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"TIMEDIFF function time unit parameter should be one of the following: [1u, 1a, 1s, 1m, 1h, 1d, 1w]"
);
}
}
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
aace9c4c
...
...
@@ -385,6 +385,15 @@ SNode* createLogicConditionNode(SAstCreateContext* pCxt, ELogicConditionType typ
SNode
*
createOperatorNode
(
SAstCreateContext
*
pCxt
,
EOperatorType
type
,
SNode
*
pLeft
,
SNode
*
pRight
)
{
CHECK_PARSER_STATUS
(
pCxt
);
if
(
OP_TYPE_MINUS
==
type
&&
QUERY_NODE_VALUE
==
nodeType
(
pLeft
))
{
SValueNode
*
pVal
=
(
SValueNode
*
)
pLeft
;
char
*
pNewLiteral
=
taosMemoryCalloc
(
1
,
strlen
(
pVal
->
literal
)
+
2
);
CHECK_OUT_OF_MEM
(
pNewLiteral
);
sprintf
(
pNewLiteral
,
"-%s"
,
pVal
->
literal
);
taosMemoryFree
(
pVal
->
literal
);
pVal
->
literal
=
pNewLiteral
;
return
pLeft
;
}
SOperatorNode
*
op
=
(
SOperatorNode
*
)
nodesMakeNode
(
QUERY_NODE_OPERATOR
);
CHECK_OUT_OF_MEM
(
op
);
op
->
opType
=
type
;
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
aace9c4c
...
...
@@ -558,11 +558,11 @@ static void setColumnInfoByExpr(STempTableNode* pTable, SExprNode* pExpr, SColum
pCol
->
node
.
resType
=
pExpr
->
resType
;
}
static
int32_t
createColumnsByTable
(
STranslateContext
*
pCxt
,
const
STableNode
*
pTable
,
SNodeList
*
pList
)
{
static
int32_t
createColumnsByTable
(
STranslateContext
*
pCxt
,
const
STableNode
*
pTable
,
bool
igTags
,
SNodeList
*
pList
)
{
if
(
QUERY_NODE_REAL_TABLE
==
nodeType
(
pTable
))
{
const
STableMeta
*
pMeta
=
((
SRealTableNode
*
)
pTable
)
->
pMeta
;
int32_t
nums
=
pMeta
->
tableInfo
.
numOfColumns
+
((
TSDB_SUPER_TABLE
==
pMeta
->
tableType
)
?
pMeta
->
tableInfo
.
numOfTags
:
0
);
int32_t
nums
=
pMeta
->
tableInfo
.
numOfColumns
+
(
igTags
?
0
:
((
TSDB_SUPER_TABLE
==
pMeta
->
tableType
)
?
pMeta
->
tableInfo
.
numOfTags
:
0
)
);
for
(
int32_t
i
=
0
;
i
<
nums
;
++
i
)
{
SColumnNode
*
pCol
=
(
SColumnNode
*
)
nodesMakeNode
(
QUERY_NODE_COLUMN
);
if
(
NULL
==
pCol
)
{
...
...
@@ -878,6 +878,9 @@ static EDealRes translateNormalValue(STranslateContext* pCxt, SValueNode* pVal,
}
case
TSDB_DATA_TYPE_VARCHAR
:
case
TSDB_DATA_TYPE_VARBINARY
:
{
if
(
strict
&&
(
pVal
->
node
.
resType
.
bytes
>
targetDt
.
bytes
-
VARSTR_HEADER_SIZE
))
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
pVal
->
literal
);
}
pVal
->
datum
.
p
=
taosMemoryCalloc
(
1
,
targetDt
.
bytes
+
1
);
if
(
NULL
==
pVal
->
datum
.
p
)
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_OUT_OF_MEMORY
);
...
...
@@ -1333,6 +1336,9 @@ static int32_t rewriteSystemInfoFuncImpl(STranslateContext* pCxt, char* pLiteral
pVal
->
isNull
=
true
;
}
else
{
pVal
->
literal
=
pLiteral
;
if
(
IS_VAR_DATA_TYPE
(
pVal
->
node
.
resType
.
type
))
{
pVal
->
node
.
resType
.
bytes
=
strlen
(
pLiteral
);
}
}
if
(
DEAL_RES_ERROR
!=
translateValue
(
pCxt
,
pVal
))
{
*
pNode
=
(
SNode
*
)
pVal
;
...
...
@@ -1928,7 +1934,7 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
return
code
;
}
static
int32_t
createAllColumns
(
STranslateContext
*
pCxt
,
SNodeList
**
pCols
)
{
static
int32_t
createAllColumns
(
STranslateContext
*
pCxt
,
bool
igTags
,
SNodeList
**
pCols
)
{
*
pCols
=
nodesMakeList
();
if
(
NULL
==
*
pCols
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_OUT_OF_MEMORY
);
...
...
@@ -1937,7 +1943,7 @@ static int32_t createAllColumns(STranslateContext* pCxt, SNodeList** pCols) {
size_t
nums
=
taosArrayGetSize
(
pTables
);
for
(
size_t
i
=
0
;
i
<
nums
;
++
i
)
{
STableNode
*
pTable
=
taosArrayGetP
(
pTables
,
i
);
int32_t
code
=
createColumnsByTable
(
pCxt
,
pTable
,
*
pCols
);
int32_t
code
=
createColumnsByTable
(
pCxt
,
pTable
,
igTags
,
*
pCols
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
return
code
;
}
...
...
@@ -1974,7 +1980,7 @@ static SNode* createMultiResFunc(SFunctionNode* pSrcFunc, SExprNode* pExpr) {
return
(
SNode
*
)
pFunc
;
}
static
int32_t
createTableAllCols
(
STranslateContext
*
pCxt
,
SColumnNode
*
pCol
,
SNodeList
**
pOutput
)
{
static
int32_t
createTableAllCols
(
STranslateContext
*
pCxt
,
SColumnNode
*
pCol
,
bool
igTags
,
SNodeList
**
pOutput
)
{
STableNode
*
pTable
=
NULL
;
int32_t
code
=
findTable
(
pCxt
,
pCol
->
tableAlias
,
&
pTable
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
==
*
pOutput
)
{
...
...
@@ -1984,7 +1990,7 @@ static int32_t createTableAllCols(STranslateContext* pCxt, SColumnNode* pCol, SN
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createColumnsByTable
(
pCxt
,
pTable
,
*
pOutput
);
code
=
createColumnsByTable
(
pCxt
,
pTable
,
igTags
,
*
pOutput
);
}
return
code
;
}
...
...
@@ -2006,11 +2012,9 @@ static int32_t createMultiResFuncsParas(STranslateContext* pCxt, SNodeList* pSrc
SNode
*
pPara
=
NULL
;
FOREACH
(
pPara
,
pSrcParas
)
{
if
(
isStar
(
pPara
))
{
code
=
createAllColumns
(
pCxt
,
&
pExprs
);
// The syntax definition ensures that * and other parameters do not appear at the same time
break
;
code
=
createAllColumns
(
pCxt
,
true
,
&
pExprs
);
}
else
if
(
isTableStar
(
pPara
))
{
code
=
createTableAllCols
(
pCxt
,
(
SColumnNode
*
)
pPara
,
&
pExprs
);
code
=
createTableAllCols
(
pCxt
,
(
SColumnNode
*
)
pPara
,
true
,
&
pExprs
);
}
else
{
code
=
nodesListMakeStrictAppend
(
&
pExprs
,
nodesCloneNode
(
pPara
));
}
...
...
@@ -2069,7 +2073,7 @@ static int32_t translateStar(STranslateContext* pCxt, SSelectStmt* pSelect) {
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
(
isStar
(
pNode
))
{
SNodeList
*
pCols
=
NULL
;
code
=
createAllColumns
(
pCxt
,
&
pCols
);
code
=
createAllColumns
(
pCxt
,
false
,
&
pCols
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
INSERT_LIST
(
pSelect
->
pProjectionList
,
pCols
);
ERASE_NODE
(
pSelect
->
pProjectionList
);
...
...
@@ -2085,7 +2089,7 @@ static int32_t translateStar(STranslateContext* pCxt, SSelectStmt* pSelect) {
}
}
else
if
(
isTableStar
(
pNode
))
{
SNodeList
*
pCols
=
NULL
;
code
=
createTableAllCols
(
pCxt
,
(
SColumnNode
*
)
pNode
,
&
pCols
);
code
=
createTableAllCols
(
pCxt
,
(
SColumnNode
*
)
pNode
,
false
,
&
pCols
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
INSERT_LIST
(
pSelect
->
pProjectionList
,
pCols
);
ERASE_NODE
(
pSelect
->
pProjectionList
);
...
...
@@ -5826,10 +5830,6 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS
return
pCxt
->
errCode
;
}
if
(
IS_VAR_DATA_TYPE
(
pSchema
->
type
)
&&
strlen
(
pStmt
->
pVal
->
literal
)
>
pSchema
->
bytes
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
pStmt
->
pVal
->
literal
);
}
pReq
->
isNull
=
(
TSDB_DATA_TYPE_NULL
==
pStmt
->
pVal
->
node
.
resType
.
type
);
if
(
targetDt
.
type
==
TSDB_DATA_TYPE_JSON
)
{
pReq
->
isNull
=
0
;
...
...
source/libs/parser/src/parUtil.c
浏览文件 @
aace9c4c
...
...
@@ -236,7 +236,6 @@ int32_t buildSyntaxErrMsg(SMsgBuf* pBuf, const char* additionalInfo, const char*
const
char
*
prefix
=
"syntax error"
;
if
(
sourceStr
==
NULL
)
{
assert
(
additionalInfo
!=
NULL
);
snprintf
(
pBuf
->
buf
,
pBuf
->
len
,
msgFormat1
,
additionalInfo
);
return
TSDB_CODE_TSC_SQL_SYNTAX_ERROR
;
}
...
...
@@ -254,40 +253,25 @@ int32_t buildSyntaxErrMsg(SMsgBuf* pBuf, const char* additionalInfo, const char*
return
TSDB_CODE_TSC_SQL_SYNTAX_ERROR
;
}
SSchema
*
getTableColumnSchema
(
const
STableMeta
*
pTableMeta
)
{
assert
(
pTableMeta
!=
NULL
);
return
(
SSchema
*
)
pTableMeta
->
schema
;
}
SSchema
*
getTableColumnSchema
(
const
STableMeta
*
pTableMeta
)
{
return
(
SSchema
*
)
pTableMeta
->
schema
;
}
static
SSchema
*
getOneColumnSchema
(
const
STableMeta
*
pTableMeta
,
int32_t
colIndex
)
{
assert
(
pTableMeta
!=
NULL
&&
pTableMeta
->
schema
!=
NULL
&&
colIndex
>=
0
&&
colIndex
<
(
getNumOfColumns
(
pTableMeta
)
+
getNumOfTags
(
pTableMeta
)));
SSchema
*
pSchema
=
(
SSchema
*
)
pTableMeta
->
schema
;
return
&
pSchema
[
colIndex
];
}
SSchema
*
getTableTagSchema
(
const
STableMeta
*
pTableMeta
)
{
assert
(
pTableMeta
!=
NULL
&&
(
pTableMeta
->
tableType
==
TSDB_SUPER_TABLE
||
pTableMeta
->
tableType
==
TSDB_CHILD_TABLE
));
return
getOneColumnSchema
(
pTableMeta
,
getTableInfo
(
pTableMeta
).
numOfColumns
);
}
int32_t
getNumOfColumns
(
const
STableMeta
*
pTableMeta
)
{
assert
(
pTableMeta
!=
NULL
);
// table created according to super table, use data from super table
return
getTableInfo
(
pTableMeta
).
numOfColumns
;
}
int32_t
getNumOfTags
(
const
STableMeta
*
pTableMeta
)
{
assert
(
pTableMeta
!=
NULL
);
return
getTableInfo
(
pTableMeta
).
numOfTags
;
}
int32_t
getNumOfTags
(
const
STableMeta
*
pTableMeta
)
{
return
getTableInfo
(
pTableMeta
).
numOfTags
;
}
STableComInfo
getTableInfo
(
const
STableMeta
*
pTableMeta
)
{
assert
(
pTableMeta
!=
NULL
);
return
pTableMeta
->
tableInfo
;
}
STableComInfo
getTableInfo
(
const
STableMeta
*
pTableMeta
)
{
return
pTableMeta
->
tableInfo
;
}
STableMeta
*
tableMetaDup
(
const
STableMeta
*
pTableMeta
)
{
size_t
size
=
TABLE_META_SIZE
(
pTableMeta
);
...
...
source/libs/planner/src/planOptimizer.c
浏览文件 @
aace9c4c
...
...
@@ -75,6 +75,11 @@ static SLogicNode* optFindPossibleNode(SLogicNode* pNode, FMayBeOptimized func)
return
NULL
;
}
static
void
optResetParent
(
SLogicNode
*
pNode
)
{
SNode
*
pChild
=
NULL
;
FOREACH
(
pChild
,
pNode
->
pChildren
)
{
((
SLogicNode
*
)
pChild
)
->
pParent
=
pNode
;
}
}
EDealRes
scanPathOptHaveNormalColImpl
(
SNode
*
pNode
,
void
*
pContext
)
{
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pNode
))
{
// *((bool*)pContext) = (COLUMN_TYPE_TAG != ((SColumnNode*)pNode)->colType);
...
...
@@ -1540,6 +1545,7 @@ static int32_t rewriteTailOptCreateSort(SIndefRowsFuncLogicNode* pIndef, SLogicN
pSort
->
groupSort
=
rewriteTailOptNeedGroupSort
(
pIndef
);
TSWAP
(
pSort
->
node
.
pChildren
,
pIndef
->
node
.
pChildren
);
optResetParent
((
SLogicNode
*
)
pSort
);
pSort
->
node
.
precision
=
pIndef
->
node
.
precision
;
SFunctionNode
*
pTail
=
NULL
;
...
...
@@ -1747,6 +1753,7 @@ static int32_t rewriteUniqueOptCreateAgg(SIndefRowsFuncLogicNode* pIndef, SLogic
}
TSWAP
(
pAgg
->
node
.
pChildren
,
pIndef
->
node
.
pChildren
);
optResetParent
((
SLogicNode
*
)
pAgg
);
pAgg
->
node
.
precision
=
pIndef
->
node
.
precision
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
...
...
source/libs/planner/src/planSpliter.c
浏览文件 @
aace9c4c
...
...
@@ -1203,7 +1203,8 @@ typedef struct SQnodeSplitInfo {
static
bool
qndSplFindSplitNode
(
SSplitContext
*
pCxt
,
SLogicSubplan
*
pSubplan
,
SLogicNode
*
pNode
,
SQnodeSplitInfo
*
pInfo
)
{
if
(
QUERY_NODE_LOGIC_PLAN_SCAN
==
nodeType
(
pNode
)
&&
NULL
!=
pNode
->
pParent
)
{
if
(
QUERY_NODE_LOGIC_PLAN_SCAN
==
nodeType
(
pNode
)
&&
NULL
!=
pNode
->
pParent
&&
((
SScanLogicNode
*
)
pNode
)
->
scanSeq
[
0
]
<
1
&&
((
SScanLogicNode
*
)
pNode
)
->
scanSeq
[
1
]
<
1
)
{
pInfo
->
pSplitNode
=
pNode
;
pInfo
->
pSubplan
=
pSubplan
;
return
true
;
...
...
source/libs/planner/test/planBasicTest.cpp
浏览文件 @
aace9c4c
...
...
@@ -63,6 +63,10 @@ TEST_F(PlanBasicTest, uniqueFunc) {
run
(
"SELECT UNIQUE(c2 + 10), ts, c2 FROM t1 WHERE c1 > 10"
);
run
(
"SELECT UNIQUE(c1) a FROM t1 ORDER BY a"
);
run
(
"SELECT ts, UNIQUE(c1) FROM st1 PARTITION BY TBNAME"
);
run
(
"SELECT TBNAME, UNIQUE(c1) FROM st1 PARTITION BY TBNAME"
);
}
TEST_F
(
PlanBasicTest
,
tailFunc
)
{
...
...
@@ -81,6 +85,8 @@ TEST_F(PlanBasicTest, tailFunc) {
run
(
"SELECT TAIL(c2 + 10, 10, 80) FROM t1 WHERE c1 > 10 PARTITION BY c1 LIMIT 5"
);
run
(
"SELECT TAIL(c1, 2, 1) FROM st1s1 UNION ALL SELECT c1 FROM st1s2"
);
run
(
"SELECT TAIL(c1, 1) FROM st2 WHERE jtag->'tag1' > 10"
);
}
TEST_F
(
PlanBasicTest
,
interpFunc
)
{
...
...
source/libs/planner/test/planOtherTest.cpp
浏览文件 @
aace9c4c
...
...
@@ -91,10 +91,3 @@ TEST_F(PlanOtherTest, delete) {
run
(
"DELETE FROM st1 WHERE ts > now - 2d and ts < now - 1d AND tag1 = 10"
);
}
TEST_F
(
PlanOtherTest
,
queryPolicy
)
{
useDb
(
"root"
,
"test"
);
tsQueryPolicy
=
QUERY_POLICY_QNODE
;
run
(
"SELECT COUNT(*) FROM st1"
);
}
source/libs/planner/test/planTestMain.cpp
浏览文件 @
aace9c4c
...
...
@@ -78,6 +78,7 @@ static void parseArg(int argc, char* argv[]) {
{
"skipSql"
,
required_argument
,
NULL
,
's'
},
{
"limitSql"
,
required_argument
,
NULL
,
'i'
},
{
"log"
,
required_argument
,
NULL
,
'l'
},
{
"queryPolicy"
,
required_argument
,
NULL
,
'q'
},
{
0
,
0
,
0
,
0
}
};
// clang-format on
...
...
@@ -95,6 +96,9 @@ static void parseArg(int argc, char* argv[]) {
case
'l'
:
setLogLevel
(
optarg
);
break
;
case
'q'
:
setQueryPolicy
(
optarg
);
break
;
default:
break
;
}
...
...
source/libs/planner/test/planTestUtil.cpp
浏览文件 @
aace9c4c
...
...
@@ -24,6 +24,7 @@
#include "mockCatalogService.h"
#include "parser.h"
#include "planInt.h"
#include "tglobal.h"
using
namespace
std
;
using
namespace
testing
;
...
...
@@ -53,6 +54,7 @@ DumpModule g_dumpModule = DUMP_MODULE_NOTHING;
int32_t
g_skipSql
=
0
;
int32_t
g_limitSql
=
0
;
int32_t
g_logLevel
=
131
;
int32_t
g_queryPolicy
=
QUERY_POLICY_VNODE
;
void
setDumpModule
(
const
char
*
pModule
)
{
if
(
NULL
==
pModule
)
{
...
...
@@ -79,6 +81,7 @@ void setDumpModule(const char* pModule) {
void
setSkipSqlNum
(
const
char
*
pNum
)
{
g_skipSql
=
stoi
(
pNum
);
}
void
setLimitSqlNum
(
const
char
*
pNum
)
{
g_limitSql
=
stoi
(
pNum
);
}
void
setLogLevel
(
const
char
*
pLogLevel
)
{
g_logLevel
=
stoi
(
pLogLevel
);
}
void
setQueryPolicy
(
const
char
*
pQueryPolicy
)
{
g_queryPolicy
=
stoi
(
pQueryPolicy
);
}
int32_t
getLogLevel
()
{
return
g_logLevel
;
}
...
...
@@ -105,7 +108,23 @@ class PlannerTestBaseImpl {
}
++
sqlNum_
;
switch
(
g_queryPolicy
)
{
case
QUERY_POLICY_VNODE
:
case
QUERY_POLICY_HYBRID
:
case
QUERY_POLICY_QNODE
:
runImpl
(
sql
,
g_queryPolicy
);
break
;
default:
runImpl
(
sql
,
QUERY_POLICY_VNODE
);
runImpl
(
sql
,
QUERY_POLICY_HYBRID
);
runImpl
(
sql
,
QUERY_POLICY_QNODE
);
break
;
}
}
void
runImpl
(
const
string
&
sql
,
int32_t
queryPolicy
)
{
reset
();
tsQueryPolicy
=
queryPolicy
;
try
{
SQuery
*
pQuery
=
nullptr
;
doParseSql
(
sql
,
&
pQuery
);
...
...
source/libs/planner/test/planTestUtil.h
浏览文件 @
aace9c4c
...
...
@@ -45,6 +45,7 @@ extern void setDumpModule(const char* pModule);
extern
void
setSkipSqlNum
(
const
char
*
pNum
);
extern
void
setLimitSqlNum
(
const
char
*
pNum
);
extern
void
setLogLevel
(
const
char
*
pLogLevel
);
extern
void
setQueryPolicy
(
const
char
*
pQueryPolicy
);
extern
int32_t
getLogLevel
();
#endif // PLAN_TEST_UTIL_H
tests/script/tsim/stable/tag_modify.sim
浏览文件 @
aace9c4c
...
...
@@ -14,7 +14,7 @@ sql_error alter table db.stb MODIFY tag ts int
sql_error alter table db.stb MODIFY tag t2 binary(3)
sql_error alter table db.stb MODIFY tag t2 int
sql_error alter table db.stb MODIFY tag t1 int
sql create table db.ctb using db.stb tags(101, "123
45
")
sql create table db.ctb using db.stb tags(101, "123")
sql insert into db.ctb values(now, 1, "1234")
sql select * from db.stb
...
...
@@ -32,7 +32,7 @@ endi
if $data[0][3] != 101 then
return -1
endi
if $data[0][4] != 123
4
then
if $data[0][4] != 123 then
return -1
endi
...
...
tests/script/tsim/stable/tag_rename.sim
浏览文件 @
aace9c4c
...
...
@@ -14,7 +14,7 @@ sql_error alter table db.stb rename tag ts c3
sql_error alter table db.stb rename tag t2 t1
sql_error alter table db.stb rename tag t2 t2
sql_error alter table db.stb rename tag t1 t2
sql create table db.ctb using db.stb tags(101, "123
45
")
sql create table db.ctb using db.stb tags(101, "123")
sql insert into db.ctb values(now, 1, "1234")
sql select * from db.stb
...
...
@@ -32,7 +32,7 @@ endi
if $data[0][3] != 101 then
return -1
endi
if $data[0][4] != 123
4
then
if $data[0][4] != 123 then
return -1
endi
...
...
@@ -56,7 +56,7 @@ endi
if $data[0][3] != 101 then
return -1
endi
if $data[0][4] != 123
4
then
if $data[0][4] != 123 then
return -1
endi
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录