Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4c04b155
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
4c04b155
编写于
4月 11, 2023
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
差异文件
merge main
上级
ed286e63
28ea375f
变更
124
展开全部
隐藏空白更改
内联
并排
Showing
124 changed file
with
6925 addition
and
5420 deletion
+6925
-5420
include/common/tcommon.h
include/common/tcommon.h
+1
-4
include/common/tglobal.h
include/common/tglobal.h
+1
-0
include/common/tmsg.h
include/common/tmsg.h
+19
-7
include/common/ttokendef.h
include/common/ttokendef.h
+67
-67
include/libs/catalog/catalog.h
include/libs/catalog/catalog.h
+10
-6
include/libs/executor/executor.h
include/libs/executor/executor.h
+3
-3
include/libs/nodes/cmdnodes.h
include/libs/nodes/cmdnodes.h
+2
-0
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+1
-0
include/libs/stream/tstream.h
include/libs/stream/tstream.h
+4
-55
include/libs/wal/wal.h
include/libs/wal/wal.h
+2
-2
include/util/taoserror.h
include/util/taoserror.h
+2
-0
include/util/tdef.h
include/util/tdef.h
+1
-0
include/util/tqueue.h
include/util/tqueue.h
+8
-8
packaging/tools/install.sh
packaging/tools/install.sh
+35
-0
packaging/tools/makepkg.sh
packaging/tools/makepkg.sh
+2
-3
packaging/tools/remove.sh
packaging/tools/remove.sh
+21
-1
source/client/inc/clientLog.h
source/client/inc/clientLog.h
+1
-0
source/client/inc/clientStmt.h
source/client/inc/clientStmt.h
+4
-0
source/client/src/clientEnv.c
source/client/src/clientEnv.c
+1
-0
source/client/src/clientSml.c
source/client/src/clientSml.c
+2
-2
source/client/src/clientStmt.c
source/client/src/clientStmt.c
+19
-3
source/client/src/clientTmq.c
source/client/src/clientTmq.c
+24
-23
source/client/test/clientTests.cpp
source/client/test/clientTests.cpp
+6
-4
source/common/src/systable.c
source/common/src/systable.c
+3
-1
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+3
-2
source/common/src/tglobal.c
source/common/src/tglobal.c
+7
-0
source/common/src/tmsg.c
source/common/src/tmsg.c
+131
-1
source/dnode/mnode/impl/inc/mndConsumer.h
source/dnode/mnode/impl/inc/mndConsumer.h
+2
-2
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+3
-0
source/dnode/mnode/impl/inc/mndStb.h
source/dnode/mnode/impl/inc/mndStb.h
+1
-0
source/dnode/mnode/impl/inc/mndUser.h
source/dnode/mnode/impl/inc/mndUser.h
+1
-0
source/dnode/mnode/impl/src/mndConsumer.c
source/dnode/mnode/impl/src/mndConsumer.c
+3
-11
source/dnode/mnode/impl/src/mndPrivilege.c
source/dnode/mnode/impl/src/mndPrivilege.c
+1
-0
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+7
-0
source/dnode/mnode/impl/src/mndUser.c
source/dnode/mnode/impl/src/mndUser.c
+383
-5
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+2
-9
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+5
-5
source/dnode/vnode/src/meta/metaSnapshot.c
source/dnode/vnode/src/meta/metaSnapshot.c
+2
-2
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+91
-108
source/dnode/vnode/src/tq/tqPush.c
source/dnode/vnode/src/tq/tqPush.c
+29
-28
source/dnode/vnode/src/tq/tqRead.c
source/dnode/vnode/src/tq/tqRead.c
+27
-421
source/dnode/vnode/src/tq/tqScan.c
source/dnode/vnode/src/tq/tqScan.c
+33
-84
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+52
-53
source/dnode/vnode/src/tsdb/tsdbUtil.c
source/dnode/vnode/src/tsdb/tsdbUtil.c
+12
-23
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+1
-0
source/libs/catalog/CMakeLists.txt
source/libs/catalog/CMakeLists.txt
+2
-2
source/libs/catalog/inc/catalogInt.h
source/libs/catalog/inc/catalogInt.h
+148
-133
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+21
-32
source/libs/catalog/src/ctgAsync.c
source/libs/catalog/src/ctgAsync.c
+34
-37
source/libs/catalog/src/ctgCache.c
source/libs/catalog/src/ctgCache.c
+85
-89
source/libs/catalog/src/ctgUtil.c
source/libs/catalog/src/ctgUtil.c
+145
-3
source/libs/catalog/test/CMakeLists.txt
source/libs/catalog/test/CMakeLists.txt
+1
-1
source/libs/catalog/test/catalogTests.cpp
source/libs/catalog/test/catalogTests.cpp
+79
-86
source/libs/executor/inc/dataSinkInt.h
source/libs/executor/inc/dataSinkInt.h
+0
-1
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+6
-27
source/libs/executor/src/aggregateoperator.c
source/libs/executor/src/aggregateoperator.c
+12
-2
source/libs/executor/src/dataSinkMgt.c
source/libs/executor/src/dataSinkMgt.c
+0
-1
source/libs/executor/src/executor.c
source/libs/executor/src/executor.c
+23
-26
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+11
-9
source/libs/executor/src/projectoperator.c
source/libs/executor/src/projectoperator.c
+5
-23
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+51
-77
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+1
-0
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+4
-3
source/libs/parser/inc/parAst.h
source/libs/parser/inc/parAst.h
+9
-2
source/libs/parser/inc/parUtil.h
source/libs/parser/inc/parUtil.h
+2
-4
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+11
-7
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+16
-6
source/libs/parser/src/parAstParser.c
source/libs/parser/src/parAstParser.c
+41
-9
source/libs/parser/src/parAuthenticator.c
source/libs/parser/src/parAuthenticator.c
+130
-23
source/libs/parser/src/parInsertSml.c
source/libs/parser/src/parInsertSml.c
+6
-0
source/libs/parser/src/parInsertSql.c
source/libs/parser/src/parInsertSql.c
+130
-9
source/libs/parser/src/parInsertUtil.c
source/libs/parser/src/parInsertUtil.c
+3
-3
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+61
-8
source/libs/parser/src/parUtil.c
source/libs/parser/src/parUtil.c
+51
-37
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+3386
-3407
source/libs/parser/test/mockCatalog.cpp
source/libs/parser/test/mockCatalog.cpp
+4
-6
source/libs/parser/test/mockCatalogService.cpp
source/libs/parser/test/mockCatalogService.cpp
+2
-2
source/libs/parser/test/parInitialCTest.cpp
source/libs/parser/test/parInitialCTest.cpp
+5
-5
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+12
-0
source/libs/scheduler/inc/schInt.h
source/libs/scheduler/inc/schInt.h
+2
-3
source/libs/scheduler/src/schFlowCtrl.c
source/libs/scheduler/src/schFlowCtrl.c
+12
-12
source/libs/scheduler/src/scheduler.c
source/libs/scheduler/src/scheduler.c
+4
-2
source/libs/stream/src/stream.c
source/libs/stream/src/stream.c
+62
-12
source/libs/stream/src/streamData.c
source/libs/stream/src/streamData.c
+37
-25
source/libs/stream/src/streamExec.c
source/libs/stream/src/streamExec.c
+4
-3
source/libs/sync/inc/syncPipeline.h
source/libs/sync/inc/syncPipeline.h
+20
-20
source/libs/sync/src/syncAppendEntriesReply.c
source/libs/sync/src/syncAppendEntriesReply.c
+1
-1
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+4
-4
source/libs/sync/src/syncPipeline.c
source/libs/sync/src/syncPipeline.c
+46
-46
source/libs/sync/src/syncReplication.c
source/libs/sync/src/syncReplication.c
+2
-2
source/libs/sync/src/syncUtil.c
source/libs/sync/src/syncUtil.c
+2
-2
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+2
-0
source/libs/wal/src/walRead.c
source/libs/wal/src/walRead.c
+6
-11
source/util/src/terror.c
source/util/src/terror.c
+2
-0
tests/develop-test/5-taos-tools/taosbenchmark/default_json.py
...s/develop-test/5-taos-tools/taosbenchmark/default_json.py
+2
-2
tests/develop-test/5-taos-tools/taosbenchmark/json/default.json
...develop-test/5-taos-tools/taosbenchmark/json/default.json
+6
-1
tests/parallel_test/cases.task
tests/parallel_test/cases.task
+2
-1
tests/pytest/util/autogen.py
tests/pytest/util/autogen.py
+1
-1
tests/script/api/batchprepare.c
tests/script/api/batchprepare.c
+50
-1
tests/script/tsim/query/multi_order_by.sim
tests/script/tsim/query/multi_order_by.sim
+57
-0
tests/script/tsim/tmq/basic1.sim
tests/script/tsim/tmq/basic1.sim
+9
-9
tests/script/tsim/tmq/basic1Of2Cons.sim
tests/script/tsim/tmq/basic1Of2Cons.sim
+21
-21
tests/script/tsim/tmq/basic2.sim
tests/script/tsim/tmq/basic2.sim
+9
-9
tests/script/tsim/tmq/basic2Of2Cons.sim
tests/script/tsim/tmq/basic2Of2Cons.sim
+21
-21
tests/script/tsim/tmq/basic2Of2ConsOverlap.sim
tests/script/tsim/tmq/basic2Of2ConsOverlap.sim
+46
-46
tests/script/tsim/tmq/basic3.sim
tests/script/tsim/tmq/basic3.sim
+12
-12
tests/script/tsim/tmq/basic3Of2Cons.sim
tests/script/tsim/tmq/basic3Of2Cons.sim
+20
-20
tests/script/tsim/tmq/basic4.sim
tests/script/tsim/tmq/basic4.sim
+9
-9
tests/script/tsim/tmq/basic4Of2Cons.sim
tests/script/tsim/tmq/basic4Of2Cons.sim
+20
-20
tests/system-test/0-others/user_control.py
tests/system-test/0-others/user_control.py
+2
-2
tests/system-test/2-query/interp.py
tests/system-test/2-query/interp.py
+2
-0
tests/system-test/7-tmq/subscribeStb.py
tests/system-test/7-tmq/subscribeStb.py
+2
-2
tests/system-test/7-tmq/subscribeStb0.py
tests/system-test/7-tmq/subscribeStb0.py
+7
-7
tests/system-test/7-tmq/subscribeStb1.py
tests/system-test/7-tmq/subscribeStb1.py
+2
-2
tests/system-test/7-tmq/subscribeStb2.py
tests/system-test/7-tmq/subscribeStb2.py
+6
-3
tests/system-test/7-tmq/subscribeStb3.py
tests/system-test/7-tmq/subscribeStb3.py
+17
-13
tests/system-test/7-tmq/subscribeStb4.py
tests/system-test/7-tmq/subscribeStb4.py
+2
-2
tests/system-test/7-tmq/tmqDelete-1ctb.py
tests/system-test/7-tmq/tmqDelete-1ctb.py
+11
-15
tests/system-test/runAllOne.sh
tests/system-test/runAllOne.sh
+688
-0
tests/system-test/test.py
tests/system-test/test.py
+69
-3
tools/shell/src/shellArguments.c
tools/shell/src/shellArguments.c
+0
-12
utils/test/c/CMakeLists.txt
utils/test/c/CMakeLists.txt
+8
-0
utils/test/c/sml_test.c
utils/test/c/sml_test.c
+22
-20
utils/test/c/tmqOffset.c
utils/test/c/tmqOffset.c
+64
-0
未找到文件。
include/common/tcommon.h
浏览文件 @
4c04b155
...
...
@@ -208,15 +208,12 @@ typedef struct SSDataBlock {
}
SSDataBlock
;
enum
{
FETCH_TYPE__DATA
=
1
,
FETCH_TYPE__META
,
FETCH_TYPE__SEP
,
FETCH_TYPE__DATA
=
0
,
FETCH_TYPE__NONE
,
};
typedef
struct
{
int8_t
fetchType
;
STqOffsetVal
offset
;
union
{
SSDataBlock
data
;
void
*
meta
;
...
...
include/common/tglobal.h
浏览文件 @
4c04b155
...
...
@@ -104,6 +104,7 @@ extern int32_t tsCacheLazyLoadThreshold; // cost threshold for last/last_row lo
// query client
extern
int32_t
tsQueryPolicy
;
extern
int32_t
tsQueryRspPolicy
;
extern
int64_t
tsQueryMaxConcurrentTables
;
extern
int32_t
tsQuerySmaOptimize
;
extern
int32_t
tsQueryRsmaTolerance
;
extern
bool
tsQueryPlannerTrace
;
...
...
include/common/tmsg.h
浏览文件 @
4c04b155
...
...
@@ -177,6 +177,12 @@ typedef enum _mgmt_table {
#define TSDB_ALTER_USER_SYSINFO 0xA
#define TSDB_ALTER_USER_ADD_SUBSCRIBE_TOPIC 0xB
#define TSDB_ALTER_USER_REMOVE_SUBSCRIBE_TOPIC 0xC
#define TSDB_ALTER_USER_ADD_READ_TABLE 0xD
#define TSDB_ALTER_USER_REMOVE_READ_TABLE 0xE
#define TSDB_ALTER_USER_ADD_WRITE_TABLE 0xF
#define TSDB_ALTER_USER_REMOVE_WRITE_TABLE 0x10
#define TSDB_ALTER_USER_ADD_ALL_TABLE 0x11
#define TSDB_ALTER_USER_REMOVE_ALL_TABLE 0x12
#define TSDB_ALTER_USER_PRIVILEGES 0x2
...
...
@@ -669,13 +675,16 @@ int32_t tSerializeSCreateUserReq(void* buf, int32_t bufLen, SCreateUserReq* pReq
int32_t
tDeserializeSCreateUserReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateUserReq
*
pReq
);
typedef
struct
{
int8_t
alterType
;
int8_t
superUser
;
int8_t
sysInfo
;
int8_t
enable
;
char
user
[
TSDB_USER_LEN
];
char
pass
[
TSDB_USET_PASSWORD_LEN
];
char
objname
[
TSDB_DB_FNAME_LEN
];
// db or topic
int8_t
alterType
;
int8_t
superUser
;
int8_t
sysInfo
;
int8_t
enable
;
char
user
[
TSDB_USER_LEN
];
char
pass
[
TSDB_USET_PASSWORD_LEN
];
char
objname
[
TSDB_DB_FNAME_LEN
];
// db or topic
char
tabName
[
TSDB_TABLE_NAME_LEN
];
char
*
tagCond
;
int32_t
tagCondLen
;
}
SAlterUserReq
;
int32_t
tSerializeSAlterUserReq
(
void
*
buf
,
int32_t
bufLen
,
SAlterUserReq
*
pReq
);
...
...
@@ -698,6 +707,9 @@ typedef struct {
SHashObj
*
createdDbs
;
SHashObj
*
readDbs
;
SHashObj
*
writeDbs
;
SHashObj
*
readTbs
;
SHashObj
*
writeTbs
;
SHashObj
*
useDbs
;
}
SGetUserAuthRsp
;
int32_t
tSerializeSGetUserAuthRsp
(
void
*
buf
,
int32_t
bufLen
,
SGetUserAuthRsp
*
pRsp
);
...
...
include/common/ttokendef.h
浏览文件 @
4c04b155
...
...
@@ -63,55 +63,55 @@
#define TK_READ 45
#define TK_WRITE 46
#define TK_NK_DOT 47
#define TK_
DNODE
48
#define TK_
PORT
49
#define TK_
DNODES
50
#define TK_
NK_IPTOKEN
51
#define TK_
FORCE
52
#define TK_
LOCAL
53
#define TK_
QNODE
54
#define TK_
B
NODE 55
#define TK_
S
NODE 56
#define TK_
M
NODE 57
#define TK_
DATABASE
58
#define TK_
USE
59
#define TK_
FLUSH
60
#define TK_
TRIM
61
#define TK_
COMPACT
62
#define TK_
IF
63
#define TK_
NOT
64
#define TK_
EXISTS
65
#define TK_
BUFFER
66
#define TK_
CACHEMODEL
67
#define TK_CACHE
SIZE
68
#define TK_C
OMP
69
#define TK_
DURATION
70
#define TK_
NK_VARIABLE
71
#define TK_
MAXROWS
72
#define TK_M
IN
ROWS 73
#define TK_
KEEP
74
#define TK_
PAGES
75
#define TK_PAGES
IZE
76
#define TK_
TSDB_PAGESIZE
77
#define TK_
PRECISION
78
#define TK_
REPLICA
79
#define TK_
VGROUPS
80
#define TK_
SINGLE_STABLE
81
#define TK_
RETENTIONS
82
#define TK_
SCHEMALES
S 83
#define TK_
WAL_LEVEL
84
#define TK_WAL_
FSYNC_PERIOD
85
#define TK_WAL_
RETENTION_PERIOD
86
#define TK_WAL_RETENTION_
SIZE
87
#define TK_WAL_R
OLL_PERIOD
88
#define TK_WAL_
SEGMENT_SIZE
89
#define TK_
STT_TRIGGER
90
#define TK_
TABLE_PREFIX
91
#define TK_TABLE_
SUF
FIX 92
#define TK_
NK_COLON
93
#define TK_
MAX_SPEED
94
#define TK_
START
95
#define TK_
WITH
96
#define TK_
WITH
48
#define TK_
DNODE
49
#define TK_
PORT
50
#define TK_
DNODES
51
#define TK_
NK_IPTOKEN
52
#define TK_
FORCE
53
#define TK_
LOCAL
54
#define TK_
Q
NODE 55
#define TK_
B
NODE 56
#define TK_
S
NODE 57
#define TK_
MNODE
58
#define TK_
DATABASE
59
#define TK_
USE
60
#define TK_
FLUSH
61
#define TK_
TRIM
62
#define TK_
COMPACT
63
#define TK_
IF
64
#define TK_
NOT
65
#define TK_
EXISTS
66
#define TK_
BUFFER
67
#define TK_CACHE
MODEL
68
#define TK_C
ACHESIZE
69
#define TK_
COMP
70
#define TK_
DURATION
71
#define TK_
NK_VARIABLE
72
#define TK_M
AX
ROWS 73
#define TK_
MINROWS
74
#define TK_
KEEP
75
#define TK_PAGES
76
#define TK_
PAGESIZE
77
#define TK_
TSDB_PAGESIZE
78
#define TK_
PRECISION
79
#define TK_
REPLICA
80
#define TK_
VGROUPS
81
#define TK_
SINGLE_STABLE
82
#define TK_
RETENTION
S 83
#define TK_
SCHEMALESS
84
#define TK_WAL_
LEVEL
85
#define TK_WAL_
FSYNC_PERIOD
86
#define TK_WAL_RETENTION_
PERIOD
87
#define TK_WAL_R
ETENTION_SIZE
88
#define TK_WAL_
ROLL_PERIOD
89
#define TK_
WAL_SEGMENT_SIZE
90
#define TK_
STT_TRIGGER
91
#define TK_TABLE_
PRE
FIX 92
#define TK_
TABLE_SUFFIX
93
#define TK_
NK_COLON
94
#define TK_
MAX_SPEED
95
#define TK_
START
96
#define TK_TIMESTAMP 97
#define TK_END 98
#define TK_TABLE 99
...
...
@@ -127,24 +127,24 @@
#define TK_NK_EQ 109
#define TK_USING 110
#define TK_TAGS 111
#define TK_
COMMENT
112
#define TK_
BOOL
113
#define TK_
TINYINT
114
#define TK_
SMALLINT
115
#define TK_INT
116
#define TK_
INTEGER
117
#define TK_
BIGINT
118
#define TK_
FLOAT
119
#define TK_
DOUBLE
120
#define TK_
BINARY
121
#define TK_
NCHAR
122
#define TK_
UNSIGNED
123
#define TK_
JSON
124
#define TK_
VARCHAR
125
#define TK_
MEDIUMBLOB
126
#define TK_
BLOB
127
#define TK_
VARBINARY
128
#define TK_
DECIMAL
129
#define TK_
BOOL
112
#define TK_
TINYINT
113
#define TK_
SMALLINT
114
#define TK_
INT
115
#define TK_INT
EGER
116
#define TK_
BIGINT
117
#define TK_
FLOAT
118
#define TK_
DOUBLE
119
#define TK_
BINARY
120
#define TK_
NCHAR
121
#define TK_
UNSIGNED
122
#define TK_
JSON
123
#define TK_
VARCHAR
124
#define TK_
MEDIUMBLOB
125
#define TK_
BLOB
126
#define TK_
VARBINARY
127
#define TK_
DECIMAL
128
#define TK_
COMMENT
129
#define TK_MAX_DELAY 130
#define TK_WATERMARK 131
#define TK_ROLLUP 132
...
...
include/libs/catalog/catalog.h
浏览文件 @
4c04b155
...
...
@@ -29,6 +29,7 @@ extern "C" {
#include "tmsg.h"
#include "tname.h"
#include "transport.h"
#include "nodes.h"
typedef
struct
SCatalog
SCatalog
;
...
...
@@ -49,10 +50,15 @@ typedef enum {
typedef
struct
SUserAuthInfo
{
char
user
[
TSDB_USER_LEN
];
char
dbFName
[
TSDB_DB_FNAME_LEN
]
;
SName
tbName
;
AUTH_TYPE
type
;
}
SUserAuthInfo
;
typedef
struct
SUserAuthRes
{
bool
pass
;
SNode
*
pCond
;
}
SUserAuthRes
;
typedef
struct
SDbInfo
{
int32_t
vgVer
;
int32_t
tbNum
;
...
...
@@ -96,7 +102,7 @@ typedef struct SMetaData {
SArray
*
pTableIndex
;
// pRes = SArray<STableIndexInfo>*
SArray
*
pUdfList
;
// pRes = SFuncInfo*
SArray
*
pIndex
;
// pRes = SIndexInfo*
SArray
*
pUser
;
// pRes =
bool
*
SArray
*
pUser
;
// pRes =
SUserAuthRes
*
SArray
*
pQnodeList
;
// pRes = SArray<SQueryNodeLoad>*
SArray
*
pTableCfg
;
// pRes = STableCfg*
SArray
*
pDnodeList
;
// pRes = SArray<SEpSet>*
...
...
@@ -312,11 +318,9 @@ int32_t catalogUpdateTableIndex(SCatalog* pCtg, STableIndexRsp* pRsp);
int32_t
catalogGetUdfInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
funcName
,
SFuncInfo
*
pInfo
);
int32_t
catalogChkAuth
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
user
,
const
char
*
dbFName
,
AUTH_TYPE
type
,
bool
*
pass
);
int32_t
catalogChkAuth
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SUserAuthInfo
*
pAuth
,
SUserAuthRes
*
pRes
);
int32_t
catalogChkAuthFromCache
(
SCatalog
*
pCtg
,
const
char
*
user
,
const
char
*
dbFName
,
AUTH_TYPE
type
,
bool
*
pass
,
bool
*
exists
);
int32_t
catalogChkAuthFromCache
(
SCatalog
*
pCtg
,
SUserAuthInfo
*
pAuth
,
SUserAuthRes
*
pRes
,
bool
*
exists
);
int32_t
catalogUpdateUserAuthInfo
(
SCatalog
*
pCtg
,
SGetUserAuthRsp
*
pAuth
);
...
...
include/libs/executor/executor.h
浏览文件 @
4c04b155
...
...
@@ -199,11 +199,11 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
//
int32_t
qStreamSetScanMemData
(
qTaskInfo_t
tinfo
,
SPackedData
submit
);
int32_t
qStreamExtractOffset
(
qTaskInfo_t
tinfo
,
STqOffsetVal
*
pOffset
);
void
qStreamSetOpen
(
qTaskInfo_t
tinfo
);
SMqMetaRsp
*
qStreamExtractMetaMsg
(
qTaskInfo_t
tinfo
);
void
qStreamExtractOffset
(
qTaskInfo_t
tinfo
,
STqOffsetVal
*
pOffset
);
int64_t
qStreamExtractPrepareUid
(
qTaskInfo_t
tinfo
);
SMqMetaRsp
*
qStreamExtractMetaMsg
(
qTaskInfo_t
tinfo
);
const
SSchemaWrapper
*
qExtractSchemaFromTask
(
qTaskInfo_t
tinfo
);
...
...
include/libs/nodes/cmdnodes.h
浏览文件 @
4c04b155
...
...
@@ -458,7 +458,9 @@ typedef struct SGrantStmt {
ENodeType
type
;
char
userName
[
TSDB_USER_LEN
];
char
objName
[
TSDB_DB_NAME_LEN
];
// db or topic
char
tabName
[
TSDB_TABLE_NAME_LEN
];
int64_t
privileges
;
SNode
*
pTagCond
;
}
SGrantStmt
;
typedef
SGrantStmt
SRevokeStmt
;
...
...
include/libs/nodes/querynodes.h
浏览文件 @
4c04b155
...
...
@@ -298,6 +298,7 @@ typedef struct SSelectStmt {
bool
hasUniqueFunc
;
bool
hasTailFunc
;
bool
hasInterpFunc
;
bool
hasInterpPseudoColFunc
;
bool
hasLastRowFunc
;
bool
hasLastFunc
;
bool
hasTimeLineFunc
;
...
...
include/libs/stream/tstream.h
浏览文件 @
4c04b155
...
...
@@ -223,27 +223,12 @@ static FORCE_INLINE void* streamQueueCurItem(SStreamQueue* queue) {
return
queue
->
qItem
;
}
static
FORCE_INLINE
void
*
streamQueueNextItem
(
SStreamQueue
*
queue
)
{
int8_t
dequeueFlag
=
atomic_exchange_8
(
&
queue
->
status
,
STREAM_QUEUE__PROCESSING
);
if
(
dequeueFlag
==
STREAM_QUEUE__FAILED
)
{
ASSERT
(
queue
->
qItem
!=
NULL
);
return
streamQueueCurItem
(
queue
);
}
else
{
queue
->
qItem
=
NULL
;
taosGetQitem
(
queue
->
qall
,
&
queue
->
qItem
);
if
(
queue
->
qItem
==
NULL
)
{
taosReadAllQitems
(
queue
->
queue
,
queue
->
qall
);
taosGetQitem
(
queue
->
qall
,
&
queue
->
qItem
);
}
return
streamQueueCurItem
(
queue
);
}
}
void
*
streamQueueNextItem
(
SStreamQueue
*
queue
);
SStreamDataSubmit2
*
streamDataSubmitNew
(
SPackedData
submit
);
void
streamDataSubmitDestroy
(
SStreamDataSubmit2
*
pDataSubmit
);
void
streamDataSubmitRefDec
(
SStreamDataSubmit2
*
pDataSubmit
);
SStreamDataSubmit2
*
streamSubmitRefClone
(
SStreamDataSubmit2
*
pSubmit
);
SStreamDataSubmit2
*
streamSubmitBlockClone
(
SStreamDataSubmit2
*
pSubmit
);
typedef
struct
{
char
*
qmsg
;
...
...
@@ -371,43 +356,7 @@ SStreamTask* tNewSStreamTask(int64_t streamId);
int32_t
tEncodeSStreamTask
(
SEncoder
*
pEncoder
,
const
SStreamTask
*
pTask
);
int32_t
tDecodeSStreamTask
(
SDecoder
*
pDecoder
,
SStreamTask
*
pTask
);
void
tFreeSStreamTask
(
SStreamTask
*
pTask
);
static
FORCE_INLINE
int32_t
streamTaskInput
(
SStreamTask
*
pTask
,
SStreamQueueItem
*
pItem
)
{
int8_t
type
=
pItem
->
type
;
if
(
type
==
STREAM_INPUT__DATA_SUBMIT
)
{
SStreamDataSubmit2
*
pSubmitClone
=
streamSubmitRefClone
((
SStreamDataSubmit2
*
)
pItem
);
if
(
pSubmitClone
==
NULL
)
{
qDebug
(
"task %d %p submit enqueue failed since out of memory"
,
pTask
->
taskId
,
pTask
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
atomic_store_8
(
&
pTask
->
inputStatus
,
TASK_INPUT_STATUS__FAILED
);
return
-
1
;
}
qDebug
(
"task %d %p submit enqueue %p %p %p %d %"
PRId64
,
pTask
->
taskId
,
pTask
,
pItem
,
pSubmitClone
,
pSubmitClone
->
submit
.
msgStr
,
pSubmitClone
->
submit
.
msgLen
,
pSubmitClone
->
submit
.
ver
);
taosWriteQitem
(
pTask
->
inputQueue
->
queue
,
pSubmitClone
);
// qStreamInput(pTask->exec.executor, pSubmitClone);
}
else
if
(
type
==
STREAM_INPUT__DATA_BLOCK
||
type
==
STREAM_INPUT__DATA_RETRIEVE
||
type
==
STREAM_INPUT__REF_DATA_BLOCK
)
{
taosWriteQitem
(
pTask
->
inputQueue
->
queue
,
pItem
);
// qStreamInput(pTask->exec.executor, pItem);
}
else
if
(
type
==
STREAM_INPUT__CHECKPOINT
)
{
taosWriteQitem
(
pTask
->
inputQueue
->
queue
,
pItem
);
// qStreamInput(pTask->exec.executor, pItem);
}
else
if
(
type
==
STREAM_INPUT__GET_RES
)
{
taosWriteQitem
(
pTask
->
inputQueue
->
queue
,
pItem
);
// qStreamInput(pTask->exec.executor, pItem);
}
if
(
type
!=
STREAM_INPUT__GET_RES
&&
type
!=
STREAM_INPUT__CHECKPOINT
&&
pTask
->
triggerParam
!=
0
)
{
atomic_val_compare_exchange_8
(
&
pTask
->
triggerStatus
,
TASK_TRIGGER_STATUS__INACTIVE
,
TASK_TRIGGER_STATUS__ACTIVE
);
}
#if 0
// TODO: back pressure
atomic_store_8(&pTask->inputStatus, TASK_INPUT_STATUS__NORMAL);
#endif
return
0
;
}
int32_t
tAppendDataForStream
(
SStreamTask
*
pTask
,
SStreamQueueItem
*
pItem
);
static
FORCE_INLINE
void
streamTaskInputFail
(
SStreamTask
*
pTask
)
{
atomic_store_8
(
&
pTask
->
inputStatus
,
TASK_INPUT_STATUS__FAILED
);
...
...
include/libs/wal/wal.h
浏览文件 @
4c04b155
...
...
@@ -146,8 +146,8 @@ typedef struct {
int64_t
curFileFirstVer
;
int64_t
curVersion
;
int64_t
capacity
;
int8_t
curInvalid
;
int8_t
curStopped
;
//
int8_t curInvalid;
//
int8_t curStopped;
TdThreadMutex
mutex
;
SWalFilterCond
cond
;
// TODO remove it
...
...
include/util/taoserror.h
浏览文件 @
4c04b155
...
...
@@ -242,6 +242,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_MND_INVALID_ALTER_OPER TAOS_DEF_ERROR_CODE(0, 0x0356)
#define TSDB_CODE_MND_AUTH_FAILURE TAOS_DEF_ERROR_CODE(0, 0x0357)
#define TSDB_CODE_MND_USER_NOT_AVAILABLE TAOS_DEF_ERROR_CODE(0, 0x0358)
#define TSDB_CODE_MND_PRIVILEDGE_EXIST TAOS_DEF_ERROR_CODE(0, 0x0359)
// mnode-stable-part1
#define TSDB_CODE_MND_STB_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0360)
...
...
@@ -762,6 +763,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_TMQ_INVALID_MSG TAOS_DEF_ERROR_CODE(0, 0x4000)
#define TSDB_CODE_TMQ_CONSUMER_MISMATCH TAOS_DEF_ERROR_CODE(0, 0x4001)
#define TSDB_CODE_TMQ_CONSUMER_CLOSED TAOS_DEF_ERROR_CODE(0, 0x4002)
#define TSDB_CODE_TMQ_CONSUMER_ERROR TAOS_DEF_ERROR_CODE(0, 0x4003)
// stream
#define TSDB_CODE_STREAM_TASK_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x4100)
...
...
include/util/tdef.h
浏览文件 @
4c04b155
...
...
@@ -198,6 +198,7 @@ typedef enum ELogicConditionType {
#define TSDB_STREAM_NAME_LEN 193 // it is a null-terminated string
#define TSDB_DB_NAME_LEN 65
#define TSDB_DB_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
#define TSDB_PRIVILEDGE_CONDITION_LEN 200
#define TSDB_FUNC_NAME_LEN 65
#define TSDB_FUNC_COMMENT_LEN 1024 * 1024
...
...
include/util/tqueue.h
浏览文件 @
4c04b155
...
...
@@ -61,7 +61,7 @@ typedef void (*FItems)(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfItems);
typedef
struct
STaosQnode
STaosQnode
;
typedef
struct
STaosQnode
{
struct
STaosQnode
{
STaosQnode
*
next
;
STaosQueue
*
queue
;
int64_t
timestamp
;
...
...
@@ -70,9 +70,9 @@ typedef struct STaosQnode {
int8_t
itype
;
int8_t
reserved
[
3
];
char
item
[];
}
STaosQnode
;
};
typedef
struct
STaosQueue
{
struct
STaosQueue
{
STaosQnode
*
head
;
STaosQnode
*
tail
;
STaosQueue
*
next
;
// for queue set
...
...
@@ -84,22 +84,22 @@ typedef struct STaosQueue {
int64_t
memOfItems
;
int32_t
numOfItems
;
int64_t
threadId
;
}
STaosQueue
;
};
typedef
struct
STaosQset
{
struct
STaosQset
{
STaosQueue
*
head
;
STaosQueue
*
current
;
TdThreadMutex
mutex
;
tsem_t
sem
;
int32_t
numOfQueues
;
int32_t
numOfItems
;
}
STaosQset
;
};
typedef
struct
STaosQall
{
struct
STaosQall
{
STaosQnode
*
current
;
STaosQnode
*
start
;
int32_t
numOfItems
;
}
STaosQall
;
};
STaosQueue
*
taosOpenQueue
();
void
taosCloseQueue
(
STaosQueue
*
queue
);
...
...
packaging/tools/install.sh
浏览文件 @
4c04b155
...
...
@@ -572,6 +572,19 @@ function install_config() {
done
}
function
install_share_etc
()
{
for
c
in
`
ls
${
script_dir
}
/share/etc/
`
;
do
if
[
-e
/etc/
$c
]
;
then
out
=
/etc/
$c
.new.
`
date
+%F
`
${
csudo
}
cp
-f
${
script_dir
}
/share/etc/
$c
$out
else
${
csudo
}
cp
-f
${
script_dir
}
/share/etc/
$c
/etc/
$c
fi
done
${
csudo
}
cp
${
script_dir
}
/share/srv/
*
${
service_config_dir
}
}
function
install_log
()
{
${
csudo
}
rm
-rf
${
log_dir
}
||
:
${
csudo
}
mkdir
-p
${
log_dir
}
&&
${
csudo
}
chmod
777
${
log_dir
}
...
...
@@ -687,11 +700,33 @@ function clean_service_on_systemd() {
# if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then
# ${csudo}rm -f ${service_config_dir}/${serverName2}.service
# fi
x_service_config
=
"
${
service_config_dir
}
/
${
xName2
}
.service"
if
[
-e
"
$x_service_config
"
]
;
then
if
systemctl is-active
--quiet
${
xName2
}
;
then
echo
"
${
productName2
}
${
xName2
}
is running, stopping it..."
${
csudo
}
systemctl stop
${
xName2
}
&>/dev/null
||
echo
&>/dev/null
fi
${
csudo
}
systemctl disable
${
xName2
}
&>/dev/null
||
echo
&>/dev/null
${
csudo
}
rm
-f
${
x_service_config
}
fi
explorer_service_config
=
"
${
service_config_dir
}
/
${
explorerName2
}
.service"
if
[
-e
"
$explorer_service_config
"
]
;
then
if
systemctl is-active
--quiet
${
explorerName2
}
;
then
echo
"
${
productName2
}
${
explorerName2
}
is running, stopping it..."
${
csudo
}
systemctl stop
${
explorerName2
}
&>/dev/null
||
echo
&>/dev/null
fi
${
csudo
}
systemctl disable
${
explorerName2
}
&>/dev/null
||
echo
&>/dev/null
${
csudo
}
rm
-f
${
explorer_service_config
}
${
csudo
}
rm
-f
/etc/
${
clientName2
}
/explorer.toml
fi
}
function
install_service_on_systemd
()
{
clean_service_on_systemd
install_share_etc
[
-f
${
script_dir
}
/cfg/
${
serverName2
}
.service
]
&&
${
csudo
}
cp
${
script_dir
}
/cfg/
${
serverName2
}
.service
\
${
service_config_dir
}
/
||
:
...
...
packaging/tools/makepkg.sh
浏览文件 @
4c04b155
...
...
@@ -51,11 +51,9 @@ fi
if
[
-d
${
top_dir
}
/tools/taos-tools/packaging/deb
]
;
then
cd
${
top_dir
}
/tools/taos-tools/packaging/deb
taostools_ver
=
$(
git
for
-each-ref
--sort
=
taggerdate
--format
'%(tag)'
refs/tags|grep
-v
taos |
tail
-1
)
[
-z
"
$taos_tools_ver
"
]
&&
taos_tools_ver
=
"0.1.0"
taostools_ver
=
$(
git
for
-each-ref
--sort
=
taggerdate
--format
'%(tag)'
refs/tags|grep
-v
taos |
tail
-1
)
[
-z
"
$taostools_ver
"
]
&&
taostools_ver
=
"0.1.0"
taostools_install_dir
=
"
${
release_dir
}
/
${
clientName2
}
Tools-
${
taostools_ver
}
"
cd
${
curr_dir
}
...
...
@@ -152,6 +150,7 @@ fi
mkdir
-p
${
install_dir
}
/bin
&&
cp
${
bin_files
}
${
install_dir
}
/bin
&&
chmod
a+x
${
install_dir
}
/bin/
*
||
:
mkdir
-p
${
install_dir
}
/init.d
&&
cp
${
init_file_deb
}
${
install_dir
}
/init.d/
${
serverName
}
.deb
mkdir
-p
${
install_dir
}
/init.d
&&
cp
${
init_file_rpm
}
${
install_dir
}
/init.d/
${
serverName
}
.rpm
mkdir
-p
${
install_dir
}
/share
&&
cp
-rf
${
build_dir
}
/share/
{
etc,srv
}
${
install_dir
}
/share
if
[
$adapterName
!=
"taosadapter"
]
;
then
mv
${
install_dir
}
/cfg/
${
clientName2
}
adapter.toml
${
install_dir
}
/cfg/
$adapterName
.toml
...
...
packaging/tools/remove.sh
浏览文件 @
4c04b155
...
...
@@ -192,7 +192,27 @@ function clean_service_on_systemd() {
${
csudo
}
systemctl stop
${
tarbitrator_service_name
}
&>/dev/null
||
echo
&>/dev/null
fi
${
csudo
}
systemctl disable
${
tarbitrator_service_name
}
&>/dev/null
||
echo
&>/dev/null
${
csudo
}
rm
-f
${
tarbitratord_service_config
}
x_service_config
=
"
${
service_config_dir
}
/
${
xName2
}
.service"
if
[
-e
"
$x_service_config
"
]
;
then
if
systemctl is-active
--quiet
${
xName2
}
;
then
echo
"
${
productName2
}
${
xName2
}
is running, stopping it..."
${
csudo
}
systemctl stop
${
xName2
}
&>/dev/null
||
echo
&>/dev/null
fi
${
csudo
}
systemctl disable
${
xName2
}
&>/dev/null
||
echo
&>/dev/null
${
csudo
}
rm
-f
${
x_service_config
}
fi
explorer_service_config
=
"
${
service_config_dir
}
/
${
explorerName2
}
.service"
if
[
-e
"
$explorer_service_config
"
]
;
then
if
systemctl is-active
--quiet
${
explorerName2
}
;
then
echo
"
${
productName2
}
${
explorerName2
}
is running, stopping it..."
${
csudo
}
systemctl stop
${
explorerName2
}
&>/dev/null
||
echo
&>/dev/null
fi
${
csudo
}
systemctl disable
${
explorerName2
}
&>/dev/null
||
echo
&>/dev/null
${
csudo
}
rm
-f
${
explorer_service_config
}
${
csudo
}
rm
-f
/etc/
${
clientName2
}
/explorer.toml
fi
}
function
clean_service_on_sysvinit
()
{
...
...
source/client/inc/clientLog.h
浏览文件 @
4c04b155
...
...
@@ -26,6 +26,7 @@ extern "C" {
#define tscFatal(...) do { if (cDebugFlag & DEBUG_FATAL) { taosPrintLog("TSC FATAL ", DEBUG_FATAL, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscError(...) do { if (cDebugFlag & DEBUG_ERROR) { taosPrintLog("TSC ERROR ", DEBUG_ERROR, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscWarn(...) do { if (cDebugFlag & DEBUG_WARN) { taosPrintLog("TSC WARN ", DEBUG_WARN, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscWarnL(...) do { if (cDebugFlag & DEBUG_WARN) { taosPrintLongString("TSC WARN ", DEBUG_WARN, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscInfo(...) do { if (cDebugFlag & DEBUG_INFO) { taosPrintLog("TSC ", DEBUG_INFO, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscDebug(...) do { if (cDebugFlag & DEBUG_DEBUG) { taosPrintLog("TSC ", DEBUG_DEBUG, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscTrace(...) do { if (cDebugFlag & DEBUG_TRACE) { taosPrintLog("TSC ", DEBUG_TRACE, cDebugFlag, __VA_ARGS__); }} while(0)
...
...
source/client/inc/clientStmt.h
浏览文件 @
4c04b155
...
...
@@ -102,6 +102,7 @@ typedef struct STscStmt {
SStmtBindInfo
bInfo
;
int64_t
reqid
;
int32_t
errCode
;
}
STscStmt
;
extern
char
*
gStmtStatusStr
[];
...
...
@@ -121,6 +122,7 @@ extern char *gStmtStatusStr[];
int32_t _code = c; \
if (_code != TSDB_CODE_SUCCESS) { \
terrno = _code; \
pStmt->errCode = _code; \
return _code; \
} \
} while (0)
...
...
@@ -129,6 +131,7 @@ extern char *gStmtStatusStr[];
int32_t _code = c; \
if (_code != TSDB_CODE_SUCCESS) { \
terrno = _code; \
pStmt->errCode = _code; \
} \
return _code; \
} while (0)
...
...
@@ -137,6 +140,7 @@ extern char *gStmtStatusStr[];
code = c; \
if (code != TSDB_CODE_SUCCESS) { \
terrno = code; \
pStmt->errCode = code; \
goto _return; \
} \
} while (0)
...
...
source/client/src/clientEnv.c
浏览文件 @
4c04b155
...
...
@@ -107,6 +107,7 @@ static void deregisterRequest(SRequestObj *pRequest) {
if
(
duration
>=
SLOW_QUERY_INTERVAL
)
{
atomic_add_fetch_64
((
int64_t
*
)
&
pActivity
->
numOfSlowQueries
,
1
);
tscWarnL
(
"slow query: %s, duration:%"
PRId64
,
pRequest
->
sqlstr
,
duration
);
}
releaseTscObj
(
pTscObj
->
id
);
...
...
source/client/src/clientSml.c
浏览文件 @
4c04b155
...
...
@@ -174,6 +174,7 @@ static int32_t smlParseTableName(SArray *tags, char *childTableName) {
if
(
childTableNameLen
==
tag
->
keyLen
&&
strncmp
(
tag
->
key
,
tsSmlChildTableName
,
tag
->
keyLen
)
==
0
)
{
memset
(
childTableName
,
0
,
TSDB_TABLE_NAME_LEN
);
strncpy
(
childTableName
,
tag
->
value
,
(
tag
->
length
<
TSDB_TABLE_NAME_LEN
?
tag
->
length
:
TSDB_TABLE_NAME_LEN
));
taosArrayRemove
(
tags
,
i
);
break
;
}
}
...
...
@@ -533,8 +534,7 @@ static int32_t smlGenerateSchemaAction(SSchema *colField, SHashObj *colHash, SSm
uint16_t
*
index
=
colHash
?
(
uint16_t
*
)
taosHashGet
(
colHash
,
kv
->
key
,
kv
->
keyLen
)
:
NULL
;
if
(
index
)
{
if
(
colField
[
*
index
].
type
!=
kv
->
type
)
{
uError
(
"SML:0x%"
PRIx64
" point type and db type mismatch. key: %s. point type: %d, db type: %d"
,
info
->
id
,
kv
->
key
,
colField
[
*
index
].
type
,
kv
->
type
);
uError
(
"SML:0x%"
PRIx64
" point type and db type mismatch. point type: %d, db type: %d, key: %s"
,
info
->
id
,
colField
[
*
index
].
type
,
kv
->
type
,
kv
->
key
);
return
TSDB_CODE_TSC_INVALID_VALUE
;
}
...
...
source/client/src/clientStmt.c
浏览文件 @
4c04b155
...
...
@@ -32,8 +32,14 @@ int32_t stmtSwitchStatus(STscStmt* pStmt, STMT_STATUS newStatus) {
STMT_LOG_SEQ
(
newStatus
);
}
if
(
pStmt
->
errCode
&&
newStatus
!=
STMT_PREPARE
)
{
STMT_DLOG
(
"stmt already failed with err: %s"
,
tstrerror
(
pStmt
->
errCode
));
return
pStmt
->
errCode
;
}
switch
(
newStatus
)
{
case
STMT_PREPARE
:
pStmt
->
errCode
=
0
;
break
;
case
STMT_SETTBNAME
:
if
(
STMT_STATUS_EQ
(
INIT
)
||
STMT_STATUS_EQ
(
BIND
)
||
STMT_STATUS_EQ
(
BIND_COL
))
{
...
...
@@ -197,7 +203,10 @@ int32_t stmtGetExecInfo(TAOS_STMT* stmt, SHashObj** pVgHash, SHashObj** pBlockHa
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
*
pVgHash
=
pStmt
->
sql
.
pVgHash
;
pStmt
->
sql
.
pVgHash
=
NULL
;
*
pBlockHash
=
pStmt
->
exec
.
pBlockHash
;
pStmt
->
exec
.
pBlockHash
=
NULL
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -325,6 +334,8 @@ int32_t stmtCleanExecInfo(STscStmt* pStmt, bool keepTable, bool deepClean) {
}
int32_t
stmtCleanSQLInfo
(
STscStmt
*
pStmt
)
{
STMT_DLOG_E
(
"start to free SQL info"
);
taosMemoryFree
(
pStmt
->
sql
.
queryRes
.
fields
);
taosMemoryFree
(
pStmt
->
sql
.
queryRes
.
userFields
);
taosMemoryFree
(
pStmt
->
sql
.
sqlStr
);
...
...
@@ -351,6 +362,8 @@ int32_t stmtCleanSQLInfo(STscStmt* pStmt) {
memset
(
&
pStmt
->
sql
,
0
,
sizeof
(
pStmt
->
sql
));
STMT_DLOG_E
(
"end to free SQL info"
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -441,11 +454,10 @@ int32_t stmtGetFromCache(STscStmt* pStmt) {
.
mgmtEps
=
getEpSet_s
(
&
pStmt
->
taos
->
pAppInfo
->
mgmtEp
)};
int32_t
code
=
catalogGetTableMeta
(
pStmt
->
pCatalog
,
&
conn
,
&
pStmt
->
bInfo
.
sname
,
&
pTableMeta
);
if
(
TSDB_CODE_PAR_TABLE_NOT_EXIST
==
code
)
{
STMT_ERR_RET
(
stmtCleanBindInfo
(
pStmt
));
tscDebug
(
"tb %s not exist"
,
pStmt
->
bInfo
.
tbFName
);
stmtCleanBindInfo
(
pStmt
);
return
TSDB_CODE_SUCCESS
;
STMT_ERR_RET
(
code
)
;
}
STMT_ERR_RET
(
code
);
...
...
@@ -922,9 +934,13 @@ _return:
int
stmtClose
(
TAOS_STMT
*
stmt
)
{
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
STMT_DLOG_E
(
"start to free stmt"
);
stmtCleanSQLInfo
(
pStmt
);
taosMemoryFree
(
stmt
);
STMT_DLOG_E
(
"stmt freed"
);
return
TSDB_CODE_SUCCESS
;
}
...
...
source/client/src/clientTmq.c
浏览文件 @
4c04b155
...
...
@@ -98,17 +98,16 @@ struct tmq_t {
int64_t
totalRows
;
// timer
tmr_h
hbLiveTimer
;
tmr_h
epTimer
;
tmr_h
reportTimer
;
tmr_h
commitTimer
;
STscObj
*
pTscObj
;
// connection
SArray
*
clientTopics
;
// SArray<SMqClientTopic>
STaosQueue
*
mqueue
;
// queue of rsp
STaosQall
*
qall
;
STaosQueue
*
delayedTask
;
// delayed task queue for heartbeat and auto commit
TdThreadMutex
lock
;
// used to protect the operation on each topic, when updating the epsets.
tsem_t
rspSem
;
tmr_h
hbLiveTimer
;
tmr_h
epTimer
;
tmr_h
reportTimer
;
tmr_h
commitTimer
;
STscObj
*
pTscObj
;
// connection
SArray
*
clientTopics
;
// SArray<SMqClientTopic>
STaosQueue
*
mqueue
;
// queue of rsp
STaosQall
*
qall
;
STaosQueue
*
delayedTask
;
// delayed task queue for heartbeat and auto commit
tsem_t
rspSem
;
};
typedef
struct
SAskEpInfo
{
...
...
@@ -188,7 +187,6 @@ typedef struct {
SMqClientVg
*
pVg
;
SMqClientTopic
*
pTopic
;
int32_t
vgId
;
tsem_t
rspSem
;
uint64_t
requestId
;
// request id for debug purpose
}
SMqPollCbParam
;
...
...
@@ -979,7 +977,6 @@ void tmqFreeImpl(void* handle) {
taosFreeQall
(
tmq
->
qall
);
tsem_destroy
(
&
tmq
->
rspSem
);
taosThreadMutexDestroy
(
&
tmq
->
lock
);
taosArrayDestroyEx
(
tmq
->
clientTopics
,
freeClientVgImpl
);
taos_close_internal
(
tmq
->
pTscObj
);
...
...
@@ -1024,7 +1021,6 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
pTmq
->
delayedTask
=
taosOpenQueue
();
pTmq
->
qall
=
taosAllocateQall
();
taosThreadMutexInit
(
&
pTmq
->
lock
,
NULL
);
if
(
pTmq
->
clientTopics
==
NULL
||
pTmq
->
mqueue
==
NULL
||
pTmq
->
qall
==
NULL
||
pTmq
->
delayedTask
==
NULL
||
conf
->
groupId
[
0
]
==
0
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -1155,6 +1151,7 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
};
if
(
tsem_init
(
&
param
.
rspSem
,
0
,
0
)
!=
0
)
{
code
=
TSDB_CODE_TSC_INTERNAL_ERROR
;
goto
FAIL
;
}
...
...
@@ -1190,6 +1187,8 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
int32_t
retryCnt
=
0
;
while
(
TSDB_CODE_MND_CONSUMER_NOT_READY
==
doAskEp
(
tmq
))
{
if
(
retryCnt
++
>
MAX_RETRY_COUNT
)
{
tscError
(
"consumer:0x%"
PRIx64
", mnd not ready for subscribe, retry:%d in 500ms"
,
tmq
->
consumerId
,
retryCnt
);
code
=
TSDB_CODE_TSC_INTERNAL_ERROR
;
goto
FAIL
;
}
...
...
@@ -1233,7 +1232,6 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) {
tmq_t
*
tmq
=
taosAcquireRef
(
tmqMgmt
.
rsetId
,
refId
);
if
(
tmq
==
NULL
)
{
tsem_destroy
(
&
pParam
->
rspSem
);
taosMemoryFree
(
pParam
);
taosMemoryFree
(
pMsg
->
pData
);
taosMemoryFree
(
pMsg
->
pEpSet
);
...
...
@@ -1270,6 +1268,8 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) {
pRspWrapper
->
tmqRspType
=
TMQ_MSG_TYPE__END_RSP
;
taosWriteQitem
(
tmq
->
mqueue
,
pRspWrapper
);
}
else
if
(
code
==
TSDB_CODE_WAL_LOG_NOT_EXIST
)
{
// poll data while insert
taosMsleep
(
500
);
}
goto
CREATE_MSG_FAIL
;
...
...
@@ -1346,8 +1346,9 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) {
taosMemoryFree
(
pMsg
->
pData
);
taosWriteQitem
(
tmq
->
mqueue
,
pRspWrapper
);
int32_t
total
=
taosQueueItemSize
(
tmq
->
mqueue
);
tscDebug
(
"consumer:0x%"
PRIx64
" put poll res into mqueue, type:%d, vgId:%d, total in queue:%d, reqId:0x%"
PRIx64
,
tmq
->
consumerId
,
rspType
,
vgId
,
t
mq
->
mqueue
->
numOfItems
,
requestId
);
tmq
->
consumerId
,
rspType
,
vgId
,
t
otal
,
requestId
);
tsem_post
(
&
tmq
->
rspSem
);
taosReleaseRef
(
tmqMgmt
.
rsetId
,
refId
);
...
...
@@ -1422,7 +1423,7 @@ static void freeClientVgInfo(void* param) {
taosArrayDestroy
(
pTopic
->
vgs
);
}
static
bool
tmqUpdate
Ep
(
tmq_t
*
tmq
,
int32_t
epoch
,
const
SMqAskEpRsp
*
pRsp
)
{
static
bool
doUpdateLocal
Ep
(
tmq_t
*
tmq
,
int32_t
epoch
,
const
SMqAskEpRsp
*
pRsp
)
{
bool
set
=
false
;
int32_t
topicNumCur
=
taosArrayGetSize
(
tmq
->
clientTopics
);
...
...
@@ -1431,6 +1432,9 @@ static bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, const SMqAskEpRsp* pRsp) {
char
vgKey
[
TSDB_TOPIC_FNAME_LEN
+
22
];
tscDebug
(
"consumer:0x%"
PRIx64
" update ep epoch from %d to epoch %d, incoming topics:%d, existed topics:%d"
,
tmq
->
consumerId
,
tmq
->
epoch
,
epoch
,
topicNumGet
,
topicNumCur
);
if
(
epoch
<=
tmq
->
epoch
)
{
return
false
;
}
SArray
*
newTopics
=
taosArrayInit
(
topicNumGet
,
sizeof
(
SMqClientTopic
));
if
(
newTopics
==
NULL
)
{
...
...
@@ -1474,14 +1478,11 @@ static bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, const SMqAskEpRsp* pRsp) {
taosHashCleanup
(
pVgOffsetHashMap
);
taosThreadMutexLock
(
&
tmq
->
lock
);
// destroy current buffered existed topics info
if
(
tmq
->
clientTopics
)
{
taosArrayDestroyEx
(
tmq
->
clientTopics
,
freeClientVgInfo
);
}
tmq
->
clientTopics
=
newTopics
;
taosThreadMutexUnlock
(
&
tmq
->
lock
);
int8_t
flag
=
(
topicNumGet
==
0
)
?
TMQ_CONSUMER_STATUS__NO_TOPIC
:
TMQ_CONSUMER_STATUS__READY
;
atomic_store_8
(
&
tmq
->
status
,
flag
);
...
...
@@ -1537,8 +1538,8 @@ int32_t askEpCallbackFn(void* param, SDataBuf* pMsg, int32_t code) {
}
else
{
tscDebug
(
"consumer:0x%"
PRIx64
", recv ep, msg epoch %d, current epoch %d, update local ep"
,
tmq
->
consumerId
,
head
->
epoch
,
epoch
);
pParam
->
pUserFn
(
tmq
,
code
,
pMsg
,
pParam
->
pParam
);
}
pParam
->
pUserFn
(
tmq
,
code
,
pMsg
,
pParam
->
pParam
);
taosReleaseRef
(
tmqMgmt
.
rsetId
,
pParam
->
refId
);
...
...
@@ -1745,7 +1746,7 @@ static int32_t tmqHandleNoPollRsp(tmq_t* tmq, SMqRspWrapper* rspWrapper, bool* p
if
(
rspWrapper
->
epoch
>
atomic_load_32
(
&
tmq
->
epoch
))
{
SMqAskEpRspWrapper
*
pEpRspWrapper
=
(
SMqAskEpRspWrapper
*
)
rspWrapper
;
SMqAskEpRsp
*
rspMsg
=
&
pEpRspWrapper
->
msg
;
tmqUpdate
Ep
(
tmq
,
rspWrapper
->
epoch
,
rspMsg
);
doUpdateLocal
Ep
(
tmq
,
rspWrapper
->
epoch
,
rspMsg
);
/*tmqClearUnhandleMsg(tmq);*/
tDeleteSMqAskEpRsp
(
rspMsg
);
*
pReset
=
true
;
...
...
@@ -2168,7 +2169,7 @@ void updateEpCallbackFn(tmq_t* pTmq, int32_t code, SDataBuf* pDataBuf, void* par
SMqAskEpRsp
rsp
;
tDecodeSMqAskEpRsp
(
POINTER_SHIFT
(
pDataBuf
->
pData
,
sizeof
(
SMqRspHead
)),
&
rsp
);
tmqUpdate
Ep
(
pTmq
,
head
->
epoch
,
&
rsp
);
doUpdateLocal
Ep
(
pTmq
,
head
->
epoch
,
&
rsp
);
tDeleteSMqAskEpRsp
(
&
rsp
);
}
...
...
source/client/test/clientTests.cpp
浏览文件 @
4c04b155
...
...
@@ -162,9 +162,11 @@ void* queryThread(void* arg) {
return
NULL
;
}
static
int32_t
numOfThreads
=
1
;
int32_t
numOfThreads
=
1
;
void
tmq_commit_cb_print
(
tmq_t
*
pTmq
,
int32_t
code
,
void
*
param
)
{
printf
(
"success, code:%d
\n
"
,
code
);
}
void
tmq_commit_cb_print
(
tmq_t
*
pTmq
,
int32_t
code
,
void
*
param
)
{
printf
(
"auto commit success, code:%d
\n\n\n\n
"
,
code
);
}
void
*
doConsumeData
(
void
*
param
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
...
...
@@ -172,7 +174,7 @@ void* doConsumeData(void* param) {
tmq_conf_t
*
conf
=
tmq_conf_new
();
tmq_conf_set
(
conf
,
"enable.auto.commit"
,
"true"
);
tmq_conf_set
(
conf
,
"auto.commit.interval.ms"
,
"1000"
);
tmq_conf_set
(
conf
,
"group.id"
,
"cgrpName
12
"
);
tmq_conf_set
(
conf
,
"group.id"
,
"cgrpName
41
"
);
tmq_conf_set
(
conf
,
"td.connect.user"
,
"root"
);
tmq_conf_set
(
conf
,
"td.connect.pass"
,
"taosdata"
);
tmq_conf_set
(
conf
,
"auto.offset.reset"
,
"earliest"
);
...
...
@@ -1059,7 +1061,7 @@ TEST(clientCase, sub_tb_test) {
tmq_conf_t
*
conf
=
tmq_conf_new
();
tmq_conf_set
(
conf
,
"enable.auto.commit"
,
"true"
);
tmq_conf_set
(
conf
,
"auto.commit.interval.ms"
,
"1000"
);
tmq_conf_set
(
conf
,
"group.id"
,
"cgrpName
27
"
);
tmq_conf_set
(
conf
,
"group.id"
,
"cgrpName
45
"
);
tmq_conf_set
(
conf
,
"td.connect.user"
,
"root"
);
tmq_conf_set
(
conf
,
"td.connect.pass"
,
"taosdata"
);
tmq_conf_set
(
conf
,
"auto.offset.reset"
,
"earliest"
);
...
...
source/common/src/systable.c
浏览文件 @
4c04b155
...
...
@@ -298,7 +298,9 @@ static const SSysDbTableSchema vnodesSchema[] = {
static
const
SSysDbTableSchema
userUserPrivilegesSchema
[]
=
{
{.
name
=
"user_name"
,
.
bytes
=
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
{.
name
=
"privilege"
,
.
bytes
=
10
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
{.
name
=
"object_name"
,
.
bytes
=
TSDB_DB_NAME_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
{.
name
=
"db_name"
,
.
bytes
=
TSDB_DB_NAME_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
{.
name
=
"table_name"
,
.
bytes
=
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
{.
name
=
"condition"
,
.
bytes
=
TSDB_PRIVILEDGE_CONDITION_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
};
static
const
SSysTableMeta
infosMeta
[]
=
{
...
...
source/common/src/tdatablock.c
浏览文件 @
4c04b155
...
...
@@ -1590,12 +1590,13 @@ static void doShiftBitmap(char* nullBitmap, size_t n, size_t total) {
i
+=
1
;
}
}
else
if
(
n
>
8
)
{
int32_t
gap
=
len
-
newLen
;
int32_t
remain
=
(
total
%
8
!=
0
&&
total
%
8
<=
tail
)
?
1
:
0
;
int32_t
gap
=
len
-
newLen
-
remain
;
while
(
i
<
newLen
)
{
uint8_t
v
=
p
[
i
+
gap
];
p
[
i
]
=
(
v
<<
tail
);
if
(
i
<
newLen
-
1
)
{
if
(
i
<
newLen
-
1
+
remain
)
{
uint8_t
next
=
p
[
i
+
gap
+
1
];
p
[
i
]
|=
(
next
>>
(
8
-
tail
));
}
...
...
source/common/src/tglobal.c
浏览文件 @
4c04b155
...
...
@@ -20,6 +20,10 @@
#include "tlog.h"
#include "tmisce.h"
#if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL)
#include "cus_name.h"
#endif
GRANT_CFG_DECLARE
;
SConfig
*
tsCfg
=
NULL
;
...
...
@@ -99,6 +103,7 @@ char tsSmlChildTableName[TSDB_TABLE_NAME_LEN] = ""; // user defined child table
// query
int32_t
tsQueryPolicy
=
1
;
int32_t
tsQueryRspPolicy
=
0
;
int64_t
tsQueryMaxConcurrentTables
=
200
;
// unit is TSDB_TABLE_NUM_UNIT
bool
tsEnableQueryHb
=
false
;
int32_t
tsQuerySmaOptimize
=
0
;
int32_t
tsQueryRsmaTolerance
=
1000
;
// the tolerance time (ms) to judge from which level to query rsma data.
...
...
@@ -336,6 +341,7 @@ static int32_t taosAddClientCfg(SConfig *pCfg) {
if
(
cfgAddInt32
(
pCfg
,
"maxRetryWaitTime"
,
tsMaxRetryWaitTime
,
0
,
86400000
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"useAdapter"
,
tsUseAdapter
,
true
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"crashReporting"
,
tsEnableCrashReport
,
true
)
!=
0
)
return
-
1
;
if
(
cfgAddInt64
(
pCfg
,
"queryMaxConcurrentTables"
,
tsQueryMaxConcurrentTables
,
INT64_MIN
,
INT64_MAX
,
1
)
!=
0
)
return
-
1
;
tsNumOfRpcThreads
=
tsNumOfCores
/
2
;
tsNumOfRpcThreads
=
TRANGE
(
tsNumOfRpcThreads
,
2
,
TSDB_MAX_RPC_THREADS
);
...
...
@@ -731,6 +737,7 @@ static int32_t taosSetClientCfg(SConfig *pCfg) {
tsKeepColumnName
=
cfgGetItem
(
pCfg
,
"keepColumnName"
)
->
bval
;
tsUseAdapter
=
cfgGetItem
(
pCfg
,
"useAdapter"
)
->
bval
;
tsEnableCrashReport
=
cfgGetItem
(
pCfg
,
"crashReporting"
)
->
bval
;
tsQueryMaxConcurrentTables
=
cfgGetItem
(
pCfg
,
"queryMaxConcurrentTables"
)
->
i64
;
tsMaxRetryWaitTime
=
cfgGetItem
(
pCfg
,
"maxRetryWaitTime"
)
->
i32
;
...
...
source/common/src/tmsg.c
浏览文件 @
4c04b155
...
...
@@ -1368,6 +1368,12 @@ int32_t tSerializeSAlterUserReq(void *buf, int32_t bufLen, SAlterUserReq *pReq)
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
user
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
pass
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
objname
)
<
0
)
return
-
1
;
int32_t
len
=
strlen
(
pReq
->
tabName
);
if
(
tEncodeI32
(
&
encoder
,
len
)
<
0
)
return
-
1
;
if
(
len
>
0
)
{
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
tabName
)
<
0
)
return
-
1
;
}
if
(
tEncodeBinary
(
&
encoder
,
pReq
->
tagCond
,
pReq
->
tagCondLen
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
...
...
@@ -1387,6 +1393,16 @@ int32_t tDeserializeSAlterUserReq(void *buf, int32_t bufLen, SAlterUserReq *pReq
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
user
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
pass
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
objname
)
<
0
)
return
-
1
;
if
(
!
tDecodeIsEnd
(
&
decoder
))
{
int32_t
len
=
0
;
if
(
tDecodeI32
(
&
decoder
,
&
len
)
<
0
)
return
-
1
;
if
(
len
>
0
)
{
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
tabName
)
<
0
)
return
-
1
;
}
uint64_t
tagCondLen
=
0
;
if
(
tDecodeBinaryAlloc
(
&
decoder
,
(
void
**
)
&
pReq
->
tagCond
,
&
tagCondLen
)
<
0
)
return
-
1
;
pReq
->
tagCondLen
=
tagCondLen
;
}
tEndDecode
(
&
decoder
);
tDecoderClear
(
&
decoder
);
...
...
@@ -1429,6 +1445,7 @@ int32_t tSerializeSGetUserAuthRspImpl(SEncoder *pEncoder, SGetUserAuthRsp *pRsp)
int32_t
numOfCreatedDbs
=
taosHashGetSize
(
pRsp
->
createdDbs
);
int32_t
numOfReadDbs
=
taosHashGetSize
(
pRsp
->
readDbs
);
int32_t
numOfWriteDbs
=
taosHashGetSize
(
pRsp
->
writeDbs
);
if
(
tEncodeI32
(
pEncoder
,
numOfCreatedDbs
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
numOfReadDbs
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
numOfWriteDbs
)
<
0
)
return
-
1
;
...
...
@@ -1451,6 +1468,54 @@ int32_t tSerializeSGetUserAuthRspImpl(SEncoder *pEncoder, SGetUserAuthRsp *pRsp)
db
=
taosHashIterate
(
pRsp
->
writeDbs
,
db
);
}
int32_t
numOfReadTbs
=
taosHashGetSize
(
pRsp
->
readTbs
);
int32_t
numOfWriteTbs
=
taosHashGetSize
(
pRsp
->
writeTbs
);
int32_t
numOfUseTbs
=
taosHashGetSize
(
pRsp
->
useDbs
);
if
(
tEncodeI32
(
pEncoder
,
numOfReadTbs
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
numOfWriteTbs
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
numOfUseTbs
)
<
0
)
return
-
1
;
char
*
tb
=
taosHashIterate
(
pRsp
->
readTbs
,
NULL
);
while
(
tb
!=
NULL
)
{
size_t
keyLen
=
0
;
void
*
key
=
taosHashGetKey
(
tb
,
&
keyLen
);
if
(
tEncodeI32
(
pEncoder
,
keyLen
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
key
)
<
0
)
return
-
1
;
size_t
valueLen
=
0
;
valueLen
=
strlen
(
tb
);
if
(
tEncodeI32
(
pEncoder
,
valueLen
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
tb
)
<
0
)
return
-
1
;
tb
=
taosHashIterate
(
pRsp
->
readTbs
,
tb
);
}
tb
=
taosHashIterate
(
pRsp
->
writeTbs
,
NULL
);
while
(
tb
!=
NULL
)
{
size_t
keyLen
=
0
;
void
*
key
=
taosHashGetKey
(
tb
,
&
keyLen
);
if
(
tEncodeI32
(
pEncoder
,
keyLen
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
key
)
<
0
)
return
-
1
;
size_t
valueLen
=
0
;
valueLen
=
strlen
(
tb
);
if
(
tEncodeI32
(
pEncoder
,
valueLen
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
tb
)
<
0
)
return
-
1
;
tb
=
taosHashIterate
(
pRsp
->
writeTbs
,
tb
);
}
int32_t
*
useDb
=
taosHashIterate
(
pRsp
->
useDbs
,
NULL
);
while
(
useDb
!=
NULL
)
{
size_t
keyLen
=
0
;
void
*
key
=
taosHashGetKey
(
useDb
,
&
keyLen
);
if
(
tEncodeI32
(
pEncoder
,
keyLen
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
key
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
*
useDb
)
<
0
)
return
-
1
;
useDb
=
taosHashIterate
(
pRsp
->
useDbs
,
useDb
);
}
return
0
;
}
...
...
@@ -1473,7 +1538,11 @@ int32_t tDeserializeSGetUserAuthRspImpl(SDecoder *pDecoder, SGetUserAuthRsp *pRs
pRsp
->
createdDbs
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
pRsp
->
readDbs
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
pRsp
->
writeDbs
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
if
(
pRsp
->
readDbs
==
NULL
||
pRsp
->
writeDbs
==
NULL
)
{
pRsp
->
readTbs
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
pRsp
->
writeTbs
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
pRsp
->
useDbs
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
if
(
pRsp
->
createdDbs
==
NULL
||
pRsp
->
readDbs
==
NULL
||
pRsp
->
writeDbs
==
NULL
||
pRsp
->
readTbs
==
NULL
||
pRsp
->
writeTbs
==
NULL
||
pRsp
->
useDbs
==
NULL
)
{
return
-
1
;
}
...
...
@@ -1512,6 +1581,63 @@ int32_t tDeserializeSGetUserAuthRspImpl(SDecoder *pDecoder, SGetUserAuthRsp *pRs
taosHashPut
(
pRsp
->
writeDbs
,
db
,
len
,
db
,
len
);
}
if
(
!
tDecodeIsEnd
(
pDecoder
))
{
int32_t
numOfReadTbs
=
0
;
int32_t
numOfWriteTbs
=
0
;
int32_t
numOfUseDbs
=
0
;
if
(
tDecodeI32
(
pDecoder
,
&
numOfReadTbs
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
numOfWriteTbs
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
numOfUseDbs
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
numOfReadTbs
;
++
i
)
{
int32_t
keyLen
=
0
;
if
(
tDecodeI32
(
pDecoder
,
&
keyLen
)
<
0
)
return
-
1
;
char
*
key
=
taosMemoryCalloc
(
keyLen
+
1
,
sizeof
(
char
));
if
(
tDecodeCStrTo
(
pDecoder
,
key
)
<
0
)
return
-
1
;
int32_t
valuelen
=
0
;
if
(
tDecodeI32
(
pDecoder
,
&
valuelen
)
<
0
)
return
-
1
;
char
*
value
=
taosMemoryCalloc
(
valuelen
+
1
,
sizeof
(
char
));
if
(
tDecodeCStrTo
(
pDecoder
,
value
)
<
0
)
return
-
1
;
taosHashPut
(
pRsp
->
readTbs
,
key
,
strlen
(
key
),
value
,
valuelen
+
1
);
taosMemoryFree
(
key
);
taosMemoryFree
(
value
);
}
for
(
int32_t
i
=
0
;
i
<
numOfWriteTbs
;
++
i
)
{
int32_t
keyLen
=
0
;
if
(
tDecodeI32
(
pDecoder
,
&
keyLen
)
<
0
)
return
-
1
;
char
*
key
=
taosMemoryCalloc
(
keyLen
+
1
,
sizeof
(
char
));
if
(
tDecodeCStrTo
(
pDecoder
,
key
)
<
0
)
return
-
1
;
int32_t
valuelen
=
0
;
if
(
tDecodeI32
(
pDecoder
,
&
valuelen
)
<
0
)
return
-
1
;
char
*
value
=
taosMemoryCalloc
(
valuelen
+
1
,
sizeof
(
char
));
if
(
tDecodeCStrTo
(
pDecoder
,
value
)
<
0
)
return
-
1
;
taosHashPut
(
pRsp
->
writeTbs
,
key
,
strlen
(
key
),
value
,
valuelen
+
1
);
taosMemoryFree
(
key
);
taosMemoryFree
(
value
);
}
for
(
int32_t
i
=
0
;
i
<
numOfUseDbs
;
++
i
)
{
int32_t
keyLen
=
0
;
if
(
tDecodeI32
(
pDecoder
,
&
keyLen
)
<
0
)
return
-
1
;
char
*
key
=
taosMemoryCalloc
(
keyLen
+
1
,
sizeof
(
char
));
if
(
tDecodeCStrTo
(
pDecoder
,
key
)
<
0
)
return
-
1
;
int32_t
ref
=
0
;
if
(
tDecodeI32
(
pDecoder
,
&
ref
)
<
0
)
return
-
1
;
taosHashPut
(
pRsp
->
useDbs
,
key
,
strlen
(
key
),
&
ref
,
sizeof
(
ref
));
}
}
return
0
;
}
...
...
@@ -1533,6 +1659,9 @@ void tFreeSGetUserAuthRsp(SGetUserAuthRsp *pRsp) {
taosHashCleanup
(
pRsp
->
createdDbs
);
taosHashCleanup
(
pRsp
->
readDbs
);
taosHashCleanup
(
pRsp
->
writeDbs
);
taosHashCleanup
(
pRsp
->
writeTbs
);
taosHashCleanup
(
pRsp
->
readTbs
);
taosHashCleanup
(
pRsp
->
useDbs
);
}
int32_t
tSerializeSCreateDropMQSNodeReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateQnodeReq
*
pReq
)
{
...
...
@@ -7291,6 +7420,7 @@ void tDestroySSubmitReq2(SSubmitReq2 *pReq, int32_t flag) {
tDestroySSubmitTbData
(
&
aSubmitTbData
[
i
],
flag
);
}
taosArrayDestroy
(
pReq
->
aSubmitTbData
);
pReq
->
aSubmitTbData
=
NULL
;
}
int32_t
tEncodeSSubmitRsp2
(
SEncoder
*
pCoder
,
const
SSubmitRsp2
*
pRsp
)
{
...
...
source/dnode/mnode/impl/inc/mndConsumer.h
浏览文件 @
4c04b155
...
...
@@ -24,10 +24,10 @@ extern "C" {
enum
{
MQ_CONSUMER_STATUS__MODIFY
=
1
,
MQ_CONSUMER_STATUS__MODIFY_IN_REB
,
// this value is not used anymore
//
MQ_CONSUMER_STATUS__MODIFY_IN_REB, // this value is not used anymore
MQ_CONSUMER_STATUS__READY
,
MQ_CONSUMER_STATUS__LOST
,
MQ_CONSUMER_STATUS__LOST_IN_REB
,
// this value is not used anymore
//
MQ_CONSUMER_STATUS__LOST_IN_REB, // this value is not used anymore
MQ_CONSUMER_STATUS__LOST_REBD
,
MQ_CONSUMER_STATUS__REMOVED
,
};
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
4c04b155
...
...
@@ -281,6 +281,9 @@ typedef struct {
SHashObj
*
readDbs
;
SHashObj
*
writeDbs
;
SHashObj
*
topics
;
SHashObj
*
readTbs
;
SHashObj
*
writeTbs
;
SHashObj
*
useDbs
;
SRWLatch
lock
;
}
SUserObj
;
...
...
source/dnode/mnode/impl/inc/mndStb.h
浏览文件 @
4c04b155
...
...
@@ -38,6 +38,7 @@ void mndFreeStb(SStbObj *pStb);
int32_t
mndBuildSMCreateStbRsp
(
SMnode
*
pMnode
,
char
*
dbFName
,
char
*
stbFName
,
void
**
pCont
,
int32_t
*
pLen
);
void
mndExtractDbNameFromStbFullName
(
const
char
*
stbFullName
,
char
*
dst
);
void
mndExtractShortDbNameFromStbFullName
(
const
char
*
stbFullName
,
char
*
dst
);
void
mndExtractTbNameFromStbFullName
(
const
char
*
stbFullName
,
char
*
dst
,
int32_t
dstSize
);
const
char
*
mndGetStbStr
(
const
char
*
src
);
...
...
source/dnode/mnode/impl/inc/mndUser.h
浏览文件 @
4c04b155
...
...
@@ -31,6 +31,7 @@ void mndReleaseUser(SMnode *pMnode, SUserObj *pUser);
// for trans test
SSdbRaw
*
mndUserActionEncode
(
SUserObj
*
pUser
);
SHashObj
*
mndDupDbHash
(
SHashObj
*
pOld
);
SHashObj
*
mndDupTableHash
(
SHashObj
*
pOld
);
SHashObj
*
mndDupTopicHash
(
SHashObj
*
pOld
);
int32_t
mndValidateUserAuthInfo
(
SMnode
*
pMnode
,
SUserAuthVersion
*
pUsers
,
int32_t
numOfUses
,
void
**
ppRsp
,
int32_t
*
pRspLen
);
...
...
source/dnode/mnode/impl/src/mndConsumer.c
浏览文件 @
4c04b155
...
...
@@ -335,7 +335,7 @@ static int32_t mndProcessMqTimerMsg(SRpcMsg *pMsg) {
taosArrayPush
(
pRebSub
->
removedConsumers
,
&
pConsumer
->
consumerId
);
}
taosRUnLockLatch
(
&
pConsumer
->
lock
);
}
else
if
(
status
==
MQ_CONSUMER_STATUS__MODIFY
||
status
==
MQ_CONSUMER_STATUS__MODIFY_IN_REB
)
{
}
else
if
(
status
==
MQ_CONSUMER_STATUS__MODIFY
)
{
taosRLockLatch
(
&
pConsumer
->
lock
);
int32_t
newTopicNum
=
taosArrayGetSize
(
pConsumer
->
rebNewTopics
);
...
...
@@ -873,17 +873,11 @@ static void updateConsumerStatus(SMqConsumerObj *pConsumer) {
int32_t
status
=
pConsumer
->
status
;
if
(
taosArrayGetSize
(
pConsumer
->
rebNewTopics
)
==
0
&&
taosArrayGetSize
(
pConsumer
->
rebRemovedTopics
)
==
0
)
{
if
(
status
==
MQ_CONSUMER_STATUS__MODIFY
||
status
==
MQ_CONSUMER_STATUS__MODIFY_IN_REB
)
{
if
(
status
==
MQ_CONSUMER_STATUS__MODIFY
)
{
pConsumer
->
status
=
MQ_CONSUMER_STATUS__READY
;
}
else
if
(
status
==
MQ_CONSUMER_STATUS__LOST
_IN_REB
||
status
==
MQ_CONSUMER_STATUS__LOST
)
{
}
else
if
(
status
==
MQ_CONSUMER_STATUS__LOST
)
{
pConsumer
->
status
=
MQ_CONSUMER_STATUS__LOST_REBD
;
}
}
else
{
if
(
status
==
MQ_CONSUMER_STATUS__MODIFY
||
status
==
MQ_CONSUMER_STATUS__MODIFY_IN_REB
)
{
pConsumer
->
status
=
MQ_CONSUMER_STATUS__MODIFY
;
}
else
if
(
status
==
MQ_CONSUMER_STATUS__LOST
||
status
==
MQ_CONSUMER_STATUS__LOST_IN_REB
)
{
pConsumer
->
status
=
MQ_CONSUMER_STATUS__LOST
;
}
}
}
...
...
@@ -1192,10 +1186,8 @@ static const char *mndConsumerStatusName(int status) {
return
"ready"
;
case
MQ_CONSUMER_STATUS__LOST
:
case
MQ_CONSUMER_STATUS__LOST_REBD
:
case
MQ_CONSUMER_STATUS__LOST_IN_REB
:
return
"lost"
;
case
MQ_CONSUMER_STATUS__MODIFY
:
case
MQ_CONSUMER_STATUS__MODIFY_IN_REB
:
return
"rebalancing"
;
default:
return
"unknown"
;
...
...
source/dnode/mnode/impl/src/mndPrivilege.c
浏览文件 @
4c04b155
...
...
@@ -35,6 +35,7 @@ int32_t mndCheckTopicPrivilegeByName(SMnode *pMnode, const char *user, EOperType
int32_t
mndSetUserAuthRsp
(
SMnode
*
pMnode
,
SUserObj
*
pUser
,
SGetUserAuthRsp
*
pRsp
)
{
memcpy
(
pRsp
->
user
,
pUser
->
user
,
TSDB_USER_LEN
);
pRsp
->
superAuth
=
1
;
pRsp
->
enable
=
pUser
->
enable
;
pRsp
->
version
=
pUser
->
authVersion
;
return
0
;
}
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
4c04b155
...
...
@@ -2614,6 +2614,13 @@ void mndExtractDbNameFromStbFullName(const char *stbFullName, char *dst) {
tNameGetFullDbName
(
&
name
,
dst
);
}
void
mndExtractShortDbNameFromStbFullName
(
const
char
*
stbFullName
,
char
*
dst
)
{
SName
name
=
{
0
};
tNameFromString
(
&
name
,
stbFullName
,
T_NAME_ACCT
|
T_NAME_DB
|
T_NAME_TABLE
);
tNameGetDbName
(
&
name
,
dst
);
}
void
mndExtractTbNameFromStbFullName
(
const
char
*
stbFullName
,
char
*
dst
,
int32_t
dstSize
)
{
int32_t
pos
=
-
1
;
int32_t
num
=
0
;
...
...
source/dnode/mnode/impl/src/mndUser.c
浏览文件 @
4c04b155
...
...
@@ -18,11 +18,12 @@
#include "mndDb.h"
#include "mndPrivilege.h"
#include "mndShow.h"
#include "mndStb.h"
#include "mndTopic.h"
#include "mndTrans.h"
#include "tbase64.h"
#define USER_VER_NUMBER
2
#define USER_VER_NUMBER
3
#define USER_RESERVE_SIZE 64
static
int32_t
mndCreateDefaultUsers
(
SMnode
*
pMnode
);
...
...
@@ -124,9 +125,40 @@ SSdbRaw *mndUserActionEncode(SUserObj *pUser) {
int32_t
numOfReadDbs
=
taosHashGetSize
(
pUser
->
readDbs
);
int32_t
numOfWriteDbs
=
taosHashGetSize
(
pUser
->
writeDbs
);
int32_t
numOfReadStbs
=
taosHashGetSize
(
pUser
->
readTbs
);
int32_t
numOfWriteStbs
=
taosHashGetSize
(
pUser
->
writeTbs
);
int32_t
numOfTopics
=
taosHashGetSize
(
pUser
->
topics
);
int32_t
size
=
sizeof
(
SUserObj
)
+
USER_RESERVE_SIZE
+
(
numOfReadDbs
+
numOfWriteDbs
)
*
TSDB_DB_FNAME_LEN
+
numOfTopics
*
TSDB_TOPIC_FNAME_LEN
;
int32_t
numOfUseDbs
=
taosHashGetSize
(
pUser
->
useDbs
);
int32_t
size
=
sizeof
(
SUserObj
)
+
USER_RESERVE_SIZE
+
(
numOfReadDbs
+
numOfWriteDbs
+
numOfUseDbs
)
*
TSDB_DB_FNAME_LEN
+
numOfTopics
*
TSDB_TOPIC_FNAME_LEN
;
char
*
stb
=
taosHashIterate
(
pUser
->
readTbs
,
NULL
);
while
(
stb
!=
NULL
)
{
size_t
keyLen
=
0
;
void
*
key
=
taosHashGetKey
(
stb
,
&
keyLen
);
size
+=
sizeof
(
int32_t
);
size
+=
keyLen
;
size_t
valueLen
=
0
;
valueLen
=
strlen
(
stb
);
size
+=
sizeof
(
int32_t
);
size
+=
valueLen
;
stb
=
taosHashIterate
(
pUser
->
readTbs
,
stb
);
}
stb
=
taosHashIterate
(
pUser
->
writeTbs
,
NULL
);
while
(
stb
!=
NULL
)
{
size_t
keyLen
=
0
;
void
*
key
=
taosHashGetKey
(
stb
,
&
keyLen
);
size
+=
sizeof
(
int32_t
);
size
+=
keyLen
;
size_t
valueLen
=
0
;
valueLen
=
strlen
(
stb
);
size
+=
sizeof
(
int32_t
);
size
+=
keyLen
;
stb
=
taosHashIterate
(
pUser
->
writeTbs
,
stb
);
}
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_USER
,
USER_VER_NUMBER
,
size
);
if
(
pRaw
==
NULL
)
goto
_OVER
;
...
...
@@ -164,6 +196,49 @@ SSdbRaw *mndUserActionEncode(SUserObj *pUser) {
topic
=
taosHashIterate
(
pUser
->
topics
,
topic
);
}
SDB_SET_INT32
(
pRaw
,
dataPos
,
numOfReadStbs
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
numOfWriteStbs
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
numOfUseDbs
,
_OVER
)
stb
=
taosHashIterate
(
pUser
->
readTbs
,
NULL
);
while
(
stb
!=
NULL
)
{
size_t
keyLen
=
0
;
void
*
key
=
taosHashGetKey
(
stb
,
&
keyLen
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
keyLen
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
key
,
keyLen
,
_OVER
);
size_t
valueLen
=
0
;
valueLen
=
strlen
(
stb
)
+
1
;
SDB_SET_INT32
(
pRaw
,
dataPos
,
valueLen
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
stb
,
valueLen
,
_OVER
);
stb
=
taosHashIterate
(
pUser
->
readTbs
,
stb
);
}
stb
=
taosHashIterate
(
pUser
->
writeTbs
,
NULL
);
while
(
stb
!=
NULL
)
{
size_t
keyLen
=
0
;
void
*
key
=
taosHashGetKey
(
stb
,
&
keyLen
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
keyLen
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
key
,
keyLen
,
_OVER
);
size_t
valueLen
=
0
;
valueLen
=
strlen
(
stb
)
+
1
;
SDB_SET_INT32
(
pRaw
,
dataPos
,
valueLen
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
stb
,
valueLen
,
_OVER
);
stb
=
taosHashIterate
(
pUser
->
writeTbs
,
stb
);
}
int32_t
*
useDb
=
taosHashIterate
(
pUser
->
useDbs
,
NULL
);
while
(
useDb
!=
NULL
)
{
size_t
keyLen
=
0
;
void
*
key
=
taosHashGetKey
(
useDb
,
&
keyLen
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
keyLen
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
key
,
keyLen
,
_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
*
useDb
,
_OVER
)
useDb
=
taosHashIterate
(
pUser
->
writeTbs
,
useDb
);
}
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
USER_RESERVE_SIZE
,
_OVER
)
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
_OVER
)
...
...
@@ -188,7 +263,7 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
int8_t
sver
=
0
;
if
(
sdbGetRawSoftVer
(
pRaw
,
&
sver
)
!=
0
)
goto
_OVER
;
if
(
sver
!=
1
&&
sver
!=
2
)
{
if
(
sver
!=
1
&&
sver
!=
2
&&
sver
!=
3
)
{
terrno
=
TSDB_CODE_SDB_INVALID_DATA_VER
;
goto
_OVER
;
}
...
...
@@ -249,6 +324,75 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
}
}
if
(
sver
>=
3
)
{
int32_t
numOfReadStbs
=
0
;
int32_t
numOfWriteStbs
=
0
;
int32_t
numOfUseDbs
=
0
;
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
numOfReadStbs
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
numOfWriteStbs
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
numOfUseDbs
,
_OVER
)
pUser
->
readTbs
=
taosHashInit
(
numOfReadStbs
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
pUser
->
writeTbs
=
taosHashInit
(
numOfWriteStbs
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
pUser
->
useDbs
=
taosHashInit
(
numOfUseDbs
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
for
(
int32_t
i
=
0
;
i
<
numOfReadStbs
;
++
i
)
{
int32_t
keyLen
=
0
;
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
keyLen
,
_OVER
);
char
*
key
=
taosMemoryCalloc
(
keyLen
,
sizeof
(
char
));
memset
(
key
,
0
,
keyLen
);
SDB_GET_BINARY
(
pRaw
,
dataPos
,
key
,
keyLen
,
_OVER
);
int32_t
valuelen
=
0
;
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
valuelen
,
_OVER
);
char
*
value
=
taosMemoryCalloc
(
valuelen
,
sizeof
(
char
));
memset
(
value
,
0
,
valuelen
);
SDB_GET_BINARY
(
pRaw
,
dataPos
,
value
,
valuelen
,
_OVER
)
taosHashPut
(
pUser
->
readTbs
,
key
,
keyLen
,
value
,
valuelen
);
taosMemoryFree
(
key
);
taosMemoryFree
(
value
);
}
for
(
int32_t
i
=
0
;
i
<
numOfWriteStbs
;
++
i
)
{
int32_t
keyLen
=
0
;
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
keyLen
,
_OVER
);
char
*
key
=
taosMemoryCalloc
(
keyLen
,
sizeof
(
char
));
memset
(
key
,
0
,
keyLen
);
SDB_GET_BINARY
(
pRaw
,
dataPos
,
key
,
keyLen
,
_OVER
);
int32_t
valuelen
=
0
;
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
valuelen
,
_OVER
);
char
*
value
=
taosMemoryCalloc
(
valuelen
,
sizeof
(
char
));
memset
(
value
,
0
,
keyLen
);
SDB_GET_BINARY
(
pRaw
,
dataPos
,
value
,
valuelen
,
_OVER
)
taosHashPut
(
pUser
->
writeTbs
,
key
,
keyLen
,
value
,
valuelen
);
taosMemoryFree
(
key
);
taosMemoryFree
(
value
);
}
for
(
int32_t
i
=
0
;
i
<
numOfUseDbs
;
++
i
)
{
int32_t
keyLen
=
0
;
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
keyLen
,
_OVER
);
char
*
key
=
taosMemoryCalloc
(
keyLen
,
sizeof
(
char
));
memset
(
key
,
0
,
keyLen
);
SDB_GET_BINARY
(
pRaw
,
dataPos
,
key
,
keyLen
,
_OVER
);
int32_t
ref
=
0
;
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
ref
,
_OVER
);
taosHashPut
(
pUser
->
useDbs
,
key
,
keyLen
,
&
ref
,
sizeof
(
ref
));
}
}
SDB_GET_RESERVE
(
pRaw
,
dataPos
,
USER_RESERVE_SIZE
,
_OVER
)
taosInitRWLatch
(
&
pUser
->
lock
);
...
...
@@ -261,6 +405,9 @@ _OVER:
taosHashCleanup
(
pUser
->
readDbs
);
taosHashCleanup
(
pUser
->
writeDbs
);
taosHashCleanup
(
pUser
->
topics
);
taosHashCleanup
(
pUser
->
readTbs
);
taosHashCleanup
(
pUser
->
writeTbs
);
taosHashCleanup
(
pUser
->
useDbs
);
}
taosMemoryFreeClear
(
pRow
);
return
NULL
;
...
...
@@ -285,6 +432,32 @@ static int32_t mndUserActionInsert(SSdb *pSdb, SUserObj *pUser) {
return
0
;
}
SHashObj
*
mndDupTableHash
(
SHashObj
*
pOld
)
{
SHashObj
*
pNew
=
taosHashInit
(
taosHashGetSize
(
pOld
),
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
if
(
pNew
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
char
*
tb
=
taosHashIterate
(
pOld
,
NULL
);
while
(
tb
!=
NULL
)
{
size_t
keyLen
=
0
;
char
*
key
=
taosHashGetKey
(
tb
,
&
keyLen
);
int32_t
valueLen
=
strlen
(
tb
)
+
1
;
if
(
taosHashPut
(
pNew
,
key
,
keyLen
,
tb
,
valueLen
)
!=
0
)
{
taosHashCancelIterate
(
pOld
,
tb
);
taosHashCleanup
(
pNew
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
tb
=
taosHashIterate
(
pOld
,
tb
);
}
return
pNew
;
}
static
int32_t
mndUserDupObj
(
SUserObj
*
pUser
,
SUserObj
*
pNew
)
{
memcpy
(
pNew
,
pUser
,
sizeof
(
SUserObj
));
pNew
->
authVersion
++
;
...
...
@@ -293,7 +466,10 @@ static int32_t mndUserDupObj(SUserObj *pUser, SUserObj *pNew) {
taosRLockLatch
(
&
pUser
->
lock
);
pNew
->
readDbs
=
mndDupDbHash
(
pUser
->
readDbs
);
pNew
->
writeDbs
=
mndDupDbHash
(
pUser
->
writeDbs
);
pNew
->
readTbs
=
mndDupTableHash
(
pUser
->
readTbs
);
pNew
->
writeTbs
=
mndDupTableHash
(
pUser
->
writeTbs
);
pNew
->
topics
=
mndDupTopicHash
(
pUser
->
topics
);
pNew
->
useDbs
=
mndDupDbHash
(
pUser
->
useDbs
);
taosRUnLockLatch
(
&
pUser
->
lock
);
if
(
pNew
->
readDbs
==
NULL
||
pNew
->
writeDbs
==
NULL
||
pNew
->
topics
==
NULL
)
{
...
...
@@ -306,9 +482,15 @@ static void mndUserFreeObj(SUserObj *pUser) {
taosHashCleanup
(
pUser
->
readDbs
);
taosHashCleanup
(
pUser
->
writeDbs
);
taosHashCleanup
(
pUser
->
topics
);
taosHashCleanup
(
pUser
->
readTbs
);
taosHashCleanup
(
pUser
->
writeTbs
);
taosHashCleanup
(
pUser
->
useDbs
);
pUser
->
readDbs
=
NULL
;
pUser
->
writeDbs
=
NULL
;
pUser
->
topics
=
NULL
;
pUser
->
readTbs
=
NULL
;
pUser
->
writeTbs
=
NULL
;
pUser
->
useDbs
=
NULL
;
}
static
int32_t
mndUserActionDelete
(
SSdb
*
pSdb
,
SUserObj
*
pUser
)
{
...
...
@@ -328,6 +510,9 @@ static int32_t mndUserActionUpdate(SSdb *pSdb, SUserObj *pOld, SUserObj *pNew) {
TSWAP
(
pOld
->
readDbs
,
pNew
->
readDbs
);
TSWAP
(
pOld
->
writeDbs
,
pNew
->
writeDbs
);
TSWAP
(
pOld
->
topics
,
pNew
->
topics
);
TSWAP
(
pOld
->
readTbs
,
pNew
->
readTbs
);
TSWAP
(
pOld
->
writeTbs
,
pNew
->
writeTbs
);
TSWAP
(
pOld
->
useDbs
,
pNew
->
useDbs
);
taosWUnLockLatch
(
&
pOld
->
lock
);
return
0
;
...
...
@@ -498,6 +683,71 @@ SHashObj *mndDupDbHash(SHashObj *pOld) { return mndDupObjHash(pOld, TSDB_DB_FNAM
SHashObj
*
mndDupTopicHash
(
SHashObj
*
pOld
)
{
return
mndDupObjHash
(
pOld
,
TSDB_TOPIC_FNAME_LEN
);
}
static
int32_t
mndTablePriviledge
(
SMnode
*
pMnode
,
SHashObj
*
hash
,
SHashObj
*
useDbHash
,
SAlterUserReq
*
alterReq
,
SSdb
*
pSdb
)
{
void
*
pIter
=
NULL
;
char
tbFName
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
snprintf
(
tbFName
,
sizeof
(
tbFName
),
"%s.%s"
,
alterReq
->
objname
,
alterReq
->
tabName
);
int32_t
len
=
strlen
(
tbFName
)
+
1
;
if
(
alterReq
->
tagCond
!=
NULL
&&
alterReq
->
tagCondLen
!=
0
)
{
char
*
value
=
taosHashGet
(
hash
,
tbFName
,
len
);
if
(
value
!=
NULL
)
{
terrno
=
TSDB_CODE_MND_PRIVILEDGE_EXIST
;
return
-
1
;
}
int32_t
condLen
=
alterReq
->
tagCondLen
;
if
(
taosHashPut
(
hash
,
tbFName
,
len
,
alterReq
->
tagCond
,
condLen
)
!=
0
)
{
return
-
1
;
}
}
else
{
if
(
taosHashPut
(
hash
,
tbFName
,
len
,
"t"
,
2
)
!=
0
)
{
return
-
1
;
}
}
int32_t
dbKeyLen
=
strlen
(
alterReq
->
objname
)
+
1
;
int32_t
ref
=
1
;
int32_t
*
currRef
=
taosHashGet
(
useDbHash
,
alterReq
->
objname
,
dbKeyLen
);
if
(
NULL
!=
currRef
)
{
ref
=
(
*
currRef
)
+
1
;
}
if
(
taosHashPut
(
useDbHash
,
alterReq
->
objname
,
dbKeyLen
,
&
ref
,
sizeof
(
ref
))
!=
0
)
{
return
-
1
;
}
return
0
;
}
static
int32_t
mndRemoveTablePriviledge
(
SMnode
*
pMnode
,
SHashObj
*
hash
,
SHashObj
*
useDbHash
,
SAlterUserReq
*
alterReq
,
SSdb
*
pSdb
)
{
void
*
pIter
=
NULL
;
char
tbFName
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
snprintf
(
tbFName
,
sizeof
(
tbFName
),
"%s.%s"
,
alterReq
->
objname
,
alterReq
->
tabName
);
int32_t
len
=
strlen
(
tbFName
)
+
1
;
if
(
taosHashRemove
(
hash
,
tbFName
,
len
)
!=
0
)
{
return
-
1
;
}
int32_t
dbKeyLen
=
strlen
(
alterReq
->
objname
)
+
1
;
int32_t
*
currRef
=
taosHashGet
(
useDbHash
,
alterReq
->
objname
,
dbKeyLen
);
if
(
NULL
==
currRef
||
1
==
*
currRef
)
{
if
(
taosHashRemove
(
useDbHash
,
alterReq
->
objname
,
dbKeyLen
)
!=
0
)
{
return
-
1
;
}
return
0
;
}
int32_t
ref
=
(
*
currRef
)
-
1
;
if
(
taosHashPut
(
useDbHash
,
alterReq
->
objname
,
dbKeyLen
,
&
ref
,
sizeof
(
ref
))
!=
0
)
{
return
-
1
;
}
return
0
;
}
static
int32_t
mndProcessAlterUserReq
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
...
...
@@ -637,6 +887,22 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) {
}
}
if
(
alterReq
.
alterType
==
TSDB_ALTER_USER_ADD_READ_TABLE
)
{
if
(
mndTablePriviledge
(
pMnode
,
newUser
.
readTbs
,
newUser
.
useDbs
,
&
alterReq
,
pSdb
)
!=
0
)
goto
_OVER
;
}
if
(
alterReq
.
alterType
==
TSDB_ALTER_USER_ADD_WRITE_TABLE
)
{
if
(
mndTablePriviledge
(
pMnode
,
newUser
.
writeTbs
,
newUser
.
useDbs
,
&
alterReq
,
pSdb
)
!=
0
)
goto
_OVER
;
}
if
(
alterReq
.
alterType
==
TSDB_ALTER_USER_REMOVE_READ_TABLE
)
{
if
(
mndRemoveTablePriviledge
(
pMnode
,
newUser
.
readTbs
,
newUser
.
useDbs
,
&
alterReq
,
pSdb
)
!=
0
)
goto
_OVER
;
}
if
(
alterReq
.
alterType
==
TSDB_ALTER_USER_REMOVE_WRITE_TABLE
)
{
if
(
mndRemoveTablePriviledge
(
pMnode
,
newUser
.
writeTbs
,
newUser
.
useDbs
,
&
alterReq
,
pSdb
)
!=
0
)
goto
_OVER
;
}
if
(
alterReq
.
alterType
==
TSDB_ALTER_USER_ADD_SUBSCRIBE_TOPIC
)
{
int32_t
len
=
strlen
(
alterReq
.
objname
)
+
1
;
SMqTopicObj
*
pTopic
=
mndAcquireTopic
(
pMnode
,
alterReq
.
objname
);
...
...
@@ -830,6 +1096,72 @@ static void mndCancelGetNextUser(SMnode *pMnode, void *pIter) {
sdbCancelFetch
(
pSdb
,
pIter
);
}
static
void
mndLoopHash
(
SHashObj
*
hash
,
char
*
priType
,
SSDataBlock
*
pBlock
,
int32_t
*
numOfRows
,
char
*
user
,
SShowObj
*
pShow
)
{
char
*
value
=
taosHashIterate
(
hash
,
NULL
);
int32_t
cols
=
0
;
while
(
value
!=
NULL
)
{
cols
=
0
;
char
userName
[
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
userName
,
user
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
*
numOfRows
,
(
const
char
*
)
userName
,
false
);
char
privilege
[
20
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
privilege
,
priType
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
*
numOfRows
,
(
const
char
*
)
privilege
,
false
);
size_t
keyLen
=
0
;
void
*
key
=
taosHashGetKey
(
value
,
&
keyLen
);
char
dbName
[
TSDB_DB_NAME_LEN
]
=
{
0
};
mndExtractShortDbNameFromStbFullName
(
key
,
dbName
);
char
dbNameContent
[
TSDB_DB_NAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
dbNameContent
,
dbName
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
*
numOfRows
,
(
const
char
*
)
dbNameContent
,
false
);
char
tableName
[
TSDB_TABLE_NAME_LEN
]
=
{
0
};
mndExtractTbNameFromStbFullName
(
key
,
tableName
,
TSDB_TABLE_NAME_LEN
);
char
tableNameContent
[
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
tableNameContent
,
tableName
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
*
numOfRows
,
(
const
char
*
)
tableNameContent
,
false
);
if
(
strcmp
(
"t"
,
value
)
!=
0
)
{
SNode
*
pAst
=
NULL
;
int32_t
sqlLen
=
0
;
char
sql
[
TSDB_EXPLAIN_RESULT_ROW_SIZE
]
=
{
0
};
if
(
nodesStringToNode
(
value
,
&
pAst
)
==
0
)
{
nodesNodeToSQL
(
pAst
,
sql
,
TSDB_EXPLAIN_RESULT_ROW_SIZE
,
&
sqlLen
);
nodesDestroyNode
(
pAst
);
}
else
{
sqlLen
=
5
;
sprintf
(
sql
,
"error"
);
}
// char *obj = taosMemoryMalloc(sqlLen + VARSTR_HEADER_SIZE + 1);
char
obj
[
TSDB_PRIVILEDGE_CONDITION_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
obj
,
sql
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
*
numOfRows
,
(
const
char
*
)
obj
,
false
);
// taosMemoryFree(obj);
}
else
{
char
condition
[
20
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
condition
,
""
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
*
numOfRows
,
(
const
char
*
)
condition
,
false
);
}
(
*
numOfRows
)
++
;
value
=
taosHashIterate
(
hash
,
value
);
}
}
static
int32_t
mndRetrievePrivileges
(
SRpcMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
...
...
@@ -845,7 +1177,9 @@ static int32_t mndRetrievePrivileges(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
int32_t
numOfReadDbs
=
taosHashGetSize
(
pUser
->
readDbs
);
int32_t
numOfWriteDbs
=
taosHashGetSize
(
pUser
->
writeDbs
);
int32_t
numOfTopics
=
taosHashGetSize
(
pUser
->
topics
);
if
(
numOfRows
+
numOfReadDbs
+
numOfWriteDbs
+
numOfTopics
>=
rows
)
break
;
int32_t
numOfReadTbs
=
taosHashGetSize
(
pUser
->
readTbs
);
int32_t
numOfWriteTbs
=
taosHashGetSize
(
pUser
->
writeTbs
);
if
(
numOfRows
+
numOfReadDbs
+
numOfWriteDbs
+
numOfTopics
+
numOfReadTbs
+
numOfWriteTbs
>=
rows
)
break
;
if
(
pUser
->
superUser
)
{
cols
=
0
;
...
...
@@ -864,6 +1198,16 @@ static int32_t mndRetrievePrivileges(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
objName
,
false
);
char
tableName
[
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
tableName
,
""
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
tableName
,
false
);
char
condition
[
TSDB_PRIVILEDGE_CONDITION_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
condition
,
""
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
condition
,
false
);
numOfRows
++
;
}
...
...
@@ -888,6 +1232,16 @@ static int32_t mndRetrievePrivileges(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
objName
,
false
);
char
tableName
[
20
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
tableName
,
""
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
tableName
,
false
);
char
condition
[
20
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
condition
,
""
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
condition
,
false
);
numOfRows
++
;
db
=
taosHashIterate
(
pUser
->
readDbs
,
db
);
}
...
...
@@ -913,10 +1267,24 @@ static int32_t mndRetrievePrivileges(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
objName
,
false
);
char
tableName
[
20
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
tableName
,
""
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
tableName
,
false
);
char
condition
[
20
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
condition
,
""
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
condition
,
false
);
numOfRows
++
;
db
=
taosHashIterate
(
pUser
->
writeDbs
,
db
);
}
mndLoopHash
(
pUser
->
readTbs
,
"read"
,
pBlock
,
&
numOfRows
,
pUser
->
user
,
pShow
);
mndLoopHash
(
pUser
->
writeTbs
,
"write"
,
pBlock
,
&
numOfRows
,
pUser
->
user
,
pShow
);
char
*
topic
=
taosHashIterate
(
pUser
->
topics
,
NULL
);
while
(
topic
!=
NULL
)
{
cols
=
0
;
...
...
@@ -936,6 +1304,16 @@ static int32_t mndRetrievePrivileges(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
topicName
,
false
);
char
tableName
[
20
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
tableName
,
""
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
tableName
,
false
);
char
condition
[
20
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
condition
,
""
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
condition
,
false
);
numOfRows
++
;
topic
=
taosHashIterate
(
pUser
->
topics
,
topic
);
}
...
...
source/dnode/vnode/inc/vnode.h
浏览文件 @
4c04b155
...
...
@@ -228,19 +228,12 @@ typedef struct SSnapContext {
SArray
*
idList
;
int32_t
index
;
bool
withMeta
;
bool
queryMeta
OrData
;
// true-get meta, false-get data
bool
queryMeta
;
// true-get meta, false-get data
}
SSnapContext
;
typedef
struct
STqReader
{
// const SSubmitReq *pMsg;
// SSubmitBlk *pBlock;
// SSubmitMsgIter msgIter;
// SSubmitBlkIter blkIter;
int64_t
ver
;
SPackedData
msg2
;
int8_t
setMsg
;
SSubmitReq2
submit
;
int32_t
nextBlk
;
...
...
@@ -267,7 +260,7 @@ int32_t tqReaderAddTbUidList(STqReader *pReader, const SArray *tbUidList);
int32_t
tqReaderRemoveTbUidList
(
STqReader
*
pReader
,
const
SArray
*
tbUidList
);
int32_t
tqSeekVer
(
STqReader
*
pReader
,
int64_t
ver
,
const
char
*
id
);
int32_t
tqNextBlock
(
STqReader
*
pReader
,
SFetchRet
*
ret
);
void
tqNextBlock
(
STqReader
*
pReader
,
SFetchRet
*
ret
);
int32_t
tqReaderSetSubmitReq2
(
STqReader
*
pReader
,
void
*
msgStr
,
int32_t
msgLen
,
int64_t
ver
);
// int32_t tqReaderSetDataMsg(STqReader *pReader, const SSubmitReq *pMsg, int64_t ver);
...
...
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
4c04b155
...
...
@@ -123,12 +123,12 @@ int32_t tsdbRowIterOpen(STSDBRowIter *pIter, TSDBROW *pRow, STSchema *pTSchema)
void
tsdbRowClose
(
STSDBRowIter
*
pIter
);
SColVal
*
tsdbRowIterNext
(
STSDBRowIter
*
pIter
);
// SRowMerger
int32_t
tsdbRowMergerInit
2
(
SRowMerger
*
pMerger
,
STSchema
*
pResTSchema
,
TSDBROW
*
pRow
,
STSchema
*
pTSchema
);
int32_t
tsdbRowMergerInit
(
SRowMerger
*
pMerger
,
STSchema
*
pResTSchema
,
TSDBROW
*
pRow
,
STSchema
*
pTSchema
);
int32_t
tsdbRowMergerAdd
(
SRowMerger
*
pMerger
,
TSDBROW
*
pRow
,
STSchema
*
pTSchema
);
int32_t
tsdbRowMergerInit
(
SRowMerger
*
pMerger
,
TSDBROW
*
pRow
,
STSchema
*
pTSchema
);
void
tsdbRowMergerClear
(
SRowMerger
*
pMerger
);
int32_t
tsdbRowMerge
(
SRowMerger
*
pMerger
,
TSDBROW
*
pRow
);
//
int32_t tsdbRowMergerInit(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema);
void
tsdbRowMergerClear
(
SRowMerger
*
pMerger
);
//
int32_t tsdbRowMerge(SRowMerger *pMerger, TSDBROW *pRow);
int32_t
tsdbRowMergerGetRow
(
SRowMerger
*
pMerger
,
SRow
**
ppRow
);
// TABLEID
int32_t
tTABLEIDCmprFn
(
const
void
*
p1
,
const
void
*
p2
);
...
...
@@ -224,7 +224,7 @@ int32_t tsdbTbDataIterCreate(STbData *pTbData, TSDBKEY *pFrom, int8_t backward,
void
*
tsdbTbDataIterDestroy
(
STbDataIter
*
pIter
);
void
tsdbTbDataIterOpen
(
STbData
*
pTbData
,
TSDBKEY
*
pFrom
,
int8_t
backward
,
STbDataIter
*
pIter
);
bool
tsdbTbDataIterNext
(
STbDataIter
*
pIter
);
void
tsdbMemTableCountRows
(
SMemTable
*
pMemTable
,
SHashObj
*
pTableMap
,
int64_t
*
rowsNum
);
void
tsdbMemTableCountRows
(
SMemTable
*
pMemTable
,
SHashObj
*
pTableMap
,
int64_t
*
rowsNum
);
// STbData
int32_t
tsdbGetNRowsInTbData
(
STbData
*
pTbData
);
...
...
source/dnode/vnode/src/meta/metaSnapshot.c
浏览文件 @
4c04b155
...
...
@@ -268,7 +268,7 @@ int32_t buildSnapContext(SMeta* pMeta, int64_t snapVersion, int64_t suid, int8_t
ctx
->
snapVersion
=
snapVersion
;
ctx
->
suid
=
suid
;
ctx
->
subType
=
subType
;
ctx
->
queryMeta
OrData
=
withMeta
;
ctx
->
queryMeta
=
withMeta
;
ctx
->
withMeta
=
withMeta
;
ctx
->
idVersion
=
taosHashInit
(
100
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
true
,
HASH_NO_LOCK
);
if
(
ctx
->
idVersion
==
NULL
)
{
...
...
@@ -475,7 +475,7 @@ int32_t getMetafromSnapShot(SSnapContext* ctx, void** pBuf, int32_t* contLen, in
if
(
ctx
->
index
>=
taosArrayGetSize
(
ctx
->
idList
))
{
metaDebug
(
"tmqsnap get meta end"
);
ctx
->
index
=
0
;
ctx
->
queryMeta
OrData
=
false
;
// change to get data
ctx
->
queryMeta
=
false
;
// change to get data
return
0
;
}
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
4c04b155
...
...
@@ -240,17 +240,6 @@ int32_t tqPushDataRsp(STQ* pTq, STqPushEntry* pPushEntry) {
}
int32_t
tqSendDataRsp
(
STQ
*
pTq
,
const
SRpcMsg
*
pMsg
,
const
SMqPollReq
*
pReq
,
const
SMqDataRsp
*
pRsp
,
int32_t
type
)
{
#if 0
A(taosArrayGetSize(pRsp->blockData) == pRsp->blockNum);
A(taosArrayGetSize(pRsp->blockDataLen) == pRsp->blockNum);
A(!pRsp->withSchema);
A(taosArrayGetSize(pRsp->blockSchema) == 0);
if (pRsp->reqOffset.type == TMQ_OFFSET__LOG) {
A(pRsp->rspOffset.version > pRsp->reqOffset.version);
}
#endif
doSendDataRsp
(
&
pMsg
->
info
,
pRsp
,
pReq
->
epoch
,
pReq
->
consumerId
,
type
);
char
buf1
[
80
]
=
{
0
};
...
...
@@ -352,17 +341,6 @@ static int32_t tqInitDataRsp(SMqDataRsp* pRsp, const SMqPollReq* pReq, int8_t su
}
pRsp
->
withTbName
=
0
;
#if 0
pRsp->withTbName = pReq->withTbName;
if (pRsp->withTbName) {
pRsp->blockTbName = taosArrayInit(0, sizeof(void*));
if (pRsp->blockTbName == NULL) {
// TODO free
return -1;
}
}
#endif
pRsp
->
withSchema
=
false
;
return
0
;
}
...
...
@@ -422,6 +400,7 @@ static int32_t extractResetOffsetVal(STqOffsetVal* pOffsetVal, STQ* pTq, STqHand
return
-
1
;
}
// offset set to previous version when init
tqOffsetResetToLog
(
pOffsetVal
,
pHandle
->
pRef
->
refVer
-
1
);
}
}
else
if
(
reqOffset
.
type
==
TMQ_OFFSET__RESET_LATEST
)
{
...
...
@@ -463,7 +442,6 @@ static int32_t extractResetOffsetVal(STqOffsetVal* pOffsetVal, STQ* pTq, STqHand
static
int32_t
extractDataAndRspForNormalSubscribe
(
STQ
*
pTq
,
STqHandle
*
pHandle
,
const
SMqPollReq
*
pRequest
,
SRpcMsg
*
pMsg
,
STqOffsetVal
*
pOffset
)
{
int32_t
code
=
0
;
uint64_t
consumerId
=
pRequest
->
consumerId
;
int32_t
vgId
=
TD_VID
(
pTq
->
pVnode
);
...
...
@@ -474,10 +452,9 @@ static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle,
taosWLockLatch
(
&
pTq
->
lock
);
qSetTaskId
(
pHandle
->
execHandle
.
task
,
consumerId
,
pRequest
->
reqId
);
code
=
tqScanData
(
pTq
,
pHandle
,
&
dataRsp
,
pOffset
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
taosWUnLockLatch
(
&
pTq
->
lock
);
return
code
;
int
code
=
tqScanData
(
pTq
,
pHandle
,
&
dataRsp
,
pOffset
);
if
(
code
!=
0
)
{
goto
end
;
}
// till now, all data has been transferred to consumer, new data needs to push client once arrived.
...
...
@@ -488,59 +465,33 @@ static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle,
return
code
;
}
taosWUnLockLatch
(
&
pTq
->
lock
);
code
=
tqSendDataRsp
(
pTq
,
pMsg
,
pRequest
,
(
SMqDataRsp
*
)
&
dataRsp
,
TMQ_MSG_TYPE__POLL_RSP
);
// NOTE: this pHandle->consumerId may have been changed already.
tqDebug
(
"tmq poll: consumer:0x%"
PRIx64
", subkey %s, vgId:%d, rsp block:%d, offset type:%d, uid/version:%"
PRId64
", ts:%"
PRId64
", reqId:0x%"
PRIx64
,
consumerId
,
pHandle
->
subKey
,
vgId
,
dataRsp
.
blockNum
,
dataRsp
.
rspOffset
.
type
,
dataRsp
.
rspOffset
.
uid
,
dataRsp
.
rspOffset
.
ts
,
pRequest
->
reqId
);
end
:
{
char
buf
[
80
]
=
{
0
};
tFormatOffset
(
buf
,
80
,
&
dataRsp
.
rspOffset
);
tqDebug
(
"tmq poll: consumer:0x%"
PRIx64
", subkey %s, vgId:%d, rsp block:%d, rsp offset type:%s, reqId:0x%"
PRIx64
" code:%d"
,
consumerId
,
pHandle
->
subKey
,
vgId
,
dataRsp
.
blockNum
,
buf
,
pRequest
->
reqId
,
code
);
taosWUnLockLatch
(
&
pTq
->
lock
);
tDeleteSMqDataRsp
(
&
dataRsp
);
}
return
code
;
}
static
int32_t
doPollDataForMq
(
STQ
*
pTq
,
STqHandle
*
pHandle
,
const
SMqPollReq
*
pRequest
,
SRpcMsg
*
pMsg
)
{
int32_t
code
=
-
1
;
STqOffsetVal
offset
=
{
0
};
SWalCkHead
*
pCkHead
=
NULL
;
int32_t
vgId
=
TD_VID
(
pTq
->
pVnode
);
STqOffsetVal
reqOffset
=
pRequest
->
reqOffset
;
uint64_t
consumerId
=
pRequest
->
consumerId
;
// 1. reset the offset if needed
if
(
IS_OFFSET_RESET_TYPE
(
reqOffset
.
type
))
{
// handle the reset offset cases, according to the consumer's choice.
bool
blockReturned
=
false
;
code
=
extractResetOffsetVal
(
&
offset
,
pTq
,
pHandle
,
pRequest
,
pMsg
,
&
blockReturned
);
if
(
code
!=
0
)
{
return
code
;
}
// empty block returned, quit
if
(
blockReturned
)
{
return
0
;
}
}
else
{
// use the consumer specified offset
// the offset value can not be monotonious increase??
offset
=
reqOffset
;
}
// this is a normal subscribe requirement
if
(
pHandle
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
return
extractDataAndRspForNormalSubscribe
(
pTq
,
pHandle
,
pRequest
,
pMsg
,
&
offset
);
}
// todo handle the case where re-balance occurs.
// for taosx
SMqMetaRsp
metaRsp
=
{
0
};
STaosxRsp
taosxRsp
=
{
0
};
static
int32_t
extractDataAndRspForDbStbSubscribe
(
STQ
*
pTq
,
STqHandle
*
pHandle
,
const
SMqPollReq
*
pRequest
,
SRpcMsg
*
pMsg
,
STqOffsetVal
*
offset
)
{
int
code
=
0
;
int32_t
vgId
=
TD_VID
(
pTq
->
pVnode
);
SWalCkHead
*
pCkHead
=
NULL
;
SMqMetaRsp
metaRsp
=
{
0
};
STaosxRsp
taosxRsp
=
{
0
};
tqInitTaosxRsp
(
&
taosxRsp
,
pRequest
);
if
(
offset
.
type
!=
TMQ_OFFSET__LOG
)
{
if
(
tqScanTaosx
(
pTq
,
pHandle
,
&
taosxRsp
,
&
metaRsp
,
&
offset
)
<
0
)
{
if
(
offset
->
type
!=
TMQ_OFFSET__LOG
)
{
if
(
tqScanTaosx
(
pTq
,
pHandle
,
&
taosxRsp
,
&
metaRsp
,
offset
)
<
0
)
{
return
-
1
;
}
...
...
@@ -548,28 +499,28 @@ static int32_t doPollDataForMq(STQ* pTq, STqHandle* pHandle, const SMqPollReq* p
code
=
tqSendMetaPollRsp
(
pTq
,
pMsg
,
pRequest
,
&
metaRsp
);
tqDebug
(
"tmq poll: consumer:0x%"
PRIx64
" subkey:%s vgId:%d, send meta offset type:%d,uid:%"
PRId64
",ts:%"
PRId64
,
consumerId
,
pHandle
->
subKey
,
vgId
,
metaRsp
.
rspOffset
.
type
,
metaRsp
.
rspOffset
.
uid
,
metaRsp
.
rspOffset
.
ts
);
pRequest
->
consumerId
,
pHandle
->
subKey
,
vgId
,
metaRsp
.
rspOffset
.
type
,
metaRsp
.
rspOffset
.
uid
,
metaRsp
.
rspOffset
.
ts
);
taosMemoryFree
(
metaRsp
.
metaRsp
);
tDeleteSTaosxRsp
(
&
taosxRsp
);
return
code
;
}
tqDebug
(
"taosx poll: consumer:0x%"
PRIx64
" subkey:%s vgId:%d, send data blockNum:%d, offset type:%d,uid:%"
PRId64
",ts:%"
PRId64
,
pRequest
->
consumerId
,
pHandle
->
subKey
,
vgId
,
taosxRsp
.
blockNum
,
taosxRsp
.
rspOffset
.
type
,
taosxRsp
.
rspOffset
.
uid
,
taosxRsp
.
rspOffset
.
ts
);
if
(
taosxRsp
.
blockNum
>
0
)
{
code
=
tqSendDataRsp
(
pTq
,
pMsg
,
pRequest
,
(
SMqDataRsp
*
)
&
taosxRsp
,
TMQ_MSG_TYPE__TAOSX_RSP
);
tDeleteSTaosxRsp
(
&
taosxRsp
);
return
code
;
}
else
{
offset
=
taosxRsp
.
rspOffset
;
*
offset
=
taosxRsp
.
rspOffset
;
}
tqDebug
(
"taosx poll: consumer:0x%"
PRIx64
" subkey:%s vgId:%d, send data blockNum:%d, offset type:%d,uid:%"
PRId64
",version:%"
PRId64
,
consumerId
,
pHandle
->
subKey
,
vgId
,
taosxRsp
.
blockNum
,
taosxRsp
.
rspOffset
.
type
,
taosxRsp
.
rspOffset
.
uid
,
taosxRsp
.
rspOffset
.
version
);
}
if
(
offset
.
type
==
TMQ_OFFSET__LOG
)
{
int64_t
fetchVer
=
offset
.
version
+
1
;
if
(
offset
->
type
==
TMQ_OFFSET__LOG
)
{
int64_t
fetchVer
=
offset
->
version
+
1
;
pCkHead
=
taosMemoryMalloc
(
sizeof
(
SWalCkHead
)
+
2048
);
if
(
pCkHead
==
NULL
)
{
tDeleteSTaosxRsp
(
&
taosxRsp
);
...
...
@@ -579,12 +530,11 @@ static int32_t doPollDataForMq(STQ* pTq, STqHandle* pHandle, const SMqPollReq* p
walSetReaderCapacity
(
pHandle
->
pWalReader
,
2048
);
int
totalRows
=
0
;
while
(
1
)
{
// todo refactor: this is not correct.
int32_t
savedEpoch
=
atomic_load_32
(
&
pHandle
->
epoch
);
if
(
savedEpoch
>
pRequest
->
epoch
)
{
tqWarn
(
"tmq poll: consumer:0x%"
PRIx64
" (epoch %d), subkey:%s vgId:%d offset %"
PRId64
", found new consumer epoch %d, discard req epoch %d"
,
consumerId
,
pRequest
->
epoch
,
pHandle
->
subKey
,
vgId
,
fetchVer
,
savedEpoch
,
pRequest
->
epoch
);
pRequest
->
consumerId
,
pRequest
->
epoch
,
pHandle
->
subKey
,
vgId
,
fetchVer
,
savedEpoch
,
pRequest
->
epoch
);
break
;
}
...
...
@@ -597,8 +547,8 @@ static int32_t doPollDataForMq(STQ* pTq, STqHandle* pHandle, const SMqPollReq* p
}
SWalCont
*
pHead
=
&
pCkHead
->
head
;
tqDebug
(
"tmq poll: consumer:0x%"
PRIx64
" (epoch %d) iter log, vgId:%d offset %"
PRId64
" msgType %d"
,
consumerId
,
pRequest
->
epoch
,
vgId
,
fetchVer
,
pHead
->
msgType
);
tqDebug
(
"tmq poll: consumer:0x%"
PRIx64
" (epoch %d) iter log, vgId:%d offset %"
PRId64
" msgType %d"
,
pRequest
->
consumerId
,
pRequest
->
epoch
,
vgId
,
fetchVer
,
pHead
->
msgType
);
// process meta
if
(
pHead
->
msgType
!=
TDMT_VND_SUBMIT
)
{
...
...
@@ -635,7 +585,7 @@ static int32_t doPollDataForMq(STQ* pTq, STqHandle* pHandle, const SMqPollReq* p
};
if
(
tqTaosxScanLog
(
pTq
,
pHandle
,
submit
,
&
taosxRsp
,
&
totalRows
)
<
0
)
{
tqError
(
"tmq poll: tqTaosxScanLog error %"
PRId64
", in vgId:%d, subkey %s"
,
consumerId
,
vgId
,
tqError
(
"tmq poll: tqTaosxScanLog error %"
PRId64
", in vgId:%d, subkey %s"
,
pRequest
->
consumerId
,
vgId
,
pRequest
->
subKey
);
taosMemoryFreeClear
(
pCkHead
);
tDeleteSTaosxRsp
(
&
taosxRsp
);
...
...
@@ -659,6 +609,39 @@ static int32_t doPollDataForMq(STQ* pTq, STqHandle* pHandle, const SMqPollReq* p
return
0
;
}
static
int32_t
doPollDataForMq
(
STQ
*
pTq
,
STqHandle
*
pHandle
,
const
SMqPollReq
*
pRequest
,
SRpcMsg
*
pMsg
)
{
int32_t
code
=
-
1
;
STqOffsetVal
offset
=
{
0
};
STqOffsetVal
reqOffset
=
pRequest
->
reqOffset
;
// 1. reset the offset if needed
if
(
IS_OFFSET_RESET_TYPE
(
reqOffset
.
type
))
{
// handle the reset offset cases, according to the consumer's choice.
bool
blockReturned
=
false
;
code
=
extractResetOffsetVal
(
&
offset
,
pTq
,
pHandle
,
pRequest
,
pMsg
,
&
blockReturned
);
if
(
code
!=
0
)
{
return
code
;
}
// empty block returned, quit
if
(
blockReturned
)
{
return
0
;
}
}
else
{
// use the consumer specified offset
// the offset value can not be monotonious increase??
offset
=
reqOffset
;
}
// this is a normal subscribe requirement
if
(
pHandle
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
return
extractDataAndRspForNormalSubscribe
(
pTq
,
pHandle
,
pRequest
,
pMsg
,
&
offset
);
}
// todo handle the case where re-balance occurs.
// for taosx
return
extractDataAndRspForDbStbSubscribe
(
pTq
,
pHandle
,
pRequest
,
pMsg
,
&
offset
);
}
int32_t
tqProcessPollReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
)
{
SMqPollReq
req
=
{
0
};
if
(
tDeserializeSMqPollReq
(
pMsg
->
pCont
,
pMsg
->
contLen
,
&
req
)
<
0
)
{
...
...
@@ -821,13 +804,7 @@ int32_t tqProcessSubscribeReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg
pHandle
->
pRef
=
pRef
;
SReadHandle
handle
=
{
.
meta
=
pVnode
->
pMeta
,
.
vnode
=
pVnode
,
.
initTableReader
=
true
,
.
initTqReader
=
true
,
.
version
=
ver
,
};
.
meta
=
pVnode
->
pMeta
,
.
vnode
=
pVnode
,
.
initTableReader
=
true
,
.
initTqReader
=
true
,
.
version
=
ver
};
pHandle
->
snapshotVer
=
ver
;
if
(
pHandle
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
...
...
@@ -1341,7 +1318,7 @@ int32_t tqProcessDelReq(STQ* pTq, void* pReq, int32_t len, int64_t ver) {
pRefBlock
->
dataRef
=
pRef
;
atomic_add_fetch_32
(
pRefBlock
->
dataRef
,
1
);
if
(
streamTaskInput
(
pTask
,
(
SStreamQueueItem
*
)
pRefBlock
)
<
0
)
{
if
(
tAppendDataForStream
(
pTask
,
(
SStreamQueueItem
*
)
pRefBlock
)
<
0
)
{
qError
(
"stream task input del failed, task id %d"
,
pTask
->
taskId
);
atomic_sub_fetch_32
(
pRef
,
1
);
...
...
@@ -1376,7 +1353,7 @@ int32_t tqProcessDelReq(STQ* pTq, void* pReq, int32_t len, int64_t ver) {
taosArrayPush(pStreamBlock->blocks, &block);
if (!failed) {
if (
streamTaskInput
(pTask, (SStreamQueueItem*)pStreamBlock) < 0) {
if (
tAppendDataForStream
(pTask, (SStreamQueueItem*)pStreamBlock) < 0) {
qError("stream task input del failed, task id %d", pTask->taskId);
continue;
}
...
...
@@ -1396,15 +1373,14 @@ int32_t tqProcessDelReq(STQ* pTq, void* pReq, int32_t len, int64_t ver) {
}
int32_t
tqProcessSubmitReq
(
STQ
*
pTq
,
SPackedData
submit
)
{
void
*
pIter
=
NULL
;
bool
failed
=
false
;
SStreamDataSubmit2
*
pSubmit
=
NULL
;
void
*
pIter
=
NULL
;
bool
succ
=
true
;
pSubmit
=
streamDataSubmitNew
(
submit
);
SStreamDataSubmit2
*
pSubmit
=
streamDataSubmitNew
(
submit
);
if
(
pSubmit
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
tqError
(
"failed to create data submit for stream since out of memory"
);
failed
=
tru
e
;
succ
=
fals
e
;
}
while
(
1
)
{
...
...
@@ -1414,22 +1390,27 @@ int32_t tqProcessSubmitReq(STQ* pTq, SPackedData submit) {
}
SStreamTask
*
pTask
=
*
(
SStreamTask
**
)
pIter
;
if
(
pTask
->
taskLevel
!=
TASK_LEVEL__SOURCE
)
continue
;
if
(
pTask
->
taskLevel
!=
TASK_LEVEL__SOURCE
)
{
continue
;
}
if
(
pTask
->
taskStatus
==
TASK_STATUS__RECOVER_PREPARE
||
pTask
->
taskStatus
==
TASK_STATUS__WAIT_DOWNSTREAM
)
{
tqDebug
(
"s
kip push task %d, task
status %d"
,
pTask
->
taskId
,
pTask
->
taskStatus
);
tqDebug
(
"s
tream task:%d skip push data, not ready for processing,
status %d"
,
pTask
->
taskId
,
pTask
->
taskStatus
);
continue
;
}
tqDebug
(
"data submit enqueue stream task: %d, ver: %"
PRId64
,
pTask
->
taskId
,
submit
.
ver
);
tqDebug
(
"data submit enqueue stream task:%d, ver: %"
PRId64
,
pTask
->
taskId
,
submit
.
ver
);
if
(
succ
)
{
int32_t
code
=
tAppendDataForStream
(
pTask
,
(
SStreamQueueItem
*
)
pSubmit
);
if
(
code
<
0
)
{
// let's handle the back pressure
if
(
!
failed
)
{
if
(
streamTaskInput
(
pTask
,
(
SStreamQueueItem
*
)
pSubmit
)
<
0
)
{
tqError
(
"stream task input failed, task id %d"
,
pTask
->
taskId
);
tqError
(
"stream task:%d failed to put into queue for, too many"
,
pTask
->
taskId
);
continue
;
}
if
(
streamSchedExec
(
pTask
)
<
0
)
{
tqError
(
"stream task
launch failed, task id %d"
,
pTask
->
taskId
);
tqError
(
"stream task
:%d launch failed, code:%s"
,
pTask
->
taskId
,
tstrerror
(
terrno
)
);
continue
;
}
}
else
{
...
...
@@ -1437,12 +1418,12 @@ int32_t tqProcessSubmitReq(STQ* pTq, SPackedData submit) {
}
}
if
(
pSubmit
)
{
streamDataSubmit
RefDec
(
pSubmit
);
if
(
pSubmit
!=
NULL
)
{
streamDataSubmit
Destroy
(
pSubmit
);
taosFreeQitem
(
pSubmit
);
}
return
failed
?
-
1
:
0
;
return
succ
?
0
:
-
1
;
}
int32_t
tqProcessTaskRunReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
)
{
...
...
@@ -1562,6 +1543,8 @@ int32_t vnodeEnqueueStreamMsg(SVnode* pVnode, SRpcMsg* pMsg) {
rpcFreeCont
(
pMsg
->
pCont
);
taosFreeQitem
(
pMsg
);
return
0
;
}
else
{
tDeleteStreamDispatchReq
(
&
req
);
}
code
=
TSDB_CODE_STREAM_TASK_NOT_EXIST
;
...
...
source/dnode/vnode/src/tq/tqPush.c
浏览文件 @
4c04b155
...
...
@@ -30,7 +30,7 @@ static int32_t tqLoopExecFromQueue(STQ* pTq, STqHandle* pHandle, SStreamDataSubm
// update processed
atomic_store_64(&pHandle->pushHandle.processedVer, pSubmit->ver);
streamQueueProcessSuccess(&pHandle->pushHandle.inputQ);
streamDataSubmit
RefDec
(pSubmit);
streamDataSubmit
Destroy
(pSubmit);
if (pRsp->blockNum > 0) {
*ppSubmit = pSubmit;
return 0;
...
...
@@ -58,7 +58,7 @@ int32_t tqExecFromInputQ(STQ* pTq, STqHandle* pHandle) {
}
while (pHandle->pushHandle.processedVer > pSubmit->ver + 1) {
streamQueueProcessSuccess(&pHandle->pushHandle.inputQ);
streamDataSubmit
RefDec
(pSubmit);
streamDataSubmit
Destroy
(pSubmit);
pSubmit = streamQueueNextItem(&pHandle->pushHandle.inputQ);
if (pSubmit == NULL) break;
}
...
...
@@ -120,7 +120,7 @@ int32_t tqPreparePush(STQ* pTq, STqHandle* pHandle, int64_t reqId, const SRpcHan
int32_t tqEnqueue(STqHandle* pHandle, SStreamDataSubmit* pSubmit) {
int8_t inputStatus = atomic_load_8(&pHandle->pushHandle.inputStatus);
if (inputStatus == TASK_INPUT_STATUS__NORMAL) {
SStreamDataSubmit* pSubmitClone = streamSubmit
Ref
Clone(pSubmit);
SStreamDataSubmit* pSubmitClone = streamSubmit
Block
Clone(pSubmit);
if (pSubmitClone == NULL) {
return -1;
}
...
...
@@ -212,28 +212,13 @@ typedef struct {
}
SItem
;
static
void
recordPushedEntry
(
SArray
*
cachedKey
,
void
*
pIter
);
static
void
doRemovePushedEntry
(
SArray
*
pCachedKeys
,
STQ
*
pTq
);
static
void
freeItem
(
void
*
param
)
{
SItem
*
p
=
(
SItem
*
)
param
;
taosMemoryFree
(
p
->
pKey
);
}
static
void
doRemovePushedEntry
(
SArray
*
pCachedKeys
,
STQ
*
pTq
)
{
int32_t
vgId
=
TD_VID
(
pTq
->
pVnode
);
int32_t
numOfKeys
=
(
int32_t
)
taosArrayGetSize
(
pCachedKeys
);
for
(
int32_t
i
=
0
;
i
<
numOfKeys
;
i
++
)
{
SItem
*
pItem
=
taosArrayGet
(
pCachedKeys
,
i
);
if
(
taosHashRemove
(
pTq
->
pPushMgr
,
pItem
->
pKey
,
pItem
->
keyLen
)
!=
0
)
{
tqError
(
"vgId:%d, tq push hash remove key error, key: %s"
,
vgId
,
(
char
*
)
pItem
->
pKey
);
}
}
if
(
numOfKeys
>
0
)
{
tqDebug
(
"vgId:%d, pushed %d items and remain:%d"
,
vgId
,
numOfKeys
,
(
int32_t
)
taosHashGetSize
(
pTq
->
pPushMgr
));
}
}
static
void
doPushDataForEntry
(
void
*
pIter
,
STqExecHandle
*
pExec
,
STQ
*
pTq
,
int64_t
ver
,
int32_t
vgId
,
char
*
pData
,
int32_t
dataLen
,
SArray
*
pCachedKey
)
{
STqPushEntry
*
pPushEntry
=
*
(
STqPushEntry
**
)
pIter
;
...
...
@@ -253,7 +238,7 @@ static void doPushDataForEntry(void* pIter, STqExecHandle* pExec, STQ* pTq, int6
if
(
qStreamSetScanMemData
(
pTaskInfo
,
submit
)
!=
0
)
{
return
;
}
qStreamSetOpen
(
pTaskInfo
);
// here start to scan submit block to extract the subscribed data
int32_t
totalRows
=
0
;
...
...
@@ -348,7 +333,7 @@ int32_t tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t v
void
*
data
=
taosMemoryMalloc
(
len
);
if
(
data
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
tqError
(
"
failed to copy data for stream since out of memory"
);
tqError
(
"
vgId:%d, failed to copy submit data for stream processing, since out of memory"
,
vgId
);
return
-
1
;
}
...
...
@@ -367,13 +352,6 @@ int32_t tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t v
return
0
;
}
void
recordPushedEntry
(
SArray
*
cachedKey
,
void
*
pIter
)
{
size_t
kLen
=
0
;
void
*
key
=
taosHashGetKey
(
pIter
,
&
kLen
);
SItem
item
=
{.
pKey
=
strndup
(
key
,
kLen
),
.
keyLen
=
kLen
};
taosArrayPush
(
cachedKey
,
&
item
);
}
int32_t
tqRegisterPushEntry
(
STQ
*
pTq
,
void
*
pHandle
,
const
SMqPollReq
*
pRequest
,
SRpcMsg
*
pRpcMsg
,
SMqDataRsp
*
pDataRsp
,
int32_t
type
)
{
uint64_t
consumerId
=
pRequest
->
consumerId
;
...
...
@@ -431,3 +409,26 @@ int32_t tqUnregisterPushEntry(STQ* pTq, const char* pKey, int32_t keyLen, uint64
return
0
;
}
void
recordPushedEntry
(
SArray
*
cachedKey
,
void
*
pIter
)
{
size_t
kLen
=
0
;
void
*
key
=
taosHashGetKey
(
pIter
,
&
kLen
);
SItem
item
=
{.
pKey
=
strndup
(
key
,
kLen
),
.
keyLen
=
kLen
};
taosArrayPush
(
cachedKey
,
&
item
);
}
void
doRemovePushedEntry
(
SArray
*
pCachedKeys
,
STQ
*
pTq
)
{
int32_t
vgId
=
TD_VID
(
pTq
->
pVnode
);
int32_t
numOfKeys
=
(
int32_t
)
taosArrayGetSize
(
pCachedKeys
);
for
(
int32_t
i
=
0
;
i
<
numOfKeys
;
i
++
)
{
SItem
*
pItem
=
taosArrayGet
(
pCachedKeys
,
i
);
if
(
taosHashRemove
(
pTq
->
pPushMgr
,
pItem
->
pKey
,
pItem
->
keyLen
)
!=
0
)
{
tqError
(
"vgId:%d, tq push hash remove key error, key: %s"
,
vgId
,
(
char
*
)
pItem
->
pKey
);
}
}
if
(
numOfKeys
>
0
)
{
tqDebug
(
"vgId:%d, pushed %d items and remain:%d"
,
vgId
,
numOfKeys
,
(
int32_t
)
taosHashGetSize
(
pTq
->
pPushMgr
));
}
}
source/dnode/vnode/src/tq/tqRead.c
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
source/dnode/vnode/src/tq/tqScan.c
浏览文件 @
4c04b155
...
...
@@ -74,33 +74,23 @@ int32_t tqScanData(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffs
qTaskInfo_t
task
=
pExec
->
task
;
if
(
qStreamPrepareScan
(
task
,
pOffset
,
pHandle
->
execHandle
.
subType
)
<
0
)
{
tqDebug
(
"prepare scan failed, vgId:%d, consumer:0x%"
PRIx64
,
vgId
,
pHandle
->
consumerId
);
if
(
pOffset
->
type
==
TMQ_OFFSET__LOG
)
{
pRsp
->
rspOffset
=
*
pOffset
;
return
code
;
}
else
{
tqOffsetResetToLog
(
pOffset
,
pHandle
->
snapshotVer
);
if
(
qStreamPrepareScan
(
task
,
pOffset
,
pHandle
->
execHandle
.
subType
)
<
0
)
{
tqDebug
(
"prepare scan failed, vgId:%d, consumer:0x%"
PRIx64
,
vgId
,
pHandle
->
consumerId
);
pRsp
->
rspOffset
=
*
pOffset
;
return
code
;
}
}
tqError
(
"prepare scan failed, return"
);
return
-
1
;
}
while
(
1
)
{
SSDataBlock
*
pDataBlock
=
NULL
;
uint64_t
ts
=
0
;
tqDebug
(
"vgId:%d, tmq task start to execute, consumer:0x%"
PRIx64
,
vgId
,
pHandle
->
consumerId
);
code
=
qExecTask
(
task
,
&
pDataBlock
,
&
ts
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tqError
(
"vgId:%d, task exec error since %s, consumer:0x%"
PRIx64
,
vgId
,
terrstr
(),
pHandle
->
consumerId
);
return
code
;
qStreamSetOpen
(
task
);
tqDebug
(
"consumer:0x%"
PRIx64
" vgId:%d, tmq one task start execute"
,
pHandle
->
consumerId
,
vgId
);
if
(
qExecTask
(
task
,
&
pDataBlock
,
&
ts
)
!=
TSDB_CODE_SUCCESS
)
{
tqError
(
"consumer:0x%"
PRIx64
" vgId:%d, task exec error since %s"
,
pHandle
->
consumerId
,
vgId
,
terrstr
());
return
-
1
;
}
// current scan should be stopped ASAP, since the re-balance occurs.
tqDebug
(
"consumer:0x%"
PRIx64
" vgId:%d tmq one task end executed, pDataBlock:%p"
,
pHandle
->
consumerId
,
vgId
,
pDataBlock
);
// current scan should be stopped asap, since the rebalance occurs.
if
(
pDataBlock
==
NULL
)
{
break
;
}
...
...
@@ -112,37 +102,16 @@ int32_t tqScanData(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffs
}
pRsp
->
blockNum
++
;
tqDebug
(
"vgId:%d, consumer:0x%"
PRIx64
" tmq task executed, rows:%"
PRId64
", total blocks:%d"
,
vgId
,
pHandle
->
consumerId
,
pDataBlock
->
info
.
rows
,
pRsp
->
blockNum
);
if
(
pOffset
->
type
==
TMQ_OFFSET__SNAPSHOT_DATA
)
{
totalRows
+=
pDataBlock
->
info
.
rows
;
if
(
totalRows
>=
MAX_ROWS_TO_RETURN
)
{
break
;
}
totalRows
+=
pDataBlock
->
info
.
rows
;
if
(
totalRows
>=
MAX_ROWS_TO_RETURN
)
{
break
;
}
}
tqDebug
(
"consumer:0x%"
PRIx64
" vgId:%d tmq task executed finished, total blocks:%d, totalRows:%d"
,
pHandle
->
consumerId
,
vgId
,
pRsp
->
blockNum
,
totalRows
);
qStreamExtractOffset
(
task
,
&
pRsp
->
rspOffset
);
if
(
pRsp
->
rspOffset
.
type
==
0
)
{
code
=
TSDB_CODE_INVALID_PARA
;
tqError
(
"vgId:%d, expected rsp offset: type %d %"
PRId64
" %"
PRId64
" %"
PRId64
,
vgId
,
pRsp
->
rspOffset
.
type
,
pRsp
->
rspOffset
.
ts
,
pRsp
->
rspOffset
.
uid
,
pRsp
->
rspOffset
.
version
);
return
code
;
}
if
(
pRsp
->
withTbName
||
pRsp
->
withSchema
)
{
code
=
TSDB_CODE_INVALID_PARA
;
tqError
(
"vgId:%d, get column should not with meta:%d,%d"
,
vgId
,
pRsp
->
withTbName
,
pRsp
->
withSchema
);
return
code
;
}
tqDebug
(
"vgId:%d, consumer:0x%"
PRIx64
" tmq task executed, total blocks:%d, rows:%d"
,
vgId
,
pHandle
->
consumerId
,
pRsp
->
blockNum
,
totalRows
);
return
code
;
return
0
;
}
int32_t
tqScanTaosx
(
STQ
*
pTq
,
const
STqHandle
*
pHandle
,
STaosxRsp
*
pRsp
,
SMqMetaRsp
*
pMetaRsp
,
STqOffsetVal
*
pOffset
)
{
...
...
@@ -150,18 +119,8 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqMeta
qTaskInfo_t
task
=
pExec
->
task
;
if
(
qStreamPrepareScan
(
task
,
pOffset
,
pHandle
->
execHandle
.
subType
)
<
0
)
{
tqDebug
(
"prepare scan failed, return"
);
if
(
pOffset
->
type
==
TMQ_OFFSET__LOG
)
{
pRsp
->
rspOffset
=
*
pOffset
;
return
0
;
}
else
{
tqOffsetResetToLog
(
pOffset
,
pHandle
->
snapshotVer
);
if
(
qStreamPrepareScan
(
task
,
pOffset
,
pHandle
->
execHandle
.
subType
)
<
0
)
{
tqDebug
(
"prepare scan failed, return"
);
pRsp
->
rspOffset
=
*
pOffset
;
return
0
;
}
}
tqDebug
(
"tqScanTaosx prepare scan failed, return"
);
return
-
1
;
}
int32_t
rowCnt
=
0
;
...
...
@@ -207,42 +166,32 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqMeta
}
}
if
(
pDataBlock
==
NULL
&&
pOffset
->
type
==
TMQ_OFFSET__SNAPSHOT_DATA
)
{
if
(
qStreamExtractPrepareUid
(
task
)
!=
0
)
{
// get meta
SMqMetaRsp
*
tmp
=
qStreamExtractMetaMsg
(
task
);
if
(
tmp
->
metaRspLen
>
0
)
{
qStreamExtractOffset
(
task
,
&
tmp
->
rspOffset
);
*
pMetaRsp
=
*
tmp
;
tqDebug
(
"tmqsnap task get meta"
);
break
;
}
if
(
pDataBlock
==
NULL
)
{
qStreamExtractOffset
(
task
,
pOffset
);
if
(
pOffset
->
type
==
TMQ_OFFSET__SNAPSHOT_DATA
)
{
continue
;
}
tqDebug
(
"tmqsnap vgId: %d, tsdb consume over, switch to wal, ver %"
PRId64
,
TD_VID
(
pTq
->
pVnode
),
pHandle
->
snapshotVer
+
1
);
qStreamExtractOffset
(
task
,
&
pRsp
->
rspOffset
);
break
;
}
if
(
pRsp
->
blockNum
>
0
)
{
tqDebug
(
"tmqsnap task exec exited, get data"
);
qStreamExtractOffset
(
task
,
&
pRsp
->
rspOffset
);
break
;
}
SMqMetaRsp
*
tmp
=
qStreamExtractMetaMsg
(
task
);
if
(
tmp
->
rspOffset
.
type
==
TMQ_OFFSET__SNAPSHOT_DATA
)
{
tqOffsetResetToData
(
pOffset
,
tmp
->
rspOffset
.
uid
,
tmp
->
rspOffset
.
ts
);
qStreamPrepareScan
(
task
,
pOffset
,
pHandle
->
execHandle
.
subType
);
tmp
->
rspOffset
.
type
=
TMQ_OFFSET__SNAPSHOT_META
;
tqDebug
(
"tmqsnap task exec change to get data"
);
continue
;
}
*
pMetaRsp
=
*
tmp
;
tqDebug
(
"tmqsnap task exec exited, get meta"
);
tqDebug
(
"task exec exited"
);
break
;
}
qStreamExtractOffset
(
task
,
&
pRsp
->
rspOffset
);
if
(
pRsp
->
rspOffset
.
type
==
0
)
{
tqError
(
"expected rsp offset: type %d %"
PRId64
" %"
PRId64
" %"
PRId64
,
pRsp
->
rspOffset
.
type
,
pRsp
->
rspOffset
.
ts
,
pRsp
->
rspOffset
.
uid
,
pRsp
->
rspOffset
.
version
);
return
-
1
;
}
return
0
;
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
4c04b155
...
...
@@ -1969,7 +1969,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo*
if
(
pReader
->
order
==
TSDB_ORDER_ASC
)
{
if
(
minKey
==
key
)
{
init
=
true
;
int32_t
code
=
tsdbRowMergerInit
(
&
merge
,
&
fRow
,
pReader
->
pSchema
);
int32_t
code
=
tsdbRowMergerInit
(
&
merge
,
NULL
,
&
fRow
,
pReader
->
pSchema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -1979,10 +1979,10 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo*
if
(
minKey
==
tsLast
)
{
TSDBROW
fRow1
=
tMergeTreeGetRow
(
&
pLastBlockReader
->
mergeTree
);
if
(
init
)
{
tsdbRowMerge
(
&
merge
,
&
fRow1
);
tsdbRowMerge
rAdd
(
&
merge
,
&
fRow1
,
NULL
);
}
else
{
init
=
true
;
int32_t
code
=
tsdbRowMergerInit
(
&
merge
,
&
fRow1
,
pReader
->
pSchema
);
int32_t
code
=
tsdbRowMergerInit
(
&
merge
,
NULL
,
&
fRow1
,
pReader
->
pSchema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -1999,7 +1999,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo*
tsdbRowMergerAdd
(
&
merge
,
pRow
,
pSchema
);
}
else
{
init
=
true
;
int32_t
code
=
tsdbRowMergerInit
(
&
merge
,
pRow
,
pSchema
);
int32_t
code
=
tsdbRowMergerInit
(
&
merge
,
NULL
,
pRow
,
pSchema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -2013,7 +2013,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo*
if
(
minKey
==
k
.
ts
)
{
init
=
true
;
STSchema
*
pSchema
=
doGetSchemaForTSRow
(
TSDBROW_SVERSION
(
pRow
),
pReader
,
pBlockScanInfo
->
uid
);
int32_t
code
=
tsdbRowMergerInit
(
&
merge
,
pRow
,
pSchema
);
int32_t
code
=
tsdbRowMergerInit
(
&
merge
,
NULL
,
pRow
,
pSchema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -2027,10 +2027,10 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo*
if
(
minKey
==
tsLast
)
{
TSDBROW
fRow1
=
tMergeTreeGetRow
(
&
pLastBlockReader
->
mergeTree
);
if
(
init
)
{
tsdbRowMerge
(
&
merge
,
&
fRow1
);
tsdbRowMerge
rAdd
(
&
merge
,
&
fRow1
,
NULL
);
}
else
{
init
=
true
;
int32_t
code
=
tsdbRowMergerInit
(
&
merge
,
&
fRow1
,
pReader
->
pSchema
);
int32_t
code
=
tsdbRowMergerInit
(
&
merge
,
NULL
,
&
fRow1
,
pReader
->
pSchema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -2040,10 +2040,10 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo*
if
(
minKey
==
key
)
{
if
(
init
)
{
tsdbRowMerge
(
&
merge
,
&
fRow
);
tsdbRowMerge
rAdd
(
&
merge
,
&
fRow
,
NULL
);
}
else
{
init
=
true
;
int32_t
code
=
tsdbRowMergerInit
(
&
merge
,
&
fRow
,
pReader
->
pSchema
);
int32_t
code
=
tsdbRowMergerInit
(
&
merge
,
NULL
,
&
fRow
,
pReader
->
pSchema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -2088,13 +2088,13 @@ static int32_t doMergeFileBlockAndLastBlock(SLastBlockReader* pLastBlockReader,
pBlockScanInfo
->
lastKey
=
tsLastBlock
;
return
TSDB_CODE_SUCCESS
;
}
else
{
int32_t
code
=
tsdbRowMergerInit
(
&
merge
,
&
fRow
,
pReader
->
pSchema
);
int32_t
code
=
tsdbRowMergerInit
(
&
merge
,
NULL
,
&
fRow
,
pReader
->
pSchema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
TSDBROW
fRow1
=
tMergeTreeGetRow
(
&
pLastBlockReader
->
mergeTree
);
tsdbRowMerge
(
&
merge
,
&
fRow1
);
tsdbRowMerge
rAdd
(
&
merge
,
&
fRow1
,
NULL
);
doMergeRowsInLastBlock
(
pLastBlockReader
,
pBlockScanInfo
,
tsLastBlock
,
&
merge
,
&
pReader
->
verRange
,
pReader
->
idStr
);
code
=
tsdbRowMergerGetRow
(
&
merge
,
&
pTSRow
);
...
...
@@ -2112,7 +2112,7 @@ static int32_t doMergeFileBlockAndLastBlock(SLastBlockReader* pLastBlockReader,
}
}
}
else
{
// not merge block data
int32_t
code
=
tsdbRowMergerInit
(
&
merge
,
&
fRow
,
pReader
->
pSchema
);
int32_t
code
=
tsdbRowMergerInit
(
&
merge
,
NULL
,
&
fRow
,
pReader
->
pSchema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -2164,7 +2164,7 @@ static int32_t mergeFileBlockAndLastBlock(STsdbReader* pReader, SLastBlockReader
SRow
*
pTSRow
=
NULL
;
SRowMerger
merge
=
{
0
};
int32_t
code
=
tsdbRowMergerInit
(
&
merge
,
&
fRow
,
pReader
->
pSchema
);
int32_t
code
=
tsdbRowMergerInit
(
&
merge
,
NULL
,
&
fRow
,
pReader
->
pSchema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -2172,7 +2172,7 @@ static int32_t mergeFileBlockAndLastBlock(STsdbReader* pReader, SLastBlockReader
doMergeRowsInFileBlocks
(
pBlockData
,
pBlockScanInfo
,
pReader
,
&
merge
);
TSDBROW
fRow1
=
tMergeTreeGetRow
(
&
pLastBlockReader
->
mergeTree
);
tsdbRowMerge
(
&
merge
,
&
fRow1
);
tsdbRowMerge
rAdd
(
&
merge
,
&
fRow1
,
NULL
);
doMergeRowsInLastBlock
(
pLastBlockReader
,
pBlockScanInfo
,
ts
,
&
merge
,
&
pReader
->
verRange
,
pReader
->
idStr
);
...
...
@@ -2215,8 +2215,16 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo*
int64_t
key
=
hasDataInFileBlock
(
pBlockData
,
pDumpInfo
)
?
pBlockData
->
aTSKEY
[
pDumpInfo
->
rowIndex
]
:
INT64_MIN
;
TSDBKEY
k
=
TSDBROW_KEY
(
pRow
);
TSDBKEY
ik
=
TSDBROW_KEY
(
piRow
);
TSDBKEY
k
=
TSDBROW_KEY
(
pRow
);
TSDBKEY
ik
=
TSDBROW_KEY
(
piRow
);
STSchema
*
pSchema
=
doGetSchemaForTSRow
(
TSDBROW_SVERSION
(
pRow
),
pReader
,
pBlockScanInfo
->
uid
);
if
(
pSchema
==
NULL
)
{
return
code
;
}
STSchema
*
piSchema
=
doGetSchemaForTSRow
(
TSDBROW_SVERSION
(
piRow
),
pReader
,
pBlockScanInfo
->
uid
);
if
(
piSchema
==
NULL
)
{
return
code
;
}
int64_t
minKey
=
0
;
if
(
ASCENDING_TRAVERSE
(
pReader
->
order
))
{
...
...
@@ -2263,7 +2271,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo*
if
(
minKey
==
key
)
{
init
=
true
;
TSDBROW
fRow
=
tsdbRowFromBlockData
(
pBlockData
,
pDumpInfo
->
rowIndex
);
code
=
tsdbRowMergerInit
(
&
merge
,
&
fRow
,
pReader
->
pSchema
);
code
=
tsdbRowMergerInit
(
&
merge
,
NULL
,
&
fRow
,
pReader
->
pSchema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -2274,10 +2282,10 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo*
if
(
minKey
==
tsLast
)
{
TSDBROW
fRow1
=
tMergeTreeGetRow
(
&
pLastBlockReader
->
mergeTree
);
if
(
init
)
{
tsdbRowMerge
(
&
merge
,
&
fRow1
);
tsdbRowMerge
rAdd
(
&
merge
,
&
fRow1
,
NULL
);
}
else
{
init
=
true
;
code
=
tsdbRowMergerInit
(
&
merge
,
&
fRow1
,
pReader
->
pSchema
);
code
=
tsdbRowMergerInit
(
&
merge
,
NULL
,
&
fRow1
,
pReader
->
pSchema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -2288,15 +2296,10 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo*
if
(
minKey
==
ik
.
ts
)
{
if
(
init
)
{
tsdbRowMerge
(
&
merge
,
piRow
);
tsdbRowMerge
rAdd
(
&
merge
,
piRow
,
piSchema
);
}
else
{
init
=
true
;
STSchema
*
pSchema
=
doGetSchemaForTSRow
(
TSDBROW_SVERSION
(
piRow
),
pReader
,
pBlockScanInfo
->
uid
);
if
(
pSchema
==
NULL
)
{
return
code
;
}
code
=
tsdbRowMergerInit
(
&
merge
,
piRow
,
pSchema
);
code
=
tsdbRowMergerInit
(
&
merge
,
pSchema
,
piRow
,
piSchema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -2315,10 +2318,10 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo*
return
code
;
}
tsdbRowMerge
(
&
merge
,
pRow
);
tsdbRowMerge
rAdd
(
&
merge
,
pRow
,
pSchema
);
}
else
{
STSchema
*
pSchema
=
doGetSchemaForTSRow
(
TSDBROW_SVERSION
(
pRow
),
pReader
,
pBlockScanInfo
->
uid
);
code
=
tsdbRowMergerInit
(
&
merge
,
pRow
,
pSchema
);
code
=
tsdbRowMergerInit
(
&
merge
,
NULL
,
pRow
,
pSchema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -2332,8 +2335,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo*
}
else
{
if
(
minKey
==
k
.
ts
)
{
init
=
true
;
STSchema
*
pSchema
=
doGetSchemaForTSRow
(
TSDBROW_SVERSION
(
pRow
),
pReader
,
pBlockScanInfo
->
uid
);
code
=
tsdbRowMergerInit
(
&
merge
,
pRow
,
pSchema
);
code
=
tsdbRowMergerInit
(
&
merge
,
NULL
,
pRow
,
pSchema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -2347,11 +2349,11 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo*
if
(
minKey
==
ik
.
ts
)
{
if
(
init
)
{
tsdbRowMerge
(
&
merge
,
piRow
);
tsdbRowMerge
rAdd
(
&
merge
,
piRow
,
piSchema
);
}
else
{
init
=
true
;
STSchema
*
pSchema
=
doGetSchemaForTSRow
(
TSDBROW_SVERSION
(
piRow
),
pReader
,
pBlockScanInfo
->
uid
);
code
=
tsdbRowMergerInit
(
&
merge
,
p
iRow
,
p
Schema
);
code
=
tsdbRowMergerInit
(
&
merge
,
p
Schema
,
piRow
,
pi
Schema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -2366,10 +2368,10 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo*
if
(
minKey
==
tsLast
)
{
TSDBROW
fRow1
=
tMergeTreeGetRow
(
&
pLastBlockReader
->
mergeTree
);
if
(
init
)
{
tsdbRowMerge
(
&
merge
,
&
fRow1
);
tsdbRowMerge
rAdd
(
&
merge
,
&
fRow1
,
NULL
);
}
else
{
init
=
true
;
code
=
tsdbRowMergerInit
(
&
merge
,
&
fRow1
,
pReader
->
pSchema
);
code
=
tsdbRowMergerInit
(
&
merge
,
NULL
,
&
fRow1
,
pReader
->
pSchema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -2380,7 +2382,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo*
if
(
minKey
==
key
)
{
TSDBROW
fRow
=
tsdbRowFromBlockData
(
pBlockData
,
pDumpInfo
->
rowIndex
);
if
(
!
init
)
{
code
=
tsdbRowMergerInit
(
&
merge
,
&
fRow
,
pReader
->
pSchema
);
code
=
tsdbRowMergerInit
(
&
merge
,
NULL
,
&
fRow
,
pReader
->
pSchema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -2388,7 +2390,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo*
if
(
merge
.
pTSchema
==
NULL
)
{
return
code
;
}
tsdbRowMerge
(
&
merge
,
&
fRow
);
tsdbRowMerge
rAdd
(
&
merge
,
&
fRow
,
NULL
);
}
doMergeRowsInFileBlocks
(
pBlockData
,
pBlockScanInfo
,
pReader
,
&
merge
);
}
...
...
@@ -2573,7 +2575,7 @@ int32_t mergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pBloc
SRow
*
pTSRow
=
NULL
;
SRowMerger
merge
=
{
0
};
int32_t
code
=
tsdbRowMergerInit
(
&
merge
,
&
fRow
,
pReader
->
pSchema
);
int32_t
code
=
tsdbRowMergerInit
(
&
merge
,
NULL
,
&
fRow
,
pReader
->
pSchema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -3694,7 +3696,7 @@ int32_t doMergeRowsInBuf(SIterInfo* pIter, uint64_t uid, int64_t ts, SArray* pDe
tsdbRowMergerAdd
(
pMerger
,
pRow
,
pTSchema
);
}
else
{
// column format
tsdbRowMerge
(
pMerger
,
pRow
);
tsdbRowMerge
rAdd
(
pMerger
,
pRow
,
NULL
);
}
}
...
...
@@ -3710,7 +3712,7 @@ static int32_t doMergeRowsInFileBlockImpl(SBlockData* pBlockData, int32_t rowInd
}
TSDBROW
fRow
=
tsdbRowFromBlockData
(
pBlockData
,
rowIndex
);
tsdbRowMerge
(
pMerger
,
&
fRow
);
tsdbRowMerge
rAdd
(
pMerger
,
&
fRow
,
NULL
);
rowIndex
+=
step
;
}
...
...
@@ -3788,7 +3790,7 @@ int32_t doMergeRowsInLastBlock(SLastBlockReader* pLastBlockReader, STableBlockSc
int64_t
next1
=
getCurrentKeyInLastBlock
(
pLastBlockReader
);
if
(
next1
==
ts
)
{
TSDBROW
fRow1
=
tMergeTreeGetRow
(
&
pLastBlockReader
->
mergeTree
);
tsdbRowMerge
(
pMerger
,
&
fRow1
);
tsdbRowMerge
rAdd
(
pMerger
,
&
fRow1
,
NULL
);
}
else
{
tsdbTrace
(
"uid:%"
PRIu64
" last del index:%d, del range:%d, lastKeyInStt:%"
PRId64
", %s"
,
pScanInfo
->
uid
,
pScanInfo
->
lastBlockDelIndex
,
(
int32_t
)
taosArrayGetSize
(
pScanInfo
->
delSkyline
),
pScanInfo
->
lastKeyInStt
,
...
...
@@ -3844,7 +3846,7 @@ int32_t doMergeMemTableMultiRows(TSDBROW* pRow, uint64_t uid, SIterInfo* pIter,
pReader
->
pSchema
=
pTSchema
;
}
code
=
tsdbRowMergerInit
2
(
&
merge
,
pReader
->
pSchema
,
&
current
,
pTSchema
);
code
=
tsdbRowMergerInit
(
&
merge
,
pReader
->
pSchema
,
&
current
,
pTSchema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -3856,12 +3858,12 @@ int32_t doMergeMemTableMultiRows(TSDBROW* pRow, uint64_t uid, SIterInfo* pIter,
tsdbRowMergerAdd
(
&
merge
,
pNextRow
,
pTSchema1
);
}
else
{
// let's merge rows in file block
code
=
tsdbRowMergerInit
(
&
merge
,
&
current
,
pReader
->
pSchema
);
code
=
tsdbRowMergerInit
(
&
merge
,
NULL
,
&
current
,
pReader
->
pSchema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
tsdbRowMerge
(
&
merge
,
pNextRow
);
tsdbRowMerge
rAdd
(
&
merge
,
pNextRow
,
NULL
);
}
code
=
doMergeRowsInBuf
(
pIter
,
uid
,
TSDBROW_TS
(
&
current
),
pDelList
,
&
merge
,
pReader
);
...
...
@@ -3885,14 +3887,13 @@ int32_t doMergeMemIMemRows(TSDBROW* pRow, TSDBROW* piRow, STableBlockScanInfo* p
SRow
**
pTSRow
)
{
SRowMerger
merge
=
{
0
};
TSDBKEY
k
=
TSDBROW_KEY
(
pRow
);
TSDBKEY
ik
=
TSDBROW_KEY
(
piRow
);
TSDBKEY
k
=
TSDBROW_KEY
(
pRow
);
TSDBKEY
ik
=
TSDBROW_KEY
(
piRow
);
STSchema
*
pSchema
=
doGetSchemaForTSRow
(
TSDBROW_SVERSION
(
pRow
),
pReader
,
pBlockScanInfo
->
uid
);
STSchema
*
piSchema
=
doGetSchemaForTSRow
(
TSDBROW_SVERSION
(
piRow
),
pReader
,
pBlockScanInfo
->
uid
);
if
(
ASCENDING_TRAVERSE
(
pReader
->
order
))
{
// ascending order imem --> mem
STSchema
*
pSchema
=
doGetSchemaForTSRow
(
TSDBROW_SVERSION
(
pRow
),
pReader
,
pBlockScanInfo
->
uid
);
STSchema
*
piSchema
=
doGetSchemaForTSRow
(
TSDBROW_SVERSION
(
piRow
),
pReader
,
pBlockScanInfo
->
uid
);
int32_t
code
=
tsdbRowMergerInit2
(
&
merge
,
pSchema
,
piRow
,
piSchema
);
int32_t
code
=
tsdbRowMergerInit
(
&
merge
,
pSchema
,
piRow
,
piSchema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -3911,9 +3912,7 @@ int32_t doMergeMemIMemRows(TSDBROW* pRow, TSDBROW* piRow, STableBlockScanInfo* p
}
}
else
{
STSchema
*
pSchema
=
doGetSchemaForTSRow
(
TSDBROW_SVERSION
(
pRow
),
pReader
,
pBlockScanInfo
->
uid
);
int32_t
code
=
tsdbRowMergerInit
(
&
merge
,
pRow
,
pSchema
);
int32_t
code
=
tsdbRowMergerInit
(
&
merge
,
NULL
,
pRow
,
pSchema
);
if
(
code
!=
TSDB_CODE_SUCCESS
||
merge
.
pTSchema
==
NULL
)
{
return
code
;
}
...
...
@@ -3924,7 +3923,7 @@ int32_t doMergeMemIMemRows(TSDBROW* pRow, TSDBROW* piRow, STableBlockScanInfo* p
return
code
;
}
tsdbRowMerge
(
&
merge
,
piRow
);
tsdbRowMerge
rAdd
(
&
merge
,
piRow
,
piSchema
);
code
=
doMergeRowsInBuf
(
&
pBlockScanInfo
->
iiter
,
pBlockScanInfo
->
uid
,
ik
.
ts
,
pBlockScanInfo
->
delSkyline
,
&
merge
,
pReader
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
source/dnode/vnode/src/tsdb/tsdbUtil.c
浏览文件 @
4c04b155
...
...
@@ -638,13 +638,17 @@ SColVal *tsdbRowIterNext(STSDBRowIter *pIter) {
// SRowMerger ======================================================
int32_t
tsdbRowMergerInit
2
(
SRowMerger
*
pMerger
,
STSchema
*
pResTSchema
,
TSDBROW
*
pRow
,
STSchema
*
pTSchema
)
{
int32_t
tsdbRowMergerInit
(
SRowMerger
*
pMerger
,
STSchema
*
pResTSchema
,
TSDBROW
*
pRow
,
STSchema
*
pTSchema
)
{
int32_t
code
=
0
;
TSDBKEY
key
=
TSDBROW_KEY
(
pRow
);
SColVal
*
pColVal
=
&
(
SColVal
){
0
};
STColumn
*
pTColumn
;
int32_t
iCol
,
jCol
=
0
;
if
(
NULL
==
pResTSchema
)
{
pResTSchema
=
pTSchema
;
}
pMerger
->
pTSchema
=
pResTSchema
;
pMerger
->
version
=
key
.
version
;
...
...
@@ -712,6 +716,9 @@ int32_t tsdbRowMergerAdd(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema)
STColumn
*
pTColumn
;
int32_t
iCol
,
jCol
=
1
;
if
(
NULL
==
pTSchema
)
{
pTSchema
=
pMerger
->
pTSchema
;
}
ASSERT
(((
SColVal
*
)
pMerger
->
pArray
->
pData
)
->
value
.
val
==
key
.
ts
);
for
(
iCol
=
1
;
iCol
<
pMerger
->
pTSchema
->
numOfCols
&&
jCol
<
pTSchema
->
numOfCols
;
++
iCol
)
{
...
...
@@ -727,23 +734,6 @@ int32_t tsdbRowMergerAdd(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema)
tsdbRowGetColVal
(
pRow
,
pTSchema
,
jCol
++
,
pColVal
);
if
(
key
.
version
>
pMerger
->
version
)
{
#if 0
if (!COL_VAL_IS_NONE(pColVal)) {
if ((!COL_VAL_IS_NULL(pColVal)) && IS_VAR_DATA_TYPE(pColVal->type)) {
SColVal *tColVal = taosArrayGet(pMerger->pArray, iCol);
code = tRealloc(&tColVal->value.pData, pColVal->value.nData);
if (code) return code;
tColVal->value.nData = pColVal->value.nData;
if (pColVal->value.nData) {
memcpy(tColVal->value.pData, pColVal->value.pData, pColVal->value.nData);
}
tColVal->flag = 0;
} else {
taosArraySet(pMerger->pArray, iCol, pColVal);
}
}
#endif
if
(
!
COL_VAL_IS_NONE
(
pColVal
))
{
if
(
IS_VAR_DATA_TYPE
(
pColVal
->
type
))
{
SColVal
*
pTColVal
=
taosArrayGet
(
pMerger
->
pArray
,
iCol
);
...
...
@@ -758,7 +748,6 @@ int32_t tsdbRowMergerAdd(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema)
pTColVal
->
flag
=
0
;
}
else
{
tFree
(
pTColVal
->
value
.
pData
);
pTColVal
->
value
.
pData
=
NULL
;
taosArraySet
(
pMerger
->
pArray
,
iCol
,
pColVal
);
}
}
else
{
...
...
@@ -789,7 +778,7 @@ int32_t tsdbRowMergerAdd(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema)
pMerger
->
version
=
key
.
version
;
return
code
;
}
/*
int32_t tsdbRowMergerInit(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema) {
int32_t code = 0;
TSDBKEY key = TSDBROW_KEY(pRow);
...
...
@@ -840,7 +829,7 @@ int32_t tsdbRowMergerInit(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema
_exit:
return code;
}
*/
void
tsdbRowMergerClear
(
SRowMerger
*
pMerger
)
{
for
(
int32_t
iCol
=
1
;
iCol
<
pMerger
->
pTSchema
->
numOfCols
;
iCol
++
)
{
SColVal
*
pTColVal
=
taosArrayGet
(
pMerger
->
pArray
,
iCol
);
...
...
@@ -851,7 +840,7 @@ void tsdbRowMergerClear(SRowMerger *pMerger) {
taosArrayDestroy
(
pMerger
->
pArray
);
}
/*
int32_t tsdbRowMerge(SRowMerger *pMerger, TSDBROW *pRow) {
int32_t code = 0;
TSDBKEY key = TSDBROW_KEY(pRow);
...
...
@@ -916,7 +905,7 @@ int32_t tsdbRowMerge(SRowMerger *pMerger, TSDBROW *pRow) {
_exit:
return code;
}
*/
int32_t
tsdbRowMergerGetRow
(
SRowMerger
*
pMerger
,
SRow
**
ppRow
)
{
return
tRowBuild
(
pMerger
->
pArray
,
pMerger
->
pTSchema
,
ppRow
);
}
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
4c04b155
...
...
@@ -541,6 +541,7 @@ int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) {
return
vnodeGetBatchMeta
(
pVnode
,
pMsg
);
case
TDMT_VND_TMQ_CONSUME
:
return
tqProcessPollReq
(
pVnode
->
pTq
,
pMsg
);
case
TDMT_STREAM_TASK_RUN
:
return
tqProcessTaskRunReq
(
pVnode
->
pTq
,
pMsg
);
#if 1
...
...
source/libs/catalog/CMakeLists.txt
浏览文件 @
4c04b155
...
...
@@ -8,9 +8,9 @@ target_include_directories(
target_link_libraries
(
catalog
PRIVATE os util transport qcom
PRIVATE os util transport qcom
nodes
)
if
(
${
BUILD_TEST
}
)
ADD_SUBDIRECTORY
(
test
)
endif
(
${
BUILD_TEST
}
)
\ No newline at end of file
endif
(
${
BUILD_TEST
}
)
source/libs/catalog/inc/catalogInt.h
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
source/libs/catalog/src/catalog.c
浏览文件 @
4c04b155
...
...
@@ -319,14 +319,13 @@ _return:
CTG_RET
(
code
);
}
int32_t
ctgChkAuth
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
user
,
const
char
*
dbFName
,
AUTH_TYPE
type
,
bool
*
pass
,
bool
*
exists
)
{
int32_t
ctgChkAuth
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SUserAuthInfo
*
pReq
,
SUserAuthRes
*
pRes
,
bool
*
exists
)
{
bool
inCache
=
false
;
int32_t
code
=
0
;
SCtgAuthRsp
rsp
=
{
0
};
rsp
.
pRawRes
=
pRes
;
*
pass
=
false
;
CTG_ERR_RET
(
ctgChkAuthFromCache
(
pCtg
,
(
char
*
)
user
,
(
char
*
)
dbFName
,
type
,
&
inCache
,
pass
));
CTG_ERR_RET
(
ctgChkAuthFromCache
(
pCtg
,
pReq
,
&
inCache
,
&
rsp
));
if
(
inCache
)
{
if
(
exists
)
{
...
...
@@ -339,30 +338,22 @@ int32_t ctgChkAuth(SCatalog* pCtg, SRequestConnInfo* pConn, const char* user, co
return
TSDB_CODE_SUCCESS
;
}
SGetUserAuthRsp
authRsp
=
{
0
};
CTG_ERR_RET
(
ctgGetUserDbAuthFromMnode
(
pCtg
,
pConn
,
user
,
&
authRsp
,
NULL
));
if
(
authRsp
.
superAuth
)
{
*
pass
=
true
;
goto
_return
;
}
if
(
authRsp
.
createdDbs
&&
taosHashGet
(
authRsp
.
createdDbs
,
dbFName
,
strlen
(
dbFName
)))
{
*
pass
=
true
;
goto
_return
;
}
SCtgAuthReq
req
=
{
0
};
req
.
pRawReq
=
pReq
;
req
.
pConn
=
pConn
;
req
.
onlyCache
=
exists
?
true
:
false
;
CTG_ERR_RET
(
ctgGetUserDbAuthFromMnode
(
pCtg
,
pConn
,
pReq
->
user
,
&
req
.
authInfo
,
NULL
));
if
(
CTG_AUTH_READ
(
type
)
&&
authRsp
.
readDbs
&&
taosHashGet
(
authRsp
.
readDbs
,
dbFName
,
strlen
(
dbFName
)))
{
*
pass
=
true
;
}
else
if
(
CTG_AUTH_WRITE
(
type
)
&&
authRsp
.
writeDbs
&&
taosHashGet
(
authRsp
.
writeDbs
,
dbFName
,
strlen
(
dbFName
)))
{
*
pass
=
true
;
CTG_ERR_JRET
(
ctgChkSetAuthRes
(
pCtg
,
&
req
,
&
rsp
));
if
(
rsp
.
metaNotExists
&&
exists
)
{
*
exists
=
false
;
}
_return:
ctgUpdateUserEnqueue
(
pCtg
,
&
authRsp
,
false
);
ctgUpdateUserEnqueue
(
pCtg
,
&
req
.
authInfo
,
false
);
return
TSDB_CODE_SUCCESS
;
CTG_RET
(
code
)
;
}
int32_t
ctgGetTbType
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SName
*
pTableName
,
int32_t
*
tbType
)
{
...
...
@@ -1373,7 +1364,7 @@ int32_t catalogGetExpiredUsers(SCatalog* pCtg, SUserAuthVersion** users, uint32_
void
*
key
=
taosHashGetKey
(
pAuth
,
&
len
);
strncpy
((
*
users
)[
i
].
user
,
key
,
len
);
(
*
users
)[
i
].
user
[
len
]
=
0
;
(
*
users
)[
i
].
version
=
pAuth
->
version
;
(
*
users
)[
i
].
version
=
pAuth
->
userAuth
.
version
;
++
i
;
if
(
i
>=
*
num
)
{
taosHashCancelIterate
(
pCtg
->
userCache
,
pAuth
);
...
...
@@ -1457,32 +1448,30 @@ _return:
CTG_API_LEAVE
(
code
);
}
int32_t
catalogChkAuth
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
user
,
const
char
*
dbFName
,
AUTH_TYPE
type
,
bool
*
pass
)
{
int32_t
catalogChkAuth
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SUserAuthInfo
*
pAuth
,
SUserAuthRes
*
pRes
)
{
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
user
||
NULL
==
dbFName
||
NULL
==
pas
s
)
{
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
pAuth
||
NULL
==
pRe
s
)
{
CTG_API_LEAVE
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
int32_t
code
=
0
;
CTG_ERR_JRET
(
ctgChkAuth
(
pCtg
,
pConn
,
user
,
dbFName
,
type
,
pas
s
,
NULL
));
CTG_ERR_JRET
(
ctgChkAuth
(
pCtg
,
pConn
,
pAuth
,
pRe
s
,
NULL
));
_return:
CTG_API_LEAVE
(
code
);
}
int32_t
catalogChkAuthFromCache
(
SCatalog
*
pCtg
,
const
char
*
user
,
const
char
*
dbFName
,
AUTH_TYPE
type
,
bool
*
pass
,
bool
*
exists
)
{
int32_t
catalogChkAuthFromCache
(
SCatalog
*
pCtg
,
SUserAuthInfo
*
pAuth
,
SUserAuthRes
*
pRes
,
bool
*
exists
)
{
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
user
||
NULL
==
dbFName
||
NULL
==
pas
s
||
NULL
==
exists
)
{
if
(
NULL
==
pCtg
||
NULL
==
pAuth
||
NULL
==
pRe
s
||
NULL
==
exists
)
{
CTG_API_LEAVE
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
int32_t
code
=
0
;
CTG_ERR_JRET
(
ctgChkAuth
(
pCtg
,
NULL
,
user
,
dbFName
,
type
,
pas
s
,
exists
));
CTG_ERR_JRET
(
ctgChkAuth
(
pCtg
,
NULL
,
pAuth
,
pRe
s
,
exists
));
_return:
...
...
source/libs/catalog/src/ctgAsync.c
浏览文件 @
4c04b155
...
...
@@ -1550,45 +1550,20 @@ _return:
int32_t
ctgHandleGetUserRsp
(
SCtgTaskReq
*
tReq
,
int32_t
reqType
,
const
SDataBuf
*
pMsg
,
int32_t
rspCode
)
{
int32_t
code
=
0
;
SCtgTask
*
pTask
=
tReq
->
pTask
;
SCtgUserCtx
*
ctx
=
(
SCtgUserCtx
*
)
pTask
->
taskCtx
;
SCatalog
*
pCtg
=
pTask
->
pJob
->
pCtg
;
bool
pass
=
false
;
SGetUserAuthRsp
*
pOut
=
(
SGetUserAuthRsp
*
)
pTask
->
msgCtx
.
out
;
CTG_ERR_JRET
(
ctgProcessRspMsg
(
pTask
->
msgCtx
.
out
,
reqType
,
pMsg
->
pData
,
pMsg
->
len
,
rspCode
,
pTask
->
msgCtx
.
target
));
if
(
pOut
->
superAuth
)
{
pass
=
true
;
goto
_return
;
}
ctgUpdateUserEnqueue
(
pCtg
,
pOut
,
true
);
taosMemoryFreeClear
(
pTask
->
msgCtx
.
out
);
if
(
pOut
->
createdDbs
&&
taosHashGet
(
pOut
->
createdDbs
,
ctx
->
user
.
dbFName
,
strlen
(
ctx
->
user
.
dbFName
)))
{
pass
=
true
;
goto
_return
;
}
CTG_ERR_JRET
((
*
gCtgAsyncFps
[
pTask
->
type
].
launchFp
)(
pTask
));
if
(
CTG_AUTH_READ
(
ctx
->
user
.
type
)
&&
pOut
->
readDbs
&&
taosHashGet
(
pOut
->
readDbs
,
ctx
->
user
.
dbFName
,
strlen
(
ctx
->
user
.
dbFName
)))
{
pass
=
true
;
}
else
if
(
CTG_AUTH_WRITE
(
ctx
->
user
.
type
)
&&
pOut
->
writeDbs
&&
taosHashGet
(
pOut
->
writeDbs
,
ctx
->
user
.
dbFName
,
strlen
(
ctx
->
user
.
dbFName
)))
{
pass
=
true
;
}
return
TSDB_CODE_SUCCESS
;
_return:
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pTask
->
res
=
taosMemoryCalloc
(
1
,
sizeof
(
bool
));
if
(
NULL
==
pTask
->
res
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
else
{
*
(
bool
*
)
pTask
->
res
=
pass
;
}
}
ctgUpdateUserEnqueue
(
pCtg
,
pOut
,
false
);
taosMemoryFreeClear
(
pTask
->
msgCtx
.
out
);
ctgHandleTaskEnd
(
pTask
,
code
);
CTG_RET
(
code
);
...
...
@@ -2081,31 +2056,39 @@ int32_t ctgLaunchGetUdfTask(SCtgTask* pTask) {
}
int32_t
ctgLaunchGetUserTask
(
SCtgTask
*
pTask
)
{
int32_t
code
=
0
;
SCatalog
*
pCtg
=
pTask
->
pJob
->
pCtg
;
SRequestConnInfo
*
pConn
=
&
pTask
->
pJob
->
conn
;
SCtgUserCtx
*
pCtx
=
(
SCtgUserCtx
*
)
pTask
->
taskCtx
;
bool
inCache
=
false
;
bool
pass
=
false
;
SCtgAuthRsp
rsp
=
{
0
}
;
SCtgJob
*
pJob
=
pTask
->
pJob
;
SCtgMsgCtx
*
pMsgCtx
=
CTG_GET_TASK_MSGCTX
(
pTask
,
-
1
);
if
(
NULL
==
pMsgCtx
->
pBatchs
)
{
pMsgCtx
->
pBatchs
=
pJob
->
pBatchs
;
}
CTG_ERR_RET
(
ctgChkAuthFromCache
(
pCtg
,
pCtx
->
user
.
user
,
pCtx
->
user
.
dbFName
,
pCtx
->
user
.
type
,
&
inCache
,
&
pass
));
rsp
.
pRawRes
=
taosMemoryCalloc
(
1
,
sizeof
(
SUserAuthRes
));
if
(
NULL
==
rsp
.
pRawRes
)
{
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
CTG_ERR_RET
(
ctgChkAuthFromCache
(
pCtg
,
&
pCtx
->
user
,
&
inCache
,
&
rsp
));
if
(
inCache
)
{
pTask
->
res
=
taosMemoryCalloc
(
1
,
sizeof
(
bool
));
if
(
NULL
==
pTask
->
res
)
{
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
*
(
bool
*
)
pTask
->
res
=
pass
;
pTask
->
res
=
rsp
.
pRawRes
;
CTG_ERR_RET
(
ctgHandleTaskEnd
(
pTask
,
0
));
return
TSDB_CODE_SUCCESS
;
}
CTG_ERR_RET
(
ctgGetUserDbAuthFromMnode
(
pCtg
,
pConn
,
pCtx
->
user
.
user
,
NULL
,
pTask
)
);
taosMemoryFreeClear
(
rsp
.
pRawRes
);
if
(
rsp
.
metaNotExists
)
{
CTG_ERR_RET
(
ctgLaunchSubTask
(
pTask
,
CTG_TASK_GET_TB_META
,
ctgGetTbCfgCb
,
&
pCtx
->
user
.
tbName
));
}
else
{
CTG_ERR_RET
(
ctgGetUserDbAuthFromMnode
(
pCtg
,
pConn
,
pCtx
->
user
.
user
,
NULL
,
pTask
));
}
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -2155,6 +2138,20 @@ _return:
CTG_RET
(
ctgHandleTaskEnd
(
pTask
,
pTask
->
subRes
.
code
));
}
int32_t
ctgGetUserCb
(
SCtgTask
*
pTask
)
{
int32_t
code
=
0
;
CTG_ERR_JRET
(
pTask
->
subRes
.
code
);
CTG_RET
(
ctgLaunchGetUserTask
(
pTask
));
_return:
CTG_RET
(
ctgHandleTaskEnd
(
pTask
,
pTask
->
subRes
.
code
));
}
int32_t
ctgCompDbVgTasks
(
SCtgTask
*
pTask
,
void
*
param
,
bool
*
equal
)
{
SCtgDbVgCtx
*
ctx
=
pTask
->
taskCtx
;
...
...
source/libs/catalog/src/ctgCache.c
浏览文件 @
4c04b155
...
...
@@ -32,27 +32,26 @@ SCtgOperation gCtgCacheOperation[CTG_OP_MAX] = {{CTG_OP_UPDATE_VGROUP, "update v
{
CTG_OP_CLEAR_CACHE
,
"clear cache"
,
ctgOpClearCache
}};
SCtgCacheItemInfo
gCtgStatItem
[
CTG_CI_MAX_VALUE
]
=
{
{
"Cluster "
,
CTG_CI_FLAG_LEVEL_GLOBAL
},
//
CTG_CI_CLUSTER
{
"Dnode "
,
CTG_CI_FLAG_LEVEL_CLUSTER
},
//
CTG_CI_DNODE,
{
"Qnode "
,
CTG_CI_FLAG_LEVEL_CLUSTER
},
//
CTG_CI_QNODE,
{
"DB "
,
CTG_CI_FLAG_LEVEL_CLUSTER
},
//
CTG_CI_DB,
{
"DbVgroup "
,
CTG_CI_FLAG_LEVEL_DB
},
//
CTG_CI_DB_VGROUP,
{
"DbCfg "
,
CTG_CI_FLAG_LEVEL_DB
},
//
CTG_CI_DB_CFG,
{
"DbInfo "
,
CTG_CI_FLAG_LEVEL_DB
},
//
CTG_CI_DB_INFO,
{
"StbMeta "
,
CTG_CI_FLAG_LEVEL_DB
},
//
CTG_CI_STABLE_META,
{
"NtbMeta "
,
CTG_CI_FLAG_LEVEL_DB
},
//
CTG_CI_NTABLE_META,
{
"CtbMeta "
,
CTG_CI_FLAG_LEVEL_DB
},
//
CTG_CI_CTABLE_META,
{
"SysTblMeta"
,
CTG_CI_FLAG_LEVEL_DB
},
//
CTG_CI_SYSTABLE_META,
{
"OthTblMeta"
,
CTG_CI_FLAG_LEVEL_DB
},
//
CTG_CI_OTHERTABLE_META,
{
"TblSMA "
,
CTG_CI_FLAG_LEVEL_DB
},
//
CTG_CI_TBL_SMA,
{
"TblCfg "
,
CTG_CI_FLAG_LEVEL_DB
},
//
CTG_CI_TBL_CFG,
{
"IndexInfo "
,
CTG_CI_FLAG_LEVEL_DB
},
//
CTG_CI_INDEX_INFO,
{
"User "
,
CTG_CI_FLAG_LEVEL_CLUSTER
},
//
CTG_CI_USER,
{
"UDF "
,
CTG_CI_FLAG_LEVEL_CLUSTER
},
//
CTG_CI_UDF,
{
"SvrVer "
,
CTG_CI_FLAG_LEVEL_CLUSTER
}
//
CTG_CI_SVR_VER,
{
"Cluster "
,
CTG_CI_FLAG_LEVEL_GLOBAL
},
//
CTG_CI_CLUSTER
{
"Dnode "
,
CTG_CI_FLAG_LEVEL_CLUSTER
},
//
CTG_CI_DNODE,
{
"Qnode "
,
CTG_CI_FLAG_LEVEL_CLUSTER
},
//
CTG_CI_QNODE,
{
"DB "
,
CTG_CI_FLAG_LEVEL_CLUSTER
},
//
CTG_CI_DB,
{
"DbVgroup "
,
CTG_CI_FLAG_LEVEL_DB
},
//
CTG_CI_DB_VGROUP,
{
"DbCfg "
,
CTG_CI_FLAG_LEVEL_DB
},
//
CTG_CI_DB_CFG,
{
"DbInfo "
,
CTG_CI_FLAG_LEVEL_DB
},
//
CTG_CI_DB_INFO,
{
"StbMeta "
,
CTG_CI_FLAG_LEVEL_DB
},
//
CTG_CI_STABLE_META,
{
"NtbMeta "
,
CTG_CI_FLAG_LEVEL_DB
},
//
CTG_CI_NTABLE_META,
{
"CtbMeta "
,
CTG_CI_FLAG_LEVEL_DB
},
//
CTG_CI_CTABLE_META,
{
"SysTblMeta"
,
CTG_CI_FLAG_LEVEL_DB
},
//
CTG_CI_SYSTABLE_META,
{
"OthTblMeta"
,
CTG_CI_FLAG_LEVEL_DB
},
//
CTG_CI_OTHERTABLE_META,
{
"TblSMA "
,
CTG_CI_FLAG_LEVEL_DB
},
//
CTG_CI_TBL_SMA,
{
"TblCfg "
,
CTG_CI_FLAG_LEVEL_DB
},
//
CTG_CI_TBL_CFG,
{
"IndexInfo "
,
CTG_CI_FLAG_LEVEL_DB
},
//
CTG_CI_INDEX_INFO,
{
"User "
,
CTG_CI_FLAG_LEVEL_CLUSTER
},
//
CTG_CI_USER,
{
"UDF "
,
CTG_CI_FLAG_LEVEL_CLUSTER
},
//
CTG_CI_UDF,
{
"SvrVer "
,
CTG_CI_FLAG_LEVEL_CLUSTER
}
//
CTG_CI_SVR_VER,
};
int32_t
ctgRLockVgInfo
(
SCatalog
*
pCtg
,
SCtgDBCache
*
dbCache
,
bool
*
inCache
)
{
CTG_LOCK
(
CTG_READ
,
&
dbCache
->
vgCache
.
vgLock
);
...
...
@@ -263,10 +262,11 @@ _return:
return
TSDB_CODE_SUCCESS
;
}
int32_t
ctgAcquireVgMetaFromCache
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
const
char
*
tbName
,
SCtgDBCache
**
pDb
,
SCtgTbCache
**
pTb
)
{
int32_t
ctgAcquireVgMetaFromCache
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
const
char
*
tbName
,
SCtgDBCache
**
pDb
,
SCtgTbCache
**
pTb
)
{
SCtgDBCache
*
dbCache
=
NULL
;
SCtgTbCache
*
tbCache
=
NULL
;
bool
vgInCache
=
false
;
bool
vgInCache
=
false
;
ctgAcquireDBCache
(
pCtg
,
dbFName
,
&
dbCache
);
if
(
NULL
==
dbCache
)
{
...
...
@@ -331,7 +331,6 @@ _return:
return
TSDB_CODE_SUCCESS
;
}
/*
int32_t ctgAcquireStbMetaFromCache(SCatalog *pCtg, char *dbFName, uint64_t suid, SCtgDBCache **pDb, SCtgTbCache **pTb) {
SCtgDBCache *dbCache = NULL;
...
...
@@ -385,9 +384,10 @@ _return:
}
*/
int32_t
ctgAcquireStbMetaFromCache
(
SCtgDBCache
*
dbCache
,
SCatalog
*
pCtg
,
char
*
dbFName
,
uint64_t
suid
,
SCtgTbCache
**
pTb
)
{
int32_t
ctgAcquireStbMetaFromCache
(
SCtgDBCache
*
dbCache
,
SCatalog
*
pCtg
,
char
*
dbFName
,
uint64_t
suid
,
SCtgTbCache
**
pTb
)
{
SCtgTbCache
*
pCache
=
NULL
;
char
*
stName
=
taosHashAcquire
(
dbCache
->
stbCache
,
&
suid
,
sizeof
(
suid
));
char
*
stName
=
taosHashAcquire
(
dbCache
->
stbCache
,
&
suid
,
sizeof
(
suid
));
if
(
NULL
==
stName
)
{
ctgDebug
(
"stb 0x%"
PRIx64
" not in cache, dbFName:%s"
,
suid
,
dbFName
);
goto
_return
;
...
...
@@ -484,10 +484,11 @@ int32_t ctgTbMetaExistInCache(SCatalog *pCtg, char *dbFName, char *tbName, int32
return
TSDB_CODE_SUCCESS
;
}
int32_t
ctgCopyTbMeta
(
SCatalog
*
pCtg
,
SCtgTbMetaCtx
*
ctx
,
SCtgDBCache
**
pDb
,
SCtgTbCache
**
pTb
,
STableMeta
**
pTableMeta
,
char
*
dbFName
)
{
int32_t
ctgCopyTbMeta
(
SCatalog
*
pCtg
,
SCtgTbMetaCtx
*
ctx
,
SCtgDBCache
**
pDb
,
SCtgTbCache
**
pTb
,
STableMeta
**
pTableMeta
,
char
*
dbFName
)
{
SCtgDBCache
*
dbCache
=
*
pDb
;
SCtgTbCache
*
tbCache
=
*
pTb
;
STableMeta
*
tbMeta
=
tbCache
->
pMeta
;
STableMeta
*
tbMeta
=
tbCache
->
pMeta
;
ctx
->
tbInfo
.
inCache
=
true
;
ctx
->
tbInfo
.
dbId
=
dbCache
->
dbId
;
ctx
->
tbInfo
.
suid
=
tbMeta
->
suid
;
...
...
@@ -516,12 +517,12 @@ int32_t ctgCopyTbMeta(SCatalog *pCtg, SCtgTbMetaCtx *ctx, SCtgDBCache **pDb, SCt
memcpy
(
*
pTableMeta
,
tbMeta
,
metaSize
);
//ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
//
ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
CTG_UNLOCK
(
CTG_READ
,
&
tbCache
->
metaLock
);
taosHashRelease
(
dbCache
->
tbCache
,
tbCache
);
*
pTb
=
NULL
;
ctgDebug
(
"Got ctb %s meta from cache, will continue to get its stb meta, type:%d, dbFName:%s"
,
ctx
->
pName
->
tname
,
ctx
->
tbInfo
.
tbType
,
dbFName
);
...
...
@@ -553,7 +554,6 @@ int32_t ctgCopyTbMeta(SCatalog *pCtg, SCtgTbMetaCtx *ctx, SCtgDBCache **pDb, SCt
return
TSDB_CODE_SUCCESS
;
}
int32_t
ctgReadTbMetaFromCache
(
SCatalog
*
pCtg
,
SCtgTbMetaCtx
*
ctx
,
STableMeta
**
pTableMeta
)
{
int32_t
code
=
0
;
SCtgDBCache
*
dbCache
=
NULL
;
...
...
@@ -623,17 +623,17 @@ int32_t ctgReadTbVerFromCache(SCatalog *pCtg, SName *pTableName, int32_t *sver,
// PROCESS FOR CHILD TABLE
//ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
//
ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
if
(
tbCache
)
{
CTG_UNLOCK
(
CTG_READ
,
&
tbCache
->
metaLock
);
taosHashRelease
(
dbCache
->
tbCache
,
tbCache
);
}
ctgDebug
(
"Got ctb %s ver from cache, will continue to get its stb ver, dbFName:%s"
,
pTableName
->
tname
,
dbFName
);
ctgAcquireStbMetaFromCache
(
dbCache
,
pCtg
,
dbFName
,
*
suid
,
&
tbCache
);
if
(
NULL
==
tbCache
)
{
//ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
//
ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
ctgDebug
(
"stb 0x%"
PRIx64
" meta not in cache"
,
*
suid
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -703,55 +703,40 @@ _return:
CTG_RET
(
code
);
}
int32_t
ctgChkAuthFromCache
(
SCatalog
*
pCtg
,
char
*
user
,
char
*
dbFName
,
AUTH_TYPE
type
,
bool
*
inCache
,
bool
*
pass
)
{
char
*
p
=
strchr
(
dbFName
,
'.'
);
if
(
p
)
{
++
p
;
}
else
{
p
=
dbFName
;
}
if
(
IS_SYS_DBNAME
(
p
))
{
int32_t
ctgChkAuthFromCache
(
SCatalog
*
pCtg
,
SUserAuthInfo
*
pReq
,
bool
*
inCache
,
SCtgAuthRsp
*
pRes
)
{
if
(
IS_SYS_DBNAME
(
pReq
->
tbName
.
dbname
))
{
*
inCache
=
true
;
*
pass
=
true
;
ctgDebug
(
"sysdb %s, pass"
,
dbFN
ame
);
pRes
->
pRawRes
->
pass
=
true
;
ctgDebug
(
"sysdb %s, pass"
,
pReq
->
tbName
.
dbn
ame
);
return
TSDB_CODE_SUCCESS
;
}
SCtgUserAuth
*
pUser
=
(
SCtgUserAuth
*
)
taosHashGet
(
pCtg
->
userCache
,
user
,
strlen
(
user
));
SCtgUserAuth
*
pUser
=
(
SCtgUserAuth
*
)
taosHashGet
(
pCtg
->
userCache
,
pReq
->
user
,
strlen
(
pReq
->
user
));
if
(
NULL
==
pUser
)
{
ctgDebug
(
"user not in cache, user:%s"
,
user
);
ctgDebug
(
"user not in cache, user:%s"
,
pReq
->
user
);
goto
_return
;
}
*
inCache
=
true
;
ctgDebug
(
"Got user from cache, user:%s"
,
user
);
ctgDebug
(
"Got user from cache, user:%s"
,
pReq
->
user
);
CTG_CACHE_HIT_INC
(
CTG_CI_USER
,
1
);
if
(
pUser
->
superUser
)
{
*
pass
=
true
;
return
TSDB_CODE_SUCCESS
;
}
SCtgAuthReq
req
=
{
0
};
req
.
pRawReq
=
pReq
;
req
.
onlyCache
=
true
;
CTG_LOCK
(
CTG_READ
,
&
pUser
->
lock
);
if
(
pUser
->
createdDbs
&&
taosHashGet
(
pUser
->
createdDbs
,
dbFName
,
strlen
(
dbFName
)))
{
*
pass
=
true
;
CTG_UNLOCK
(
CTG_READ
,
&
pUser
->
lock
);
return
TSDB_CODE_SUCCESS
;
}
if
(
pUser
->
readDbs
&&
taosHashGet
(
pUser
->
readDbs
,
dbFName
,
strlen
(
dbFName
))
&&
CTG_AUTH_READ
(
type
))
{
*
pass
=
true
;
}
memcpy
(
&
req
.
authInfo
,
&
pUser
->
userAuth
,
sizeof
(
pUser
->
userAuth
));
int32_t
code
=
ctgChkSetAuthRes
(
pCtg
,
&
req
,
pRes
);
CTG_UNLOCK
(
CTG_READ
,
&
pUser
->
lock
);
CTG_ERR_JRET
(
code
);
if
(
p
User
->
writeDbs
&&
taosHashGet
(
pUser
->
writeDbs
,
dbFName
,
strlen
(
dbFName
))
&&
CTG_AUTH_WRITE
(
type
)
)
{
*
pass
=
true
;
if
(
p
Res
->
metaNotExists
)
{
goto
_return
;
}
CTG_UNLOCK
(
CTG_READ
,
&
pUser
->
lock
);
return
TSDB_CODE_SUCCESS
;
CTG_RET
(
code
);
_return:
...
...
@@ -1639,7 +1624,7 @@ int32_t ctgWriteTbIndexToCache(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFNa
}
CTG_DB_NUM_INC
(
CTG_CI_TBL_SMA
);
*
index
=
NULL
;
ctgDebug
(
"table %s index updated to cache, ver:%d, num:%d"
,
tbName
,
pIndex
->
version
,
(
int32_t
)
taosArrayGetSize
(
pIndex
->
pIndex
));
...
...
@@ -1725,9 +1710,9 @@ void ctgFreeAllInstance(void) {
taosHashClear
(
gCtgMgmt
.
pCluster
);
}
int32_t
ctgVgInfoIdComp
(
void
const
*
lp
,
void
const
*
rp
)
{
int32_t
*
key
=
(
int32_t
*
)
lp
;
SVgroupInfo
*
pVg
=
(
SVgroupInfo
*
)
rp
;
int32_t
ctgVgInfoIdComp
(
void
const
*
lp
,
void
const
*
rp
)
{
int32_t
*
key
=
(
int32_t
*
)
lp
;
SVgroupInfo
*
pVg
=
(
SVgroupInfo
*
)
rp
;
if
(
*
key
<
pVg
->
vgId
)
{
return
-
1
;
...
...
@@ -1738,7 +1723,6 @@ int32_t ctgVgInfoIdComp(void const* lp, void const* rp) {
return
0
;
}
int32_t
ctgOpUpdateVgroup
(
SCtgCacheOperation
*
operation
)
{
int32_t
code
=
0
;
SCtgUpdateVgMsg
*
msg
=
operation
->
data
;
...
...
@@ -1805,10 +1789,10 @@ int32_t ctgOpUpdateVgroup(SCtgCacheOperation *operation) {
dbCache
=
NULL
;
//if (!IS_SYS_DBNAME(dbFName)) {
tstrncpy
(
vgVersion
.
dbFName
,
dbFName
,
sizeof
(
vgVersion
.
dbFName
));
CTG_ERR_JRET
(
ctgMetaRentUpdate
(
&
msg
->
pCtg
->
dbRent
,
&
vgVersion
,
vgVersion
.
dbId
,
sizeof
(
SDbVgVersion
),
ctgDbVgVersionSortCompare
,
ctgDbVgVersionSearchCompare
));
//
if (!IS_SYS_DBNAME(dbFName)) {
tstrncpy
(
vgVersion
.
dbFName
,
dbFName
,
sizeof
(
vgVersion
.
dbFName
));
CTG_ERR_JRET
(
ctgMetaRentUpdate
(
&
msg
->
pCtg
->
dbRent
,
&
vgVersion
,
vgVersion
.
dbId
,
sizeof
(
SDbVgVersion
),
ctgDbVgVersionSortCompare
,
ctgDbVgVersionSearchCompare
));
//}
_return:
...
...
@@ -2054,11 +2038,7 @@ int32_t ctgOpUpdateUser(SCtgCacheOperation *operation) {
if
(
NULL
==
pUser
)
{
SCtgUserAuth
userAuth
=
{
0
};
userAuth
.
version
=
msg
->
userAuth
.
version
;
userAuth
.
superUser
=
msg
->
userAuth
.
superAuth
;
userAuth
.
createdDbs
=
msg
->
userAuth
.
createdDbs
;
userAuth
.
readDbs
=
msg
->
userAuth
.
readDbs
;
userAuth
.
writeDbs
=
msg
->
userAuth
.
writeDbs
;
memcpy
(
&
userAuth
.
userAuth
,
&
msg
->
userAuth
,
sizeof
(
msg
->
userAuth
));
if
(
taosHashPut
(
pCtg
->
userCache
,
msg
->
userAuth
.
user
,
strlen
(
msg
->
userAuth
.
user
),
&
userAuth
,
sizeof
(
userAuth
)))
{
ctgError
(
"taosHashPut user %s to cache failed"
,
msg
->
userAuth
.
user
);
...
...
@@ -2072,22 +2052,32 @@ int32_t ctgOpUpdateUser(SCtgCacheOperation *operation) {
return
TSDB_CODE_SUCCESS
;
}
pUser
->
version
=
msg
->
userAuth
.
version
;
CTG_LOCK
(
CTG_WRITE
,
&
pUser
->
lock
);
taosHashCleanup
(
pUser
->
createdDbs
);
pUser
->
createdDbs
=
msg
->
userAuth
.
createdDbs
;
taosHashCleanup
(
pUser
->
userAuth
.
createdDbs
);
pUser
->
userAuth
.
createdDbs
=
msg
->
userAuth
.
createdDbs
;
msg
->
userAuth
.
createdDbs
=
NULL
;
taosHashCleanup
(
pUser
->
readDbs
);
pUser
->
readDbs
=
msg
->
userAuth
.
readDbs
;
taosHashCleanup
(
pUser
->
userAuth
.
readDbs
);
pUser
->
userAuth
.
readDbs
=
msg
->
userAuth
.
readDbs
;
msg
->
userAuth
.
readDbs
=
NULL
;
taosHashCleanup
(
pUser
->
writeDbs
);
pUser
->
writeDbs
=
msg
->
userAuth
.
writeDbs
;
taosHashCleanup
(
pUser
->
userAuth
.
writeDbs
);
pUser
->
userAuth
.
writeDbs
=
msg
->
userAuth
.
writeDbs
;
msg
->
userAuth
.
writeDbs
=
NULL
;
taosHashCleanup
(
pUser
->
userAuth
.
readTbs
);
pUser
->
userAuth
.
readTbs
=
msg
->
userAuth
.
readTbs
;
msg
->
userAuth
.
readTbs
=
NULL
;
taosHashCleanup
(
pUser
->
userAuth
.
writeTbs
);
pUser
->
userAuth
.
writeTbs
=
msg
->
userAuth
.
writeTbs
;
msg
->
userAuth
.
writeTbs
=
NULL
;
taosHashCleanup
(
pUser
->
userAuth
.
useDbs
);
pUser
->
userAuth
.
useDbs
=
msg
->
userAuth
.
useDbs
;
msg
->
userAuth
.
useDbs
=
NULL
;
CTG_UNLOCK
(
CTG_WRITE
,
&
pUser
->
lock
);
_return:
...
...
@@ -2095,6 +2085,9 @@ _return:
taosHashCleanup
(
msg
->
userAuth
.
createdDbs
);
taosHashCleanup
(
msg
->
userAuth
.
readDbs
);
taosHashCleanup
(
msg
->
userAuth
.
writeDbs
);
taosHashCleanup
(
msg
->
userAuth
.
readTbs
);
taosHashCleanup
(
msg
->
userAuth
.
writeTbs
);
taosHashCleanup
(
msg
->
userAuth
.
useDbs
);
taosMemoryFreeClear
(
msg
);
...
...
@@ -2287,6 +2280,9 @@ void ctgFreeCacheOperationData(SCtgCacheOperation *op) {
taosHashCleanup
(
msg
->
userAuth
.
createdDbs
);
taosHashCleanup
(
msg
->
userAuth
.
readDbs
);
taosHashCleanup
(
msg
->
userAuth
.
writeDbs
);
taosHashCleanup
(
msg
->
userAuth
.
readTbs
);
taosHashCleanup
(
msg
->
userAuth
.
writeTbs
);
taosHashCleanup
(
msg
->
userAuth
.
useDbs
);
taosMemoryFreeClear
(
op
->
data
);
break
;
}
...
...
@@ -2526,7 +2522,7 @@ int32_t ctgGetTbMetasFromCache(SCatalog *pCtg, SRequestConnInfo *pConn, SCtgTbMe
ctgAddFetch
(
&
ctx
->
pFetchs
,
dbIdx
,
i
,
fetchIdx
,
baseResIdx
+
i
,
flag
);
taosArrayPush
(
ctx
->
pResList
,
&
(
SMetaRes
){
0
});
CTG_META_NHIT_INC
();
continue
;
}
...
...
@@ -2544,7 +2540,7 @@ int32_t ctgGetTbMetasFromCache(SCatalog *pCtg, SRequestConnInfo *pConn, SCtgTbMe
STableMeta
*
tbMeta
=
pCache
->
pMeta
;
CTG_META_HIT_INC
(
tbMeta
->
tableType
);
SCtgTbMetaCtx
nctx
=
{
0
};
nctx
.
flag
=
flag
;
nctx
.
tbInfo
.
inCache
=
true
;
...
...
@@ -2626,7 +2622,7 @@ int32_t ctgGetTbMetasFromCache(SCatalog *pCtg, SRequestConnInfo *pConn, SCtgTbMe
ctgAddFetch
(
&
ctx
->
pFetchs
,
dbIdx
,
i
,
fetchIdx
,
baseResIdx
+
i
,
flag
);
taosArrayPush
(
ctx
->
pResList
,
&
(
SMetaRes
){
0
});
taosMemoryFreeClear
(
pTableMeta
);
CTG_META_NHIT_INC
();
continue
;
}
...
...
source/libs/catalog/src/ctgUtil.c
浏览文件 @
4c04b155
...
...
@@ -174,9 +174,12 @@ void ctgFreeSMetaData(SMetaData* pData) {
}
void
ctgFreeSCtgUserAuth
(
SCtgUserAuth
*
userCache
)
{
taosHashCleanup
(
userCache
->
createdDbs
);
taosHashCleanup
(
userCache
->
readDbs
);
taosHashCleanup
(
userCache
->
writeDbs
);
taosHashCleanup
(
userCache
->
userAuth
.
createdDbs
);
taosHashCleanup
(
userCache
->
userAuth
.
readDbs
);
taosHashCleanup
(
userCache
->
userAuth
.
writeDbs
);
taosHashCleanup
(
userCache
->
userAuth
.
readTbs
);
taosHashCleanup
(
userCache
->
userAuth
.
writeTbs
);
taosHashCleanup
(
userCache
->
userAuth
.
useDbs
);
}
void
ctgFreeMetaRent
(
SCtgRentMgmt
*
mgmt
)
{
...
...
@@ -419,6 +422,9 @@ void ctgFreeMsgCtx(SCtgMsgCtx* pCtx) {
taosHashCleanup
(
pOut
->
createdDbs
);
taosHashCleanup
(
pOut
->
readDbs
);
taosHashCleanup
(
pOut
->
writeDbs
);
taosHashCleanup
(
pOut
->
readTbs
);
taosHashCleanup
(
pOut
->
writeTbs
);
taosHashCleanup
(
pOut
->
useDbs
);
taosMemoryFreeClear
(
pCtx
->
out
);
break
;
}
...
...
@@ -1325,6 +1331,142 @@ static void* ctgCloneDnodeList(void* pSrc) { return taosArrayDup((const SArray*)
static
void
ctgFreeDnodeList
(
void
*
p
)
{
taosArrayDestroy
((
SArray
*
)((
SMetaRes
*
)
p
)
->
pRes
);
}
int32_t
ctgChkSetTbAuthRes
(
SCatalog
*
pCtg
,
SCtgAuthReq
*
req
,
SCtgAuthRsp
*
res
)
{
int32_t
code
=
0
;
STableMeta
*
pMeta
=
NULL
;
SGetUserAuthRsp
*
pInfo
=
&
req
->
authInfo
;
SHashObj
*
pTbs
=
(
AUTH_TYPE_READ
==
req
->
singleType
)
?
pInfo
->
readTbs
:
pInfo
->
writeTbs
;
char
tbFullName
[
TSDB_TABLE_FNAME_LEN
];
tNameExtractFullName
(
&
req
->
pRawReq
->
tbName
,
tbFullName
);
char
*
pCond
=
taosHashGet
(
pTbs
,
tbFullName
,
strlen
(
tbFullName
));
if
(
pCond
)
{
if
(
strlen
(
pCond
)
>
1
)
{
CTG_ERR_RET
(
nodesStringToNode
(
pCond
,
&
res
->
pRawRes
->
pCond
));
}
res
->
pRawRes
->
pass
=
true
;
return
TSDB_CODE_SUCCESS
;
}
res
->
pRawRes
->
pass
=
false
;
// CTG_ERR_RET(catalogGetCachedTableMeta(pCtg, &req->pRawReq->tbName, &pMeta));
// if (NULL == pMeta) {
// if (req->onlyCache) {
// res->metaNotExists = true;
// ctgDebug("db %s tb %s meta not in cache for auth", req->pRawReq->tbName.dbname, req->pRawReq->tbName.tname);
// return TSDB_CODE_SUCCESS;
// }
// CTG_ERR_RET(catalogGetTableMeta(pCtg, req->pConn, &req->pRawReq->tbName, &pMeta));
// }
// if (TSDB_SUPER_TABLE == pMeta->tableType || TSDB_NORMAL_TABLE == pMeta->tableType) {
// res->pRawRes->pass = false;
// goto _return;
// }
// if (TSDB_CHILD_TABLE == pMeta->tableType) {
// res->pRawRes->pass = true;
// /*
// char stbName[TSDB_TABLE_NAME_LEN] = {0};
// CTG_ERR_JRET(ctgGetCachedStbNameFromSuid(pCtg, pMeta->suid, stbName));
// if (0 == stbName[0]) {
// if (req->onlyCache) {
// res->notExists = true;
// return TSDB_CODE_SUCCESS;
// }
// CTG_ERR_RET(catalogRefreshTableMeta(pCtg, req->pConn, &req->pRawReq->tbName, 0));
// }
// */
// }
_return:
taosMemoryFree
(
pMeta
);
CTG_RET
(
code
);
}
int32_t
ctgChkSetAuthRes
(
SCatalog
*
pCtg
,
SCtgAuthReq
*
req
,
SCtgAuthRsp
*
res
)
{
int32_t
code
=
0
;
SUserAuthInfo
*
pReq
=
req
->
pRawReq
;
SUserAuthRes
*
pRes
=
res
->
pRawRes
;
SGetUserAuthRsp
*
pInfo
=
&
req
->
authInfo
;
pRes
->
pass
=
false
;
pRes
->
pCond
=
NULL
;
if
(
!
pInfo
->
enable
)
{
pRes
->
pass
=
false
;
return
TSDB_CODE_SUCCESS
;
}
if
(
pInfo
->
superAuth
)
{
pRes
->
pass
=
true
;
return
TSDB_CODE_SUCCESS
;
}
char
dbFName
[
TSDB_DB_FNAME_LEN
];
tNameGetFullDbName
(
&
pReq
->
tbName
,
dbFName
);
if
(
pInfo
->
createdDbs
&&
taosHashGet
(
pInfo
->
createdDbs
,
dbFName
,
strlen
(
dbFName
)))
{
pRes
->
pass
=
true
;
return
TSDB_CODE_SUCCESS
;
}
switch
(
pReq
->
type
)
{
case
AUTH_TYPE_READ
:
{
if
(
pInfo
->
readTbs
&&
taosHashGetSize
(
pInfo
->
readTbs
)
>
0
)
{
req
->
singleType
=
AUTH_TYPE_READ
;
CTG_ERR_RET
(
ctgChkSetTbAuthRes
(
pCtg
,
req
,
res
));
if
(
pRes
->
pass
)
{
return
TSDB_CODE_SUCCESS
;
}
}
if
(
pInfo
->
readDbs
&&
taosHashGet
(
pInfo
->
readDbs
,
dbFName
,
strlen
(
dbFName
)))
{
pRes
->
pass
=
true
;
return
TSDB_CODE_SUCCESS
;
}
break
;
}
case
AUTH_TYPE_WRITE
:
{
if
(
pInfo
->
writeTbs
&&
taosHashGetSize
(
pInfo
->
writeTbs
)
>
0
)
{
req
->
singleType
=
AUTH_TYPE_WRITE
;
CTG_ERR_RET
(
ctgChkSetTbAuthRes
(
pCtg
,
req
,
res
));
if
(
pRes
->
pass
)
{
return
TSDB_CODE_SUCCESS
;
}
}
if
(
pInfo
->
writeDbs
&&
taosHashGet
(
pInfo
->
writeDbs
,
dbFName
,
strlen
(
dbFName
)))
{
pRes
->
pass
=
true
;
return
TSDB_CODE_SUCCESS
;
}
break
;
}
case
AUTH_TYPE_READ_OR_WRITE
:
{
if
((
pInfo
->
readDbs
&&
taosHashGet
(
pInfo
->
readDbs
,
dbFName
,
strlen
(
dbFName
)))
||
(
pInfo
->
writeDbs
&&
taosHashGet
(
pInfo
->
writeDbs
,
dbFName
,
strlen
(
dbFName
))))
{
pRes
->
pass
=
true
;
return
TSDB_CODE_SUCCESS
;
}
break
;
}
default:
break
;
}
return
TSDB_CODE_SUCCESS
;
}
#if 0
static int32_t ctgCloneMetaDataArray(SArray* pSrc, __array_item_dup_fn_t copyFunc, SArray** pDst) {
if (NULL == pSrc) {
...
...
source/libs/catalog/test/CMakeLists.txt
浏览文件 @
4c04b155
...
...
@@ -9,7 +9,7 @@ IF(NOT TD_DARWIN)
ADD_EXECUTABLE
(
catalogTest
${
SOURCE_LIST
}
)
TARGET_LINK_LIBRARIES
(
catalogTest
PUBLIC os util common catalog transport gtest qcom taos_static
PUBLIC os util common
nodes
catalog transport gtest qcom taos_static
)
TARGET_INCLUDE_DIRECTORIES
(
...
...
source/libs/catalog/test/catalogTests.cpp
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
source/libs/executor/inc/dataSinkInt.h
浏览文件 @
4c04b155
...
...
@@ -29,7 +29,6 @@ struct SDataSinkHandle;
typedef
struct
SDataSinkManager
{
SDataSinkMgtCfg
cfg
;
TdThreadMutex
mutex
;
}
SDataSinkManager
;
typedef
int32_t
(
*
FPutDataBlock
)(
struct
SDataSinkHandle
*
pHandle
,
const
SInputData
*
pInput
,
bool
*
pContinue
);
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
4c04b155
...
...
@@ -128,11 +128,11 @@ enum {
typedef
struct
{
// TODO remove prepareStatus
STqOffsetVal
prepareStatus
;
// for tmq
STqOffsetVal
lastStatus
;
// for tmq
//
STqOffsetVal prepareStatus; // for tmq
STqOffsetVal
currentOffset
;
// for tmq
SMqMetaRsp
metaRsp
;
// for tmq fetching meta
int8_t
returned
;
int64_t
snapshotVer
;
//
int8_t returned;
int64_t
snapshotVer
;
// const SSubmitReq* pReq;
SPackedData
submit
;
...
...
@@ -191,7 +191,7 @@ enum {
OP_OPENED
=
0x1
,
OP_RES_TO_RETURN
=
0x5
,
OP_EXEC_DONE
=
0x9
,
OP_EXEC_RECV
=
0x11
,
//
OP_EXEC_RECV = 0x11,
};
typedef
struct
SOperatorFpSet
{
...
...
@@ -502,32 +502,12 @@ typedef struct STableCountScanSupp {
char
stbNameFilter
[
TSDB_TABLE_NAME_LEN
];
}
STableCountScanSupp
;
typedef
struct
STableCountScanOperatorInfo
{
SReadHandle
readHandle
;
SSDataBlock
*
pRes
;
STableCountScanSupp
supp
;
int32_t
currGrpIdx
;
SArray
*
stbUidList
;
// when group by db_name and/or stable_name
}
STableCountScanOperatorInfo
;
typedef
struct
SOptrBasicInfo
{
SResultRowInfo
resultRowInfo
;
SSDataBlock
*
pRes
;
bool
mergeResultBlock
;
}
SOptrBasicInfo
;
typedef
struct
SAggOperatorInfo
{
SOptrBasicInfo
binfo
;
SAggSupporter
aggSup
;
STableQueryInfo
*
current
;
uint64_t
groupId
;
SGroupResInfo
groupResInfo
;
SExprSupp
scalarExprSup
;
bool
groupKeyOptimized
;
}
SAggOperatorInfo
;
typedef
struct
SIntervalAggOperatorInfo
{
SOptrBasicInfo
binfo
;
// basic info
SAggSupporter
aggSup
;
// aggregate supporter
...
...
@@ -853,8 +833,7 @@ SArray* getTableListInfo(const SExecTaskInfo* pTaskInfo);
int32_t
createExecTaskInfo
(
SSubplan
*
pPlan
,
SExecTaskInfo
**
pTaskInfo
,
SReadHandle
*
pHandle
,
uint64_t
taskId
,
int32_t
vgId
,
char
*
sql
,
EOPTR_EXEC_MODEL
model
);
int32_t
createDataSinkParam
(
SDataSinkNode
*
pNode
,
void
**
pParam
,
STableListInfo
*
pTableListInfo
,
SReadHandle
*
readHandle
);
int32_t
createDataSinkParam
(
SDataSinkNode
*
pNode
,
void
**
pParam
,
SExecTaskInfo
*
pTask
,
SReadHandle
*
readHandle
);
int32_t
getOperatorExplainExecInfo
(
SOperatorInfo
*
operatorInfo
,
SArray
*
pExecInfoList
);
STimeWindow
getActiveTimeWindow
(
SDiskbasedBuf
*
pBuf
,
SResultRowInfo
*
pResultRowInfo
,
int64_t
ts
,
SInterval
*
pInterval
,
...
...
source/libs/executor/src/aggregateoperator.c
浏览文件 @
4c04b155
...
...
@@ -40,6 +40,16 @@ typedef struct {
int32_t
startOffset
;
}
SFunctionCtxStatus
;
typedef
struct
SAggOperatorInfo
{
SOptrBasicInfo
binfo
;
SAggSupporter
aggSup
;
STableQueryInfo
*
current
;
uint64_t
groupId
;
SGroupResInfo
groupResInfo
;
SExprSupp
scalarExprSup
;
bool
groupKeyOptimized
;
}
SAggOperatorInfo
;
static
void
destroyAggOperatorInfo
(
void
*
param
);
static
void
setExecutionContext
(
SOperatorInfo
*
pOperator
,
int32_t
numOfOutput
,
uint64_t
groupId
);
...
...
@@ -162,9 +172,9 @@ int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) {
int32_t
scanFlag
=
MAIN_SCAN
;
bool
hasValidBlock
=
false
;
bool
blockAllocated
=
false
;
while
(
1
)
{
bool
blockAllocated
=
false
;
SSDataBlock
*
pBlock
=
downstream
->
fpSet
.
getNextFn
(
downstream
);
if
(
pBlock
==
NULL
)
{
if
(
!
hasValidBlock
)
{
...
...
@@ -560,4 +570,4 @@ void functionCtxRestore(SqlFunctionCtx* pCtx, SFunctionCtxStatus* pStatus) {
pCtx
->
input
.
colDataSMAIsSet
=
pStatus
->
hasAgg
;
pCtx
->
input
.
numOfRows
=
pStatus
->
numOfRows
;
pCtx
->
input
.
startRowIndex
=
pStatus
->
startOffset
;
}
\ No newline at end of file
}
source/libs/executor/src/dataSinkMgt.c
浏览文件 @
4c04b155
...
...
@@ -23,7 +23,6 @@ SDataSinkStat gDataSinkStat = {0};
int32_t
dsDataSinkMgtInit
(
SDataSinkMgtCfg
*
cfg
)
{
gDataSinkManager
.
cfg
=
*
cfg
;
taosThreadMutexInit
(
&
gDataSinkManager
.
mutex
,
NULL
);
return
0
;
// to avoid compiler eror
}
...
...
source/libs/executor/src/executor.c
浏览文件 @
4c04b155
...
...
@@ -127,12 +127,10 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
pOperator
->
status
=
OP_NOT_OPENED
;
SStreamScanInfo
*
pInfo
=
pOperator
->
info
;
qDebug
(
"stream set total blocks:%d, task id:%s"
PRIx64
,
(
int32_t
)
numOfBlocks
,
id
);
ASSERT
(
pInfo
->
validBlockIndex
==
0
);
ASSERT
(
taosArrayGetSize
(
pInfo
->
pBlockLists
)
==
0
);
qDebug
(
"task stream set total blocks:%d %s"
,
(
int32_t
)
numOfBlocks
,
id
);
ASSERT
(
pInfo
->
validBlockIndex
==
0
&&
taosArrayGetSize
(
pInfo
->
pBlockLists
)
==
0
);
if
(
type
==
STREAM_INPUT__MERGED_SUBMIT
)
{
// ASSERT(numOfBlocks > 1);
for
(
int32_t
i
=
0
;
i
<
numOfBlocks
;
i
++
)
{
SPackedData
*
pReq
=
POINTER_SHIFT
(
input
,
i
*
sizeof
(
SPackedData
));
taosArrayPush
(
pInfo
->
pBlockLists
,
pReq
);
...
...
@@ -505,12 +503,7 @@ int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId,
if
(
handle
)
{
void
*
pSinkParam
=
NULL
;
SArray
*
pInfoList
=
getTableListInfo
(
*
pTask
);
STableListInfo
*
pTableListInfo
=
taosArrayGetP
(
pInfoList
,
0
);
taosArrayDestroy
(
pInfoList
);
code
=
createDataSinkParam
(
pSubplan
->
pDataSink
,
&
pSinkParam
,
pTableListInfo
,
readHandle
);
code
=
createDataSinkParam
(
pSubplan
->
pDataSink
,
&
pSinkParam
,
(
*
pTask
),
readHandle
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
qError
(
"failed to createDataSinkParam, vgId:%d, code:%s, %s"
,
vgId
,
tstrerror
(
code
),
(
*
pTask
)
->
id
.
str
);
goto
_error
;
...
...
@@ -1029,15 +1022,9 @@ SMqMetaRsp* qStreamExtractMetaMsg(qTaskInfo_t tinfo) {
return
&
pTaskInfo
->
streamInfo
.
metaRsp
;
}
int64_t
qStreamExtractPrepareUid
(
qTaskInfo_t
tinfo
)
{
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
tinfo
;
return
pTaskInfo
->
streamInfo
.
prepareStatus
.
uid
;
}
int32_t
qStreamExtractOffset
(
qTaskInfo_t
tinfo
,
STqOffsetVal
*
pOffset
)
{
void
qStreamExtractOffset
(
qTaskInfo_t
tinfo
,
STqOffsetVal
*
pOffset
)
{
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
tinfo
;
memcpy
(
pOffset
,
&
pTaskInfo
->
streamInfo
.
lastStatus
,
sizeof
(
STqOffsetVal
));
return
0
;
memcpy
(
pOffset
,
&
pTaskInfo
->
streamInfo
.
currentOffset
,
sizeof
(
STqOffsetVal
));
}
int32_t
initQueryTableDataCondForTmq
(
SQueryTableDataCond
*
pCond
,
SSnapContext
*
sContext
,
SMetaTableInfo
*
pMtInfo
)
{
...
...
@@ -1083,22 +1070,27 @@ int32_t qStreamSetScanMemData(qTaskInfo_t tinfo, SPackedData submit) {
return
0
;
}
void
qStreamSetOpen
(
qTaskInfo_t
tinfo
)
{
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
tinfo
;
SOperatorInfo
*
pOperator
=
pTaskInfo
->
pRoot
;
pOperator
->
status
=
OP_NOT_OPENED
;
}
int32_t
qStreamPrepareScan
(
qTaskInfo_t
tinfo
,
STqOffsetVal
*
pOffset
,
int8_t
subType
)
{
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
tinfo
;
SOperatorInfo
*
pOperator
=
pTaskInfo
->
pRoot
;
const
char
*
id
=
GET_TASKID
(
pTaskInfo
);
pTaskInfo
->
streamInfo
.
prepareStatus
=
*
pOffset
;
pTaskInfo
->
streamInfo
.
returned
=
0
;
if
(
tOffsetEqual
(
pOffset
,
&
pTaskInfo
->
streamInfo
.
lastStatus
))
{
// if pOffset equal to current offset, means continue consume
if
(
tOffsetEqual
(
pOffset
,
&
pTaskInfo
->
streamInfo
.
currentOffset
))
{
return
0
;
}
if
(
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
pOperator
->
status
=
OP_OPENED
;
pOperator
=
extractOperatorInTree
(
pOperator
,
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN
,
id
);
if
(
pOperator
==
NULL
)
{
return
-
1
;
}
SStreamScanInfo
*
pInfo
=
pOperator
->
info
;
STableScanInfo
*
pScanInfo
=
pInfo
->
pTableScanOp
->
info
;
STableScanBase
*
pScanBaseInfo
=
&
pScanInfo
->
base
;
...
...
@@ -1109,7 +1101,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
pScanBaseInfo
->
dataReader
=
NULL
;
// let's seek to the next version in wal file
if
(
tqSeekVer
(
pInfo
->
tqReader
,
pOffset
->
version
+
1
,
pTaskInfo
->
id
.
str
)
<
0
)
{
if
(
tqSeekVer
(
pInfo
->
tqReader
,
pOffset
->
version
+
1
,
id
)
<
0
)
{
qError
(
"tqSeekVer failed ver:%"
PRId64
", %s"
,
pOffset
->
version
+
1
,
id
);
return
-
1
;
}
...
...
@@ -1137,6 +1129,8 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
}
}
qDebug
(
"switch to table uid:%"
PRId64
" ts:%"
PRId64
"% "
PRId64
" rows returned"
,
uid
,
ts
,
pInfo
->
pTableScanOp
->
resultInfo
.
totalRows
);
pInfo
->
pTableScanOp
->
resultInfo
.
totalRows
=
0
;
// start from current accessed position
...
...
@@ -1207,7 +1201,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
tableListClear
(
pTableListInfo
);
if
(
mtInfo
.
uid
==
0
)
{
return
0
;
// no data
goto
end
;
// no data
}
initQueryTableDataCondForTmq
(
&
pTaskInfo
->
streamInfo
.
tableCond
,
sContext
,
&
mtInfo
);
...
...
@@ -1244,6 +1238,9 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
}
}
end:
pTaskInfo
->
streamInfo
.
currentOffset
=
*
pOffset
;
return
0
;
}
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
4c04b155
...
...
@@ -1591,8 +1591,7 @@ int32_t extractTableScanNode(SPhysiNode* pNode, STableScanPhysiNode** ppNode) {
return
-
1
;
}
int32_t
createDataSinkParam
(
SDataSinkNode
*
pNode
,
void
**
pParam
,
STableListInfo
*
pTableListInfo
,
SReadHandle
*
readHandle
)
{
int32_t
createDataSinkParam
(
SDataSinkNode
*
pNode
,
void
**
pParam
,
SExecTaskInfo
*
pTask
,
SReadHandle
*
readHandle
)
{
switch
(
pNode
->
type
)
{
case
QUERY_NODE_PHYSICAL_PLAN_QUERY_INSERT
:
{
SInserterParam
*
pInserterParam
=
taosMemoryCalloc
(
1
,
sizeof
(
SInserterParam
));
...
...
@@ -1610,23 +1609,26 @@ int32_t createDataSinkParam(SDataSinkNode* pNode, void** pParam, STableListInfo*
return
TSDB_CODE_OUT_OF_MEMORY
;
}
int32_t
tbNum
=
tableListGetSize
(
pTableListInfo
);
SArray
*
pInfoList
=
getTableListInfo
(
pTask
);
STableListInfo
*
pTableListInfo
=
taosArrayGetP
(
pInfoList
,
0
);
taosArrayDestroy
(
pInfoList
);
pDeleterParam
->
suid
=
tableListGetSuid
(
pTableListInfo
);
// TODO extract uid list
pDeleterParam
->
pUidList
=
taosArrayInit
(
tbNum
,
sizeof
(
uint64_t
));
int32_t
numOfTables
=
tableListGetSize
(
pTableListInfo
);
pDeleterParam
->
pUidList
=
taosArrayInit
(
numOfTables
,
sizeof
(
uint64_t
));
if
(
NULL
==
pDeleterParam
->
pUidList
)
{
taosMemoryFree
(
pDeleterParam
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
for
(
int32_t
i
=
0
;
i
<
tbNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfTables
;
++
i
)
{
STableKeyInfo
*
pTable
=
tableListGetInfo
(
pTableListInfo
,
i
);
taosArrayPush
(
pDeleterParam
->
pUidList
,
&
pTable
->
uid
);
}
*
pParam
=
pDeleterParam
;
break
;
}
default:
...
...
@@ -1973,11 +1975,11 @@ void qStreamCloseTsdbReader(void* task) {
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
task
;
SOperatorInfo
*
pOp
=
pTaskInfo
->
pRoot
;
qDebug
(
"stream close tsdb reader, reset status uid:%"
PRId64
" ts:%"
PRId64
,
pTaskInfo
->
streamInfo
.
lastStatus
.
uid
,
pTaskInfo
->
streamInfo
.
lastStatus
.
ts
);
qDebug
(
"stream close tsdb reader, reset status uid:%"
PRId64
" ts:%"
PRId64
,
pTaskInfo
->
streamInfo
.
currentOffset
.
uid
,
pTaskInfo
->
streamInfo
.
currentOffset
.
ts
);
// todo refactor, other thread may already use this read to extract data.
pTaskInfo
->
streamInfo
.
lastStatus
=
(
STqOffsetVal
){
0
};
pTaskInfo
->
streamInfo
.
currentOffset
=
(
STqOffsetVal
){
0
};
while
(
pOp
->
numOfDownstream
==
1
&&
pOp
->
pDownstream
[
0
])
{
SOperatorInfo
*
pDownstreamOp
=
pOp
->
pDownstream
[
0
];
if
(
pDownstreamOp
->
operatorType
==
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN
)
{
...
...
source/libs/executor/src/projectoperator.c
浏览文件 @
4c04b155
...
...
@@ -227,17 +227,8 @@ SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) {
blockDataCleanup
(
pFinalRes
);
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
if
(
pTaskInfo
->
streamInfo
.
submit
.
msgStr
)
{
pOperator
->
status
=
OP_OPENED
;
}
if
(
pOperator
->
status
==
OP_EXEC_DONE
)
{
if
(
pTaskInfo
->
execModel
==
OPTR_EXEC_MODEL_QUEUE
)
{
pOperator
->
status
=
OP_OPENED
;
qDebug
(
"projection in queue model, set status open and return null"
);
return
NULL
;
}
return
NULL
;
}
...
...
@@ -263,23 +254,14 @@ SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) {
// The downstream exec may change the value of the newgroup, so use a local variable instead.
SSDataBlock
*
pBlock
=
downstream
->
fpSet
.
getNextFn
(
downstream
);
if
(
pBlock
==
NULL
)
{
if
(
pTaskInfo
->
execModel
==
OPTR_EXEC_MODEL_QUEUE
&&
pFinalRes
->
info
.
rows
==
0
)
{
pOperator
->
status
=
OP_OPENED
;
if
(
pOperator
->
status
==
OP_EXEC_RECV
)
{
continue
;
}
else
{
return
NULL
;
}
}
qDebug
(
"set op close, exec %d, status %d rows %"
PRId64
,
pTaskInfo
->
execModel
,
pOperator
->
status
,
pFinalRes
->
info
.
rows
);
qDebug
(
"set op close, exec %d, status %d rows %"
PRId64
,
pTaskInfo
->
execModel
,
pOperator
->
status
,
pFinalRes
->
info
.
rows
);
setOperatorCompleted
(
pOperator
);
break
;
}
if
(
pTaskInfo
->
execModel
==
OPTR_EXEC_MODEL_QUEUE
)
{
qDebug
(
"set status recv"
);
pOperator
->
status
=
OP_EXEC_RECV
;
}
//
if (pTaskInfo->execModel == OPTR_EXEC_MODEL_QUEUE) {
//
qDebug("set status recv");
//
pOperator->status = OP_EXEC_RECV;
//
}
// for stream interval
if
(
pBlock
->
info
.
type
==
STREAM_RETRIEVE
||
pBlock
->
info
.
type
==
STREAM_DELETE_RESULT
||
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
source/libs/executor/src/timewindowoperator.c
浏览文件 @
4c04b155
...
...
@@ -4758,6 +4758,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
if
(
!
pInfo
->
pUpdated
)
{
pInfo
->
pUpdated
=
taosArrayInit
(
4
,
sizeof
(
SWinKey
));
}
if
(
!
pInfo
->
pUpdatedMap
)
{
_hash_fn_t
hashFn
=
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
);
pInfo
->
pUpdatedMap
=
tSimpleHashInit
(
1024
,
hashFn
);
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
4c04b155
...
...
@@ -925,6 +925,7 @@ void nodesDestroyNode(SNode* pNode) {
taosMemoryFree
(((
SDescribeStmt
*
)
pNode
)
->
pMeta
);
break
;
case
QUERY_NODE_RESET_QUERY_CACHE_STMT
:
// no pointer field
break
;
case
QUERY_NODE_COMPACT_DATABASE_STMT
:
{
SCompactDatabaseStmt
*
pStmt
=
(
SCompactDatabaseStmt
*
)
pNode
;
nodesDestroyNode
(
pStmt
->
pStart
);
...
...
@@ -942,10 +943,10 @@ void nodesDestroyNode(SNode* pNode) {
nodesDestroyNode
(
pStmt
->
pSubtable
);
break
;
}
case
QUERY_NODE_DROP_STREAM_STMT
:
// no pointer field
case
QUERY_NODE_BALANCE_VGROUP_STMT
:
// no pointer field
case
QUERY_NODE_DROP_STREAM_STMT
:
// no pointer field
case
QUERY_NODE_BALANCE_VGROUP_STMT
:
// no pointer field
case
QUERY_NODE_BALANCE_VGROUP_LEADER_STMT
:
// no pointer field
case
QUERY_NODE_MERGE_VGROUP_STMT
:
// no pointer field
case
QUERY_NODE_MERGE_VGROUP_STMT
:
// no pointer field
break
;
case
QUERY_NODE_REDISTRIBUTE_VGROUP_STMT
:
nodesDestroyList
(((
SRedistributeVgroupStmt
*
)
pNode
)
->
pDnodes
);
...
...
source/libs/parser/inc/parAst.h
浏览文件 @
4c04b155
...
...
@@ -82,6 +82,11 @@ typedef struct SAlterOption {
SNodeList
*
pList
;
}
SAlterOption
;
typedef
struct
STokenPair
{
SToken
first
;
SToken
second
;
}
STokenPair
;
extern
SToken
nil_token
;
void
initAstCreateContext
(
SParseContext
*
pParseCxt
,
SAstCreateContext
*
pCxt
);
...
...
@@ -229,8 +234,10 @@ SNode* createMergeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId1, cons
SNode
*
createRedistributeVgroupStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pVgId
,
SNodeList
*
pDnodes
);
SNode
*
createSplitVgroupStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pVgId
);
SNode
*
createSyncdbStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDbName
);
SNode
*
createGrantStmt
(
SAstCreateContext
*
pCxt
,
int64_t
privileges
,
SToken
*
pDbName
,
SToken
*
pUserName
);
SNode
*
createRevokeStmt
(
SAstCreateContext
*
pCxt
,
int64_t
privileges
,
SToken
*
pDbName
,
SToken
*
pUserName
);
SNode
*
createGrantStmt
(
SAstCreateContext
*
pCxt
,
int64_t
privileges
,
STokenPair
*
pPrivLevel
,
SToken
*
pUserName
,
SNode
*
pTagCond
);
SNode
*
createRevokeStmt
(
SAstCreateContext
*
pCxt
,
int64_t
privileges
,
STokenPair
*
pPrivLevel
,
SToken
*
pUserName
,
SNode
*
pTagCond
);
SNode
*
createDeleteStmt
(
SAstCreateContext
*
pCxt
,
SNode
*
pTable
,
SNode
*
pWhere
);
SNode
*
createInsertStmt
(
SAstCreateContext
*
pCxt
,
SNode
*
pTable
,
SNodeList
*
pCols
,
SNode
*
pQuery
);
...
...
source/libs/parser/inc/parUtil.h
浏览文件 @
4c04b155
...
...
@@ -97,9 +97,8 @@ int32_t reserveTableVgroupInCache(int32_t acctId, const char* pDb, const char* p
int32_t
reserveTableVgroupInCacheExt
(
const
SName
*
pName
,
SParseMetaCache
*
pMetaCache
);
int32_t
reserveDbVgVersionInCache
(
int32_t
acctId
,
const
char
*
pDb
,
SParseMetaCache
*
pMetaCache
);
int32_t
reserveDbCfgInCache
(
int32_t
acctId
,
const
char
*
pDb
,
SParseMetaCache
*
pMetaCache
);
int32_t
reserveUserAuthInCache
(
int32_t
acctId
,
const
char
*
pUser
,
const
char
*
pDb
,
AUTH_TYPE
type
,
int32_t
reserveUserAuthInCache
(
int32_t
acctId
,
const
char
*
pUser
,
const
char
*
pDb
,
const
char
*
pTable
,
AUTH_TYPE
type
,
SParseMetaCache
*
pMetaCache
);
int32_t
reserveUserAuthInCacheExt
(
const
char
*
pUser
,
const
SName
*
pName
,
AUTH_TYPE
type
,
SParseMetaCache
*
pMetaCache
);
int32_t
reserveUdfInCache
(
const
char
*
pFunc
,
SParseMetaCache
*
pMetaCache
);
int32_t
reserveTableIndexInCache
(
int32_t
acctId
,
const
char
*
pDb
,
const
char
*
pTable
,
SParseMetaCache
*
pMetaCache
);
int32_t
reserveTableCfgInCache
(
int32_t
acctId
,
const
char
*
pDb
,
const
char
*
pTable
,
SParseMetaCache
*
pMetaCache
);
...
...
@@ -110,8 +109,7 @@ int32_t getTableVgroupFromCache(SParseMetaCache* pMetaCache, const SName* pName,
int32_t
getDbVgVersionFromCache
(
SParseMetaCache
*
pMetaCache
,
const
char
*
pDbFName
,
int32_t
*
pVersion
,
int64_t
*
pDbId
,
int32_t
*
pTableNum
,
int64_t
*
pStateTs
);
int32_t
getDbCfgFromCache
(
SParseMetaCache
*
pMetaCache
,
const
char
*
pDbFName
,
SDbCfgInfo
*
pInfo
);
int32_t
getUserAuthFromCache
(
SParseMetaCache
*
pMetaCache
,
const
char
*
pUser
,
const
char
*
pDbFName
,
AUTH_TYPE
type
,
bool
*
pPass
);
int32_t
getUserAuthFromCache
(
SParseMetaCache
*
pMetaCache
,
SUserAuthInfo
*
pAuthReq
,
SUserAuthRes
*
pAuthRes
);
int32_t
getUdfInfoFromCache
(
SParseMetaCache
*
pMetaCache
,
const
char
*
pFunc
,
SFuncInfo
*
pInfo
);
int32_t
getTableIndexFromCache
(
SParseMetaCache
*
pMetaCache
,
const
SName
*
pName
,
SArray
**
pIndexes
);
int32_t
getTableCfgFromCache
(
SParseMetaCache
*
pMetaCache
,
const
SName
*
pName
,
STableCfg
**
pOutput
);
...
...
source/libs/parser/inc/sql.y
浏览文件 @
4c04b155
...
...
@@ -94,8 +94,8 @@ sysinfo_opt(A) ::= .
sysinfo_opt(A) ::= SYSINFO NK_INTEGER(B). { A = taosStr2Int8(B.z, NULL, 10); }
/************************************************ grant/revoke ********************************************************/
cmd ::= GRANT privileges(A) ON priv_level(B)
TO user_name(C). { pCxt->pRootNode = createGrantStmt(pCxt, A, &B, &C
); }
cmd ::= REVOKE privileges(A) ON priv_level(B)
FROM user_name(C). { pCxt->pRootNode = createRevokeStmt(pCxt, A, &B, &C
); }
cmd ::= GRANT privileges(A) ON priv_level(B)
with_opt(D) TO user_name(C). { pCxt->pRootNode = createGrantStmt(pCxt, A, &B, &C, D
); }
cmd ::= REVOKE privileges(A) ON priv_level(B)
with_opt(D) FROM user_name(C). { pCxt->pRootNode = createRevokeStmt(pCxt, A, &B, &C, D
); }
%type privileges { int64_t }
%destructor privileges { }
...
...
@@ -113,11 +113,15 @@ priv_type_list(A) ::= priv_type_list(B) NK_COMMA priv_type(C).
priv_type(A) ::= READ. { A = PRIVILEGE_TYPE_READ; }
priv_type(A) ::= WRITE. { A = PRIVILEGE_TYPE_WRITE; }
%type priv_level { SToken }
%type priv_level { SToken
Pair
}
%destructor priv_level { }
priv_level(A) ::= NK_STAR(B) NK_DOT NK_STAR. { A = B; }
priv_level(A) ::= db_name(B) NK_DOT NK_STAR. { A = B; }
priv_level(A) ::= topic_name(B). { A = B; }
priv_level(A) ::= NK_STAR(B) NK_DOT NK_STAR(C). { A.first = B; A.second = C; }
priv_level(A) ::= db_name(B) NK_DOT NK_STAR(C). { A.first = B; A.second = C; }
priv_level(A) ::= db_name(B) NK_DOT table_name(C). { A.first = B; A.second = C; }
priv_level(A) ::= topic_name(B). { A.first = B; A.second = nil_token; }
with_opt(A) ::= . { A = NULL; }
with_opt(A) ::= WITH search_condition(B). { A = B; }
/************************************************ create/drop/alter dnode *********************************************/
cmd ::= CREATE DNODE dnode_endpoint(A). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, NULL); }
...
...
@@ -342,7 +346,7 @@ column_def_list(A) ::= column_def(B).
column_def_list(A) ::= column_def_list(B) NK_COMMA column_def(C). { A = addNodeToList(pCxt, B, C); }
column_def(A) ::= column_name(B) type_name(C). { A = createColumnDefNode(pCxt, &B, C, NULL); }
column_def(A) ::= column_name(B) type_name(C) COMMENT NK_STRING(D). { A = createColumnDefNode(pCxt, &B, C, &D); }
//
column_def(A) ::= column_name(B) type_name(C) COMMENT NK_STRING(D). { A = createColumnDefNode(pCxt, &B, C, &D); }
%type type_name { SDataType }
%destructor type_name { }
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
4c04b155
...
...
@@ -1994,29 +1994,39 @@ SNode* createSyncdbStmt(SAstCreateContext* pCxt, const SToken* pDbName) {
return
pStmt
;
}
SNode
*
createGrantStmt
(
SAstCreateContext
*
pCxt
,
int64_t
privileges
,
SToken
*
pDbName
,
SToken
*
pUserName
)
{
SNode
*
createGrantStmt
(
SAstCreateContext
*
pCxt
,
int64_t
privileges
,
STokenPair
*
pPrivLevel
,
SToken
*
pUserName
,
SNode
*
pTagCond
)
{
CHECK_PARSER_STATUS
(
pCxt
);
if
(
!
checkDbName
(
pCxt
,
pDbName
,
false
)
||
!
checkUserName
(
pCxt
,
pUserName
))
{
if
(
!
checkDbName
(
pCxt
,
&
pPrivLevel
->
first
,
false
)
||
!
checkUserName
(
pCxt
,
pUserName
))
{
return
NULL
;
}
SGrantStmt
*
pStmt
=
(
SGrantStmt
*
)
nodesMakeNode
(
QUERY_NODE_GRANT_STMT
);
CHECK_OUT_OF_MEM
(
pStmt
);
pStmt
->
privileges
=
privileges
;
COPY_STRING_FORM_ID_TOKEN
(
pStmt
->
objName
,
pDbName
);
COPY_STRING_FORM_ID_TOKEN
(
pStmt
->
objName
,
&
pPrivLevel
->
first
);
if
(
TK_NK_NIL
!=
pPrivLevel
->
second
.
type
&&
TK_NK_STAR
!=
pPrivLevel
->
second
.
type
)
{
COPY_STRING_FORM_ID_TOKEN
(
pStmt
->
tabName
,
&
pPrivLevel
->
second
);
}
COPY_STRING_FORM_ID_TOKEN
(
pStmt
->
userName
,
pUserName
);
pStmt
->
pTagCond
=
pTagCond
;
return
(
SNode
*
)
pStmt
;
}
SNode
*
createRevokeStmt
(
SAstCreateContext
*
pCxt
,
int64_t
privileges
,
SToken
*
pDbName
,
SToken
*
pUserName
)
{
SNode
*
createRevokeStmt
(
SAstCreateContext
*
pCxt
,
int64_t
privileges
,
STokenPair
*
pPrivLevel
,
SToken
*
pUserName
,
SNode
*
pTagCond
)
{
CHECK_PARSER_STATUS
(
pCxt
);
if
(
!
checkDbName
(
pCxt
,
pDbName
,
false
)
||
!
checkUserName
(
pCxt
,
pUserName
))
{
if
(
!
checkDbName
(
pCxt
,
&
pPrivLevel
->
first
,
false
)
||
!
checkUserName
(
pCxt
,
pUserName
))
{
return
NULL
;
}
SRevokeStmt
*
pStmt
=
(
SRevokeStmt
*
)
nodesMakeNode
(
QUERY_NODE_REVOKE_STMT
);
CHECK_OUT_OF_MEM
(
pStmt
);
pStmt
->
privileges
=
privileges
;
COPY_STRING_FORM_ID_TOKEN
(
pStmt
->
objName
,
pDbName
);
COPY_STRING_FORM_ID_TOKEN
(
pStmt
->
objName
,
&
pPrivLevel
->
first
);
if
(
TK_NK_NIL
!=
pPrivLevel
->
second
.
type
&&
TK_NK_STAR
!=
pPrivLevel
->
second
.
type
)
{
COPY_STRING_FORM_ID_TOKEN
(
pStmt
->
tabName
,
&
pPrivLevel
->
second
);
}
COPY_STRING_FORM_ID_TOKEN
(
pStmt
->
userName
,
pUserName
);
pStmt
->
pTagCond
=
pTagCond
;
return
(
SNode
*
)
pStmt
;
}
...
...
source/libs/parser/src/parAstParser.c
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
source/libs/parser/src/parAuthenticator.c
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
source/libs/parser/src/parInsertSml.c
浏览文件 @
4c04b155
...
...
@@ -125,6 +125,12 @@ static int32_t smlBuildTagRow(SArray* cols, SBoundColInfo* tags, SSchema* pSchem
SSchema
*
pTagSchema
=
&
pSchema
[
tags
->
pColIndex
[
i
]];
SSmlKv
*
kv
=
taosArrayGet
(
cols
,
i
);
if
(
kv
->
keyLen
!=
strlen
(
pTagSchema
->
name
)
||
memcmp
(
kv
->
key
,
pTagSchema
->
name
,
kv
->
keyLen
)
!=
0
||
kv
->
type
!=
pTagSchema
->
type
){
code
=
TSDB_CODE_SML_INVALID_DATA
;
uError
(
"SML smlBuildCol error col not same %s"
,
pTagSchema
->
name
);
goto
end
;
}
taosArrayPush
(
*
tagName
,
pTagSchema
->
name
);
STagVal
val
=
{.
cid
=
pTagSchema
->
colId
,
.
type
=
pTagSchema
->
type
};
// strcpy(val.colName, pTagSchema->name);
...
...
source/libs/parser/src/parInsertSql.c
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
source/libs/parser/src/parInsertUtil.c
浏览文件 @
4c04b155
...
...
@@ -470,11 +470,11 @@ int32_t insMergeTableDataCxt(SHashObj* pTableHash, SArray** pVgDataBlocks) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
SVgroupDataCxt
*
pVgCxt
=
NULL
;
int32_t
vgId
=
pTableCxt
->
pMeta
->
vgId
;
void
**
p
=
taosHashGet
(
pVgroupHash
,
&
vgId
,
sizeof
(
vgId
));
if
(
NULL
==
p
)
{
void
**
p
p
=
taosHashGet
(
pVgroupHash
,
&
vgId
,
sizeof
(
vgId
));
if
(
NULL
==
p
p
)
{
code
=
createVgroupDataCxt
(
pTableCxt
,
pVgroupHash
,
pVgroupList
,
&
pVgCxt
);
}
else
{
pVgCxt
=
*
(
SVgroupDataCxt
**
)
p
;
pVgCxt
=
*
(
SVgroupDataCxt
**
)
p
p
;
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
fillVgroupDataCxt
(
pTableCxt
,
pVgCxt
);
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
source/libs/parser/src/parUtil.c
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
source/libs/parser/src/sql.c
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
source/libs/parser/test/mockCatalog.cpp
浏览文件 @
4c04b155
...
...
@@ -279,15 +279,13 @@ int32_t __catalogGetDBCfg(SCatalog* pCtg, SRequestConnInfo* pConn, const char* d
return
g_mockCatalogService
->
catalogGetDBCfg
(
dbFName
,
pDbCfg
);
}
int32_t
__catalogChkAuth
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
user
,
const
char
*
dbFName
,
AUTH_TYPE
type
,
bool
*
pass
)
{
*
pass
=
true
;
int32_t
__catalogChkAuth
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SUserAuthInfo
*
pAuth
,
SUserAuthRes
*
pRes
)
{
pRes
->
pass
=
true
;
return
0
;
}
int32_t
__catalogChkAuthFromCache
(
SCatalog
*
pCtg
,
const
char
*
user
,
const
char
*
dbFName
,
AUTH_TYPE
type
,
bool
*
pass
,
bool
*
exists
)
{
*
pass
=
true
;
int32_t
__catalogChkAuthFromCache
(
SCatalog
*
pCtg
,
SUserAuthInfo
*
pAuth
,
SUserAuthRes
*
pRes
,
bool
*
exists
)
{
pRes
->
pass
=
true
;
*
exists
=
true
;
return
0
;
}
...
...
source/libs/parser/test/mockCatalogService.cpp
浏览文件 @
4c04b155
...
...
@@ -589,8 +589,8 @@ class MockCatalogServiceImpl {
*
pUserAuthData
=
taosArrayInit
(
num
,
sizeof
(
SMetaRes
));
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
SMetaRes
res
=
{
0
};
res
.
pRes
=
taosMemoryCalloc
(
1
,
sizeof
(
bool
));
*
(
bool
*
)(
res
.
pRes
)
=
true
;
res
.
pRes
=
taosMemoryCalloc
(
1
,
sizeof
(
SUserAuthRes
));
((
SUserAuthRes
*
)
res
.
pRes
)
->
pass
=
true
;
taosArrayPush
(
*
pUserAuthData
,
&
res
);
}
}
...
...
source/libs/parser/test/parInitialCTest.cpp
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
source/libs/planner/src/planOptimizer.c
浏览文件 @
4c04b155
...
...
@@ -1079,11 +1079,23 @@ static bool sortPriKeyOptMayBeOptimized(SLogicNode* pNode) {
if
(
!
sortPriKeyOptIsPriKeyOrderBy
(
pSort
->
pSortKeys
)
||
1
!=
LIST_LENGTH
(
pSort
->
node
.
pChildren
))
{
return
false
;
}
SNode
*
pChild
;
FOREACH
(
pChild
,
pSort
->
node
.
pChildren
)
{
SLogicNode
*
pSortDescendent
=
optFindPossibleNode
((
SLogicNode
*
)
pChild
,
sortPriKeyOptMayBeOptimized
);
if
(
pSortDescendent
!=
NULL
)
{
return
false
;
}
}
return
true
;
}
static
int32_t
sortPriKeyOptGetSequencingNodesImpl
(
SLogicNode
*
pNode
,
bool
groupSort
,
bool
*
pNotOptimize
,
SNodeList
**
pSequencingNodes
)
{
if
(
NULL
!=
pNode
->
pLimit
||
NULL
!=
pNode
->
pSlimit
)
{
*
pNotOptimize
=
false
;
return
TSDB_CODE_SUCCESS
;
}
switch
(
nodeType
(
pNode
))
{
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
{
SScanLogicNode
*
pScan
=
(
SScanLogicNode
*
)
pNode
;
...
...
source/libs/scheduler/inc/schInt.h
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
source/libs/scheduler/src/schFlowCtrl.c
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
source/libs/scheduler/src/scheduler.c
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
source/libs/stream/src/stream.c
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
source/libs/stream/src/streamData.c
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
source/libs/stream/src/streamExec.c
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
source/libs/sync/inc/syncPipeline.h
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
source/libs/sync/src/syncAppendEntriesReply.c
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
source/libs/sync/src/syncMain.c
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
source/libs/sync/src/syncPipeline.c
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
source/libs/sync/src/syncReplication.c
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
source/libs/sync/src/syncUtil.c
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
source/libs/transport/src/transCli.c
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
source/libs/wal/src/walRead.c
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
source/util/src/terror.c
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
tests/develop-test/5-taos-tools/taosbenchmark/default_json.py
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
tests/develop-test/5-taos-tools/taosbenchmark/json/default.json
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
tests/parallel_test/cases.task
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
tests/pytest/util/autogen.py
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
tests/script/api/batchprepare.c
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
tests/script/tsim/query/multi_order_by.sim
0 → 100644
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
tests/script/tsim/tmq/basic1.sim
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
tests/script/tsim/tmq/basic1Of2Cons.sim
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
tests/script/tsim/tmq/basic2.sim
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
tests/script/tsim/tmq/basic2Of2Cons.sim
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
tests/script/tsim/tmq/basic2Of2ConsOverlap.sim
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
tests/script/tsim/tmq/basic3.sim
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
tests/script/tsim/tmq/basic3Of2Cons.sim
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
tests/script/tsim/tmq/basic4.sim
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
tests/script/tsim/tmq/basic4Of2Cons.sim
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
tests/system-test/0-others/user_control.py
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
tests/system-test/2-query/interp.py
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
tests/system-test/7-tmq/subscribeStb.py
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
tests/system-test/7-tmq/subscribeStb0.py
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
tests/system-test/7-tmq/subscribeStb1.py
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
tests/system-test/7-tmq/subscribeStb2.py
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
tests/system-test/7-tmq/subscribeStb3.py
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
tests/system-test/7-tmq/subscribeStb4.py
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
tests/system-test/7-tmq/tmqDelete-1ctb.py
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
tests/system-test/runAllOne.sh
0 → 100644
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
tests/system-test/test.py
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
tools/shell/src/shellArguments.c
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
utils/test/c/CMakeLists.txt
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
utils/test/c/sml_test.c
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
utils/test/c/tmqOffset.c
0 → 100644
浏览文件 @
4c04b155
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录