Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
377bed85
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
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看板
提交
377bed85
编写于
6月 25, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' into feature/3_liaohj
上级
54283f87
8171e326
变更
56
显示空白变更内容
内联
并排
Showing
56 changed file
with
962 addition
and
841 deletion
+962
-841
examples/c/stream_demo.c
examples/c/stream_demo.c
+2
-2
include/common/tcommon.h
include/common/tcommon.h
+2
-0
include/common/tmsg.h
include/common/tmsg.h
+5
-6
include/libs/executor/executor.h
include/libs/executor/executor.h
+1
-1
include/os/os.h
include/os/os.h
+1
-0
include/os/osMath.h
include/os/osMath.h
+1
-2
source/common/src/tglobal.c
source/common/src/tglobal.c
+4
-0
source/dnode/mgmt/node_util/src/dmFile.c
source/dnode/mgmt/node_util/src/dmFile.c
+2
-2
source/dnode/mnode/impl/inc/mndPrivilege.h
source/dnode/mnode/impl/inc/mndPrivilege.h
+18
-10
source/dnode/mnode/impl/src/mndAcct.c
source/dnode/mnode/impl/src/mndAcct.c
+13
-0
source/dnode/mnode/impl/src/mndBnode.c
source/dnode/mnode/impl/src/mndBnode.c
+7
-9
source/dnode/mnode/impl/src/mndConsumer.c
source/dnode/mnode/impl/src/mndConsumer.c
+1
-1
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+8
-9
source/dnode/mnode/impl/src/mndDnode.c
source/dnode/mnode/impl/src/mndDnode.c
+11
-10
source/dnode/mnode/impl/src/mndFunc.c
source/dnode/mnode/impl/src/mndFunc.c
+7
-9
source/dnode/mnode/impl/src/mndMain.c
source/dnode/mnode/impl/src/mndMain.c
+26
-17
source/dnode/mnode/impl/src/mndMnode.c
source/dnode/mnode/impl/src/mndMnode.c
+8
-10
source/dnode/mnode/impl/src/mndOffset.c
source/dnode/mnode/impl/src/mndOffset.c
+10
-8
source/dnode/mnode/impl/src/mndPrivilege.c
source/dnode/mnode/impl/src/mndPrivilege.c
+22
-61
source/dnode/mnode/impl/src/mndProfile.c
source/dnode/mnode/impl/src/mndProfile.c
+33
-38
source/dnode/mnode/impl/src/mndQnode.c
source/dnode/mnode/impl/src/mndQnode.c
+14
-17
source/dnode/mnode/impl/src/mndShow.c
source/dnode/mnode/impl/src/mndShow.c
+2
-2
source/dnode/mnode/impl/src/mndSma.c
source/dnode/mnode/impl/src/mndSma.c
+3
-3
source/dnode/mnode/impl/src/mndSnode.c
source/dnode/mnode/impl/src/mndSnode.c
+7
-9
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+4
-4
source/dnode/mnode/impl/src/mndStream.c
source/dnode/mnode/impl/src/mndStream.c
+4
-4
source/dnode/mnode/impl/src/mndTopic.c
source/dnode/mnode/impl/src/mndTopic.c
+2
-2
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+2
-3
source/dnode/mnode/impl/src/mndUser.c
source/dnode/mnode/impl/src/mndUser.c
+9
-11
source/dnode/mnode/impl/src/mndVgroup.c
source/dnode/mnode/impl/src/mndVgroup.c
+10
-7
source/dnode/mnode/impl/test/user/user.cpp
source/dnode/mnode/impl/test/user/user.cpp
+22
-4
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+2
-2
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+1
-1
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+4
-2
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+2
-2
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+20
-21
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+8
-4
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+8
-2
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+142
-101
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+111
-112
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+16
-3
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+1
-0
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+2
-1
source/libs/stream/src/streamData.c
source/libs/stream/src/streamData.c
+12
-3
source/libs/stream/src/streamDispatch.c
source/libs/stream/src/streamDispatch.c
+4
-0
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+5
-7
tests/script/tsim/mnode/basic5.sim
tests/script/tsim/mnode/basic5.sim
+1
-1
tests/script/tsim/user/basic.sim
tests/script/tsim/user/basic.sim
+157
-0
tests/script/tsim/user/basic1.sim
tests/script/tsim/user/basic1.sim
+0
-74
tests/script/tsim/user/pass_len.sim
tests/script/tsim/user/pass_len.sim
+0
-79
tests/script/tsim/user/password.sim
tests/script/tsim/user/password.sim
+87
-0
tests/script/tsim/user/privilege2.sim
tests/script/tsim/user/privilege2.sim
+0
-38
tests/script/tsim/user/privilege_db.sim
tests/script/tsim/user/privilege_db.sim
+23
-1
tests/script/tsim/user/privilege_sysinfo.sim
tests/script/tsim/user/privilege_sysinfo.sim
+47
-0
tests/script/tsim/user/user_len.sim
tests/script/tsim/user/user_len.sim
+0
-85
tests/system-test/2-query/json_tag.py
tests/system-test/2-query/json_tag.py
+48
-41
未找到文件。
examples/c/stream_demo.c
浏览文件 @
377bed85
...
...
@@ -99,8 +99,8 @@ int32_t create_stream() {
/*const char* sql = "select sum(k) from tu1 interval(10m)";*/
/*pRes = tmq_create_stream(pConn, "stream1", "out1", sql);*/
pRes
=
taos_query
(
pConn
,
"create stream stream1 trigger at_once into outstb as select _wstartts, sum(k) from st1 "
"
partition
by tbname interval(10s) "
);
"create stream stream1 trigger at_once into outstb as select _wstartts, sum(k) from st1
partition
"
"by tbname interval(10s) "
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create stream stream1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
...
...
include/common/tcommon.h
浏览文件 @
377bed85
...
...
@@ -50,8 +50,10 @@ typedef enum EStreamType {
}
EStreamType
;
typedef
struct
{
SArray
*
pGroupList
;
SArray
*
pTableList
;
SHashObj
*
map
;
// speedup acquire the tableQueryInfo by table uid
bool
needSortTableByGroupId
;
void
*
pTagCond
;
void
*
pTagIndexCond
;
uint64_t
suid
;
...
...
include/common/tmsg.h
浏览文件 @
377bed85
...
...
@@ -851,7 +851,6 @@ typedef struct {
int32_t
tSerializeSServerVerRsp
(
void
*
buf
,
int32_t
bufLen
,
SServerVerRsp
*
pRsp
);
int32_t
tDeserializeSServerVerRsp
(
void
*
buf
,
int32_t
bufLen
,
SServerVerRsp
*
pRsp
);
typedef
struct
SQueryNodeAddr
{
int32_t
nodeId
;
// vgId or qnodeId
SEpSet
epSet
;
...
...
@@ -878,7 +877,6 @@ int32_t tSerializeSDnodeListRsp(void* buf, int32_t bufLen, SDnodeListRsp* pRsp);
int32_t
tDeserializeSDnodeListRsp
(
void
*
buf
,
int32_t
bufLen
,
SDnodeListRsp
*
pRsp
);
void
tFreeSDnodeListRsp
(
SDnodeListRsp
*
pRsp
);
typedef
struct
{
SArray
*
pArray
;
// Array of SUseDbRsp
}
SUseDbBatchRsp
;
...
...
@@ -1250,7 +1248,7 @@ typedef struct {
}
SVariablesInfo
;
typedef
struct
{
SArray
*
variables
;
//
SArray<SVariablesInfo>
SArray
*
variables
;
//
SArray<SVariablesInfo>
}
SShowVariablesRsp
;
int32_t
tSerializeSShowVariablesRsp
(
void
*
buf
,
int32_t
bufLen
,
SShowVariablesRsp
*
pReq
);
...
...
@@ -1258,7 +1256,6 @@ int32_t tDeserializeSShowVariablesRsp(void* buf, int32_t bufLen, SShowVariablesR
void
tFreeSShowVariablesRsp
(
SShowVariablesRsp
*
pRsp
);
/*
* sql: show tables like '%a_%'
* payload is the query condition, e.g., '%a_%'
...
...
@@ -1308,6 +1305,8 @@ typedef struct {
int32_t
compLen
;
int32_t
numOfRows
;
int32_t
numOfCols
;
int64_t
skey
;
int64_t
ekey
;
char
data
[];
}
SRetrieveTableRsp
;
...
...
include/libs/executor/executor.h
浏览文件 @
377bed85
...
...
@@ -36,7 +36,7 @@ typedef struct SReadHandle {
void
*
vnode
;
void
*
mnd
;
SMsgCb
*
pMsgCb
;
int8_t
initTsdbReader
;
//
int8_t initTsdbReader;
}
SReadHandle
;
enum
{
...
...
include/os/os.h
浏览文件 @
377bed85
...
...
@@ -52,6 +52,7 @@ extern "C" {
#endif
#else
#include <malloc.h>
#include <time.h>
#ifndef TD_USE_WINSOCK
#include <winsock2.h>
...
...
include/os/osMath.h
浏览文件 @
377bed85
...
...
@@ -25,11 +25,10 @@ extern "C" {
#define TSWAP(a, b) \
do { \
char *__tmp =
taosMemoryMalloc(sizeof(a));
\
char *__tmp =
alloca(sizeof(a));
\
memcpy(__tmp, &(a), sizeof(a)); \
memcpy(&(a), &(b), sizeof(a)); \
memcpy(&(b), __tmp, sizeof(a)); \
taosMemoryFree(__tmp); \
} while (0)
#ifdef WINDOWS
...
...
source/common/src/tglobal.c
浏览文件 @
377bed85
...
...
@@ -963,6 +963,10 @@ int32_t taosSetCfg(SConfig *pCfg, char* name) {
tsTelemPort
=
(
uint16_t
)
cfgGetItem
(
pCfg
,
"telemetryPort"
)
->
i32
;
}
else
if
(
strcasecmp
(
"transPullupInterval"
,
name
)
==
0
)
{
tsTransPullupInterval
=
cfgGetItem
(
pCfg
,
"transPullupInterval"
)
->
i32
;
}
else
if
(
strcasecmp
(
"ttlUnit"
,
name
)
==
0
)
{
tsTtlUnit
=
cfgGetItem
(
pCfg
,
"ttlUnit"
)
->
i32
;
}
else
if
(
strcasecmp
(
"ttlPushInterval"
,
name
)
==
0
)
{
tsTtlPushInterval
=
cfgGetItem
(
pCfg
,
"ttlPushInterval"
)
->
i32
;
}
else
if
(
strcasecmp
(
"tmrDebugFlag"
,
name
)
==
0
)
{
tmrDebugFlag
=
cfgGetItem
(
pCfg
,
"tmrDebugFlag"
)
->
i32
;
}
else
if
(
strcasecmp
(
"tsdbDebugFlag"
,
name
)
==
0
)
{
...
...
source/dnode/mgmt/node_util/src/dmFile.c
浏览文件 @
377bed85
...
...
@@ -133,10 +133,10 @@ TdFilePtr dmCheckRunning(const char *dataDir) {
ret
=
taosLockFile
(
pFile
);
if
(
ret
==
0
)
break
;
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
taosMsleep
(
100
);
taosMsleep
(
100
0
);
retryTimes
++
;
dError
(
"failed to lock file:%s since %s, retryTimes:%d"
,
filepath
,
terrstr
(),
retryTimes
);
}
while
(
retryTimes
<
12
0
);
}
while
(
retryTimes
<
12
);
if
(
ret
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
...
...
source/dnode/mnode/impl/inc/mnd
Auth
.h
→
source/dnode/mnode/impl/inc/mnd
Privilege
.h
浏览文件 @
377bed85
...
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_MND_
AUTH_H_
#define _TD_MND_
AUTH_H_
#ifndef _TD_MND_
PRIVILEGE_H
#define _TD_MND_
PRIVILEGE_H
#include "mndInt.h"
...
...
@@ -23,13 +23,18 @@ extern "C" {
#endif
typedef
enum
{
MND_OPER_CREATE_USER
=
1
,
MND_OPER_CONNECT
=
1
,
MND_OPER_CREATE_ACCT
,
MND_OPER_DROP_ACCT
,
MND_OPER_ALTER_ACCT
,
MND_OPER_CREATE_USER
,
MND_OPER_DROP_USER
,
MND_OPER_ALTER_USER
,
MND_OPER_CREATE_BNODE
,
MND_OPER_DROP_BNODE
,
MND_OPER_CREATE_DNODE
,
MND_OPER_DROP_DNODE
,
MND_OPER_CONFIG_DNODE
,
MND_OPER_CREATE_MNODE
,
MND_OPER_DROP_MNODE
,
MND_OPER_CREATE_QNODE
,
...
...
@@ -37,11 +42,14 @@ typedef enum {
MND_OPER_CREATE_SNODE
,
MND_OPER_DROP_SNODE
,
MND_OPER_REDISTRIBUTE_VGROUP
,
MND_OPER_MERGE_VGROUP
,
MND_OPER_SPLIT_VGROUP
,
MND_OPER_BALANCE_VGROUP
,
MND_OPER_CREATE_FUNC
,
MND_OPER_DROP_FUNC
,
MND_OPER_KILL_TRANS
,
MND_OPER_KILL_CONN
,
MND_OPER_KILL_QUERY
,
MND_OPER_CREATE_DB
,
MND_OPER_ALTER_DB
,
MND_OPER_DROP_DB
,
...
...
@@ -51,16 +59,16 @@ typedef enum {
MND_OPER_READ_DB
,
}
EOperType
;
int32_t
mndInit
Auth
(
SMnode
*
pMnode
);
void
mndCleanup
Auth
(
SMnode
*
pMnode
);
int32_t
mndInit
Privilege
(
SMnode
*
pMnode
);
void
mndCleanup
Privilege
(
SMnode
*
pMnode
);
int32_t
mndCheckOper
Auth
(
SMnode
*
pMnode
,
const
char
*
user
,
EOperType
operType
);
int32_t
mndCheckDb
Auth
(
SMnode
*
pMnode
,
const
char
*
user
,
EOperType
operType
,
SDbObj
*
pDb
);
int32_t
mndCheckShow
Auth
(
SMnode
*
pMnode
,
const
char
*
user
,
int32_t
showType
);
int32_t
mndCheckAlterUser
Auth
(
SUserObj
*
pOperUser
,
SUserObj
*
pUser
,
SAlterUserReq
*
pAlter
);
int32_t
mndCheckOper
Privilege
(
SMnode
*
pMnode
,
const
char
*
user
,
EOperType
operType
);
int32_t
mndCheckDb
Privilege
(
SMnode
*
pMnode
,
const
char
*
user
,
EOperType
operType
,
SDbObj
*
pDb
);
int32_t
mndCheckShow
Privilege
(
SMnode
*
pMnode
,
const
char
*
user
,
int32_t
showType
);
int32_t
mndCheckAlterUser
Privilege
(
SUserObj
*
pOperUser
,
SUserObj
*
pUser
,
SAlterUserReq
*
pAlter
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_MND_
AUTH_H_
*/
#endif
/*_TD_MND_
PRIVILEGE_H
*/
source/dnode/mnode/impl/src/mndAcct.c
浏览文件 @
377bed85
...
...
@@ -15,6 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndAcct.h"
#include "mndPrivilege.h"
#include "mndShow.h"
#include "mndTrans.h"
...
...
@@ -212,18 +213,30 @@ static int32_t mndAcctActionUpdate(SSdb *pSdb, SAcctObj *pOld, SAcctObj *pNew) {
}
static
int32_t
mndProcessCreateAcctReq
(
SRpcMsg
*
pReq
)
{
if
(
mndCheckOperPrivilege
(
pReq
->
info
.
node
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_ACCT
)
!=
0
)
{
return
-
1
;
}
terrno
=
TSDB_CODE_MSG_NOT_PROCESSED
;
mError
(
"failed to process create acct request since %s"
,
terrstr
());
return
-
1
;
}
static
int32_t
mndProcessAlterAcctReq
(
SRpcMsg
*
pReq
)
{
if
(
mndCheckOperPrivilege
(
pReq
->
info
.
node
,
pReq
->
info
.
conn
.
user
,
MND_OPER_ALTER_ACCT
)
!=
0
)
{
return
-
1
;
}
terrno
=
TSDB_CODE_MSG_NOT_PROCESSED
;
mError
(
"failed to process create acct request since %s"
,
terrstr
());
return
-
1
;
}
static
int32_t
mndProcessDropAcctReq
(
SRpcMsg
*
pReq
)
{
if
(
mndCheckOperPrivilege
(
pReq
->
info
.
node
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_ACCT
)
!=
0
)
{
return
-
1
;
}
terrno
=
TSDB_CODE_MSG_NOT_PROCESSED
;
mError
(
"failed to process create acct request since %s"
,
terrstr
());
return
-
1
;
...
...
source/dnode/mnode/impl/src/mndBnode.c
浏览文件 @
377bed85
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndBnode.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndDnode.h"
#include "mndShow.h"
#include "mndTrans.h"
...
...
@@ -277,6 +277,9 @@ static int32_t mndProcessCreateBnodeReq(SRpcMsg *pReq) {
}
mDebug
(
"bnode:%d, start to create"
,
createReq
.
dnodeId
);
if
(
mndCheckOperPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_BNODE
)
!=
0
)
{
goto
_OVER
;
}
pObj
=
mndAcquireBnode
(
pMnode
,
createReq
.
dnodeId
);
if
(
pObj
!=
NULL
)
{
...
...
@@ -292,10 +295,6 @@ static int32_t mndProcessCreateBnodeReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_BNODE
)
!=
0
)
{
goto
_OVER
;
}
code
=
mndCreateBnode
(
pMnode
,
pReq
,
pDnode
,
&
createReq
);
if
(
code
==
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
...
...
@@ -383,6 +382,9 @@ static int32_t mndProcessDropBnodeReq(SRpcMsg *pReq) {
}
mDebug
(
"bnode:%d, start to drop"
,
dropReq
.
dnodeId
);
if
(
mndCheckOperPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_BNODE
)
!=
0
)
{
goto
_OVER
;
}
if
(
dropReq
.
dnodeId
<=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
...
...
@@ -394,10 +396,6 @@ static int32_t mndProcessDropBnodeReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_BNODE
)
!=
0
)
{
goto
_OVER
;
}
code
=
mndDropBnode
(
pMnode
,
pReq
,
pObj
);
if
(
code
==
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
...
...
source/dnode/mnode/impl/src/mndConsumer.c
浏览文件 @
377bed85
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndConsumer.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndDb.h"
#include "mndDnode.h"
#include "mndMnode.h"
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
377bed85
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndDb.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndDnode.h"
#include "mndOffset.h"
#include "mndShow.h"
...
...
@@ -506,6 +506,9 @@ static int32_t mndProcessCreateDbReq(SRpcMsg *pReq) {
}
mDebug
(
"db:%s, start to create, vgroups:%d"
,
createReq
.
db
,
createReq
.
numOfVgroups
);
if
(
mndCheckDbPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_DB
,
NULL
)
!=
0
)
{
goto
_OVER
;
}
pDb
=
mndAcquireDb
(
pMnode
,
createReq
.
db
);
if
(
pDb
!=
NULL
)
{
...
...
@@ -526,10 +529,6 @@ static int32_t mndProcessCreateDbReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckDbAuth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_DB
,
NULL
)
!=
0
)
{
goto
_OVER
;
}
code
=
mndCreateDb
(
pMnode
,
pReq
,
&
createReq
,
pUser
);
if
(
code
==
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
...
...
@@ -700,7 +699,7 @@ static int32_t mndProcessAlterDbReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckDb
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_ALTER_DB
,
pDb
)
!=
0
)
{
if
(
mndCheckDb
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_ALTER_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -980,7 +979,7 @@ static int32_t mndProcessDropDbReq(SRpcMsg *pReq) {
}
}
if
(
mndCheckDb
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_DB
,
pDb
)
!=
0
)
{
if
(
mndCheckDb
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -1127,7 +1126,7 @@ static int32_t mndProcessUseDbReq(SRpcMsg *pReq) {
mError
(
"db:%s, failed to process use db req since %s"
,
usedbReq
.
db
,
terrstr
());
}
else
{
if
(
mndCheckDb
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_USE_DB
,
pDb
)
!=
0
)
{
if
(
mndCheckDb
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_USE_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -1252,7 +1251,7 @@ static int32_t mndProcessCompactDbReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckDb
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_COMPACT_DB
,
pDb
)
!=
0
)
{
if
(
mndCheckDb
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_COMPACT_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
...
...
source/dnode/mnode/impl/src/mndDnode.c
浏览文件 @
377bed85
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndDnode.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndMnode.h"
#include "mndQnode.h"
#include "mndShow.h"
...
...
@@ -609,7 +609,6 @@ _OVER:
return
code
;
}
static
int32_t
mndProcessCreateDnodeReq
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
int32_t
code
=
-
1
;
...
...
@@ -622,6 +621,9 @@ static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq) {
}
mInfo
(
"dnode:%s:%d, start to create"
,
createReq
.
fqdn
,
createReq
.
port
);
if
(
mndCheckOperPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_DNODE
)
!=
0
)
{
goto
_OVER
;
}
if
(
createReq
.
fqdn
[
0
]
==
0
||
createReq
.
port
<=
0
||
createReq
.
port
>
UINT16_MAX
)
{
terrno
=
TSDB_CODE_MND_INVALID_DNODE_EP
;
...
...
@@ -635,10 +637,6 @@ static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_DNODE
)
!=
0
)
{
goto
_OVER
;
}
code
=
mndCreateDnode
(
pMnode
,
pReq
,
&
createReq
);
if
(
code
==
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
...
...
@@ -717,6 +715,9 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) {
}
mInfo
(
"dnode:%d, start to drop, ep:%s:%d"
,
dropReq
.
dnodeId
,
dropReq
.
fqdn
,
dropReq
.
port
);
if
(
mndCheckOperPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_MNODE
)
!=
0
)
{
goto
_OVER
;
}
pDnode
=
mndAcquireDnode
(
pMnode
,
dropReq
.
dnodeId
);
if
(
pDnode
==
NULL
)
{
...
...
@@ -753,10 +754,6 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) {
}
}
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_MNODE
)
!=
0
)
{
goto
_OVER
;
}
code
=
mndDropDnode
(
pMnode
,
pReq
,
pDnode
,
pMObj
,
pQObj
,
pSObj
,
numOfVnodes
);
if
(
code
==
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
...
...
@@ -782,6 +779,10 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
}
mInfo
(
"dnode:%d, start to config, option:%s, value:%s"
,
cfgReq
.
dnodeId
,
cfgReq
.
config
,
cfgReq
.
value
);
if
(
mndCheckOperPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CONFIG_DNODE
)
!=
0
)
{
return
-
1
;
}
SDnodeObj
*
pDnode
=
mndAcquireDnode
(
pMnode
,
cfgReq
.
dnodeId
);
if
(
pDnode
==
NULL
)
{
mError
(
"dnode:%d, failed to config since %s "
,
cfgReq
.
dnodeId
,
terrstr
());
...
...
source/dnode/mnode/impl/src/mndFunc.c
浏览文件 @
377bed85
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndFunc.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndShow.h"
#include "mndSync.h"
#include "mndTrans.h"
...
...
@@ -283,6 +283,9 @@ static int32_t mndProcessCreateFuncReq(SRpcMsg *pReq) {
}
mDebug
(
"func:%s, start to create"
,
createReq
.
name
);
if
(
mndCheckOperPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_FUNC
)
!=
0
)
{
goto
_OVER
;
}
pFunc
=
mndAcquireFunc
(
pMnode
,
createReq
.
name
);
if
(
pFunc
!=
NULL
)
{
...
...
@@ -318,10 +321,6 @@ static int32_t mndProcessCreateFuncReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_FUNC
)
!=
0
)
{
goto
_OVER
;
}
code
=
mndCreateFunc
(
pMnode
,
pReq
,
&
createReq
);
if
(
code
==
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
...
...
@@ -347,6 +346,9 @@ static int32_t mndProcessDropFuncReq(SRpcMsg *pReq) {
}
mDebug
(
"func:%s, start to drop"
,
dropReq
.
name
);
if
(
mndCheckOperPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_FUNC
)
!=
0
)
{
goto
_OVER
;
}
if
(
dropReq
.
name
[
0
]
==
0
)
{
terrno
=
TSDB_CODE_MND_INVALID_FUNC_NAME
;
...
...
@@ -365,10 +367,6 @@ static int32_t mndProcessDropFuncReq(SRpcMsg *pReq) {
}
}
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_FUNC
)
!=
0
)
{
goto
_OVER
;
}
code
=
mndDropFunc
(
pMnode
,
pReq
,
pFunc
);
if
(
code
==
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
...
...
source/dnode/mnode/impl/src/mndMain.c
浏览文件 @
377bed85
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndAcct.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndBnode.h"
#include "mndCluster.h"
#include "mndConsumer.h"
...
...
@@ -100,7 +100,7 @@ static void *mndThreadFp(void *param) {
taosMsleep
(
100
);
if
(
mndGetStop
(
pMnode
))
break
;
if
(
lastTime
%
(
tsT
ransPullup
Interval
*
10
)
==
1
)
{
if
(
lastTime
%
(
tsT
tlPush
Interval
*
10
)
==
1
)
{
mndTtlTimer
(
pMnode
);
}
...
...
@@ -239,7 +239,7 @@ static int32_t mndInitSteps(SMnode *pMnode) {
if
(
mndAllocStep
(
pMnode
,
"mnode-dnode"
,
mndInitDnode
,
mndCleanupDnode
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-user"
,
mndInitUser
,
mndCleanupUser
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-grant"
,
mndInitGrant
,
mndCleanupGrant
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-
auth"
,
mndInitAuth
,
mndCleanupAuth
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-
privilege"
,
mndInitPrivilege
,
mndCleanupPrivilege
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-acct"
,
mndInitAcct
,
mndCleanupAcct
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-stream"
,
mndInitStream
,
mndCleanupStream
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-topic"
,
mndInitTopic
,
mndCleanupTopic
)
!=
0
)
return
-
1
;
...
...
@@ -529,16 +529,22 @@ static int32_t mndCheckMnodeState(SRpcMsg *pMsg) {
if
(
!
IsReq
(
pMsg
))
return
0
;
if
(
mndAcquireRpcRef
(
pMsg
->
info
.
node
)
==
0
)
return
0
;
if
(
pMsg
->
msgType
==
TDMT_MND_MQ_TIMER
||
pMsg
->
msgType
==
TDMT_MND_TELEM_TIMER
||
pMsg
->
msgType
==
TDMT_MND_TRANS_TIMER
||
TDMT_MND_TTL_TIMER
)
{
pMsg
->
msgType
==
TDMT_MND_TRANS_TIMER
||
pMsg
->
msgType
==
TDMT_MND_TTL_TIMER
)
{
return
-
1
;
}
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
mError
(
"msg:%p, failed to check mnode state since %s, type:%s"
,
pMsg
,
terrstr
(),
TMSG_INFO
(
pMsg
->
msgType
));
SEpSet
epSet
=
{
0
};
mndGetMnodeEpSet
(
pMsg
->
info
.
node
,
&
epSet
);
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
mError
(
"msg:%p, failed to check mnode state since %s, type:%s, numOfMnodes:%d inUse:%d"
,
pMsg
,
terrstr
(),
TMSG_INFO
(
pMsg
->
msgType
),
epSet
.
numOfEps
,
epSet
.
inUse
);
if
(
epSet
.
numOfEps
>
0
)
{
for
(
int32_t
i
=
0
;
i
<
epSet
.
numOfEps
;
++
i
)
{
mInfo
(
"mnode index:%d, ep:%s:%u"
,
i
,
epSet
.
eps
[
i
].
fqdn
,
epSet
.
eps
[
i
].
port
);
}
int32_t
contLen
=
tSerializeSEpSet
(
NULL
,
0
,
&
epSet
);
pMsg
->
info
.
rsp
=
rpcMallocCont
(
contLen
);
if
(
pMsg
->
info
.
rsp
!=
NULL
)
{
...
...
@@ -548,6 +554,9 @@ static int32_t mndCheckMnodeState(SRpcMsg *pMsg) {
}
else
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
}
}
else
{
terrno
=
TSDB_CODE_APP_NOT_READY
;
}
return
-
1
;
}
...
...
source/dnode/mnode/impl/src/mndMnode.c
浏览文件 @
377bed85
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndMnode.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndDnode.h"
#include "mndShow.h"
#include "mndSync.h"
...
...
@@ -389,6 +389,9 @@ static int32_t mndProcessCreateMnodeReq(SRpcMsg *pReq) {
}
mDebug
(
"mnode:%d, start to create"
,
createReq
.
dnodeId
);
if
(
mndCheckOperPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_MNODE
)
!=
0
)
{
goto
_OVER
;
}
pObj
=
mndAcquireMnode
(
pMnode
,
createReq
.
dnodeId
);
if
(
pObj
!=
NULL
)
{
...
...
@@ -414,10 +417,6 @@ static int32_t mndProcessCreateMnodeReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_MNODE
)
!=
0
)
{
goto
_OVER
;
}
code
=
mndCreateMnode
(
pMnode
,
pReq
,
pDnode
,
&
createReq
);
if
(
code
==
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
...
...
@@ -495,7 +494,7 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode
{
int32_t
contLen
=
tSerializeSSetStandbyReq
(
NULL
,
0
,
&
standbyReq
)
+
sizeof
(
SMsgHead
);
void
*
pReq
=
taosMemoryMalloc
(
contLen
);
tSerializeSSetStandbyReq
((
char
*
)
pReq
+
sizeof
(
SMsgHead
),
contLen
,
&
standbyReq
);
tSerializeSSetStandbyReq
((
char
*
)
pReq
+
sizeof
(
SMsgHead
),
contLen
,
&
standbyReq
);
SMsgHead
*
pHead
=
pReq
;
pHead
->
contLen
=
htonl
(
contLen
);
pHead
->
vgId
=
htonl
(
MNODE_HANDLE
);
...
...
@@ -595,6 +594,9 @@ static int32_t mndProcessDropMnodeReq(SRpcMsg *pReq) {
}
mDebug
(
"mnode:%d, start to drop"
,
dropReq
.
dnodeId
);
if
(
mndCheckOperPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_MNODE
)
!=
0
)
{
goto
_OVER
;
}
if
(
dropReq
.
dnodeId
<=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
...
...
@@ -621,10 +623,6 @@ static int32_t mndProcessDropMnodeReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_MNODE
)
!=
0
)
{
goto
_OVER
;
}
code
=
mndDropMnode
(
pMnode
,
pReq
,
pObj
);
if
(
code
==
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
...
...
source/dnode/mnode/impl/src/mndOffset.c
浏览文件 @
377bed85
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndOffset.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndDb.h"
#include "mndDnode.h"
#include "mndMnode.h"
...
...
@@ -36,13 +36,15 @@ static int32_t mndOffsetActionUpdate(SSdb *pSdb, SMqOffsetObj *pOffset, SMqOffse
static
int32_t
mndProcessCommitOffsetReq
(
SRpcMsg
*
pReq
);
int32_t
mndInitOffset
(
SMnode
*
pMnode
)
{
SSdbTable
table
=
{.
sdbType
=
SDB_OFFSET
,
SSdbTable
table
=
{
.
sdbType
=
SDB_OFFSET
,
.
keyType
=
SDB_KEY_BINARY
,
.
encodeFp
=
(
SdbEncodeFp
)
mndOffsetActionEncode
,
.
decodeFp
=
(
SdbDecodeFp
)
mndOffsetActionDecode
,
.
insertFp
=
(
SdbInsertFp
)
mndOffsetActionInsert
,
.
updateFp
=
(
SdbUpdateFp
)
mndOffsetActionUpdate
,
.
deleteFp
=
(
SdbDeleteFp
)
mndOffsetActionDelete
};
.
deleteFp
=
(
SdbDeleteFp
)
mndOffsetActionDelete
,
};
mndSetMsgHandle
(
pMnode
,
TDMT_MND_MQ_COMMIT_OFFSET
,
mndProcessCommitOffsetReq
);
...
...
source/dnode/mnode/impl/src/mnd
Auth
.c
→
source/dnode/mnode/impl/src/mnd
Privilege
.c
浏览文件 @
377bed85
...
...
@@ -14,66 +14,14 @@
*/
#define _DEFAULT_SOURCE
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndUser.h"
static
int32_t
mndProcessAuthReq
(
SRpcMsg
*
pReq
);
int32_t
mndInitPrivilege
(
SMnode
*
pMnode
)
{
return
0
;
}
int32_t
mndInitAuth
(
SMnode
*
pMnode
)
{
mndSetMsgHandle
(
pMnode
,
TDMT_MND_AUTH
,
mndProcessAuthReq
);
return
0
;
}
void
mndCleanupAuth
(
SMnode
*
pMnode
)
{}
static
int32_t
mndRetriveAuth
(
SMnode
*
pMnode
,
SAuthRsp
*
pRsp
)
{
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
pRsp
->
user
);
if
(
pUser
==
NULL
)
{
*
pRsp
->
secret
=
0
;
mError
(
"user:%s, failed to auth user since %s"
,
pRsp
->
user
,
terrstr
());
return
-
1
;
}
pRsp
->
spi
=
1
;
pRsp
->
encrypt
=
0
;
*
pRsp
->
ckey
=
0
;
memcpy
(
pRsp
->
secret
,
pUser
->
pass
,
TSDB_PASSWORD_LEN
);
mndReleaseUser
(
pMnode
,
pUser
);
mDebug
(
"user:%s, auth info is returned"
,
pRsp
->
user
);
return
0
;
}
static
int32_t
mndProcessAuthReq
(
SRpcMsg
*
pReq
)
{
SAuthReq
authReq
=
{
0
};
if
(
tDeserializeSAuthReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
authReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
return
-
1
;
}
SAuthReq
authRsp
=
{
0
};
memcpy
(
authRsp
.
user
,
authReq
.
user
,
TSDB_USER_LEN
);
void
mndCleanupPrivilege
(
SMnode
*
pMnode
)
{}
int32_t
code
=
mndRetriveAuth
(
pReq
->
info
.
node
,
&
authRsp
);
mTrace
(
"user:%s, auth req received, spi:%d encrypt:%d ruser:%s"
,
pReq
->
info
.
conn
.
user
,
authRsp
.
spi
,
authRsp
.
encrypt
,
authRsp
.
user
);
int32_t
contLen
=
tSerializeSAuthReq
(
NULL
,
0
,
&
authRsp
);
void
*
pRsp
=
rpcMallocCont
(
contLen
);
if
(
pRsp
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
tSerializeSAuthReq
(
pRsp
,
contLen
,
&
authRsp
);
pReq
->
info
.
rsp
=
pRsp
;
pReq
->
info
.
rspLen
=
contLen
;
return
code
;
}
int32_t
mndCheckOperAuth
(
SMnode
*
pMnode
,
const
char
*
user
,
EOperType
operType
)
{
int32_t
mndCheckOperPrivilege
(
SMnode
*
pMnode
,
const
char
*
user
,
EOperType
operType
)
{
int32_t
code
=
0
;
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
user
);
...
...
@@ -93,16 +41,29 @@ int32_t mndCheckOperAuth(SMnode *pMnode, const char *user, EOperType operType) {
goto
_OVER
;
}
switch
(
operType
)
{
case
MND_OPER_CONNECT
:
case
MND_OPER_CREATE_FUNC
:
case
MND_OPER_DROP_FUNC
:
break
;
default:
terrno
=
TSDB_CODE_MND_NO_RIGHTS
;
code
=
-
1
;
}
_OVER:
mndReleaseUser
(
pMnode
,
pUser
);
return
code
;
}
int32_t
mndCheckAlterUserAuth
(
SUserObj
*
pOperUser
,
SUserObj
*
pUser
,
SAlterUserReq
*
pAlter
)
{
int32_t
mndCheckAlterUserPrivilege
(
SUserObj
*
pOperUser
,
SUserObj
*
pUser
,
SAlterUserReq
*
pAlter
)
{
if
(
pUser
->
superUser
&&
pAlter
->
alterType
!=
TSDB_ALTER_USER_PASSWD
)
{
terrno
=
TSDB_CODE_MND_NO_RIGHTS
;
return
-
1
;
}
if
(
pOperUser
->
superUser
)
return
0
;
if
(
!
pOperUser
->
enable
)
{
terrno
=
TSDB_CODE_MND_USER_DISABLED
;
return
-
1
;
...
...
@@ -118,7 +79,7 @@ int32_t mndCheckAlterUserAuth(SUserObj *pOperUser, SUserObj *pUser, SAlterUserRe
return
-
1
;
}
int32_t
mndCheckShow
Auth
(
SMnode
*
pMnode
,
const
char
*
user
,
int32_t
showType
)
{
int32_t
mndCheckShow
Privilege
(
SMnode
*
pMnode
,
const
char
*
user
,
int32_t
showType
)
{
int32_t
code
=
0
;
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
user
);
...
...
@@ -151,7 +112,7 @@ _OVER:
return
code
;
}
int32_t
mndCheckDb
Auth
(
SMnode
*
pMnode
,
const
char
*
user
,
EOperType
operType
,
SDbObj
*
pDb
)
{
int32_t
mndCheckDb
Privilege
(
SMnode
*
pMnode
,
const
char
*
user
,
EOperType
operType
,
SDbObj
*
pDb
)
{
int32_t
code
=
0
;
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
user
);
...
...
source/dnode/mnode/impl/src/mndProfile.c
浏览文件 @
377bed85
...
...
@@ -15,6 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndProfile.h"
#include "mndPrivilege.h"
#include "mndDb.h"
#include "mndDnode.h"
#include "mndMnode.h"
...
...
@@ -217,36 +218,41 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) {
SConnObj
*
pConn
=
NULL
;
int32_t
code
=
-
1
;
SConnectReq
connReq
=
{
0
};
char
ip
[
30
]
=
{
0
};
char
ip
[
24
]
=
{
0
};
const
STraceId
*
trace
=
&
pReq
->
info
.
traceId
;
if
(
tDeserializeSConnectReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
connReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
goto
CONN
_OVER
;
goto
_OVER
;
}
taosIp2String
(
pReq
->
info
.
conn
.
clientIp
,
ip
);
if
(
mndCheckOperPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CONNECT
)
!=
0
)
{
mGError
(
"user:%s, failed to login from %s since %s"
,
pReq
->
info
.
conn
.
user
,
ip
,
terrstr
());
goto
_OVER
;
}
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
info
.
conn
.
user
);
if
(
pUser
==
NULL
)
{
mGError
(
"user:%s, failed to login
while acquire user since %s"
,
pReq
->
info
.
conn
.
user
,
terrstr
());
goto
CONN
_OVER
;
mGError
(
"user:%s, failed to login
from %s while acquire user since %s"
,
pReq
->
info
.
conn
.
user
,
ip
,
terrstr
());
goto
_OVER
;
}
if
(
0
!=
strncmp
(
connReq
.
passwd
,
pUser
->
pass
,
TSDB_PASSWORD_LEN
-
1
))
{
mGError
(
"user:%s, failed to auth while acquire user, input:%s"
,
pReq
->
info
.
conn
.
user
,
connReq
.
passwd
);
if
(
strncmp
(
connReq
.
passwd
,
pUser
->
pass
,
TSDB_PASSWORD_LEN
-
1
)
!=
0
)
{
mGError
(
"user:%s, failed to login from %s since invalid pass, input:%s"
,
pReq
->
info
.
conn
.
user
,
ip
,
connReq
.
passwd
);
code
=
TSDB_CODE_RPC_AUTH_FAILURE
;
goto
CONN
_OVER
;
goto
_OVER
;
}
if
(
connReq
.
db
[
0
])
{
char
db
[
TSDB_DB_FNAME_LEN
];
char
db
[
TSDB_DB_FNAME_LEN
]
=
{
0
}
;
snprintf
(
db
,
TSDB_DB_FNAME_LEN
,
"%d%s%s"
,
pUser
->
acctId
,
TS_PATH_DELIMITER
,
connReq
.
db
);
pDb
=
mndAcquireDb
(
pMnode
,
db
);
if
(
pDb
==
NULL
)
{
terrno
=
TSDB_CODE_MND_INVALID_DB
;
mGError
(
"user:%s, failed to login from %s while use db:%s since %s"
,
pReq
->
info
.
conn
.
user
,
ip
,
connReq
.
db
,
terrstr
());
goto
CONN
_OVER
;
goto
_OVER
;
}
}
...
...
@@ -254,7 +260,7 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) {
pReq
->
info
.
conn
.
clientPort
,
connReq
.
pid
,
connReq
.
app
,
connReq
.
startTime
);
if
(
pConn
==
NULL
)
{
mGError
(
"user:%s, failed to login from %s while create connection since %s"
,
pReq
->
info
.
conn
.
user
,
ip
,
terrstr
());
goto
CONN
_OVER
;
goto
_OVER
;
}
SConnectRsp
connectRsp
=
{
0
};
...
...
@@ -271,9 +277,9 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) {
mndGetMnodeEpSet
(
pMnode
,
&
connectRsp
.
epSet
);
int32_t
contLen
=
tSerializeSConnectRsp
(
NULL
,
0
,
&
connectRsp
);
if
(
contLen
<
0
)
goto
CONN
_OVER
;
if
(
contLen
<
0
)
goto
_OVER
;
void
*
pRsp
=
rpcMallocCont
(
contLen
);
if
(
pRsp
==
NULL
)
goto
CONN
_OVER
;
if
(
pRsp
==
NULL
)
goto
_OVER
;
tSerializeSConnectRsp
(
pRsp
,
contLen
,
&
connectRsp
);
pReq
->
info
.
rspLen
=
contLen
;
...
...
@@ -283,7 +289,7 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) {
code
=
0
;
CONN
_OVER:
_OVER:
mndReleaseUser
(
pMnode
,
pUser
);
mndReleaseDb
(
pMnode
,
pDb
);
...
...
@@ -645,15 +651,6 @@ static int32_t mndProcessKillQueryReq(SRpcMsg *pReq) {
SMnode
*
pMnode
=
pReq
->
info
.
node
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
info
.
conn
.
user
);
if
(
pUser
==
NULL
)
return
0
;
if
(
!
pUser
->
superUser
)
{
mndReleaseUser
(
pMnode
,
pUser
);
terrno
=
TSDB_CODE_MND_NO_RIGHTS
;
return
-
1
;
}
mndReleaseUser
(
pMnode
,
pUser
);
SKillQueryReq
killReq
=
{
0
};
if
(
tDeserializeSKillQueryReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
killReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
...
...
@@ -661,6 +658,10 @@ static int32_t mndProcessKillQueryReq(SRpcMsg *pReq) {
}
mInfo
(
"kill query msg is received, queryId:%s"
,
killReq
.
queryStrId
);
if
(
mndCheckOperPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_KILL_QUERY
)
!=
0
)
{
return
-
1
;
}
int32_t
connId
=
0
;
uint64_t
queryId
=
0
;
char
*
p
=
strchr
(
killReq
.
queryStrId
,
':'
);
...
...
@@ -690,21 +691,16 @@ static int32_t mndProcessKillConnReq(SRpcMsg *pReq) {
SMnode
*
pMnode
=
pReq
->
info
.
node
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
info
.
conn
.
user
);
if
(
pUser
==
NULL
)
return
0
;
if
(
!
pUser
->
superUser
)
{
mndReleaseUser
(
pMnode
,
pUser
);
terrno
=
TSDB_CODE_MND_NO_RIGHTS
;
return
-
1
;
}
mndReleaseUser
(
pMnode
,
pUser
);
SKillConnReq
killReq
=
{
0
};
if
(
tDeserializeSKillConnReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
killReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
return
-
1
;
}
if
(
mndCheckOperPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_KILL_CONN
)
!=
0
)
{
return
-
1
;
}
SConnObj
*
pConn
=
taosCacheAcquireByKey
(
pMgmt
->
connCache
,
&
killReq
.
connId
,
sizeof
(
uint32_t
));
if
(
pConn
==
NULL
)
{
mError
(
"connId:%u, failed to kill connection, conn not exist"
,
killReq
.
connId
);
...
...
@@ -739,7 +735,6 @@ _over:
return
code
;
}
static
int32_t
mndRetrieveConns
(
SRpcMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
...
...
source/dnode/mnode/impl/src/mndQnode.c
浏览文件 @
377bed85
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndQnode.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndDnode.h"
#include "mndShow.h"
#include "mndTrans.h"
...
...
@@ -279,6 +279,9 @@ static int32_t mndProcessCreateQnodeReq(SRpcMsg *pReq) {
}
mDebug
(
"qnode:%d, start to create"
,
createReq
.
dnodeId
);
if
(
mndCheckOperPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_QNODE
)
!=
0
)
{
goto
_OVER
;
}
pObj
=
mndAcquireQnode
(
pMnode
,
createReq
.
dnodeId
);
if
(
pObj
!=
NULL
)
{
...
...
@@ -294,10 +297,6 @@ static int32_t mndProcessCreateQnodeReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_QNODE
)
!=
0
)
{
goto
_OVER
;
}
code
=
mndCreateQnode
(
pMnode
,
pReq
,
pDnode
,
&
createReq
);
if
(
code
==
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
...
...
@@ -391,6 +390,9 @@ static int32_t mndProcessDropQnodeReq(SRpcMsg *pReq) {
}
mDebug
(
"qnode:%d, start to drop"
,
dropReq
.
dnodeId
);
if
(
mndCheckOperPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_QNODE
)
!=
0
)
{
goto
_OVER
;
}
if
(
dropReq
.
dnodeId
<=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
...
...
@@ -402,10 +404,6 @@ static int32_t mndProcessDropQnodeReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_QNODE
)
!=
0
)
{
goto
_OVER
;
}
code
=
mndDropQnode
(
pMnode
,
pReq
,
pObj
);
if
(
code
==
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
...
...
@@ -418,13 +416,13 @@ _OVER:
return
code
;
}
int32_t
mndCreateQnodeList
(
SMnode
*
pMnode
,
SArray
**
pList
,
int32_t
limit
)
{
int32_t
mndCreateQnodeList
(
SMnode
*
pMnode
,
SArray
**
pList
,
int32_t
limit
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
void
*
pIter
=
NULL
;
SQnodeObj
*
pObj
=
NULL
;
int32_t
numOfRows
=
0
;
SArray
*
qnodeList
=
taosArrayInit
(
5
,
sizeof
(
SQueryNodeLoad
));
SArray
*
qnodeList
=
taosArrayInit
(
5
,
sizeof
(
SQueryNodeLoad
));
if
(
NULL
==
qnodeList
)
{
mError
(
"failed to alloc epSet while process qnode list req"
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -457,7 +455,6 @@ int32_t mndCreateQnodeList(SMnode *pMnode, SArray** pList, int32_t limit)
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mndProcessQnodeListReq
(
SRpcMsg
*
pReq
)
{
int32_t
code
=
-
1
;
SMnode
*
pMnode
=
pReq
->
info
.
node
;
...
...
source/dnode/mnode/impl/src/mndShow.c
浏览文件 @
377bed85
...
...
@@ -16,7 +16,7 @@
#define _DEFAULT_SOURCE
#include "mndShow.h"
#include "systable.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#define SHOW_STEP_SIZE 100
...
...
@@ -231,7 +231,7 @@ static int32_t mndProcessRetrieveSysTableReq(SRpcMsg *pReq) {
mDebug
(
"show:0x%"
PRIx64
", start retrieve data, type:%d"
,
pShow
->
id
,
pShow
->
type
);
// if (mndCheckShow
Auth
(pMnode, pReq->info.conn.user, pShow->type) != 0) return -1;
// if (mndCheckShow
Privilege
(pMnode, pReq->info.conn.user, pShow->type) != 0) return -1;
int32_t
numOfCols
=
pShow
->
pMeta
->
numOfColumns
;
SSDataBlock
*
pBlock
=
taosMemoryCalloc
(
1
,
sizeof
(
SSDataBlock
));
...
...
source/dnode/mnode/impl/src/mndSma.c
浏览文件 @
377bed85
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndSma.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndDb.h"
#include "mndDnode.h"
#include "mndInfoSchema.h"
...
...
@@ -713,7 +713,7 @@ static int32_t mndProcessCreateSmaReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckDb
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
if
(
mndCheckDb
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -974,7 +974,7 @@ static int32_t mndProcessDropSmaReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckDb
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
if
(
mndCheckDb
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
...
...
source/dnode/mnode/impl/src/mndSnode.c
浏览文件 @
377bed85
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndSnode.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndDnode.h"
#include "mndShow.h"
#include "mndTrans.h"
...
...
@@ -285,6 +285,9 @@ static int32_t mndProcessCreateSnodeReq(SRpcMsg *pReq) {
}
mDebug
(
"snode:%d, start to create"
,
createReq
.
dnodeId
);
if
(
mndCheckOperPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_SNODE
)
!=
0
)
{
goto
_OVER
;
}
pObj
=
mndAcquireSnode
(
pMnode
,
createReq
.
dnodeId
);
if
(
pObj
!=
NULL
)
{
...
...
@@ -300,10 +303,6 @@ static int32_t mndProcessCreateSnodeReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_SNODE
)
!=
0
)
{
goto
_OVER
;
}
code
=
mndCreateSnode
(
pMnode
,
pReq
,
pDnode
,
&
createReq
);
if
(
code
==
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
...
...
@@ -398,6 +397,9 @@ static int32_t mndProcessDropSnodeReq(SRpcMsg *pReq) {
}
mDebug
(
"snode:%d, start to drop"
,
dropReq
.
dnodeId
);
if
(
mndCheckOperPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_SNODE
)
!=
0
)
{
goto
_OVER
;
}
if
(
dropReq
.
dnodeId
<=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
...
...
@@ -409,10 +411,6 @@ static int32_t mndProcessDropSnodeReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_SNODE
)
!=
0
)
{
goto
_OVER
;
}
// check deletable
code
=
mndDropSnode
(
pMnode
,
pReq
,
pObj
);
if
(
code
==
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
377bed85
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndStb.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndDb.h"
#include "mndDnode.h"
#include "mndInfoSchema.h"
...
...
@@ -876,7 +876,7 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckDb
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
if
(
mndCheckDb
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -1607,7 +1607,7 @@ static int32_t mndProcessAlterStbReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckDb
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
if
(
mndCheckDb
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -1737,7 +1737,7 @@ static int32_t mndProcessDropStbReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckDb
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
if
(
mndCheckDb
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
...
...
source/dnode/mnode/impl/src/mndStream.c
浏览文件 @
377bed85
...
...
@@ -14,7 +14,7 @@
*/
#include "mndStream.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndDb.h"
#include "mndDnode.h"
#include "mndMnode.h"
...
...
@@ -437,7 +437,7 @@ static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStre
goto
_OVER
;
}
if
(
mndCheckDb
Auth
(
pMnode
,
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
if
(
mndCheckDb
Privilege
(
pMnode
,
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -550,7 +550,7 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
goto _OVER;
}
if (mndCheckDb
Auth
(pMnode, pReq->info.conn.user, MND_OPER_WRITE_DB, pDb) != 0) {
if (mndCheckDb
Privilege
(pMnode, pReq->info.conn.user, MND_OPER_WRITE_DB, pDb) != 0) {
goto _OVER;
}
#endif
...
...
@@ -634,7 +634,7 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
if
(
dropReq
.
igNotExists
)
{
mDebug
(
"stream:%s, not exist, ignore not exist is set"
,
dropReq
.
name
);
sdbRelease
(
pMnode
->
pSdb
,
pStream
);
return
-
1
;
return
0
;
}
else
{
terrno
=
TSDB_CODE_MND_STREAM_NOT_EXIST
;
return
-
1
;
...
...
source/dnode/mnode/impl/src/mndTopic.c
浏览文件 @
377bed85
...
...
@@ -14,7 +14,7 @@
*/
#include "mndTopic.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndConsumer.h"
#include "mndDb.h"
#include "mndDnode.h"
...
...
@@ -480,7 +480,7 @@ static int32_t mndProcessCreateTopicReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckDb
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
if
(
mndCheckDb
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
377bed85
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndTrans.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndConsumer.h"
#include "mndDb.h"
#include "mndShow.h"
...
...
@@ -1384,8 +1384,7 @@ static int32_t mndProcessKillTransReq(SRpcMsg *pReq) {
}
mInfo
(
"trans:%d, start to kill"
,
killReq
.
transId
);
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_KILL_TRANS
)
!=
0
)
{
if
(
mndCheckOperPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_KILL_TRANS
)
!=
0
)
{
goto
_OVER
;
}
...
...
source/dnode/mnode/impl/src/mndUser.c
浏览文件 @
377bed85
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndUser.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndDb.h"
#include "mndShow.h"
#include "mndTrans.h"
...
...
@@ -295,7 +295,7 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, SCreateUserReq *pCreate
tstrncpy
(
userObj
.
acct
,
acct
,
TSDB_USER_LEN
);
userObj
.
createdTime
=
taosGetTimestampMs
();
userObj
.
updateTime
=
userObj
.
createdTime
;
userObj
.
superUser
=
pCreate
->
superUser
;
userObj
.
superUser
=
0
;
//
pCreate->superUser;
userObj
.
sysInfo
=
pCreate
->
sysInfo
;
userObj
.
enable
=
pCreate
->
enable
;
...
...
@@ -337,6 +337,9 @@ static int32_t mndProcessCreateUserReq(SRpcMsg *pReq) {
}
mDebug
(
"user:%s, start to create"
,
createReq
.
user
);
if
(
mndCheckOperPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_USER
)
!=
0
)
{
goto
_OVER
;
}
if
(
createReq
.
user
[
0
]
==
0
)
{
terrno
=
TSDB_CODE_MND_INVALID_USER_FORMAT
;
...
...
@@ -360,10 +363,6 @@ static int32_t mndProcessCreateUserReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_USER
)
!=
0
)
{
goto
_OVER
;
}
code
=
mndCreateUser
(
pMnode
,
pOperUser
->
acct
,
&
createReq
,
pReq
);
if
(
code
==
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
...
...
@@ -466,7 +465,7 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckAlterUser
Auth
(
pOperUser
,
pUser
,
&
alterReq
)
!=
0
)
{
if
(
mndCheckAlterUser
Privilege
(
pOperUser
,
pUser
,
&
alterReq
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -631,6 +630,9 @@ static int32_t mndProcessDropUserReq(SRpcMsg *pReq) {
}
mDebug
(
"user:%s, start to drop"
,
dropReq
.
user
);
if
(
mndCheckOperPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_USER
)
!=
0
)
{
goto
_OVER
;
}
if
(
dropReq
.
user
[
0
]
==
0
)
{
terrno
=
TSDB_CODE_MND_INVALID_USER_FORMAT
;
...
...
@@ -643,10 +645,6 @@ static int32_t mndProcessDropUserReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_USER
)
!=
0
)
{
goto
_OVER
;
}
code
=
mndDropUser
(
pMnode
,
pReq
,
pUser
);
if
(
code
==
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
...
...
source/dnode/mnode/impl/src/mndVgroup.c
浏览文件 @
377bed85
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndVgroup.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndDb.h"
#include "mndDnode.h"
#include "mndMnode.h"
...
...
@@ -1212,8 +1212,9 @@ static int32_t mndProcessRedistributeVgroupMsg(SRpcMsg *pReq) {
}
mInfo
(
"vgId:%d, start to redistribute vgroup to dnode %d:%d:%d"
,
req
.
vgId
,
req
.
dnodeId1
,
req
.
dnodeId2
,
req
.
dnodeId3
);
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_REDISTRIBUTE_VGROUP
)
!=
0
)
goto
_OVER
;
if
(
mndCheckOperPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_REDISTRIBUTE_VGROUP
)
!=
0
)
{
goto
_OVER
;
}
pVgroup
=
mndAcquireVgroup
(
pMnode
,
req
.
vgId
);
if
(
pVgroup
==
NULL
)
goto
_OVER
;
...
...
@@ -1506,6 +1507,9 @@ static int32_t mndProcessSplitVgroupMsg(SRpcMsg *pReq) {
SDbObj
*
pDb
=
NULL
;
mDebug
(
"vgId:%d, start to split"
,
vgId
);
if
(
mndCheckOperPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_SPLIT_VGROUP
)
!=
0
)
{
goto
_OVER
;
}
pVgroup
=
mndAcquireVgroup
(
pMnode
,
vgId
);
if
(
pVgroup
==
NULL
)
goto
_OVER
;
...
...
@@ -1513,8 +1517,6 @@ static int32_t mndProcessSplitVgroupMsg(SRpcMsg *pReq) {
pDb
=
mndAcquireDb
(
pMnode
,
pVgroup
->
dbName
);
if
(
pDb
==
NULL
)
goto
_OVER
;
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_SPLIT_VGROUP
)
!=
0
)
goto
_OVER
;
code
=
mndSplitVgroup
(
pMnode
,
pReq
,
pDb
,
pVgroup
);
if
(
code
==
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
...
...
@@ -1655,8 +1657,9 @@ static int32_t mndProcessBalanceVgroupMsg(SRpcMsg *pReq) {
}
mInfo
(
"start to balance vgroup"
);
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_BALANCE_VGROUP
)
!=
0
)
goto
_OVER
;
if
(
mndCheckOperPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_BALANCE_VGROUP
)
!=
0
)
{
goto
_OVER
;
}
while
(
1
)
{
SDnodeObj
*
pDnode
=
NULL
;
...
...
source/dnode/mnode/impl/test/user/user.cpp
浏览文件 @
377bed85
...
...
@@ -33,6 +33,8 @@ TEST_F(MndTestUser, 01_Show_User) {
TEST_F
(
MndTestUser
,
02
_Create_User
)
{
{
SCreateUserReq
createReq
=
{
0
};
createReq
.
enable
=
1
;
createReq
.
sysInfo
=
1
;
strcpy
(
createReq
.
user
,
""
);
strcpy
(
createReq
.
pass
,
"p1"
);
...
...
@@ -47,6 +49,8 @@ TEST_F(MndTestUser, 02_Create_User) {
{
SCreateUserReq
createReq
=
{
0
};
createReq
.
enable
=
1
;
createReq
.
sysInfo
=
1
;
strcpy
(
createReq
.
user
,
"u1"
);
strcpy
(
createReq
.
pass
,
""
);
...
...
@@ -61,6 +65,8 @@ TEST_F(MndTestUser, 02_Create_User) {
{
SCreateUserReq
createReq
=
{
0
};
createReq
.
enable
=
1
;
createReq
.
sysInfo
=
1
;
strcpy
(
createReq
.
user
,
"root"
);
strcpy
(
createReq
.
pass
,
"1"
);
...
...
@@ -75,6 +81,8 @@ TEST_F(MndTestUser, 02_Create_User) {
{
SCreateUserReq
createReq
=
{
0
};
createReq
.
enable
=
1
;
createReq
.
sysInfo
=
1
;
strcpy
(
createReq
.
user
,
"u1"
);
strcpy
(
createReq
.
pass
,
"p1"
);
...
...
@@ -108,9 +116,11 @@ TEST_F(MndTestUser, 02_Create_User) {
{
SCreateUserReq
createReq
=
{
0
};
createReq
.
enable
=
1
;
createReq
.
sysInfo
=
1
;
strcpy
(
createReq
.
user
,
"u2"
);
strcpy
(
createReq
.
pass
,
"p1"
);
createReq
.
superUser
=
1
;
createReq
.
superUser
=
0
;
int32_t
contLen
=
tSerializeSCreateUserReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
...
...
@@ -144,9 +154,11 @@ TEST_F(MndTestUser, 02_Create_User) {
TEST_F
(
MndTestUser
,
03
_Alter_User
)
{
{
SCreateUserReq
createReq
=
{
0
};
createReq
.
enable
=
1
;
createReq
.
sysInfo
=
1
;
strcpy
(
createReq
.
user
,
"u3"
);
strcpy
(
createReq
.
pass
,
"p1"
);
createReq
.
superUser
=
1
;
createReq
.
superUser
=
0
;
int32_t
contLen
=
tSerializeSCreateUserReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
...
...
@@ -225,7 +237,7 @@ TEST_F(MndTestUser, 03_Alter_User) {
alterReq
.
alterType
=
TSDB_ALTER_USER_SUPERUSER
;
strcpy
(
alterReq
.
user
,
"u3"
);
strcpy
(
alterReq
.
pass
,
"1"
);
alterReq
.
superUser
=
1
;
alterReq
.
superUser
=
0
;
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
0
,
&
alterReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
...
...
@@ -361,7 +373,7 @@ TEST_F(MndTestUser, 03_Alter_User) {
SGetUserAuthRsp
authRsp
=
{
0
};
tDeserializeSGetUserAuthRsp
(
pRsp
->
pCont
,
pRsp
->
contLen
,
&
authRsp
);
EXPECT_STREQ
(
authRsp
.
user
,
"u3"
);
EXPECT_EQ
(
authRsp
.
superAuth
,
1
);
EXPECT_EQ
(
authRsp
.
superAuth
,
0
);
int32_t
numOfReadDbs
=
taosHashGetSize
(
authRsp
.
readDbs
);
int32_t
numOfWriteDbs
=
taosHashGetSize
(
authRsp
.
writeDbs
);
EXPECT_EQ
(
numOfReadDbs
,
1
);
...
...
@@ -436,6 +448,8 @@ TEST_F(MndTestUser, 05_Drop_User) {
{
SCreateUserReq
createReq
=
{
0
};
createReq
.
enable
=
1
;
createReq
.
sysInfo
=
1
;
strcpy
(
createReq
.
user
,
"u1"
);
strcpy
(
createReq
.
pass
,
"p1"
);
...
...
@@ -468,6 +482,8 @@ TEST_F(MndTestUser, 05_Drop_User) {
TEST_F
(
MndTestUser
,
06
_Create_Drop_Alter_User
)
{
{
SCreateUserReq
createReq
=
{
0
};
createReq
.
enable
=
1
;
createReq
.
sysInfo
=
1
;
strcpy
(
createReq
.
user
,
"u1"
);
strcpy
(
createReq
.
pass
,
"p1"
);
...
...
@@ -482,6 +498,8 @@ TEST_F(MndTestUser, 06_Create_Drop_Alter_User) {
{
SCreateUserReq
createReq
=
{
0
};
createReq
.
enable
=
1
;
createReq
.
sysInfo
=
1
;
strcpy
(
createReq
.
user
,
"u2"
);
strcpy
(
createReq
.
pass
,
"p2"
);
...
...
source/dnode/vnode/inc/vnode.h
浏览文件 @
377bed85
...
...
@@ -116,7 +116,8 @@ typedef void *tsdbReaderT;
#define BLOCK_LOAD_TABLE_SEQ_ORDER 2
#define BLOCK_LOAD_TABLE_RR_ORDER 3
tsdbReaderT
tsdbReaderOpen
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
STableListInfo
*
tableInfoGroup
,
uint64_t
qId
,
int32_t
tsdbSetTableList
(
tsdbReaderT
reader
,
SArray
*
tableList
);
tsdbReaderT
tsdbReaderOpen
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
SArray
*
tableList
,
uint64_t
qId
,
uint64_t
taskId
);
tsdbReaderT
tsdbQueryCacheLast
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
STableListInfo
*
groupList
,
uint64_t
qId
,
void
*
pMemRef
);
...
...
@@ -195,7 +196,6 @@ struct SVnodeCfg {
typedef
struct
{
TSKEY
lastKey
;
uint64_t
uid
;
uint64_t
groupId
;
}
STableKeyInfo
;
struct
SMetaEntry
{
...
...
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
377bed85
...
...
@@ -121,7 +121,7 @@ int tsdbInsertData(STsdb* pTsdb, int64_t version, SSubmitReq* pMsg, SSub
int32_t
tsdbInsertTableData
(
STsdb
*
pTsdb
,
int64_t
version
,
SSubmitMsgIter
*
pMsgIter
,
SSubmitBlk
*
pBlock
,
SSubmitBlkRsp
*
pRsp
);
int32_t
tsdbDeleteTableData
(
STsdb
*
pTsdb
,
int64_t
version
,
tb_uid_t
suid
,
tb_uid_t
uid
,
TSKEY
sKey
,
TSKEY
eKey
);
tsdbReaderT
tsdbReaderOpen
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
S
TableListInfo
*
tableList
,
uint64_t
qId
,
tsdbReaderT
tsdbReaderOpen
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
S
Array
*
tableList
,
uint64_t
qId
,
uint64_t
taskId
);
tsdbReaderT
tsdbQueryCacheLastT
(
STsdb
*
tsdb
,
SQueryTableDataCond
*
pCond
,
STableListInfo
*
tableList
,
uint64_t
qId
,
void
*
pMemRef
);
...
...
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
377bed85
...
...
@@ -381,6 +381,7 @@ int metaTtlDropTable(SMeta *pMeta, int64_t ttl, SArray *tbUids) {
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
tbUids
);
++
i
)
{
tb_uid_t
*
uid
=
(
tb_uid_t
*
)
taosArrayGet
(
tbUids
,
i
);
metaDropTableByUid
(
pMeta
,
*
uid
,
NULL
);
metaDebug
(
"ttl drop table:%"
PRId64
,
*
uid
);
}
metaULock
(
pMeta
);
return
0
;
...
...
@@ -443,7 +444,6 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
// drop schema.db (todo)
}
metaError
(
"ttl drop table:%s"
,
e
.
name
);
tDecoderClear
(
&
dc
);
tdbFree
(
pData
);
...
...
@@ -976,7 +976,9 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) {
SDecoder
dc
=
{
0
};
// get super table
tdbTbGet
(
pMeta
->
pUidIdx
,
&
pCtbEntry
->
ctbEntry
.
suid
,
sizeof
(
tb_uid_t
),
&
pData
,
&
nData
);
if
(
tdbTbGet
(
pMeta
->
pUidIdx
,
&
pCtbEntry
->
ctbEntry
.
suid
,
sizeof
(
tb_uid_t
),
&
pData
,
&
nData
)
!=
0
){
return
-
1
;
}
tbDbKey
.
uid
=
pCtbEntry
->
ctbEntry
.
suid
;
tbDbKey
.
version
=
*
(
int64_t
*
)
pData
;
tdbTbGet
(
pMeta
->
pTbDb
,
&
tbDbKey
,
sizeof
(
tbDbKey
),
&
pData
,
&
nData
);
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
377bed85
...
...
@@ -403,7 +403,7 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
.
reader
=
pHandle
->
execHandle
.
pExecReader
[
i
],
.
meta
=
pTq
->
pVnode
->
pMeta
,
.
vnode
=
pTq
->
pVnode
,
.
initTsdbReader
=
1
,
//
.initTsdbReader = 1,
};
pHandle
->
execHandle
.
execCol
.
task
[
i
]
=
qCreateStreamExecTaskInfo
(
pHandle
->
execHandle
.
execCol
.
qmsg
,
&
handle
);
ASSERT
(
pHandle
->
execHandle
.
execCol
.
task
[
i
]);
...
...
@@ -479,7 +479,7 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, char* msg, int32_t msgLen) {
.
reader
=
pStreamReader
,
.
meta
=
pTq
->
pVnode
->
pMeta
,
.
vnode
=
pTq
->
pVnode
,
.
initTsdbReader
=
1
,
//
.initTsdbReader = 1,
};
/*pTask->exec.inputHandle = pStreamReader;*/
pTask
->
exec
.
executor
=
qCreateStreamExecTaskInfo
(
pTask
->
exec
.
qmsg
,
&
handle
);
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
377bed85
...
...
@@ -223,9 +223,8 @@ int64_t tsdbGetNumOfRowsInMemTable(tsdbReaderT* pHandle) {
return
rows
;
}
static
SArray
*
createCheckInfoFromTableGroup
(
STsdbReadHandle
*
pTsdbReadHandle
,
STableListInfo
*
pTableList
)
{
size_t
tableSize
=
taosArrayGetSize
(
pTableList
->
pTableList
);
assert
(
tableSize
>=
1
);
static
SArray
*
createCheckInfoFromTableGroup
(
STsdbReadHandle
*
pTsdbReadHandle
,
SArray
*
pTableList
)
{
size_t
tableSize
=
taosArrayGetSize
(
pTableList
);
// allocate buffer in order to load data blocks from file
SArray
*
pTableCheckInfo
=
taosArrayInit
(
tableSize
,
sizeof
(
STableCheckInfo
));
...
...
@@ -235,7 +234,7 @@ static SArray* createCheckInfoFromTableGroup(STsdbReadHandle* pTsdbReadHandle, S
// todo apply the lastkey of table check to avoid to load header file
for
(
int32_t
j
=
0
;
j
<
tableSize
;
++
j
)
{
STableKeyInfo
*
pKeyInfo
=
(
STableKeyInfo
*
)
taosArrayGet
(
pTableList
->
pTableList
,
j
);
STableKeyInfo
*
pKeyInfo
=
(
STableKeyInfo
*
)
taosArrayGet
(
pTableList
,
j
);
STableCheckInfo
info
=
{.
lastKey
=
pKeyInfo
->
lastKey
,
.
tableId
=
pKeyInfo
->
uid
};
info
.
suid
=
pTsdbReadHandle
->
suid
;
...
...
@@ -254,8 +253,6 @@ static SArray* createCheckInfoFromTableGroup(STsdbReadHandle* pTsdbReadHandle, S
pTsdbReadHandle
->
idStr
);
}
// TODO group table according to the tag value.
taosArraySort
(
pTableCheckInfo
,
tsdbCheckInfoCompar
);
return
pTableCheckInfo
;
}
...
...
@@ -497,8 +494,21 @@ static int32_t setCurrentSchema(SVnode* pVnode, STsdbReadHandle* pTsdbReadHandle
return
TSDB_CODE_SUCCESS
;
}
tsdbReaderT
tsdbReaderOpen
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
STableListInfo
*
tableList
,
uint64_t
qId
,
int32_t
tsdbSetTableList
(
tsdbReaderT
reader
,
SArray
*
tableList
){
STsdbReadHandle
*
pTsdbReadHandle
=
reader
;
if
(
pTsdbReadHandle
->
pTableCheckInfo
)
taosArrayDestroy
(
pTsdbReadHandle
->
pTableCheckInfo
);
pTsdbReadHandle
->
pTableCheckInfo
=
createCheckInfoFromTableGroup
(
pTsdbReadHandle
,
tableList
);
if
(
pTsdbReadHandle
->
pTableCheckInfo
==
NULL
)
{
return
TSDB_CODE_TDB_OUT_OF_MEMORY
;
}
return
TDB_CODE_SUCCESS
;
}
tsdbReaderT
tsdbReaderOpen
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
SArray
*
tableList
,
uint64_t
qId
,
uint64_t
taskId
)
{
if
(
taosArrayGetSize
(
tableList
)
==
0
){
return
NULL
;
}
STsdbReadHandle
*
pTsdbReadHandle
=
tsdbQueryTablesImpl
(
pVnode
,
pCond
,
qId
,
taskId
);
if
(
pTsdbReadHandle
==
NULL
)
{
return
NULL
;
...
...
@@ -543,7 +553,7 @@ tsdbReaderT tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, STableLis
}
tsdbDebug
(
"%p total numOfTable:%"
PRIzu
" in this query, table %"
PRIzu
" %s"
,
pTsdbReadHandle
,
taosArrayGetSize
(
pTsdbReadHandle
->
pTableCheckInfo
),
taosArrayGetSize
(
tableList
->
pTableList
),
taosArrayGetSize
(
pTsdbReadHandle
->
pTableCheckInfo
),
taosArrayGetSize
(
tableList
),
pTsdbReadHandle
->
idStr
);
return
(
tsdbReaderT
)
pTsdbReadHandle
;
...
...
@@ -639,7 +649,7 @@ tsdbReaderT tsdbQueryLastRow(SVnode* pVnode, SQueryTableDataCond* pCond, STableL
return
NULL
;
}
STsdbReadHandle
*
pTsdbReadHandle
=
(
STsdbReadHandle
*
)
tsdbReaderOpen
(
pVnode
,
pCond
,
pList
,
qId
,
taskId
);
STsdbReadHandle
*
pTsdbReadHandle
=
(
STsdbReadHandle
*
)
tsdbReaderOpen
(
pVnode
,
pCond
,
pList
->
pTableList
,
qId
,
taskId
);
if
(
pTsdbReadHandle
==
NULL
)
{
return
NULL
;
}
...
...
@@ -2842,7 +2852,7 @@ int32_t tsdbGetAllTableList(SMeta* pMeta, uint64_t uid, SArray* list) {
break
;
}
STableKeyInfo
info
=
{.
lastKey
=
TSKEY_INITIAL_VAL
,
uid
=
id
,
.
groupId
=
0
};
STableKeyInfo
info
=
{.
lastKey
=
TSKEY_INITIAL_VAL
,
uid
=
id
};
taosArrayPush
(
list
,
&
info
);
}
...
...
@@ -3644,17 +3654,6 @@ SArray* tsdbRetrieveDataBlock(tsdbReaderT* pTsdbReadHandle, SArray* pIdList) {
}
}
static
int
tsdbCheckInfoCompar
(
const
void
*
key1
,
const
void
*
key2
)
{
if
(((
STableCheckInfo
*
)
key1
)
->
tableId
<
((
STableCheckInfo
*
)
key2
)
->
tableId
)
{
return
-
1
;
}
else
if
(((
STableCheckInfo
*
)
key1
)
->
tableId
>
((
STableCheckInfo
*
)
key2
)
->
tableId
)
{
return
1
;
}
else
{
ASSERT
(
false
);
return
0
;
}
}
static
void
*
doFreeColumnInfoData
(
SArray
*
pColumnInfoData
)
{
if
(
pColumnInfoData
==
NULL
)
{
return
NULL
;
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
377bed85
...
...
@@ -273,6 +273,10 @@ typedef struct STableScanInfo {
SSampleExecInfo
sample
;
// sample execution info
int32_t
curTWinIdx
;
int32_t
currentGroupId
;
uint64_t
queryId
;
uint64_t
taskId
;
}
STableScanInfo
;
typedef
struct
STagScanInfo
{
...
...
@@ -706,7 +710,7 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR
SOperatorInfo
*
createExchangeOperatorInfo
(
void
*
pTransporter
,
SExchangePhysiNode
*
pExNode
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createTableScanOperatorInfo
(
STableScanPhysiNode
*
pTableScanNode
,
tsdbReaderT
pDataReader
,
SReadHandle
*
pHandle
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createTableScanOperatorInfo
(
STableScanPhysiNode
*
pTableScanNode
,
SReadHandle
*
pHandle
,
SExecTaskInfo
*
pTaskInfo
,
uint64_t
queryId
,
uint64_t
taskId
);
SOperatorInfo
*
createTagScanOperatorInfo
(
SReadHandle
*
pReadHandle
,
STagScanPhysiNode
*
pPhyNode
,
STableListInfo
*
pTableListInfo
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createSysTableScanOperatorInfo
(
void
*
readHandle
,
SSystemTableScanPhysiNode
*
pScanPhyNode
,
SExecTaskInfo
*
pTaskInfo
);
...
...
@@ -749,8 +753,8 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
SOperatorInfo
*
createDataBlockInfoScanOperator
(
void
*
dataReader
,
SReadHandle
*
readHandle
,
uint64_t
uid
,
SBlockDistScanPhysiNode
*
pBlockScanNode
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createStreamScanOperatorInfo
(
void
*
pDataReader
,
SReadHandle
*
pHandle
,
STableScanPhysiNode
*
pTableScanNode
,
SExecTaskInfo
*
pTaskInfo
,
STimeWindowAggSupp
*
pTwSup
);
SOperatorInfo
*
createStreamScanOperatorInfo
(
SReadHandle
*
pHandle
,
STableScanPhysiNode
*
pTableScanNode
,
SExecTaskInfo
*
pTaskInfo
,
STimeWindowAggSupp
*
pTwSup
,
uint64_t
queryId
,
uint64_t
taskId
);
SOperatorInfo
*
createFillOperatorInfo
(
SOperatorInfo
*
downstream
,
SFillPhysiNode
*
pPhyFillNode
,
bool
multigroupResult
,
SExecTaskInfo
*
pTaskInfo
);
...
...
@@ -845,7 +849,7 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN
void
copyUpdateDataBlock
(
SSDataBlock
*
pDest
,
SSDataBlock
*
pSource
,
int32_t
tsColIndex
);
int32_t
generateGroupIdMap
(
STableListInfo
*
pTableListInfo
,
SReadHandle
*
pHandle
,
S
Array
*
groupKey
);
int32_t
generateGroupIdMap
(
STableListInfo
*
pTableListInfo
,
SReadHandle
*
pHandle
,
S
NodeList
*
groupKey
);
#ifdef __cplusplus
}
...
...
source/libs/executor/src/executil.c
浏览文件 @
377bed85
...
...
@@ -287,6 +287,7 @@ static bool isTableOk(STableKeyInfo* info, SNode *pTagCond, SMeta *metaHandle){
int32_t
getTableList
(
void
*
metaHandle
,
SScanPhysiNode
*
pScanNode
,
STableListInfo
*
pListInfo
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
pListInfo
->
pTableList
=
taosArrayInit
(
8
,
sizeof
(
STableKeyInfo
));
if
(
pListInfo
->
pTableList
==
NULL
)
return
TSDB_CODE_OUT_OF_MEMORY
;
uint64_t
tableUid
=
pScanNode
->
uid
;
...
...
@@ -314,7 +315,7 @@ int32_t getTableList(void* metaHandle, SScanPhysiNode* pScanNode, STableListInfo
}
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
res
);
i
++
)
{
STableKeyInfo
info
=
{.
lastKey
=
TSKEY_INITIAL_VAL
,
.
uid
=
*
(
uint64_t
*
)
taosArrayGet
(
res
,
i
)
,
.
groupId
=
0
};
STableKeyInfo
info
=
{.
lastKey
=
TSKEY_INITIAL_VAL
,
.
uid
=
*
(
uint64_t
*
)
taosArrayGet
(
res
,
i
)};
taosArrayPush
(
pListInfo
->
pTableList
,
&
info
);
}
taosArrayDestroy
(
res
);
...
...
@@ -335,9 +336,14 @@ int32_t getTableList(void* metaHandle, SScanPhysiNode* pScanNode, STableListInfo
}
}
}
else
{
// Create one table group.
STableKeyInfo
info
=
{.
lastKey
=
0
,
.
uid
=
tableUid
,
.
groupId
=
0
};
STableKeyInfo
info
=
{.
lastKey
=
0
,
.
uid
=
tableUid
};
taosArrayPush
(
pListInfo
->
pTableList
,
&
info
);
}
pListInfo
->
pGroupList
=
taosArrayInit
(
4
,
POINTER_BYTES
);
if
(
pListInfo
->
pGroupList
==
NULL
)
return
TSDB_CODE_OUT_OF_MEMORY
;
//put into list as default group, remove it if grouping sorting is required later
taosArrayPush
(
pListInfo
->
pGroupList
,
&
pListInfo
->
pTableList
);
return
code
;
}
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
377bed85
...
...
@@ -3862,9 +3862,6 @@ static SExecTaskInfo* createExecTaskInfo(uint64_t queryId, uint64_t taskId, EOPT
return
pTaskInfo
;
}
static
tsdbReaderT
doCreateDataReader
(
STableScanPhysiNode
*
pTableScanNode
,
SReadHandle
*
pHandle
,
STableListInfo
*
pTableListInfo
,
uint64_t
queryId
,
uint64_t
taskId
);
static
SArray
*
extractColumnInfo
(
SNodeList
*
pNodeList
);
int32_t
extractTableSchemaVersion
(
SReadHandle
*
pHandle
,
uint64_t
uid
,
SExecTaskInfo
*
pTaskInfo
)
{
...
...
@@ -3895,8 +3892,67 @@ int32_t extractTableSchemaVersion(SReadHandle* pHandle, uint64_t uid, SExecTaskI
return
TSDB_CODE_SUCCESS
;
}
int32_t
generateGroupIdMap
(
STableListInfo
*
pTableListInfo
,
SReadHandle
*
pHandle
,
SArray
*
groupKey
)
{
if
(
groupKey
==
NULL
)
{
static
int32_t
sortTableGroup
(
STableListInfo
*
pTableListInfo
,
int32_t
groupNum
){
taosArrayClear
(
pTableListInfo
->
pGroupList
);
SArray
*
sortSupport
=
taosArrayInit
(
groupNum
,
sizeof
(
uint64_t
));
if
(
sortSupport
==
NULL
)
return
TSDB_CODE_OUT_OF_MEMORY
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pTableListInfo
->
pTableList
);
i
++
)
{
STableKeyInfo
*
info
=
taosArrayGet
(
pTableListInfo
->
pTableList
,
i
);
uint64_t
*
groupId
=
taosHashGet
(
pTableListInfo
->
map
,
&
info
->
uid
,
sizeof
(
uint64_t
));
int32_t
index
=
taosArraySearchIdx
(
sortSupport
,
groupId
,
compareUint64Val
,
TD_EQ
);
if
(
index
==
-
1
){
void
*
p
=
taosArraySearch
(
sortSupport
,
groupId
,
compareUint64Val
,
TD_GT
);
SArray
*
tGroup
=
taosArrayInit
(
8
,
sizeof
(
STableKeyInfo
));
if
(
tGroup
==
NULL
)
{
taosArrayDestroy
(
sortSupport
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
if
(
taosArrayPush
(
tGroup
,
info
)
==
NULL
){
qError
(
"taos push info array error"
);
taosArrayDestroy
(
sortSupport
);
return
TSDB_CODE_QRY_APP_ERROR
;
}
if
(
p
==
NULL
){
if
(
taosArrayPush
(
sortSupport
,
groupId
)
!=
NULL
){
qError
(
"taos push support array error"
);
taosArrayDestroy
(
sortSupport
);
return
TSDB_CODE_QRY_APP_ERROR
;
}
if
(
taosArrayPush
(
pTableListInfo
->
pGroupList
,
&
tGroup
)
!=
NULL
){
qError
(
"taos push group array error"
);
taosArrayDestroy
(
sortSupport
);
return
TSDB_CODE_QRY_APP_ERROR
;
}
}
else
{
int32_t
pos
=
TARRAY_ELEM_IDX
(
sortSupport
,
p
);
if
(
taosArrayInsert
(
sortSupport
,
pos
,
groupId
)
==
NULL
){
qError
(
"taos insert support array error"
);
taosArrayDestroy
(
sortSupport
);
return
TSDB_CODE_QRY_APP_ERROR
;
}
if
(
taosArrayInsert
(
pTableListInfo
->
pGroupList
,
pos
,
&
tGroup
)
==
NULL
){
qError
(
"taos insert group array error"
);
taosArrayDestroy
(
sortSupport
);
return
TSDB_CODE_QRY_APP_ERROR
;
}
}
}
else
{
SArray
*
tGroup
=
(
SArray
*
)
taosArrayGetP
(
pTableListInfo
->
pGroupList
,
index
);
if
(
taosArrayPush
(
tGroup
,
info
)
==
NULL
){
qError
(
"taos push uid array error"
);
taosArrayDestroy
(
sortSupport
);
return
TSDB_CODE_QRY_APP_ERROR
;
}
}
}
taosArrayDestroy
(
sortSupport
);
return
TDB_CODE_SUCCESS
;
}
int32_t
generateGroupIdMap
(
STableListInfo
*
pTableListInfo
,
SReadHandle
*
pHandle
,
SNodeList
*
group
)
{
if
(
group
==
NULL
)
{
return
TDB_CODE_SUCCESS
;
}
...
...
@@ -3906,13 +3962,14 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle,
}
int32_t
keyLen
=
0
;
void
*
keyBuf
=
NULL
;
int32_t
numOfGroupCols
=
taosArrayGetSize
(
groupKey
);
for
(
int32_t
j
=
0
;
j
<
numOfGroupCols
;
++
j
)
{
SColumn
*
pCol
=
taosArrayGet
(
groupKey
,
j
);
keyLen
+=
pCol
->
bytes
;
// actual data + null_flag
SNode
*
node
;
FOREACH
(
node
,
group
)
{
SExprNode
*
pExpr
=
(
SExprNode
*
)
node
;
keyLen
+=
pExpr
->
resType
.
bytes
;
}
int32_t
nullFlagSize
=
sizeof
(
int8_t
)
*
numOfGroupCols
;
int32_t
nullFlagSize
=
sizeof
(
int8_t
)
*
LIST_LENGTH
(
group
)
;
keyLen
+=
nullFlagSize
;
keyBuf
=
taosMemoryCalloc
(
1
,
keyLen
);
...
...
@@ -3920,59 +3977,68 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle,
return
TSDB_CODE_OUT_OF_MEMORY
;
}
int32_t
groupNum
=
0
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pTableListInfo
->
pTableList
);
i
++
)
{
STableKeyInfo
*
info
=
taosArrayGet
(
pTableListInfo
->
pTableList
,
i
);
SMetaReader
mr
=
{
0
};
metaReaderInit
(
&
mr
,
pHandle
->
meta
,
0
);
metaGetTableEntryByUid
(
&
mr
,
info
->
uid
);
SNodeList
*
groupNew
=
nodesCloneList
(
group
);
nodesRewriteExprsPostOrder
(
groupNew
,
doTranslateTagExpr
,
&
mr
);
char
*
isNull
=
(
char
*
)
keyBuf
;
char
*
pStart
=
(
char
*
)
keyBuf
+
sizeof
(
int8_t
)
*
numOfGroupCols
;
for
(
int32_t
j
=
0
;
j
<
numOfGroupCols
;
++
j
)
{
SColumn
*
pCol
=
taosArrayGet
(
groupKey
,
j
);
if
(
strcmp
(
pCol
->
name
,
"tbname"
)
==
0
)
{
isNull
[
i
]
=
0
;
memcpy
(
pStart
,
mr
.
me
.
name
,
strlen
(
mr
.
me
.
name
));
pStart
+=
strlen
(
mr
.
me
.
name
);
char
*
pStart
=
(
char
*
)
keyBuf
+
nullFlagSize
;
SNode
*
pNode
;
int32_t
index
=
0
;
FOREACH
(
pNode
,
groupNew
){
SNode
*
pNew
=
NULL
;
int32_t
code
=
scalarCalculateConstants
(
pNode
,
&
pNew
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
REPLACE_NODE
(
pNew
);
}
else
{
STagVal
tagVal
=
{
0
};
tagVal
.
cid
=
pCol
->
colId
;
const
char
*
p
=
metaGetTableTagVal
(
&
mr
.
me
,
pCol
->
type
,
&
tagVal
);
if
(
p
==
NULL
)
{
isNull
[
j
]
=
1
;
continue
;
taosMemoryFree
(
keyBuf
);
nodesClearList
(
groupNew
);
return
code
;
}
isNull
[
i
]
=
0
;
if
(
pCol
->
type
==
TSDB_DATA_TYPE_JSON
)
{
// int32_t dataLen = getJsonValueLen(pkey->pData);
// memcpy(pStart, (pkey->pData), dataLen);
// pStart += dataLen;
}
else
if
(
IS_VAR_DATA_TYPE
(
pCol
->
type
))
{
memcpy
(
pStart
,
tagVal
.
pData
,
tagVal
.
nData
);
pStart
+=
tagVal
.
nData
;
ASSERT
(
tagVal
.
nData
<=
pCol
->
bytes
);
ASSERT
(
nodeType
(
pNew
)
==
QUERY_NODE_VALUE
);
SValueNode
*
pValue
=
(
SValueNode
*
)
pNew
;
if
(
pValue
->
node
.
resType
.
type
==
TSDB_DATA_TYPE_NULL
)
{
isNull
[
index
++
]
=
1
;
continue
;
}
else
{
memcpy
(
pStart
,
&
(
tagVal
.
i64
),
pCol
->
bytes
);
pStart
+=
pCol
->
bytes
;
isNull
[
index
++
]
=
0
;
char
*
data
=
nodesGetValueFromNode
(
pValue
);
if
(
pValue
->
node
.
resType
.
type
==
TSDB_DATA_TYPE_JSON
){
int32_t
len
=
getJsonValueLen
(
data
);
memcpy
(
pStart
,
data
,
len
);
pStart
+=
len
;
}
else
if
(
IS_VAR_DATA_TYPE
(
pValue
->
node
.
resType
.
type
))
{
memcpy
(
pStart
,
data
,
varDataTLen
(
data
));
pStart
+=
varDataTLen
(
data
);
}
else
{
memcpy
(
pStart
,
data
,
pValue
->
node
.
resType
.
bytes
);
pStart
+=
pValue
->
node
.
resType
.
bytes
;
}
}
}
int32_t
len
=
(
int32_t
)(
pStart
-
(
char
*
)
keyBuf
);
uint64_t
groupId
=
calcGroupId
(
keyBuf
,
len
);
taosHashPut
(
pTableListInfo
->
map
,
&
(
info
->
uid
),
sizeof
(
uint64_t
),
&
groupId
,
sizeof
(
uint64_t
));
groupNum
++
;
uint64_t
*
pGroupId
=
taosHashGet
(
pTableListInfo
->
map
,
keyBuf
,
len
);
if
(
!
pGroupId
)
{
uint64_t
tmpId
=
calcGroupId
(
keyBuf
,
len
);
info
->
groupId
=
tmpId
;
taosHashPut
(
pTableListInfo
->
map
,
&
(
info
->
uid
),
sizeof
(
uint64_t
),
&
tmpId
,
sizeof
(
uint64_t
));
}
else
{
info
->
groupId
=
*
pGroupId
;
}
nodesClearList
(
groupNew
);
metaReaderClear
(
&
mr
);
}
taosMemoryFree
(
keyBuf
);
if
(
pTableListInfo
->
needSortTableByGroupId
){
return
sortTableGroup
(
pTableListInfo
,
groupNum
);
}
return
TDB_CODE_SUCCESS
;
}
...
...
@@ -3984,39 +4050,36 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
if
(
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
==
type
)
{
STableScanPhysiNode
*
pTableScanNode
=
(
STableScanPhysiNode
*
)
pPhyNode
;
tsdbReaderT
pDataReader
=
doCreateDataReader
(
pTableScanNode
,
pHandle
,
pTableListInfo
,
(
uint64_t
)
queryId
,
taskId
);
if
(
pDataReader
==
NULL
&&
terrno
!=
0
)
{
pTaskInfo
->
code
=
terrno
;
return
NULL
;
}
int32_t
code
=
extractTableSchemaVersion
(
pHandle
,
pTableScanNode
->
scan
.
uid
,
pTaskInfo
);
if
(
code
)
{
tsdbCleanupReadHandle
(
pDataReader
);
pTaskInfo
->
code
=
terrno
;
int32_t
code
=
createScanTableListInfo
(
pTableScanNode
,
pHandle
,
pTableListInfo
,
queryId
,
taskId
);
if
(
code
){
pTaskInfo
->
code
=
code
;
return
NULL
;
}
SArray
*
groupKeys
=
extractPartitionColInfo
(
pTableScanNode
->
pPartitionTags
);
code
=
generateGroupIdMap
(
pTableListInfo
,
pHandle
,
groupKeys
);
// todo for json
taosArrayDestroy
(
groupKeys
);
code
=
extractTableSchemaVersion
(
pHandle
,
pTableScanNode
->
scan
.
uid
,
pTaskInfo
);
if
(
code
)
{
tsdbCleanupReadHandle
(
pDataReader
);
pTaskInfo
->
code
=
terrno
;
return
NULL
;
}
SOperatorInfo
*
pOperator
=
createTableScanOperatorInfo
(
pTableScanNode
,
p
DataReader
,
pHandle
,
pTaskInfo
);
SOperatorInfo
*
pOperator
=
createTableScanOperatorInfo
(
pTableScanNode
,
p
Handle
,
pTaskInfo
,
queryId
,
taskId
);
STableScanInfo
*
pScanInfo
=
pOperator
->
info
;
pTaskInfo
->
cost
.
pRecoder
=
&
pScanInfo
->
readRecorder
;
return
pOperator
;
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN
==
type
)
{
STableMergeScanPhysiNode
*
pTableScanNode
=
(
STableMergeScanPhysiNode
*
)
pPhyNode
;
createScanTableListInfo
(
pTableScanNode
,
pHandle
,
pTableListInfo
,
queryId
,
taskId
);
extractTableSchemaVersion
(
pHandle
,
pTableScanNode
->
scan
.
uid
,
pTaskInfo
);
SOperatorInfo
*
pOperator
=
createTableMergeScanOperatorInfo
(
pTableScanNode
,
pTableListInfo
,
pHandle
,
pTaskInfo
,
queryId
,
taskId
);
int32_t
code
=
createScanTableListInfo
(
pTableScanNode
,
pHandle
,
pTableListInfo
,
queryId
,
taskId
);
if
(
code
){
return
NULL
;
}
code
=
extractTableSchemaVersion
(
pHandle
,
pTableScanNode
->
scan
.
uid
,
pTaskInfo
);
if
(
code
)
{
pTaskInfo
->
code
=
terrno
;
return
NULL
;
}
SOperatorInfo
*
pOperator
=
createTableMergeScanOperatorInfo
(
pTableScanNode
,
pTableListInfo
,
pHandle
,
pTaskInfo
,
queryId
,
taskId
);
STableScanInfo
*
pScanInfo
=
pOperator
->
info
;
pTaskInfo
->
cost
.
pRecoder
=
&
pScanInfo
->
readRecorder
;
return
pOperator
;
...
...
@@ -4025,46 +4088,17 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
return
createExchangeOperatorInfo
(
pHandle
->
pMsgCb
->
clientRpc
,
(
SExchangePhysiNode
*
)
pPhyNode
,
pTaskInfo
);
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN
==
type
)
{
SScanPhysiNode
*
pScanPhyNode
=
(
SScanPhysiNode
*
)
pPhyNode
;
// simple child table.
STableScanPhysiNode
*
pTableScanNode
=
(
STableScanPhysiNode
*
)
pPhyNode
;
STimeWindowAggSupp
twSup
=
{
.
waterMark
=
pTableScanNode
->
watermark
,
.
calTrigger
=
pTableScanNode
->
triggerType
,
.
maxTs
=
INT64_MIN
,
};
tsdbReaderT
pDataReader
=
NULL
;
if
(
pHandle
)
{
if
(
pHandle
->
initTsdbReader
)
{
// for stream
ASSERT
(
pHandle
->
vnode
);
pDataReader
=
doCreateDataReader
(
pTableScanNode
,
pHandle
,
pTableListInfo
,
(
uint64_t
)
queryId
,
taskId
);
}
else
{
// for tq
ASSERT
(
pHandle
->
meta
);
getTableList
(
pHandle
->
meta
,
pScanPhyNode
,
pTableListInfo
);
}
}
#if 0
if (pDataReader == NULL && terrno != 0) {
qDebug("%s pDataReader is NULL", GET_TASKID(pTaskInfo));
// return NULL;
} else {
qDebug("%s pDataReader is not NULL", GET_TASKID(pTaskInfo));
}
#endif
SArray
*
groupKeys
=
extractPartitionColInfo
(
pTableScanNode
->
pPartitionTags
);
int32_t
code
=
generateGroupIdMap
(
pTableListInfo
,
pHandle
,
groupKeys
);
// todo for json
taosArrayDestroy
(
groupKeys
);
if
(
code
)
{
tsdbCleanupReadHandle
(
pDataReader
);
return
NULL
;
createScanTableListInfo
(
pTableScanNode
,
pHandle
,
pTableListInfo
,
queryId
,
taskId
);
}
SOperatorInfo
*
pOperator
=
createStreamScanOperatorInfo
(
pDataReader
,
pHandle
,
pTableScanNode
,
pTaskInfo
,
&
twSup
);
SOperatorInfo
*
pOperator
=
createStreamScanOperatorInfo
(
pHandle
,
pTableScanNode
,
pTaskInfo
,
&
twSup
,
queryId
,
taskId
);
return
pOperator
;
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN
==
type
)
{
...
...
@@ -4093,7 +4127,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
return
NULL
;
}
}
else
{
// Create one table group.
STableKeyInfo
info
=
{.
lastKey
=
0
,
.
uid
=
pBlockNode
->
uid
,
.
groupId
=
0
};
STableKeyInfo
info
=
{.
lastKey
=
0
,
.
uid
=
pBlockNode
->
uid
};
taosArrayPush
(
pTableListInfo
->
pTableList
,
&
info
);
}
...
...
@@ -4118,7 +4152,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
cond
.
suid
=
pBlockNode
->
suid
;
cond
.
type
=
BLOCK_LOAD_OFFSET_SEQ_ORDER
;
}
tsdbReaderT
*
pReader
=
tsdbReaderOpen
(
pHandle
->
vnode
,
&
cond
,
pTableListInfo
,
queryId
,
taskId
);
tsdbReaderT
*
pReader
=
tsdbReaderOpen
(
pHandle
->
vnode
,
&
cond
,
pTableListInfo
->
pTableList
,
queryId
,
taskId
);
cleanupQueryTableDataCond
(
&
cond
);
return
createDataBlockInfoScanOperator
(
pReader
,
pHandle
,
cond
.
suid
,
pBlockNode
,
pTaskInfo
);
...
...
@@ -4355,7 +4389,7 @@ tsdbReaderT doCreateDataReader(STableScanPhysiNode* pTableScanNode, SReadHandle*
goto
_error
;
}
tsdbReaderT
pReader
=
tsdbReaderOpen
(
pHandle
->
vnode
,
&
cond
,
pTableListInfo
,
queryId
,
taskId
);
tsdbReaderT
pReader
=
tsdbReaderOpen
(
pHandle
->
vnode
,
&
cond
,
pTableListInfo
->
pTableList
,
queryId
,
taskId
);
cleanupQueryTableDataCond
(
&
cond
);
return
pReader
;
...
...
@@ -4584,6 +4618,13 @@ _complete:
static
void
doDestroyTableList
(
STableListInfo
*
pTableqinfoList
)
{
taosArrayDestroy
(
pTableqinfoList
->
pTableList
);
taosHashCleanup
(
pTableqinfoList
->
map
);
if
(
pTableqinfoList
->
needSortTableByGroupId
){
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pTableqinfoList
->
pGroupList
);
i
++
){
SArray
*
tmp
=
taosArrayGetP
(
pTableqinfoList
->
pGroupList
,
i
);
taosArrayDestroy
(
tmp
);
}
}
taosArrayDestroy
(
pTableqinfoList
->
pGroupList
);
pTableqinfoList
->
pTableList
=
NULL
;
pTableqinfoList
->
map
=
NULL
;
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
377bed85
...
...
@@ -418,7 +418,7 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) {
return
NULL
;
}
static
SSDataBlock
*
doTableScan
(
SOperatorInfo
*
pOperator
)
{
static
SSDataBlock
*
doTableScan
Group
(
SOperatorInfo
*
pOperator
)
{
STableScanInfo
*
pTableScanInfo
=
pOperator
->
info
;
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
...
...
@@ -500,6 +500,48 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
}
}
return
NULL
;
}
static
SSDataBlock
*
doTableScan
(
SOperatorInfo
*
pOperator
)
{
STableScanInfo
*
pInfo
=
pOperator
->
info
;
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
if
(
pInfo
->
currentGroupId
==
-
1
){
pInfo
->
currentGroupId
++
;
if
(
pInfo
->
currentGroupId
>=
taosArrayGetSize
(
pTaskInfo
->
tableqinfoList
.
pGroupList
))
{
setTaskStatus
(
pTaskInfo
,
TASK_COMPLETED
);
return
NULL
;
}
SArray
*
tableList
=
taosArrayGetP
(
pTaskInfo
->
tableqinfoList
.
pGroupList
,
pInfo
->
currentGroupId
);
tsdbCleanupReadHandle
(
pInfo
->
dataReader
);
tsdbReaderT
*
pReader
=
tsdbReaderOpen
(
pInfo
->
readHandle
.
vnode
,
&
pInfo
->
cond
,
tableList
,
pInfo
->
queryId
,
pInfo
->
taskId
);
pInfo
->
dataReader
=
pReader
;
}
SSDataBlock
*
result
=
doTableScanGroup
(
pOperator
);
if
(
result
){
return
result
;
}
pInfo
->
currentGroupId
++
;
if
(
pInfo
->
currentGroupId
>=
taosArrayGetSize
(
pTaskInfo
->
tableqinfoList
.
pGroupList
))
{
setTaskStatus
(
pTaskInfo
,
TASK_COMPLETED
);
return
NULL
;
}
SArray
*
tableList
=
taosArrayGetP
(
pTaskInfo
->
tableqinfoList
.
pGroupList
,
pInfo
->
currentGroupId
);
tsdbSetTableList
(
pInfo
->
dataReader
,
tableList
);
tsdbResetReadHandle
(
pInfo
->
dataReader
,
&
pInfo
->
cond
,
0
);
pInfo
->
curTWinIdx
=
0
;
pInfo
->
scanTimes
=
0
;
result
=
doTableScanGroup
(
pOperator
);
if
(
result
){
return
result
;
}
setTaskStatus
(
pTaskInfo
,
TASK_COMPLETED
);
return
NULL
;
}
...
...
@@ -525,8 +567,8 @@ static void destroyTableScanOperatorInfo(void* param, int32_t numOfOutput) {
}
}
SOperatorInfo
*
createTableScanOperatorInfo
(
STableScanPhysiNode
*
pTableScanNode
,
tsdbReaderT
pDataReader
,
S
ReadHandle
*
readHandle
,
SExecTaskInfo
*
pTaskInfo
)
{
SOperatorInfo
*
createTableScanOperatorInfo
(
STableScanPhysiNode
*
pTableScanNode
,
SReadHandle
*
readHandle
,
S
ExecTaskInfo
*
pTaskInfo
,
uint64_t
queryId
,
uint64_t
taskId
)
{
STableScanInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
STableScanInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
if
(
pInfo
==
NULL
||
pOperator
==
NULL
)
{
...
...
@@ -561,10 +603,12 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode,
pInfo
->
dataBlockLoadFlag
=
pTableScanNode
->
dataRequired
;
pInfo
->
pResBlock
=
createResDataBlock
(
pDescNode
);
pInfo
->
pFilterNode
=
pTableScanNode
->
scan
.
node
.
pConditions
;
pInfo
->
dataReader
=
pDataReader
;
pInfo
->
scanFlag
=
MAIN_SCAN
;
pInfo
->
pColMatchInfo
=
pColList
;
pInfo
->
curTWinIdx
=
0
;
pInfo
->
queryId
=
queryId
;
pInfo
->
taskId
=
taskId
;
pInfo
->
currentGroupId
=
-
1
;
pOperator
->
name
=
"TableScanOperator"
;
// for debug purpose
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
;
...
...
@@ -778,8 +822,9 @@ static bool prepareDataScan(SStreamBlockScanInfo* pInfo) {
STableScanInfo
*
pTableScanInfo
=
pInfo
->
pSnapshotReadOp
->
info
;
pTableScanInfo
->
cond
.
twindows
[
0
]
=
win
;
pTableScanInfo
->
curTWinIdx
=
0
;
tsdbResetReadHandle
(
pTableScanInfo
->
dataReader
,
&
pTableScanInfo
->
cond
,
0
);
//
tsdbResetReadHandle(pTableScanInfo->dataReader, &pTableScanInfo->cond, 0);
pTableScanInfo
->
scanTimes
=
0
;
pTableScanInfo
->
currentGroupId
=
-
1
;
return
true
;
}
...
...
@@ -1085,9 +1130,9 @@ static SArray* extractTableIdList(const STableListInfo* pTableGroupInfo) {
return
tableIdList
;
}
SOperatorInfo
*
createStreamScanOperatorInfo
(
void
*
pDataReader
,
SReadHandle
*
pHandle
,
SOperatorInfo
*
createStreamScanOperatorInfo
(
SReadHandle
*
pHandle
,
STableScanPhysiNode
*
pTableScanNode
,
SExecTaskInfo
*
pTaskInfo
,
STimeWindowAggSupp
*
pTwSup
)
{
STimeWindowAggSupp
*
pTwSup
,
uint64_t
queryId
,
uint64_t
taskId
)
{
SStreamBlockScanInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamBlockScanInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
...
...
@@ -1127,7 +1172,7 @@ SOperatorInfo* createStreamScanOperatorInfo(void* pDataReader, SReadHandle* pHan
}
if
(
pHandle
)
{
SOperatorInfo
*
pTableScanDummy
=
createTableScanOperatorInfo
(
pTableScanNode
,
p
DataReader
,
pHandle
,
pTaskInfo
);
SOperatorInfo
*
pTableScanDummy
=
createTableScanOperatorInfo
(
pTableScanNode
,
p
Handle
,
pTaskInfo
,
queryId
,
taskId
);
STableScanInfo
*
pSTInfo
=
(
STableScanInfo
*
)
pTableScanDummy
->
info
;
if
(
pSTInfo
->
interval
.
interval
>
0
)
{
pInfo
->
pUpdateInfo
=
updateInfoInitP
(
&
pSTInfo
->
interval
,
pTwSup
->
waterMark
);
...
...
@@ -1892,6 +1937,7 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysi
pInfo
->
pRes
=
createResDataBlock
(
pDescNode
);
pInfo
->
readHandle
=
*
pReadHandle
;
pInfo
->
curPos
=
0
;
pOperator
->
name
=
"TagScanOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN
;
...
...
@@ -1917,10 +1963,7 @@ _error:
typedef
struct
STableMergeScanInfo
{
STableListInfo
*
tableListInfo
;
int32_t
tableStartIndex
;
int32_t
tableEndIndex
;
bool
hasGroupId
;
uint64_t
groupId
;
int32_t
currentGroupId
;
SArray
*
dataReaders
;
// array of tsdbReaderT*
SReadHandle
readHandle
;
...
...
@@ -1966,12 +2009,6 @@ typedef struct STableMergeScanInfo {
SSampleExecInfo
sample
;
// sample execution info
}
STableMergeScanInfo
;
int32_t
compareTableKeyInfoByGid
(
const
void
*
p1
,
const
void
*
p2
)
{
const
STableKeyInfo
*
info1
=
p1
;
const
STableKeyInfo
*
info2
=
p2
;
return
info1
->
groupId
-
info2
->
groupId
;
}
int32_t
createScanTableListInfo
(
STableScanPhysiNode
*
pTableScanNode
,
SReadHandle
*
pHandle
,
STableListInfo
*
pTableListInfo
,
uint64_t
queryId
,
uint64_t
taskId
)
{
int32_t
code
=
getTableList
(
pHandle
->
meta
,
&
pTableScanNode
->
scan
,
pTableListInfo
);
...
...
@@ -1983,55 +2020,9 @@ int32_t createScanTableListInfo(STableScanPhysiNode* pTableScanNode, SReadHandle
qDebug
(
"no table qualified for query, TID:0x%"
PRIx64
", QID:0x%"
PRIx64
,
taskId
,
queryId
);
return
TSDB_CODE_SUCCESS
;
}
SArray
*
groupKeys
=
extractPartitionColInfo
(
pTableScanNode
->
pPartitionTags
);
generateGroupIdMap
(
pTableListInfo
,
pHandle
,
groupKeys
);
// todo for json
if
(
groupKeys
)
{
taosArraySort
(
pTableListInfo
->
pTableList
,
compareTableKeyInfoByGid
);
}
taosArrayDestroy
(
groupKeys
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
doCreateMultipleDataReaders
(
STableScanPhysiNode
*
pTableScanNode
,
SReadHandle
*
pHandle
,
STableListInfo
*
pTableListInfo
,
SArray
*
arrayReader
,
uint64_t
queryId
,
uint64_t
taskId
)
{
SQueryTableDataCond
cond
=
{
0
};
int32_t
code
=
initQueryTableDataCond
(
&
cond
,
pTableScanNode
);
code
=
generateGroupIdMap
(
pTableListInfo
,
pHandle
,
pTableScanNode
->
pPartitionTags
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pTableListInfo
->
pTableList
);
++
i
)
{
STableListInfo
*
subListInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
subListInfo
));
subListInfo
->
pTableList
=
taosArrayInit
(
1
,
sizeof
(
STableKeyInfo
));
taosArrayPush
(
subListInfo
->
pTableList
,
taosArrayGet
(
pTableListInfo
->
pTableList
,
i
));
tsdbReaderT
*
pReader
=
tsdbReaderOpen
(
pHandle
->
vnode
,
&
cond
,
subListInfo
,
queryId
,
taskId
);
taosArrayPush
(
arrayReader
,
&
pReader
);
taosArrayDestroy
(
subListInfo
->
pTableList
);
taosMemoryFree
(
subListInfo
);
}
cleanupQueryTableDataCond
(
&
cond
);
return
TSDB_CODE_SUCCESS
;
_error:
return
code
;
}
int32_t
createMultipleDataReaders
(
SQueryTableDataCond
*
pQueryCond
,
SReadHandle
*
pHandle
,
STableListInfo
*
pTableListInfo
,
int32_t
tableStartIdx
,
int32_t
tableEndIdx
,
SArray
*
arrayReader
,
uint64_t
queryId
,
uint64_t
taskId
)
{
for
(
int32_t
i
=
tableStartIdx
;
i
<=
tableEndIdx
;
++
i
)
{
STableListInfo
*
subListInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
subListInfo
));
subListInfo
->
pTableList
=
taosArrayInit
(
1
,
sizeof
(
STableKeyInfo
));
taosArrayPush
(
subListInfo
->
pTableList
,
taosArrayGet
(
pTableListInfo
->
pTableList
,
i
));
tsdbReaderT
*
pReader
=
tsdbReaderOpen
(
pHandle
->
vnode
,
pQueryCond
,
subListInfo
,
queryId
,
taskId
);
taosArrayPush
(
arrayReader
,
&
pReader
);
taosArrayDestroy
(
subListInfo
->
pTableList
);
taosMemoryFree
(
subListInfo
);
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -2223,32 +2214,34 @@ SArray* generateSortByTsInfo(int32_t order) {
return
pList
;
}
static
int32_t
createMultipleDataReaders
(
SQueryTableDataCond
*
pQueryCond
,
SReadHandle
*
pHandle
,
SArray
*
tableList
,
SArray
*
arrayReader
,
uint64_t
queryId
,
uint64_t
taskId
)
{
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
tableList
);
++
i
)
{
SArray
*
tmp
=
taosArrayInit
(
1
,
sizeof
(
STableKeyInfo
));
taosArrayPush
(
tmp
,
taosArrayGet
(
tableList
,
i
));
tsdbReaderT
*
pReader
=
tsdbReaderOpen
(
pHandle
->
vnode
,
pQueryCond
,
tmp
,
queryId
,
taskId
);
taosArrayPush
(
arrayReader
,
&
pReader
);
taosArrayDestroy
(
tmp
);
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
startGroupTableMergeScan
(
SOperatorInfo
*
pOperator
)
{
STableMergeScanInfo
*
pInfo
=
pOperator
->
info
;
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
{
size_t
tableListSize
=
taosArrayGetSize
(
pInfo
->
tableListInfo
->
pTableList
);
int32_t
i
=
pInfo
->
tableStartIndex
+
1
;
for
(;
i
<
tableListSize
;
++
i
)
{
STableKeyInfo
*
tableKeyInfo
=
taosArrayGet
(
pInfo
->
tableListInfo
->
pTableList
,
i
);
if
(
tableKeyInfo
->
groupId
!=
pInfo
->
groupId
)
{
break
;
}
}
pInfo
->
tableEndIndex
=
i
-
1
;
}
int32_t
tableStartIdx
=
pInfo
->
tableStartIndex
;
int32_t
tableEndIdx
=
pInfo
->
tableEndIndex
;
SArray
*
tableList
=
taosArrayGetP
(
pInfo
->
tableListInfo
->
pGroupList
,
pInfo
->
currentGroupId
);
STableListInfo
*
tableListInfo
=
pInfo
->
tableListInfo
;
createMultipleDataReaders
(
&
pInfo
->
cond
,
&
pInfo
->
readHandle
,
tableListInfo
,
tableStartIdx
,
tableEndIdx
,
createMultipleDataReaders
(
&
pInfo
->
cond
,
&
pInfo
->
readHandle
,
tableList
,
pInfo
->
dataReaders
,
pInfo
->
queryId
,
pInfo
->
taskId
);
// todo the total available buffer should be determined by total capacity of buffer of this task.
// the additional one is reserved for merge result
pInfo
->
sortBufSize
=
pInfo
->
bufPageSize
*
(
tableEndIdx
-
tableStartIdx
+
1
+
1
);
int32_t
tableLen
=
taosArrayGetSize
(
tableList
);
pInfo
->
sortBufSize
=
pInfo
->
bufPageSize
*
((
tableLen
==
0
?
1
:
tableLen
)
+
1
);
int32_t
numOfBufPage
=
pInfo
->
sortBufSize
/
pInfo
->
bufPageSize
;
pInfo
->
pSortHandle
=
tsortCreateSortHandle
(
pInfo
->
pSortInfo
,
SORT_MULTISOURCE_MERGE
,
pInfo
->
bufPageSize
,
numOfBufPage
,
pInfo
->
pSortInputBlock
,
pTaskInfo
->
id
.
str
);
...
...
@@ -2335,37 +2328,42 @@ SSDataBlock* doTableMergeScan(SOperatorInfo* pOperator) {
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pTaskInfo
->
env
,
code
);
}
size_t
tableListSize
=
taosArrayGetSize
(
pInfo
->
tableListInfo
->
pTableList
);
if
(
!
pInfo
->
hasGroupId
)
{
pInfo
->
hasGroupId
=
true
;
if
(
tableListSize
==
0
)
{
if
(
pInfo
->
currentGroupId
==
-
1
)
{
pInfo
->
currentGroupId
++
;
if
(
pInfo
->
currentGroupId
>=
taosArrayGetSize
(
pInfo
->
tableListInfo
->
pGroupList
))
{
doSetOperatorCompleted
(
pOperator
);
return
NULL
;
}
pInfo
->
tableStartIndex
=
0
;
pInfo
->
groupId
=
((
STableKeyInfo
*
)
taosArrayGet
(
pInfo
->
tableListInfo
->
pTableList
,
pInfo
->
tableStartIndex
))
->
groupId
;
startGroupTableMergeScan
(
pOperator
);
}
SSDataBlock
*
pBlock
=
NULL
;
while
(
pInfo
->
tableStartIndex
<
tableListSize
)
{
pBlock
=
getSortedTableMergeScanBlockData
(
pInfo
->
pSortHandle
,
pOperator
->
resultInfo
.
capacity
,
pOperator
);
SSDataBlock
*
pBlock
=
getSortedTableMergeScanBlockData
(
pInfo
->
pSortHandle
,
pOperator
->
resultInfo
.
capacity
,
pOperator
);
if
(
pBlock
!=
NULL
)
{
pBlock
->
info
.
groupId
=
pInfo
->
groupId
;
uint64_t
*
groupId
=
taosHashGet
(
pInfo
->
tableListInfo
->
map
,
&
(
pBlock
->
info
.
uid
),
sizeof
(
uint64_t
));
if
(
groupId
)
pBlock
->
info
.
groupId
=
*
groupId
;
pOperator
->
resultInfo
.
totalRows
+=
pBlock
->
info
.
rows
;
return
pBlock
;
}
else
{
}
stopGroupTableMergeScan
(
pOperator
);
if
(
pInfo
->
tableEndIndex
>=
tableListSize
-
1
)
{
pInfo
->
currentGroupId
++
;
if
(
pInfo
->
currentGroupId
>=
taosArrayGetSize
(
pInfo
->
tableListInfo
->
pGroupList
))
{
doSetOperatorCompleted
(
pOperator
);
break
;
return
NULL
;
}
pInfo
->
tableStartIndex
=
pInfo
->
tableEndIndex
+
1
;
pInfo
->
groupId
=
((
STableKeyInfo
*
)
taosArrayGet
(
pInfo
->
tableListInfo
->
pTableList
,
pInfo
->
tableStartIndex
))
->
groupId
;
startGroupTableMergeScan
(
pOperator
);
pBlock
=
getSortedTableMergeScanBlockData
(
pInfo
->
pSortHandle
,
pOperator
->
resultInfo
.
capacity
,
pOperator
);
if
(
pBlock
!=
NULL
)
{
uint64_t
*
groupId
=
taosHashGet
(
pInfo
->
tableListInfo
->
map
,
&
(
pBlock
->
info
.
uid
),
sizeof
(
uint64_t
));
if
(
groupId
)
pBlock
->
info
.
groupId
=
*
groupId
;
pOperator
->
resultInfo
.
totalRows
+=
pBlock
->
info
.
rows
;
return
pBlock
;
}
}
doSetOperatorCompleted
(
pOperator
);
return
pBlock
;
}
...
...
@@ -2443,6 +2441,7 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN
pInfo
->
dataReaders
=
taosArrayInit
(
64
,
POINTER_BYTES
);
pInfo
->
queryId
=
queryId
;
pInfo
->
taskId
=
taskId
;
pInfo
->
currentGroupId
=
-
1
;
pInfo
->
sortSourceParams
=
taosArrayInit
(
64
,
sizeof
(
STableMergeScanSortSourceParam
));
...
...
source/libs/function/src/builtinsimpl.c
浏览文件 @
377bed85
...
...
@@ -264,6 +264,7 @@ typedef struct SRateInfo {
typedef
struct
SGroupKeyInfo
{
bool
hasResult
;
bool
isNull
;
char
data
[];
}
SGroupKeyInfo
;
...
...
@@ -5371,14 +5372,21 @@ int32_t groupKeyFunction(SqlFunctionCtx* pCtx) {
int32_t
bytes
=
pInputCol
->
info
.
bytes
;
int32_t
startIndex
=
pInput
->
startRowIndex
;
if
(
colDataIsNull_s
(
pInputCol
,
startIndex
))
{
pInfo
->
hasResult
=
false
;
//escape rest of data blocks to avoid first entry be overwritten.
if
(
pInfo
->
hasResult
)
{
goto
_group_key_over
;
}
if
(
colDataIsNull_s
(
pInputCol
,
startIndex
))
{
pInfo
->
isNull
=
true
;
pInfo
->
hasResult
=
true
;
goto
_group_key_over
;
}
char
*
data
=
colDataGetData
(
pInputCol
,
startIndex
);
memcpy
(
pInfo
->
data
,
data
,
bytes
);
pInfo
->
hasResult
=
true
;
_group_key_over:
...
...
@@ -5393,7 +5401,12 @@ int32_t groupKeyFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SGroupKeyInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
colDataAppend
(
pCol
,
pBlock
->
info
.
rows
,
pInfo
->
data
,
pInfo
->
hasResult
?
false
:
true
);
if
(
pInfo
->
hasResult
)
{
colDataAppend
(
pCol
,
pBlock
->
info
.
rows
,
pInfo
->
data
,
pInfo
->
isNull
?
true
:
false
);
}
else
{
pResInfo
->
numOfRes
=
0
;
}
return
pResInfo
->
numOfRes
;
}
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
377bed85
...
...
@@ -1220,6 +1220,7 @@ int32_t nodesSetValueNodeValue(SValueNode* pNode, void* value) {
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_VARCHAR
:
case
TSDB_DATA_TYPE_VARBINARY
:
case
TSDB_DATA_TYPE_JSON
:
pNode
->
datum
.
p
=
(
char
*
)
value
;
break
;
default:
...
...
source/libs/planner/src/planOptimizer.c
浏览文件 @
377bed85
...
...
@@ -1061,6 +1061,7 @@ static EDealRes partTagsOptRebuildTbanmeImpl(SNode** pNode, void* pContext) {
}
strcpy
(
pFunc
->
functionName
,
"tbname"
);
pFunc
->
funcType
=
FUNCTION_TYPE_TBNAME
;
pFunc
->
node
.
resType
=
((
SColumnNode
*
)
*
pNode
)
->
node
.
resType
;
nodesDestroyNode
(
*
pNode
);
*
pNode
=
(
SNode
*
)
pFunc
;
return
DEAL_RES_IGNORE_CHILD
;
...
...
@@ -1188,7 +1189,7 @@ static const SOptimizeRule optimizeRuleSet[] = {
{.
pName
=
"ConditionPushDown"
,
.
optimizeFunc
=
cpdOptimize
},
{.
pName
=
"OrderByPrimaryKey"
,
.
optimizeFunc
=
opkOptimize
},
{.
pName
=
"SmaIndex"
,
.
optimizeFunc
=
smaOptimize
},
//
{.pName = "PartitionTags", .optimizeFunc = partTagsOptimize},
{.
pName
=
"PartitionTags"
,
.
optimizeFunc
=
partTagsOptimize
},
{.
pName
=
"EliminateProject"
,
.
optimizeFunc
=
eliminateProjOptimize
}
};
// clang-format on
...
...
source/libs/stream/src/streamData.c
浏览文件 @
377bed85
...
...
@@ -27,11 +27,14 @@ int32_t streamDispatchReqToData(const SStreamDispatchReq* pReq, SStreamDataBlock
ASSERT
(
pReq
->
blockNum
==
taosArrayGetSize
(
pReq
->
dataLen
));
for
(
int32_t
i
=
0
;
i
<
blockNum
;
i
++
)
{
int32_t
len
=
*
(
int32_t
*
)
taosArrayGet
(
pReq
->
dataLen
,
i
);
/*int32_t len = *(int32_t*)taosArrayGet(pReq->dataLen, i);*/
SRetrieveTableRsp
*
pRetrieve
=
taosArrayGetP
(
pReq
->
data
,
i
);
SSDataBlock
*
pDataBlock
=
taosArrayGet
(
pArray
,
i
);
blockCompressDecode
(
pDataBlock
,
htonl
(
pRetrieve
->
numOfCols
),
htonl
(
pRetrieve
->
numOfRows
),
pRetrieve
->
data
);
// TODO: refactor
pDataBlock
->
info
.
window
.
skey
=
be64toh
(
pRetrieve
->
skey
);
pDataBlock
->
info
.
window
.
ekey
=
be64toh
(
pRetrieve
->
ekey
);
pDataBlock
->
info
.
type
=
pRetrieve
->
streamBlockType
;
pDataBlock
->
info
.
childId
=
pReq
->
upstreamChildId
;
}
...
...
@@ -46,8 +49,14 @@ int32_t streamRetrieveReqToData(const SStreamRetrieveReq* pReq, SStreamDataBlock
}
taosArraySetSize
(
pArray
,
1
);
SRetrieveTableRsp
*
pRetrieve
=
pReq
->
pRetrieve
;
SSDataBlock
*
pBlock
=
taosArrayGet
(
pArray
,
0
);
blockCompressDecode
(
pBlock
,
htonl
(
pRetrieve
->
numOfCols
),
htonl
(
pRetrieve
->
numOfRows
),
pRetrieve
->
data
);
SSDataBlock
*
pDataBlock
=
taosArrayGet
(
pArray
,
0
);
blockCompressDecode
(
pDataBlock
,
htonl
(
pRetrieve
->
numOfCols
),
htonl
(
pRetrieve
->
numOfRows
),
pRetrieve
->
data
);
// TODO: refactor
pDataBlock
->
info
.
window
.
skey
=
be64toh
(
pRetrieve
->
skey
);
pDataBlock
->
info
.
window
.
ekey
=
be64toh
(
pRetrieve
->
ekey
);
pDataBlock
->
info
.
type
=
pRetrieve
->
streamBlockType
;
pData
->
blocks
=
pArray
;
return
0
;
}
...
...
source/libs/stream/src/streamDispatch.c
浏览文件 @
377bed85
...
...
@@ -104,6 +104,8 @@ int32_t streamBroadcastToChildren(SStreamTask* pTask, const SSDataBlock* pBlock)
pRetrieve
->
streamBlockType
=
pBlock
->
info
.
type
;
pRetrieve
->
numOfRows
=
htonl
(
pBlock
->
info
.
rows
);
pRetrieve
->
numOfCols
=
htonl
(
numOfCols
);
pRetrieve
->
skey
=
htobe64
(
pBlock
->
info
.
window
.
skey
);
pRetrieve
->
ekey
=
htobe64
(
pBlock
->
info
.
window
.
ekey
);
int32_t
actualLen
=
0
;
blockCompressEncode
(
pBlock
,
pRetrieve
->
data
,
&
actualLen
,
numOfCols
,
false
);
...
...
@@ -171,6 +173,8 @@ static int32_t streamAddBlockToDispatchMsg(const SSDataBlock* pBlock, SStreamDis
pRetrieve
->
completed
=
1
;
pRetrieve
->
streamBlockType
=
pBlock
->
info
.
type
;
pRetrieve
->
numOfRows
=
htonl
(
pBlock
->
info
.
rows
);
pRetrieve
->
skey
=
htobe64
(
pBlock
->
info
.
window
.
skey
);
pRetrieve
->
ekey
=
htobe64
(
pBlock
->
info
.
window
.
ekey
);
int32_t
numOfCols
=
(
int32_t
)
taosArrayGetSize
(
pBlock
->
pDataBlock
);
pRetrieve
->
numOfCols
=
htonl
(
numOfCols
);
...
...
tests/script/jenkins/basic.txt
浏览文件 @
377bed85
...
...
@@ -2,12 +2,10 @@
#======================b1-start===============
# ---- user
./test.sh -f tsim/user/basic1.sim
./test.sh -f tsim/user/pass_alter.sim
./test.sh -f tsim/user/pass_len.sim
./test.sh -f tsim/user/user_len.sim
./test.sh -f tsim/user/privilege1.sim
./test.sh -f tsim/user/privilege2.sim
./test.sh -f tsim/user/basic.sim
./test.sh -f tsim/user/password.sim
./test.sh -f tsim/user/privilege_db.sim
./test.sh -f tsim/user/privilege_sysinfo.sim
## ---- db
./test.sh -f tsim/db/create_all_options.sim
...
...
@@ -135,7 +133,7 @@
./test.sh -f tsim/stable/tag_filter.sim
# --- for multi process mode
./test.sh -f tsim/user/basic
1
.sim -m
./test.sh -f tsim/user/basic.sim -m
./test.sh -f tsim/db/basic3.sim -m
./test.sh -f tsim/db/error1.sim -m
./test.sh -f tsim/insert/backquote.sim -m
...
...
tests/script/tsim/mnode/basic5.sim
浏览文件 @
377bed85
...
...
@@ -157,7 +157,7 @@ step61:
if $x == 10 then
return -1
endi
sql show mnodes
sql show mnodes
-x step61
print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
print ===> $data20 $data21 $data22 $data23 $data24 $data25
...
...
tests/script/tsim/user/basic.sim
0 → 100644
浏览文件 @
377bed85
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
print =============== step0
sql show users
if $data(root)[1] != 1 then
return -1
endi
if $data(root)[2] != 1 then
return -1
endi
if $data(root)[3] != 1 then
return -1
endi
sql alter user root pass 'taosdata'
sql_error ALTER USER root SYSINFO 0
sql_error ALTER USER root SYSINFO 1
sql_error ALTER USER root enable 0
sql_error ALTER USER root enable 1
sql_error create database db vgroups 1;
sql_error GRANT read ON db.* to root;
sql_error GRANT read ON *.* to root;
sql_error REVOKE read ON db.* from root;
sql_error REVOKE read ON *.* from root;
sql_error GRANT write ON db.* to root;
sql_error GRANT write ON *.* to root;
sql_error REVOKE write ON db.* from root;
sql_error REVOKE write ON *.* from root;
sql_error REVOKE write ON *.* from root;
sql_error GRANT all ON *.* to root;
sql_error REVOKE all ON *.* from root;
sql_error GRANT read,write ON *.* to root;
sql_error REVOKE read,write ON *.* from root;
print =============== step1: sysinfo create
sql CREATE USER u1 PASS 'taosdata' SYSINFO 0;
sql show users
if $rows != 2 then
return -1
endi
if $data(u1)[1] != 0 then
return -1
endi
if $data(u1)[2] != 1 then
return -1
endi
if $data(u1)[3] != 0 then
return -1
endi
sql CREATE USER u2 PASS 'taosdata' SYSINFO 1;
sql show users
if $rows != 3 then
return -1
endi
if $data(u2)[1] != 0 then
return -1
endi
if $data(u2)[2] != 1 then
return -1
endi
if $data(u2)[3] != 1 then
return -1
endi
print =============== step2: sysinfo alter
sql ALTER USER u1 SYSINFO 1
sql show users
if $data(u1)[1] != 0 then
return -1
endi
if $data(u1)[2] != 1 then
return -1
endi
if $data(u1)[3] != 1 then
return -1
endi
sql ALTER USER u1 SYSINFO 0
sql show users
if $data(u1)[1] != 0 then
return -1
endi
if $data(u1)[2] != 1 then
return -1
endi
if $data(u1)[3] != 0 then
return -1
endi
sql ALTER USER u1 SYSINFO 0
sql ALTER USER u1 SYSINFO 0
sql drop user u1
sql show users
if $rows != 2 then
return -1
endi
print =============== step3: enable alter
sql ALTER USER u2 enable 0
sql show users
if $rows != 2 then
return -1
endi
if $data(u2)[1] != 0 then
return -1
endi
if $data(u2)[2] != 0 then
return -1
endi
if $data(u2)[3] != 1 then
return -1
endi
sql ALTER USER u2 enable 1
sql show users
if $data(u2)[1] != 0 then
return -1
endi
if $data(u2)[2] != 1 then
return -1
endi
if $data(u2)[3] != 1 then
return -1
endi
sql ALTER USER u2 enable 1
sql ALTER USER u2 enable 1
print =============== restart taosd
system sh/exec.sh -n dnode1 -s stop
system sh/exec.sh -n dnode1 -s start
print =============== step4: enable privilege
sql show users
if $rows != 2 then
return -1
endi
if $data(u2)[1] != 0 then
return -1
endi
if $data(u2)[2] != 1 then
return -1
endi
if $data(u2)[3] != 1 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
tests/script/tsim/user/basic1.sim
已删除
100644 → 0
浏览文件 @
54283f87
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
print =============== show users
sql show users
if $rows != 1 then
return -1
endi
print $data[0][0] $data[0][1] $data[0][2]
print $data[1][0] $data[1][1] $data[1][2]
print $data[2][0] $data[1][2] $data[2][2]
sql_error show accounts;
sql_error create account a pass "a"
sql_error drop account a
sql_error drop account root
print =============== create user1
sql create user user1 PASS 'user1'
sql show users
if $rows != 2 then
return -1
endi
print $data[0][0] $data[0][1] $data[0][2]
print $data[1][0] $data[1][1] $data[1][2]
print $data[2][0] $data[1][2] $data[2][2]
print $data[3][0] $data[3][1] $data[3][2]
print =============== create user2
sql create user user2 PASS 'user2'
sql show users
if $rows != 3 then
return -1
endi
print $data[0][0] $data[0][1] $data[0][2]
print $data[1][0] $data[1][1] $data[1][2]
print $data[2][0] $data[1][2] $data[2][2]
print $data[3][0] $data[3][1] $data[3][2]
print $data40 $data41 $data42
print =============== drop user1
sql drop user user1
sql show users
if $rows != 2 then
return -1
endi
print $data[0][0] $data[0][1] $data[0][2]
print $data[1][0] $data[1][1] $data[1][2]
print $data[2][0] $data[1][2] $data[2][2]
print $data[3][0] $data[3][1] $data[3][2]
print =============== restart taosd
system sh/exec.sh -n dnode1 -s stop
sleep 1000
system sh/exec.sh -n dnode1 -s start
print =============== show users
sql show users
if $rows != 2 then
return -1
endi
print $data[0][0] $data[0][1] $data[0][2]
print $data[1][0] $data[1][1] $data[1][2]
print $data[2][0] $data[1][2] $data[2][2]
print $data[3][0] $data[3][1] $data[3][2]
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/tsim/user/pass_len.sim
已删除
100644 → 0
浏览文件 @
54283f87
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
$i = 0
$dbPrefix = apdb
$tbPrefix = aptb
$db = $dbPrefix . $i
$tb = $tbPrefix . $i
$userPrefix = apusr
print =============== step1
$i = 0
$user = $userPrefix . $i
sql drop user $user -x step11
return -1
step11:
sql create user $user PASS -x step12
return -1
step12:
sql create user $user PASS 'taosdata'
sql show users
if $rows != 2 then
return -1
endi
print =============== step2
$i = 1
$user = $userPrefix . $i
sql drop user $user -x step2
step2:
sql create user $user PASS '1'
sql show users
if $rows != 3 then
return -1
endi
print =============== step3
$i = 2
$user = $userPrefix . $i
sql drop user $user -x step3
step3:
sql create user $user PASS 'abc0123456789'
sql show users
if $rows != 4 then
return -1
endi
print =============== step4
$i = 3
$user = $userPrefix . $i
sql create user $user PASS 'abcd012345678901234567891234567890abcd012345678901234567891234567890abcd012345678901234567891234567890abcd012345678901234567891234567890123' -x step4
return -1
step4:
sql show users
if $rows != 4 then
return -1
endi
$i = 0
while $i < 3
$user = $userPrefix . $i
sql drop user $user
$i = $i + 1
endw
sql show users
if $rows != 1 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
tests/script/tsim/user/pass
_alter
.sim
→
tests/script/tsim/user/pass
word
.sim
浏览文件 @
377bed85
...
...
@@ -16,14 +16,12 @@ if $rows != 3 then
endi
print ============= step2
sql close
sleep 2500
print user u_read login
sql close
sql connect u_read
sql alter user u_read pass 'taosdata'
sql alter user u_write pass 'taosdata1' -x step2
return -1
step2:
sql_error alter user u_write pass 'taosdata1'
sql_error create user read1 pass 'taosdata1'
sql_error create user write1 pass 'taosdata1'
...
...
@@ -34,17 +32,14 @@ if $rows != 3 then
endi
print ============= step3
sql close
sleep 2500
print user u_write login
sql close
sql connect u_write
sql_error create user read2 pass 'taosdata1'
sql_error create user write2 pass 'taosdata1'
sql alter user u_write pass 'taosdata'
sql alter user u_read pass 'taosdata' -x step3
return -1
step3:
sql_error alter user u_read pass 'taosdata'
sql show users
if $rows != 3 then
...
...
@@ -52,15 +47,41 @@ if $rows != 3 then
endi
print ============= step4
sql close
sleep 2500
print user root login
sql close
sql connect
sql create user oroot pass 'taosdata'
sql_error create user $user PASS 'abcd012345678901234567891234567890abcd012345678901234567891234567890abcd012345678901234567891234567890abcd012345678901234567891234567890123'
sql_error create userabcd012345678901234567891234567890abcd01234567890123456789123456789 PASS 'taosdata'
sql_error create user abcd0123456789012345678901234567890111 PASS '123'
sql create user abc01234567890123456789 PASS '123'
sql show users
if $rows !=
4
then
if $rows !=
5
then
return -1
endi
print ============= step5
sql create database db vgroups 1
sql_error ALTER USER o_root SYSINFO 0
sql_error ALTER USER o_root SYSINFO 1
sql_error ALTER USER o_root enable 0
sql_error ALTER USER o_root enable 1
sql_error create database db vgroups 1;
sql_error GRANT read ON db.* to o_root;
sql_error GRANT read ON *.* to o_root;
sql_error REVOKE read ON db.* from o_root;
sql_error REVOKE read ON *.* from o_root;
sql_error GRANT write ON db.* to o_root;
sql_error GRANT write ON *.* to o_root;
sql_error REVOKE write ON db.* from o_root;
sql_error REVOKE write ON *.* from o_root;
sql_error REVOKE write ON *.* from o_root;
sql_error GRANT all ON *.* to o_root;
sql_error REVOKE all ON *.* from o_root;
sql_error GRANT read,write ON *.* to o_root;
sql_error REVOKE read,write ON *.* from o_root;
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
tests/script/tsim/user/privilege2.sim
已删除
100644 → 0
浏览文件 @
54283f87
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
print =============== show users
sql create database d1 vgroups 1;
sql create database d2 vgroups 1;
sql create database d3 vgroups 1;
sql show databases
if $rows != 5 then
return -1
endi
print =============== create users
sql create user user1 PASS 'taosdata'
sql create user user2 PASS 'taosdata'
sql show users
if $rows != 3 then
return -1
endi
sql GRANT read ON d1.* to user1;
sql GRANT write ON d2.* to user1;
print =============== re connect
sql close
sleep 2500
print user user1 login
sql connect user1
sql_error drop database d1;
sql_error drop database d2;
sql_error create stable d1.st (ts timestamp, i int) tags (j int)
sql create stable d2.st (ts timestamp, i int) tags (j int)
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
tests/script/tsim/user/privilege
1
.sim
→
tests/script/tsim/user/privilege
_db
.sim
浏览文件 @
377bed85
...
...
@@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
print ===============
show users
print ===============
create db
sql create database d1 vgroups 1;
sql create database d2 vgroups 1;
sql create database d3 vgroups 1;
...
...
@@ -68,4 +68,26 @@ sql REVOKE read,write ON d1.* from user1;
sql REVOKE read,write ON d2.* from user1;
sql REVOKE read,write ON *.* from user1;
print =============== create users
sql create user u1 PASS 'taosdata'
sql show users
if $rows != 4 then
return -1
endi
sql GRANT read ON d1.* to u1;
sql GRANT write ON d2.* to u1;
print =============== re connect
print user u1 login
sql close
sql connect u1
sql_error drop database d1;
sql_error drop database d2;
sql_error create stable d1.st (ts timestamp, i int) tags (j int)
sql create stable d2.st (ts timestamp, i int) tags (j int)
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/tsim/user/privilege_sysinfo.sim
0 → 100644
浏览文件 @
377bed85
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
print =============== create user and login
sql create user sysinfo0 pass 'taosdata'
sql create user sysinfo1 pass 'taosdata'
sql alter user sysinfo0 sysinfo 0
sql alter user sysinfo1 sysinfo 1
print user sysinfo0 login
sql close
sql connect sysinfo0
system sh/exec.sh -n dnode1 -s stop
return
print =============== check oper
sql_error create user u1 pass 'u1'
sql_error drop user sysinfo1
sql_error alter user sysinfo1 pass '1'
sql_error alter user sysinfo0 pass '1'
sql_error create dnode $hostname port 7200
sql_error drop dnode 1
sql_error create qnode on dnode 1
sql_error drop qnode on dnode 1
sql_error create mnode on dnode 1
sql_error drop mnode on dnode 1
sql_error create snode on dnode 1
sql_error drop snode on dnode 1
sql_error redistribute vgroup 2 dnode 1 dnode 2
sql_error balance vgroup
sql_error kill transaction 1
sql_error kill connection 1
sql_error kill query 1
print =============== check db
sql_error create database db
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
tests/script/tsim/user/user_len.sim
已删除
100644 → 0
浏览文件 @
54283f87
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
$i = 0
$dbPrefix = lm_us_db
$tbPrefix = lm_us_tb
$db = $dbPrefix . $i
$tb = $tbPrefix . $i
print =============== step1
sql drop user ac -x step0
return -1
step0:
sql create user PASS '123' -x step1
return -1
step1:
sql show users
if $rows != 1 then
return -1
endi
print =============== step2
sql drop user a -x step2
step2:
sql create user a PASS '123'
sql show users
if $rows != 2 then
return -1
endi
sql drop user a
sql show users
if $rows != 1 then
return -1
endi
print =============== step3
sql drop user abc01234567890123456789 -x step3
step3:
sql create user abc01234567890123456789 PASS '123'
sql show users
if $rows != 2 then
return -1
endi
sql drop user abc01234567890123456789
sql show users
if $rows != 1 then
return -1
endi
print =============== step4
sql create user abcd0123456789012345678901234567890111 PASS '123' -x step4
return -1
step4:
sql show users
if $rows != 1 then
return -1
endi
print =============== step5
sql drop user 123 -x step5
step5:
sql create user 123 PASS '123' -x step61
return -1
step61:
sql create user a123 PASS '123'
sql show users
if $rows != 2 then
return -1
endi
sql drop user a123
sql show users
if $rows != 1 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
tests/system-test/2-query/json_tag.py
浏览文件 @
377bed85
...
...
@@ -412,52 +412,59 @@ class TDTestCase:
tdSql
.
checkColNameList
(
res
,
cname_list
)
#
# test group by & order by json tag
tdSql
.
query
(
"select ts,jtag->'tag1' from jsons1 partition by jtag->'tag1' order by jtag->'tag1' desc"
)
tdSql
.
checkRows
(
11
)
tdSql
.
checkData
(
0
,
1
,
'"femail"'
)
tdSql
.
checkData
(
2
,
1
,
'"收到货"'
)
tdSql
.
checkData
(
7
,
1
,
"false"
)
# tdSql.error("select count(*) from jsons1 group by jtag")
# tdSql.error("select count(*) from jsons1 partition by jtag")
# tdSql.error("select count(*) from jsons1 group by jtag order by jtag")
tdSql
.
error
(
"select count(*) from jsons1 group by jtag->'tag1' order by jtag->'tag2'"
)
tdSql
.
error
(
"select count(*) from jsons1 group by jtag->'tag1' order by jtag"
)
tdSql
.
query
(
"select count(*),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1' desc"
)
tdSql
.
checkRows
(
8
)
tdSql
.
checkData
(
0
,
0
,
2
)
tdSql
.
checkData
(
0
,
1
,
'"femail"'
)
tdSql
.
checkData
(
1
,
0
,
2
)
tdSql
.
checkData
(
1
,
1
,
'"收到货"'
)
tdSql
.
checkData
(
2
,
0
,
1
)
tdSql
.
checkData
(
2
,
1
,
"11.000000000"
)
tdSql
.
checkData
(
5
,
0
,
1
)
tdSql
.
checkData
(
5
,
1
,
"false"
)
tdSql
.
checkData
(
6
,
0
,
1
)
tdSql
.
checkData
(
6
,
1
,
"null"
)
tdSql
.
checkData
(
7
,
0
,
2
)
tdSql
.
checkData
(
7
,
1
,
None
)
tdSql
.
query
(
"select count(*),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1' asc"
)
tdSql
.
checkRows
(
8
)
tdSql
.
checkData
(
0
,
0
,
2
)
tdSql
.
checkData
(
0
,
1
,
None
)
tdSql
.
checkData
(
2
,
0
,
1
)
tdSql
.
checkData
(
2
,
1
,
"false"
)
tdSql
.
checkData
(
5
,
0
,
1
)
tdSql
.
checkData
(
5
,
1
,
"11.000000000"
)
tdSql
.
checkData
(
7
,
0
,
2
)
tdSql
.
checkData
(
7
,
1
,
'"femail"'
)
#
tdSql.query("select count(*),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1' desc")
#
tdSql.checkRows(8)
#
tdSql.checkData(0, 0, 2)
#
tdSql.checkData(0, 1, '"femail"')
#
tdSql.checkData(1, 0, 2)
#
tdSql.checkData(1, 1, '"收到货"')
#
tdSql.checkData(2, 0, 1)
#
tdSql.checkData(2, 1, "11.000000000")
#
tdSql.checkData(5, 0, 1)
#
tdSql.checkData(5, 1, "false")
#
tdSql.checkData(6, 0, 1)
#
tdSql.checkData(6, 1, "null")
#
tdSql.checkData(7, 0, 2)
#
tdSql.checkData(7, 1, None)
#
tdSql.query("select count(*),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1' asc")
#
tdSql.checkRows(8)
#
tdSql.checkData(0, 0, 2)
#
tdSql.checkData(0, 1, None)
#
tdSql.checkData(2, 0, 1)
#
tdSql.checkData(2, 1, "false")
#
tdSql.checkData(5, 0, 1)
#
tdSql.checkData(5, 1, "11.000000000")
#
tdSql.checkData(7, 0, 2)
#
tdSql.checkData(7, 1, '"femail"')
#
# test stddev with group by json tag
tdSql
.
query
(
"select stddev(dataint),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1'"
)
tdSql
.
checkRows
(
8
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
checkData
(
0
,
1
,
None
)
tdSql
.
checkData
(
4
,
0
,
0
)
tdSql
.
checkData
(
4
,
1
,
"5.000000000"
)
tdSql
.
checkData
(
7
,
0
,
11
)
tdSql
.
checkData
(
7
,
1
,
'"femail"'
)
res
=
tdSql
.
getColNameList
(
"select stddev(dataint),jsons1.jtag->'tag1' from jsons1 group by jsons1.jtag->'tag1' order by jtag->'tag1'"
)
cname_list
=
[]
cname_list
.
append
(
"stddev(dataint)"
)
cname_list
.
append
(
"jsons1.jtag->'tag1'"
)
tdSql
.
checkColNameList
(
res
,
cname_list
)
#
tdSql.query("select stddev(dataint),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1'")
#
tdSql.checkRows(8)
#
tdSql.checkData(0, 0, 10)
#
tdSql.checkData(0, 1, None)
#
tdSql.checkData(4, 0, 0)
#
tdSql.checkData(4, 1, "5.000000000")
#
tdSql.checkData(7, 0, 11)
#
tdSql.checkData(7, 1, '"femail"')
#
#
res = tdSql.getColNameList("select stddev(dataint),jsons1.jtag->'tag1' from jsons1 group by jsons1.jtag->'tag1' order by jtag->'tag1'")
#
cname_list = []
#
cname_list.append("stddev(dataint)")
#
cname_list.append("jsons1.jtag->'tag1'")
#
tdSql.checkColNameList(res, cname_list)
# test top/bottom with group by json tag
# tdSql.query("select top(dataint,2),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1'")
...
...
@@ -470,8 +477,8 @@ class TDTestCase:
# tdSql.checkData(10, 1, '"femail"')
# test having
tdSql
.
query
(
"select count(*),jtag->'tag1' from jsons1 group by jtag->'tag1' having count(*) > 1"
)
tdSql
.
checkRows
(
3
)
#
tdSql.query("select count(*),jtag->'tag1' from jsons1 group by jtag->'tag1' having count(*) > 1")
#
tdSql.checkRows(3)
# subquery with json tag
tdSql
.
query
(
"select * from (select jtag, dataint from jsons1) order by dataint"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录