Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
291aab04
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
Star
22019
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
291aab04
编写于
6月 24, 2022
作者:
P
plum-lihui
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' into test3.0/lihui
上级
40d4da3c
53755c23
变更
83
展开全部
隐藏空白更改
内联
并排
Showing
83 changed file
with
4640 addition
and
3609 deletion
+4640
-3609
include/client/taos.h
include/client/taos.h
+0
-1
include/common/tdatablock.h
include/common/tdatablock.h
+5
-3
include/common/tglobal.h
include/common/tglobal.h
+1
-0
include/common/tmsg.h
include/common/tmsg.h
+2
-0
include/common/tname.h
include/common/tname.h
+2
-0
include/common/ttokendef.h
include/common/ttokendef.h
+103
-101
include/dnode/mnode/mnode.h
include/dnode/mnode/mnode.h
+3
-1
include/libs/function/functionMgt.h
include/libs/function/functionMgt.h
+1
-0
include/libs/monitor/monitor.h
include/libs/monitor/monitor.h
+10
-0
include/libs/nodes/cmdnodes.h
include/libs/nodes/cmdnodes.h
+8
-8
include/libs/nodes/nodes.h
include/libs/nodes/nodes.h
+2
-0
include/libs/nodes/plannodes.h
include/libs/nodes/plannodes.h
+5
-9
include/libs/qcom/query.h
include/libs/qcom/query.h
+3
-3
include/libs/stream/tstream.h
include/libs/stream/tstream.h
+2
-0
include/libs/sync/sync.h
include/libs/sync/sync.h
+3
-3
include/util/tconfig.h
include/util/tconfig.h
+2
-1
source/client/inc/clientInt.h
source/client/inc/clientInt.h
+8
-2
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+276
-10
source/client/src/clientMain.c
source/client/src/clientMain.c
+77
-84
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+52
-20
source/common/src/tglobal.c
source/common/src/tglobal.c
+367
-0
source/common/src/tmsg.c
source/common/src/tmsg.c
+14
-10
source/common/src/tname.c
source/common/src/tname.c
+14
-0
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
+1
-1
source/dnode/mnode/impl/src/mndMain.c
source/dnode/mnode/impl/src/mndMain.c
+25
-2
source/dnode/vnode/src/tq/tqExec.c
source/dnode/vnode/src/tq/tqExec.c
+1
-0
source/dnode/vnode/src/tq/tqOffset.c
source/dnode/vnode/src/tq/tqOffset.c
+2
-2
source/dnode/vnode/src/tq/tqRead.c
source/dnode/vnode/src/tq/tqRead.c
+6
-4
source/libs/command/src/command.c
source/libs/command/src/command.c
+11
-1
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+0
-1
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+25
-17
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+11
-9
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+10
-9
source/libs/monitor/src/monMain.c
source/libs/monitor/src/monMain.c
+22
-0
source/libs/monitor/src/monMsg.c
source/libs/monitor/src/monMsg.c
+30
-0
source/libs/nodes/src/nodesCloneFuncs.c
source/libs/nodes/src/nodesCloneFuncs.c
+207
-170
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+56
-57
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+21
-1
source/libs/parser/inc/parAst.h
source/libs/parser/inc/parAst.h
+2
-1
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+9
-3
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+3
-2
source/libs/parser/src/parAstParser.c
source/libs/parser/src/parAstParser.c
+14
-0
source/libs/parser/src/parCalcConst.c
source/libs/parser/src/parCalcConst.c
+23
-1
source/libs/parser/src/parTokenizer.c
source/libs/parser/src/parTokenizer.c
+2
-0
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+43
-6
source/libs/parser/src/parUtil.c
source/libs/parser/src/parUtil.c
+4
-4
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+2489
-2472
source/libs/parser/test/mockCatalog.cpp
source/libs/parser/test/mockCatalog.cpp
+66
-35
source/libs/parser/test/mockCatalogService.cpp
source/libs/parser/test/mockCatalogService.cpp
+11
-6
source/libs/parser/test/parSelectTest.cpp
source/libs/parser/test/parSelectTest.cpp
+13
-5
source/libs/parser/test/parShowToUse.cpp
source/libs/parser/test/parShowToUse.cpp
+18
-0
source/libs/planner/src/planLogicCreater.c
source/libs/planner/src/planLogicCreater.c
+32
-59
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+1
-2
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+6
-5
source/libs/planner/src/planSpliter.c
source/libs/planner/src/planSpliter.c
+1
-0
source/libs/planner/test/planBasicTest.cpp
source/libs/planner/test/planBasicTest.cpp
+0
-7
source/libs/planner/test/planOrderByTest.cpp
source/libs/planner/test/planOrderByTest.cpp
+2
-0
source/libs/planner/test/planSetOpTest.cpp
source/libs/planner/test/planSetOpTest.cpp
+16
-0
source/libs/planner/test/planSubqueryTest.cpp
source/libs/planner/test/planSubqueryTest.cpp
+3
-1
source/libs/planner/test/planTestMain.cpp
source/libs/planner/test/planTestMain.cpp
+8
-1
source/libs/planner/test/planTestUtil.cpp
source/libs/planner/test/planTestUtil.cpp
+9
-2
source/libs/scalar/src/sclfunc.c
source/libs/scalar/src/sclfunc.c
+22
-17
source/libs/stream/inc/streamInc.h
source/libs/stream/inc/streamInc.h
+1
-1
source/libs/stream/src/streamDispatch.c
source/libs/stream/src/streamDispatch.c
+4
-2
source/libs/stream/src/streamExec.c
source/libs/stream/src/streamExec.c
+25
-20
source/libs/sync/inc/syncEnv.h
source/libs/sync/inc/syncEnv.h
+6
-6
source/libs/sync/inc/syncRaftLog.h
source/libs/sync/inc/syncRaftLog.h
+5
-3
source/libs/sync/src/syncAppendEntries.c
source/libs/sync/src/syncAppendEntries.c
+29
-42
source/libs/sync/src/syncAppendEntriesReply.c
source/libs/sync/src/syncAppendEntriesReply.c
+19
-23
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+49
-20
source/libs/sync/src/syncRaftCfg.c
source/libs/sync/src/syncRaftCfg.c
+21
-17
source/libs/sync/src/syncRaftLog.c
source/libs/sync/src/syncRaftLog.c
+190
-55
source/libs/sync/src/syncReplication.c
source/libs/sync/src/syncReplication.c
+11
-0
source/libs/sync/src/syncSnapshot.c
source/libs/sync/src/syncSnapshot.c
+2
-1
source/libs/sync/test/syncRaftLogTest2.cpp
source/libs/sync/test/syncRaftLogTest2.cpp
+29
-4
source/libs/sync/test/syncRaftLogTest3.cpp
source/libs/sync/test/syncRaftLogTest3.cpp
+3
-1
source/libs/wal/src/walRead.c
source/libs/wal/src/walRead.c
+13
-2
source/libs/wal/src/walWrite.c
source/libs/wal/src/walWrite.c
+9
-0
tests/pytest/util/cluster.py
tests/pytest/util/cluster.py
+26
-236
tests/script/tmp/monitor.sim
tests/script/tmp/monitor.sim
+2
-0
tests/system-test/6-cluster/5dnode3mnodeStop.py
tests/system-test/6-cluster/5dnode3mnodeStop.py
+0
-10
tests/system-test/fulltest.sh
tests/system-test/fulltest.sh
+1
-1
tests/system-test/test.py
tests/system-test/test.py
+10
-6
未找到文件。
include/client/taos.h
浏览文件 @
291aab04
...
@@ -128,7 +128,6 @@ typedef struct setConfRet {
...
@@ -128,7 +128,6 @@ typedef struct setConfRet {
DLL_EXPORT
void
taos_cleanup
(
void
);
DLL_EXPORT
void
taos_cleanup
(
void
);
DLL_EXPORT
int
taos_options
(
TSDB_OPTION
option
,
const
void
*
arg
,
...);
DLL_EXPORT
int
taos_options
(
TSDB_OPTION
option
,
const
void
*
arg
,
...);
DLL_EXPORT
setConfRet
taos_set_config
(
const
char
*
config
);
DLL_EXPORT
int
taos_init
(
void
);
DLL_EXPORT
int
taos_init
(
void
);
DLL_EXPORT
TAOS
*
taos_connect
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
db
,
uint16_t
port
);
DLL_EXPORT
TAOS
*
taos_connect
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
db
,
uint16_t
port
);
DLL_EXPORT
TAOS
*
taos_connect_auth
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
auth
,
const
char
*
db
,
uint16_t
port
);
DLL_EXPORT
TAOS
*
taos_connect_auth
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
auth
,
const
char
*
db
,
uint16_t
port
);
...
...
include/common/tdatablock.h
浏览文件 @
291aab04
...
@@ -71,8 +71,8 @@ SEpSet getEpSet_s(SCorEpSet* pEpSet);
...
@@ -71,8 +71,8 @@ SEpSet getEpSet_s(SCorEpSet* pEpSet);
#define colDataGetData(p1_, r_) \
#define colDataGetData(p1_, r_) \
((IS_VAR_DATA_TYPE((p1_)->info.type)) ? colDataGetVarData(p1_, r_) : colDataGetNumData(p1_, r_))
((IS_VAR_DATA_TYPE((p1_)->info.type)) ? colDataGetVarData(p1_, r_) : colDataGetNumData(p1_, r_))
#define IS_JSON_NULL(type, data)
((type) == TSDB_DATA_TYPE_JSON &&
\
#define IS_JSON_NULL(type, data) \
(*(data) == TSDB_DATA_TYPE_NULL || tTagIsJsonNull(data)))
((type) == TSDB_DATA_TYPE_JSON &&
(*(data) == TSDB_DATA_TYPE_NULL || tTagIsJsonNull(data)))
static
FORCE_INLINE
bool
colDataIsNull_s
(
const
SColumnInfoData
*
pColumnInfoData
,
uint32_t
row
)
{
static
FORCE_INLINE
bool
colDataIsNull_s
(
const
SColumnInfoData
*
pColumnInfoData
,
uint32_t
row
)
{
if
(
!
pColumnInfoData
->
hasNull
)
{
if
(
!
pColumnInfoData
->
hasNull
)
{
...
@@ -186,7 +186,8 @@ int32_t getJsonValueLen(const char* data);
...
@@ -186,7 +186,8 @@ int32_t getJsonValueLen(const char* data);
int32_t
colDataAppend
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
currentRow
,
const
char
*
pData
,
bool
isNull
);
int32_t
colDataAppend
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
currentRow
,
const
char
*
pData
,
bool
isNull
);
int32_t
colDataMergeCol
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
numOfRow1
,
uint32_t
*
capacity
,
int32_t
colDataMergeCol
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
numOfRow1
,
uint32_t
*
capacity
,
const
SColumnInfoData
*
pSource
,
uint32_t
numOfRow2
);
const
SColumnInfoData
*
pSource
,
uint32_t
numOfRow2
);
int32_t
colDataAssign
(
SColumnInfoData
*
pColumnInfoData
,
const
SColumnInfoData
*
pSource
,
int32_t
numOfRows
,
const
SDataBlockInfo
*
pBlockInfo
);
int32_t
colDataAssign
(
SColumnInfoData
*
pColumnInfoData
,
const
SColumnInfoData
*
pSource
,
int32_t
numOfRows
,
const
SDataBlockInfo
*
pBlockInfo
);
int32_t
blockDataUpdateTsWindow
(
SSDataBlock
*
pDataBlock
,
int32_t
tsColumnIndex
);
int32_t
blockDataUpdateTsWindow
(
SSDataBlock
*
pDataBlock
,
int32_t
tsColumnIndex
);
int32_t
colDataGetLength
(
const
SColumnInfoData
*
pColumnInfoData
,
int32_t
numOfRows
);
int32_t
colDataGetLength
(
const
SColumnInfoData
*
pColumnInfoData
,
int32_t
numOfRows
);
...
@@ -222,6 +223,7 @@ size_t blockDataGetCapacityInRow(const SSDataBlock* pBlock, size_t pageSize);
...
@@ -222,6 +223,7 @@ size_t blockDataGetCapacityInRow(const SSDataBlock* pBlock, size_t pageSize);
int32_t
blockDataTrimFirstNRows
(
SSDataBlock
*
pBlock
,
size_t
n
);
int32_t
blockDataTrimFirstNRows
(
SSDataBlock
*
pBlock
,
size_t
n
);
int32_t
assignOneDataBlock
(
SSDataBlock
*
dst
,
const
SSDataBlock
*
src
);
SSDataBlock
*
createOneDataBlock
(
const
SSDataBlock
*
pDataBlock
,
bool
copyData
);
SSDataBlock
*
createOneDataBlock
(
const
SSDataBlock
*
pDataBlock
,
bool
copyData
);
SSDataBlock
*
createDataBlock
();
SSDataBlock
*
createDataBlock
();
int32_t
blockDataAppendColInfo
(
SSDataBlock
*
pBlock
,
SColumnInfoData
*
pColInfoData
);
int32_t
blockDataAppendColInfo
(
SSDataBlock
*
pBlock
,
SColumnInfoData
*
pColInfoData
);
...
...
include/common/tglobal.h
浏览文件 @
291aab04
...
@@ -151,6 +151,7 @@ void taosCfgDynamicOptions(const char *option, const char *value);
...
@@ -151,6 +151,7 @@ void taosCfgDynamicOptions(const char *option, const char *value);
void
taosAddDataDir
(
int32_t
index
,
char
*
v1
,
int32_t
level
,
int32_t
primary
);
void
taosAddDataDir
(
int32_t
index
,
char
*
v1
,
int32_t
level
,
int32_t
primary
);
struct
SConfig
*
taosGetCfg
();
struct
SConfig
*
taosGetCfg
();
int32_t
taosSetCfg
(
SConfig
*
pCfg
,
char
*
name
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
include/common/tmsg.h
浏览文件 @
291aab04
...
@@ -2463,6 +2463,8 @@ typedef struct {
...
@@ -2463,6 +2463,8 @@ typedef struct {
int64_t
interval
;
int64_t
interval
;
int64_t
offset
;
int64_t
offset
;
int64_t
sliding
;
int64_t
sliding
;
int64_t
maxDelay
;
int64_t
watermark
;
int32_t
exprLen
;
// strlen + 1
int32_t
exprLen
;
// strlen + 1
int32_t
tagsFilterLen
;
// strlen + 1
int32_t
tagsFilterLen
;
// strlen + 1
int32_t
sqlLen
;
// strlen + 1
int32_t
sqlLen
;
// strlen + 1
...
...
include/common/tname.h
浏览文件 @
291aab04
...
@@ -57,6 +57,8 @@ void tNameAssign(SName* dst, const SName* src);
...
@@ -57,6 +57,8 @@ void tNameAssign(SName* dst, const SName* src);
int32_t
tNameSetDbName
(
SName
*
dst
,
int32_t
acctId
,
const
char
*
dbName
,
size_t
nameLen
);
int32_t
tNameSetDbName
(
SName
*
dst
,
int32_t
acctId
,
const
char
*
dbName
,
size_t
nameLen
);
int32_t
tNameAddTbName
(
SName
*
dst
,
const
char
*
tbName
,
size_t
nameLen
);
int32_t
tNameFromString
(
SName
*
dst
,
const
char
*
str
,
uint32_t
type
);
int32_t
tNameFromString
(
SName
*
dst
,
const
char
*
str
,
uint32_t
type
);
int32_t
tNameSetAcctId
(
SName
*
dst
,
int32_t
acctId
);
int32_t
tNameSetAcctId
(
SName
*
dst
,
int32_t
acctId
);
...
...
include/common/ttokendef.h
浏览文件 @
291aab04
...
@@ -158,107 +158,109 @@
...
@@ -158,107 +158,109 @@
#define TK_CLUSTER 140
#define TK_CLUSTER 140
#define TK_TRANSACTIONS 141
#define TK_TRANSACTIONS 141
#define TK_DISTRIBUTED 142
#define TK_DISTRIBUTED 142
#define TK_LIKE 143
#define TK_CONSUMERS 143
#define TK_INDEX 144
#define TK_SUBSCRIPTIONS 144
#define TK_FUNCTION 145
#define TK_LIKE 145
#define TK_INTERVAL 146
#define TK_INDEX 146
#define TK_TOPIC 147
#define TK_FUNCTION 147
#define TK_AS 148
#define TK_INTERVAL 148
#define TK_WITH 149
#define TK_TOPIC 149
#define TK_META 150
#define TK_AS 150
#define TK_CONSUMER 151
#define TK_WITH 151
#define TK_GROUP 152
#define TK_META 152
#define TK_DESC 153
#define TK_CONSUMER 153
#define TK_DESCRIBE 154
#define TK_GROUP 154
#define TK_RESET 155
#define TK_DESC 155
#define TK_QUERY 156
#define TK_DESCRIBE 156
#define TK_CACHE 157
#define TK_RESET 157
#define TK_EXPLAIN 158
#define TK_QUERY 158
#define TK_ANALYZE 159
#define TK_CACHE 159
#define TK_VERBOSE 160
#define TK_EXPLAIN 160
#define TK_NK_BOOL 161
#define TK_ANALYZE 161
#define TK_RATIO 162
#define TK_VERBOSE 162
#define TK_NK_FLOAT 163
#define TK_NK_BOOL 163
#define TK_COMPACT 164
#define TK_RATIO 164
#define TK_VNODES 165
#define TK_NK_FLOAT 165
#define TK_IN 166
#define TK_COMPACT 166
#define TK_OUTPUTTYPE 167
#define TK_VNODES 167
#define TK_AGGREGATE 168
#define TK_IN 168
#define TK_BUFSIZE 169
#define TK_OUTPUTTYPE 169
#define TK_STREAM 170
#define TK_AGGREGATE 170
#define TK_INTO 171
#define TK_BUFSIZE 171
#define TK_TRIGGER 172
#define TK_STREAM 172
#define TK_AT_ONCE 173
#define TK_INTO 173
#define TK_WINDOW_CLOSE 174
#define TK_TRIGGER 174
#define TK_KILL 175
#define TK_AT_ONCE 175
#define TK_CONNECTION 176
#define TK_WINDOW_CLOSE 176
#define TK_TRANSACTION 177
#define TK_KILL 177
#define TK_BALANCE 178
#define TK_CONNECTION 178
#define TK_VGROUP 179
#define TK_TRANSACTION 179
#define TK_MERGE 180
#define TK_BALANCE 180
#define TK_REDISTRIBUTE 181
#define TK_VGROUP 181
#define TK_SPLIT 182
#define TK_MERGE 182
#define TK_SYNCDB 183
#define TK_REDISTRIBUTE 183
#define TK_DELETE 184
#define TK_SPLIT 184
#define TK_NULL 185
#define TK_SYNCDB 185
#define TK_NK_QUESTION 186
#define TK_DELETE 186
#define TK_NK_ARROW 187
#define TK_NULL 187
#define TK_ROWTS 188
#define TK_NK_QUESTION 188
#define TK_TBNAME 189
#define TK_NK_ARROW 189
#define TK_QSTARTTS 190
#define TK_ROWTS 190
#define TK_QENDTS 191
#define TK_TBNAME 191
#define TK_WSTARTTS 192
#define TK_QSTARTTS 192
#define TK_WENDTS 193
#define TK_QENDTS 193
#define TK_WDURATION 194
#define TK_WSTARTTS 194
#define TK_CAST 195
#define TK_WENDTS 195
#define TK_NOW 196
#define TK_WDURATION 196
#define TK_TODAY 197
#define TK_CAST 197
#define TK_TIMEZONE 198
#define TK_NOW 198
#define TK_COUNT 199
#define TK_TODAY 199
#define TK_LAST_ROW 200
#define TK_TIMEZONE 200
#define TK_BETWEEN 201
#define TK_COUNT 201
#define TK_IS 202
#define TK_LAST_ROW 202
#define TK_NK_LT 203
#define TK_BETWEEN 203
#define TK_NK_GT 204
#define TK_IS 204
#define TK_NK_LE 205
#define TK_NK_LT 205
#define TK_NK_GE 206
#define TK_NK_GT 206
#define TK_NK_NE 207
#define TK_NK_LE 207
#define TK_MATCH 208
#define TK_NK_GE 208
#define TK_NMATCH 209
#define TK_NK_NE 209
#define TK_CONTAINS 210
#define TK_MATCH 210
#define TK_JOIN 211
#define TK_NMATCH 211
#define TK_INNER 212
#define TK_CONTAINS 212
#define TK_SELECT 213
#define TK_JOIN 213
#define TK_DISTINCT 214
#define TK_INNER 214
#define TK_WHERE 215
#define TK_SELECT 215
#define TK_PARTITION 216
#define TK_DISTINCT 216
#define TK_BY 217
#define TK_WHERE 217
#define TK_SESSION 218
#define TK_PARTITION 218
#define TK_STATE_WINDOW 219
#define TK_BY 219
#define TK_SLIDING 220
#define TK_SESSION 220
#define TK_FILL 221
#define TK_STATE_WINDOW 221
#define TK_VALUE 222
#define TK_SLIDING 222
#define TK_NONE 223
#define TK_FILL 223
#define TK_PREV 224
#define TK_VALUE 224
#define TK_LINEAR 225
#define TK_NONE 225
#define TK_NEXT 226
#define TK_PREV 226
#define TK_HAVING 227
#define TK_LINEAR 227
#define TK_RANGE 228
#define TK_NEXT 228
#define TK_EVERY 229
#define TK_HAVING 229
#define TK_ORDER 230
#define TK_RANGE 230
#define TK_SLIMIT 231
#define TK_EVERY 231
#define TK_SOFFSET 232
#define TK_ORDER 232
#define TK_LIMIT 233
#define TK_SLIMIT 233
#define TK_OFFSET 234
#define TK_SOFFSET 234
#define TK_ASC 235
#define TK_LIMIT 235
#define TK_NULLS 236
#define TK_OFFSET 236
#define TK_ID 237
#define TK_ASC 237
#define TK_NK_BITNOT 238
#define TK_NULLS 238
#define TK_INSERT 239
#define TK_ID 239
#define TK_VALUES 240
#define TK_NK_BITNOT 240
#define TK_IMPORT 241
#define TK_INSERT 241
#define TK_NK_SEMI 242
#define TK_VALUES 242
#define TK_FILE 243
#define TK_IMPORT 243
#define TK_NK_SEMI 244
#define TK_FILE 245
#define TK_NK_SPACE 300
#define TK_NK_SPACE 300
#define TK_NK_COMMENT 301
#define TK_NK_COMMENT 301
...
...
include/dnode/mnode/mnode.h
浏览文件 @
291aab04
...
@@ -73,10 +73,12 @@ void mndStop(SMnode *pMnode);
...
@@ -73,10 +73,12 @@ void mndStop(SMnode *pMnode);
* @param pMnode The mnode object.
* @param pMnode The mnode object.
* @param pCluster
* @param pCluster
* @param pVgroup
* @param pVgroup
* @param pStbInfo
* @param pGrant
* @param pGrant
* @return int32_t 0 for success, -1 for failure.
* @return int32_t 0 for success, -1 for failure.
*/
*/
int32_t
mndGetMonitorInfo
(
SMnode
*
pMnode
,
SMonClusterInfo
*
pCluster
,
SMonVgroupInfo
*
pVgroup
,
SMonGrantInfo
*
pGrant
);
int32_t
mndGetMonitorInfo
(
SMnode
*
pMnode
,
SMonClusterInfo
*
pClusterInfo
,
SMonVgroupInfo
*
pVgroupInfo
,
SMonStbInfo
*
pStbInfo
,
SMonGrantInfo
*
pGrantInfo
);
/**
/**
* @brief Get mnode loads for status msg.
* @brief Get mnode loads for status msg.
...
...
include/libs/function/functionMgt.h
浏览文件 @
291aab04
...
@@ -123,6 +123,7 @@ typedef enum EFunctionType {
...
@@ -123,6 +123,7 @@ typedef enum EFunctionType {
FUNCTION_TYPE_SELECT_VALUE
,
FUNCTION_TYPE_SELECT_VALUE
,
FUNCTION_TYPE_BLOCK_DIST
,
// block distribution aggregate function
FUNCTION_TYPE_BLOCK_DIST
,
// block distribution aggregate function
FUNCTION_TYPE_BLOCK_DIST_INFO
,
// block distribution pseudo column function
FUNCTION_TYPE_BLOCK_DIST_INFO
,
// block distribution pseudo column function
FUNCTION_TYPE_TO_COLUMN
,
// distributed splitting functions
// distributed splitting functions
FUNCTION_TYPE_APERCENTILE_PARTIAL
=
4000
,
FUNCTION_TYPE_APERCENTILE_PARTIAL
=
4000
,
...
...
include/libs/monitor/monitor.h
浏览文件 @
291aab04
...
@@ -138,6 +138,15 @@ typedef struct {
...
@@ -138,6 +138,15 @@ typedef struct {
SArray
*
vgroups
;
// array of SMonVgroupDesc
SArray
*
vgroups
;
// array of SMonVgroupDesc
}
SMonVgroupInfo
;
}
SMonVgroupInfo
;
typedef
struct
{
char
stb_name
[
TSDB_TABLE_NAME_LEN
];
char
database_name
[
TSDB_DB_NAME_LEN
];
}
SMonStbDesc
;
typedef
struct
{
SArray
*
stbs
;
// array of SMonStbDesc
}
SMonStbInfo
;
typedef
struct
{
typedef
struct
{
int32_t
expire_time
;
int32_t
expire_time
;
int64_t
timeseries_used
;
int64_t
timeseries_used
;
...
@@ -147,6 +156,7 @@ typedef struct {
...
@@ -147,6 +156,7 @@ typedef struct {
typedef
struct
{
typedef
struct
{
SMonClusterInfo
cluster
;
SMonClusterInfo
cluster
;
SMonVgroupInfo
vgroup
;
SMonVgroupInfo
vgroup
;
SMonStbInfo
stb
;
SMonGrantInfo
grant
;
SMonGrantInfo
grant
;
SMonSysInfo
sys
;
SMonSysInfo
sys
;
SMonLogs
log
;
SMonLogs
log
;
...
...
include/libs/nodes/cmdnodes.h
浏览文件 @
291aab04
...
@@ -28,19 +28,18 @@ extern "C" {
...
@@ -28,19 +28,18 @@ extern "C" {
#define DESCRIBE_RESULT_TYPE_LEN (20 + VARSTR_HEADER_SIZE)
#define DESCRIBE_RESULT_TYPE_LEN (20 + VARSTR_HEADER_SIZE)
#define DESCRIBE_RESULT_NOTE_LEN (8 + VARSTR_HEADER_SIZE)
#define DESCRIBE_RESULT_NOTE_LEN (8 + VARSTR_HEADER_SIZE)
#define SHOW_CREATE_DB_RESULT_COLS 2
#define SHOW_CREATE_DB_RESULT_COLS
2
#define SHOW_CREATE_DB_RESULT_FIELD1_LEN (TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE)
#define SHOW_CREATE_DB_RESULT_FIELD1_LEN (TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE)
#define SHOW_CREATE_DB_RESULT_FIELD2_LEN (TSDB_MAX_BINARY_LEN + VARSTR_HEADER_SIZE)
#define SHOW_CREATE_DB_RESULT_FIELD2_LEN (TSDB_MAX_BINARY_LEN + VARSTR_HEADER_SIZE)
#define SHOW_CREATE_TB_RESULT_COLS 2
#define SHOW_CREATE_TB_RESULT_COLS
2
#define SHOW_CREATE_TB_RESULT_FIELD1_LEN (TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE)
#define SHOW_CREATE_TB_RESULT_FIELD1_LEN (TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE)
#define SHOW_CREATE_TB_RESULT_FIELD2_LEN (TSDB_MAX_BINARY_LEN + VARSTR_HEADER_SIZE)
#define SHOW_CREATE_TB_RESULT_FIELD2_LEN (TSDB_MAX_BINARY_LEN + VARSTR_HEADER_SIZE)
#define SHOW_LOCAL_VARIABLES_RESULT_COLS 2
#define SHOW_LOCAL_VARIABLES_RESULT_COLS
2
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD1_LEN (TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE)
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD1_LEN (TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE)
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD2_LEN (TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE)
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD2_LEN (TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE)
#define PRIVILEGE_TYPE_MASK(n) (1 << n)
#define PRIVILEGE_TYPE_MASK(n) (1 << n)
#define PRIVILEGE_TYPE_ALL PRIVILEGE_TYPE_MASK(0)
#define PRIVILEGE_TYPE_ALL PRIVILEGE_TYPE_MASK(0)
...
@@ -234,10 +233,10 @@ typedef struct SShowCreateDatabaseStmt {
...
@@ -234,10 +233,10 @@ typedef struct SShowCreateDatabaseStmt {
}
SShowCreateDatabaseStmt
;
}
SShowCreateDatabaseStmt
;
typedef
struct
SShowCreateTableStmt
{
typedef
struct
SShowCreateTableStmt
{
ENodeType
type
;
ENodeType
type
;
char
dbName
[
TSDB_DB_NAME_LEN
];
char
dbName
[
TSDB_DB_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
void
*
pCfg
;
// STableCfg
void
*
pCfg
;
// STableCfg
}
SShowCreateTableStmt
;
}
SShowCreateTableStmt
;
typedef
struct
SShowTableDistributedStmt
{
typedef
struct
SShowTableDistributedStmt
{
...
@@ -259,6 +258,7 @@ typedef struct SIndexOptions {
...
@@ -259,6 +258,7 @@ typedef struct SIndexOptions {
SNode
*
pInterval
;
SNode
*
pInterval
;
SNode
*
pOffset
;
SNode
*
pOffset
;
SNode
*
pSliding
;
SNode
*
pSliding
;
SNode
*
pStreamOptions
;
}
SIndexOptions
;
}
SIndexOptions
;
typedef
struct
SCreateIndexStmt
{
typedef
struct
SCreateIndexStmt
{
...
...
include/libs/nodes/nodes.h
浏览文件 @
291aab04
...
@@ -188,6 +188,7 @@ typedef enum ENodeType {
...
@@ -188,6 +188,7 @@ typedef enum ENodeType {
QUERY_NODE_SHOW_CREATE_STABLE_STMT
,
QUERY_NODE_SHOW_CREATE_STABLE_STMT
,
QUERY_NODE_SHOW_TRANSACTIONS_STMT
,
QUERY_NODE_SHOW_TRANSACTIONS_STMT
,
QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT
,
QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT
,
QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT
,
QUERY_NODE_KILL_CONNECTION_STMT
,
QUERY_NODE_KILL_CONNECTION_STMT
,
QUERY_NODE_KILL_QUERY_STMT
,
QUERY_NODE_KILL_QUERY_STMT
,
QUERY_NODE_KILL_TRANSACTION_STMT
,
QUERY_NODE_KILL_TRANSACTION_STMT
,
...
@@ -284,6 +285,7 @@ int32_t nodesListPushFront(SNodeList* pList, SNode* pNode);
...
@@ -284,6 +285,7 @@ int32_t nodesListPushFront(SNodeList* pList, SNode* pNode);
SListCell
*
nodesListErase
(
SNodeList
*
pList
,
SListCell
*
pCell
);
SListCell
*
nodesListErase
(
SNodeList
*
pList
,
SListCell
*
pCell
);
void
nodesListInsertList
(
SNodeList
*
pTarget
,
SListCell
*
pPos
,
SNodeList
*
pSrc
);
void
nodesListInsertList
(
SNodeList
*
pTarget
,
SListCell
*
pPos
,
SNodeList
*
pSrc
);
SNode
*
nodesListGetNode
(
SNodeList
*
pList
,
int32_t
index
);
SNode
*
nodesListGetNode
(
SNodeList
*
pList
,
int32_t
index
);
SListCell
*
nodesListGetCell
(
SNodeList
*
pList
,
int32_t
index
);
void
nodesDestroyList
(
SNodeList
*
pList
);
void
nodesDestroyList
(
SNodeList
*
pList
);
// Only clear the linked list structure, without releasing the elements inside
// Only clear the linked list structure, without releasing the elements inside
void
nodesClearList
(
SNodeList
*
pList
);
void
nodesClearList
(
SNodeList
*
pList
);
...
...
include/libs/nodes/plannodes.h
浏览文件 @
291aab04
...
@@ -32,6 +32,8 @@ typedef struct SLogicNode {
...
@@ -32,6 +32,8 @@ typedef struct SLogicNode {
struct
SLogicNode
*
pParent
;
struct
SLogicNode
*
pParent
;
int32_t
optimizedFlag
;
int32_t
optimizedFlag
;
uint8_t
precision
;
uint8_t
precision
;
SNode
*
pLimit
;
SNode
*
pSlimit
;
}
SLogicNode
;
}
SLogicNode
;
typedef
enum
EScanType
{
typedef
enum
EScanType
{
...
@@ -92,10 +94,6 @@ typedef struct SProjectLogicNode {
...
@@ -92,10 +94,6 @@ typedef struct SProjectLogicNode {
SLogicNode
node
;
SLogicNode
node
;
SNodeList
*
pProjections
;
SNodeList
*
pProjections
;
char
stmtName
[
TSDB_TABLE_NAME_LEN
];
char
stmtName
[
TSDB_TABLE_NAME_LEN
];
int64_t
limit
;
int64_t
offset
;
int64_t
slimit
;
int64_t
soffset
;
}
SProjectLogicNode
;
}
SProjectLogicNode
;
typedef
struct
SIndefRowsFuncLogicNode
{
typedef
struct
SIndefRowsFuncLogicNode
{
...
@@ -248,6 +246,8 @@ typedef struct SPhysiNode {
...
@@ -248,6 +246,8 @@ typedef struct SPhysiNode {
SNode
*
pConditions
;
SNode
*
pConditions
;
SNodeList
*
pChildren
;
SNodeList
*
pChildren
;
struct
SPhysiNode
*
pParent
;
struct
SPhysiNode
*
pParent
;
SNode
*
pLimit
;
SNode
*
pSlimit
;
}
SPhysiNode
;
}
SPhysiNode
;
typedef
struct
SScanPhysiNode
{
typedef
struct
SScanPhysiNode
{
...
@@ -297,10 +297,6 @@ typedef STableScanPhysiNode SStreamScanPhysiNode;
...
@@ -297,10 +297,6 @@ typedef STableScanPhysiNode SStreamScanPhysiNode;
typedef
struct
SProjectPhysiNode
{
typedef
struct
SProjectPhysiNode
{
SPhysiNode
node
;
SPhysiNode
node
;
SNodeList
*
pProjections
;
SNodeList
*
pProjections
;
int64_t
limit
;
int64_t
offset
;
int64_t
slimit
;
int64_t
soffset
;
}
SProjectPhysiNode
;
}
SProjectPhysiNode
;
typedef
struct
SIndefRowsFuncPhysiNode
{
typedef
struct
SIndefRowsFuncPhysiNode
{
...
@@ -378,7 +374,7 @@ typedef struct SIntervalPhysiNode {
...
@@ -378,7 +374,7 @@ typedef struct SIntervalPhysiNode {
int8_t
slidingUnit
;
int8_t
slidingUnit
;
}
SIntervalPhysiNode
;
}
SIntervalPhysiNode
;
typedef
SIntervalPhysiNode
SMergeIntervalPhysiNode
;
typedef
SIntervalPhysiNode
SMergeIntervalPhysiNode
;
typedef
SIntervalPhysiNode
SMergeAlignedIntervalPhysiNode
;
typedef
SIntervalPhysiNode
SMergeAlignedIntervalPhysiNode
;
typedef
SIntervalPhysiNode
SStreamIntervalPhysiNode
;
typedef
SIntervalPhysiNode
SStreamIntervalPhysiNode
;
typedef
SIntervalPhysiNode
SStreamFinalIntervalPhysiNode
;
typedef
SIntervalPhysiNode
SStreamFinalIntervalPhysiNode
;
...
...
include/libs/qcom/query.h
浏览文件 @
291aab04
...
@@ -266,19 +266,19 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t
...
@@ -266,19 +266,19 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t
#define qDebug(...) \
#define qDebug(...) \
do { \
do { \
if (qDebugFlag & DEBUG_DEBUG) { \
if (qDebugFlag & DEBUG_DEBUG) { \
taosPrintLog("QRY ", DEBUG_DEBUG,
tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__);
\
taosPrintLog("QRY ", DEBUG_DEBUG,
qDebugFlag, __VA_ARGS__);
\
} \
} \
} while (0)
} while (0)
#define qTrace(...) \
#define qTrace(...) \
do { \
do { \
if (qDebugFlag & DEBUG_TRACE) { \
if (qDebugFlag & DEBUG_TRACE) { \
taosPrintLog("QRY ", DEBUG_TRACE,
tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__);
\
taosPrintLog("QRY ", DEBUG_TRACE,
qDebugFlag, __VA_ARGS__);
\
} \
} \
} while (0)
} while (0)
#define qDebugL(...) \
#define qDebugL(...) \
do { \
do { \
if (qDebugFlag & DEBUG_DEBUG) { \
if (qDebugFlag & DEBUG_DEBUG) { \
taosPrintLongString("QRY ", DEBUG_DEBUG,
tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__);
\
taosPrintLongString("QRY ", DEBUG_DEBUG,
qDebugFlag, __VA_ARGS__);
\
} \
} \
} while (0)
} while (0)
...
...
include/libs/stream/tstream.h
浏览文件 @
291aab04
...
@@ -344,10 +344,12 @@ static FORCE_INLINE int32_t streamTaskOutput(SStreamTask* pTask, SStreamDataBloc
...
@@ -344,10 +344,12 @@ static FORCE_INLINE int32_t streamTaskOutput(SStreamTask* pTask, SStreamDataBloc
if
(
pTask
->
sinkType
==
TASK_SINK__TABLE
)
{
if
(
pTask
->
sinkType
==
TASK_SINK__TABLE
)
{
ASSERT
(
pTask
->
dispatchType
==
TASK_DISPATCH__NONE
);
ASSERT
(
pTask
->
dispatchType
==
TASK_DISPATCH__NONE
);
pTask
->
tbSink
.
tbSinkFunc
(
pTask
,
pTask
->
tbSink
.
vnode
,
0
,
pBlock
->
blocks
);
pTask
->
tbSink
.
tbSinkFunc
(
pTask
,
pTask
->
tbSink
.
vnode
,
0
,
pBlock
->
blocks
);
taosArrayDestroyEx
(
pBlock
->
blocks
,
(
FDelete
)
tDeleteSSDataBlock
);
taosFreeQitem
(
pBlock
);
taosFreeQitem
(
pBlock
);
}
else
if
(
pTask
->
sinkType
==
TASK_SINK__SMA
)
{
}
else
if
(
pTask
->
sinkType
==
TASK_SINK__SMA
)
{
ASSERT
(
pTask
->
dispatchType
==
TASK_DISPATCH__NONE
);
ASSERT
(
pTask
->
dispatchType
==
TASK_DISPATCH__NONE
);
pTask
->
smaSink
.
smaSink
(
pTask
->
smaSink
.
vnode
,
pTask
->
smaSink
.
smaId
,
pBlock
->
blocks
);
pTask
->
smaSink
.
smaSink
(
pTask
->
smaSink
.
vnode
,
pTask
->
smaSink
.
smaId
,
pBlock
->
blocks
);
taosArrayDestroyEx
(
pBlock
->
blocks
,
(
FDelete
)
tDeleteSSDataBlock
);
taosFreeQitem
(
pBlock
);
taosFreeQitem
(
pBlock
);
}
else
{
}
else
{
ASSERT
(
pTask
->
dispatchType
!=
TASK_DISPATCH__NONE
);
ASSERT
(
pTask
->
dispatchType
!=
TASK_DISPATCH__NONE
);
...
...
include/libs/sync/sync.h
浏览文件 @
291aab04
...
@@ -157,13 +157,13 @@ typedef struct SSyncLogStore {
...
@@ -157,13 +157,13 @@ typedef struct SSyncLogStore {
SyncIndex
(
*
getCommitIndex
)(
struct
SSyncLogStore
*
pLogStore
);
SyncIndex
(
*
getCommitIndex
)(
struct
SSyncLogStore
*
pLogStore
);
// refactor, log[0 .. n] ==> log[m .. n]
// refactor, log[0 .. n] ==> log[m .. n]
int32_t
(
*
syncLogSetBeginIndex
)(
struct
SSyncLogStore
*
pLogStore
,
SyncIndex
beginIndex
);
//
int32_t (*syncLogSetBeginIndex)(struct SSyncLogStore* pLogStore, SyncIndex beginIndex);
int32_t
(
*
syncLogResetBeginIndex
)(
struct
SSyncLogStore
*
pLogStore
);
SyncIndex
(
*
syncLogBeginIndex
)(
struct
SSyncLogStore
*
pLogStore
);
SyncIndex
(
*
syncLogBeginIndex
)(
struct
SSyncLogStore
*
pLogStore
);
SyncIndex
(
*
syncLogEndIndex
)(
struct
SSyncLogStore
*
pLogStore
);
SyncIndex
(
*
syncLogEndIndex
)(
struct
SSyncLogStore
*
pLogStore
);
bool
(
*
syncLogIsEmpty
)(
struct
SSyncLogStore
*
pLogStore
);
bool
(
*
syncLogIsEmpty
)(
struct
SSyncLogStore
*
pLogStore
);
int32_t
(
*
syncLogEntryCount
)(
struct
SSyncLogStore
*
pLogStore
);
int32_t
(
*
syncLogEntryCount
)(
struct
SSyncLogStore
*
pLogStore
);
// bool (*syncLogInRange
)(struct SSyncLogStore* pLogStore, SyncIndex index);
int32_t
(
*
syncLogRestoreFromSnapshot
)(
struct
SSyncLogStore
*
pLogStore
,
SyncIndex
index
);
SyncIndex
(
*
syncLogWriteIndex
)(
struct
SSyncLogStore
*
pLogStore
);
SyncIndex
(
*
syncLogWriteIndex
)(
struct
SSyncLogStore
*
pLogStore
);
SyncIndex
(
*
syncLogLastIndex
)(
struct
SSyncLogStore
*
pLogStore
);
SyncIndex
(
*
syncLogLastIndex
)(
struct
SSyncLogStore
*
pLogStore
);
...
...
include/util/tconfig.h
浏览文件 @
291aab04
...
@@ -33,7 +33,8 @@ typedef enum {
...
@@ -33,7 +33,8 @@ typedef enum {
CFG_STYPE_ENV_CMD
,
CFG_STYPE_ENV_CMD
,
CFG_STYPE_APOLLO_URL
,
CFG_STYPE_APOLLO_URL
,
CFG_STYPE_ARG_LIST
,
CFG_STYPE_ARG_LIST
,
CFG_STYPE_TAOS_OPTIONS
CFG_STYPE_TAOS_OPTIONS
,
CFG_STYPE_ALTER_CMD
,
}
ECfgSrcType
;
}
ECfgSrcType
;
typedef
enum
{
typedef
enum
{
...
...
source/client/inc/clientInt.h
浏览文件 @
291aab04
...
@@ -215,6 +215,7 @@ typedef struct SRequestObj {
...
@@ -215,6 +215,7 @@ typedef struct SRequestObj {
SQueryExecMetric
metric
;
SQueryExecMetric
metric
;
SRequestSendRecvBody
body
;
SRequestSendRecvBody
body
;
bool
stableQuery
;
bool
stableQuery
;
bool
validateOnly
;
bool
killed
;
bool
killed
;
uint32_t
prevCode
;
// previous error code: todo refactor, add update flag for catalog
uint32_t
prevCode
;
// previous error code: todo refactor, add update flag for catalog
...
@@ -235,7 +236,12 @@ int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveT
...
@@ -235,7 +236,12 @@ int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveT
bool
freeAfterUse
);
bool
freeAfterUse
);
void
setResSchemaInfo
(
SReqResultInfo
*
pResInfo
,
const
SSchema
*
pSchema
,
int32_t
numOfCols
);
void
setResSchemaInfo
(
SReqResultInfo
*
pResInfo
,
const
SSchema
*
pSchema
,
int32_t
numOfCols
);
void
doFreeReqResultInfo
(
SReqResultInfo
*
pResInfo
);
void
doFreeReqResultInfo
(
SReqResultInfo
*
pResInfo
);
SRequestObj
*
execQuery
(
STscObj
*
pTscObj
,
const
char
*
sql
,
int
sqlLen
);
int32_t
transferTableNameList
(
const
char
*
tbList
,
int32_t
acctId
,
char
*
dbName
,
SArray
**
pReq
);
void
syncCatalogFn
(
SMetaData
*
pResult
,
void
*
param
,
int32_t
code
);
SRequestObj
*
execQuery
(
STscObj
*
pTscObj
,
const
char
*
sql
,
int
sqlLen
,
bool
validateOnly
);
TAOS_RES
*
taosQueryImpl
(
TAOS
*
taos
,
const
char
*
sql
,
bool
validateOnly
);
void
taosAsyncQueryImpl
(
TAOS
*
taos
,
const
char
*
sql
,
__taos_async_fn_t
fp
,
void
*
param
,
bool
validateOnly
);
static
FORCE_INLINE
SReqResultInfo
*
tmqGetCurResInfo
(
TAOS_RES
*
res
)
{
static
FORCE_INLINE
SReqResultInfo
*
tmqGetCurResInfo
(
TAOS_RES
*
res
)
{
SMqRspObj
*
msg
=
(
SMqRspObj
*
)
res
;
SMqRspObj
*
msg
=
(
SMqRspObj
*
)
res
;
...
@@ -301,7 +307,7 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet);
...
@@ -301,7 +307,7 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet);
STscObj
*
taos_connect_internal
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
auth
,
const
char
*
db
,
STscObj
*
taos_connect_internal
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
auth
,
const
char
*
db
,
uint16_t
port
,
int
connType
);
uint16_t
port
,
int
connType
);
SRequestObj
*
launchQuery
(
STscObj
*
pTscObj
,
const
char
*
sql
,
int
sqlLen
);
SRequestObj
*
launchQuery
(
STscObj
*
pTscObj
,
const
char
*
sql
,
int
sqlLen
,
bool
validateOnly
);
int32_t
parseSql
(
SRequestObj
*
pRequest
,
bool
topicQuery
,
SQuery
**
pQuery
,
SStmtCallback
*
pStmtCb
);
int32_t
parseSql
(
SRequestObj
*
pRequest
,
bool
topicQuery
,
SQuery
**
pQuery
,
SStmtCallback
*
pStmtCb
);
...
...
source/client/src/clientImpl.c
浏览文件 @
291aab04
...
@@ -237,6 +237,10 @@ static SAppInstInfo* getAppInfo(SRequestObj* pRequest) { return pRequest->pTscOb
...
@@ -237,6 +237,10 @@ static SAppInstInfo* getAppInfo(SRequestObj* pRequest) { return pRequest->pTscOb
void
asyncExecLocalCmd
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
)
{
void
asyncExecLocalCmd
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
)
{
SRetrieveTableRsp
*
pRsp
=
NULL
;
SRetrieveTableRsp
*
pRsp
=
NULL
;
if
(
pRequest
->
validateOnly
)
{
pRequest
->
body
.
queryFp
(
pRequest
->
body
.
param
,
pRequest
,
0
);
return
;
}
int32_t
code
=
qExecCommand
(
pQuery
->
pRoot
,
&
pRsp
);
int32_t
code
=
qExecCommand
(
pQuery
->
pRoot
,
&
pRsp
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pRsp
)
{
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pRsp
)
{
...
@@ -261,6 +265,11 @@ void asyncExecLocalCmd(SRequestObj* pRequest, SQuery* pQuery) {
...
@@ -261,6 +265,11 @@ void asyncExecLocalCmd(SRequestObj* pRequest, SQuery* pQuery) {
}
}
int32_t
asyncExecDdlQuery
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
)
{
int32_t
asyncExecDdlQuery
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
)
{
if
(
pRequest
->
validateOnly
)
{
pRequest
->
body
.
queryFp
(
pRequest
->
body
.
param
,
pRequest
,
0
);
return
TSDB_CODE_SUCCESS
;
}
// drop table if exists not_exists_table
// drop table if exists not_exists_table
if
(
NULL
==
pQuery
->
pCmdMsg
)
{
if
(
NULL
==
pQuery
->
pCmdMsg
)
{
pRequest
->
body
.
queryFp
(
pRequest
->
body
.
param
,
pRequest
,
0
);
pRequest
->
body
.
queryFp
(
pRequest
->
body
.
param
,
pRequest
,
0
);
...
@@ -276,8 +285,11 @@ int32_t asyncExecDdlQuery(SRequestObj* pRequest, SQuery* pQuery) {
...
@@ -276,8 +285,11 @@ int32_t asyncExecDdlQuery(SRequestObj* pRequest, SQuery* pQuery) {
SMsgSendInfo
*
pSendMsg
=
buildMsgInfoImpl
(
pRequest
);
SMsgSendInfo
*
pSendMsg
=
buildMsgInfoImpl
(
pRequest
);
int64_t
transporterId
=
0
;
int64_t
transporterId
=
0
;
asyncSendMsgToServer
(
pAppInfo
->
pTransporter
,
&
pMsgInfo
->
epSet
,
&
transporterId
,
pSendMsg
);
int32_t
code
=
asyncSendMsgToServer
(
pAppInfo
->
pTransporter
,
&
pMsgInfo
->
epSet
,
&
transporterId
,
pSendMsg
);
return
TSDB_CODE_SUCCESS
;
if
(
code
)
{
pRequest
->
body
.
queryFp
(
pRequest
->
body
.
param
,
pRequest
,
code
);
}
return
code
;
}
}
int
compareQueryNodeLoad
(
const
void
*
elem1
,
const
void
*
elem2
)
{
int
compareQueryNodeLoad
(
const
void
*
elem1
,
const
void
*
elem2
)
{
...
@@ -851,15 +863,19 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, bool keepQue
...
@@ -851,15 +863,19 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, bool keepQue
switch
(
pQuery
->
execMode
)
{
switch
(
pQuery
->
execMode
)
{
case
QUERY_EXEC_MODE_LOCAL
:
case
QUERY_EXEC_MODE_LOCAL
:
code
=
execLocalCmd
(
pRequest
,
pQuery
);
if
(
!
pRequest
->
validateOnly
)
{
code
=
execLocalCmd
(
pRequest
,
pQuery
);
}
break
;
break
;
case
QUERY_EXEC_MODE_RPC
:
case
QUERY_EXEC_MODE_RPC
:
code
=
execDdlQuery
(
pRequest
,
pQuery
);
if
(
!
pRequest
->
validateOnly
)
{
code
=
execDdlQuery
(
pRequest
,
pQuery
);
}
break
;
break
;
case
QUERY_EXEC_MODE_SCHEDULE
:
{
case
QUERY_EXEC_MODE_SCHEDULE
:
{
SArray
*
pMnodeList
=
taosArrayInit
(
4
,
sizeof
(
SQueryNodeLoad
));
SArray
*
pMnodeList
=
taosArrayInit
(
4
,
sizeof
(
SQueryNodeLoad
));
code
=
getPlan
(
pRequest
,
pQuery
,
&
pRequest
->
body
.
pDag
,
pMnodeList
);
code
=
getPlan
(
pRequest
,
pQuery
,
&
pRequest
->
body
.
pDag
,
pMnodeList
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
&&
!
pRequest
->
validateOnly
)
{
SArray
*
pNodeList
=
NULL
;
SArray
*
pNodeList
=
NULL
;
buildSyncExecNodeList
(
pRequest
,
&
pNodeList
,
pMnodeList
);
buildSyncExecNodeList
(
pRequest
,
&
pNodeList
,
pMnodeList
);
...
@@ -894,7 +910,7 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, bool keepQue
...
@@ -894,7 +910,7 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, bool keepQue
return
pRequest
;
return
pRequest
;
}
}
SRequestObj
*
launchQuery
(
STscObj
*
pTscObj
,
const
char
*
sql
,
int
sqlLen
)
{
SRequestObj
*
launchQuery
(
STscObj
*
pTscObj
,
const
char
*
sql
,
int
sqlLen
,
bool
validateOnly
)
{
SRequestObj
*
pRequest
=
NULL
;
SRequestObj
*
pRequest
=
NULL
;
SQuery
*
pQuery
=
NULL
;
SQuery
*
pQuery
=
NULL
;
...
@@ -904,6 +920,8 @@ SRequestObj* launchQuery(STscObj* pTscObj, const char* sql, int sqlLen) {
...
@@ -904,6 +920,8 @@ SRequestObj* launchQuery(STscObj* pTscObj, const char* sql, int sqlLen) {
return
NULL
;
return
NULL
;
}
}
pRequest
->
validateOnly
=
validateOnly
;
code
=
parseSql
(
pRequest
,
false
,
&
pQuery
,
NULL
);
code
=
parseSql
(
pRequest
,
false
,
&
pQuery
,
NULL
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
pRequest
->
code
=
code
;
pRequest
->
code
=
code
;
...
@@ -945,7 +963,7 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData *pResultM
...
@@ -945,7 +963,7 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData *pResultM
pRequest
->
requestId
);
pRequest
->
requestId
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
&&
!
pRequest
->
validateOnly
)
{
SArray
*
pNodeList
=
NULL
;
SArray
*
pNodeList
=
NULL
;
buildAsyncExecNodeList
(
pRequest
,
&
pNodeList
,
pMnodeList
,
pResultMeta
);
buildAsyncExecNodeList
(
pRequest
,
&
pNodeList
,
pMnodeList
,
pResultMeta
);
...
@@ -962,7 +980,7 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData *pResultM
...
@@ -962,7 +980,7 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData *pResultM
code
=
schedulerAsyncExecJob
(
&
req
,
&
pRequest
->
body
.
queryJob
);
code
=
schedulerAsyncExecJob
(
&
req
,
&
pRequest
->
body
.
queryJob
);
taosArrayDestroy
(
pNodeList
);
taosArrayDestroy
(
pNodeList
);
}
else
{
}
else
{
tsc
Error
(
"0x%"
PRIx64
" failed to create query plan
, code:%s 0x%"
PRIx64
,
pRequest
->
self
,
tstrerror
(
code
),
tsc
Debug
(
"0x%"
PRIx64
" plan not executed
, code:%s 0x%"
PRIx64
,
pRequest
->
self
,
tstrerror
(
code
),
pRequest
->
requestId
);
pRequest
->
requestId
);
pRequest
->
body
.
queryFp
(
pRequest
->
body
.
param
,
pRequest
,
code
);
pRequest
->
body
.
queryFp
(
pRequest
->
body
.
param
,
pRequest
,
code
);
}
}
...
@@ -1045,14 +1063,14 @@ int32_t removeMeta(STscObj* pTscObj, SArray* tbList) {
...
@@ -1045,14 +1063,14 @@ int32_t removeMeta(STscObj* pTscObj, SArray* tbList) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
SRequestObj
*
execQuery
(
STscObj
*
pTscObj
,
const
char
*
sql
,
int
sqlLen
)
{
SRequestObj
*
execQuery
(
STscObj
*
pTscObj
,
const
char
*
sql
,
int
sqlLen
,
bool
validateOnly
)
{
SRequestObj
*
pRequest
=
NULL
;
SRequestObj
*
pRequest
=
NULL
;
int32_t
retryNum
=
0
;
int32_t
retryNum
=
0
;
int32_t
code
=
0
;
int32_t
code
=
0
;
do
{
do
{
destroyRequest
(
pRequest
);
destroyRequest
(
pRequest
);
pRequest
=
launchQuery
(
pTscObj
,
sql
,
sqlLen
);
pRequest
=
launchQuery
(
pTscObj
,
sql
,
sqlLen
,
validateOnly
);
if
(
pRequest
==
NULL
||
TSDB_CODE_SUCCESS
==
pRequest
->
code
||
!
NEED_CLIENT_HANDLE_ERROR
(
pRequest
->
code
))
{
if
(
pRequest
==
NULL
||
TSDB_CODE_SUCCESS
==
pRequest
->
code
||
!
NEED_CLIENT_HANDLE_ERROR
(
pRequest
->
code
))
{
break
;
break
;
}
}
...
@@ -1819,3 +1837,251 @@ _OVER:
...
@@ -1819,3 +1837,251 @@ _OVER:
}
}
return
code
;
return
code
;
}
}
int32_t
appendTbToReq
(
SArray
*
pList
,
int32_t
pos1
,
int32_t
len1
,
int32_t
pos2
,
int32_t
len2
,
const
char
*
str
,
int32_t
acctId
,
char
*
db
)
{
SName
name
;
if
(
len1
<=
0
)
{
return
-
1
;
}
const
char
*
dbName
=
db
;
const
char
*
tbName
=
NULL
;
int32_t
dbLen
=
0
;
int32_t
tbLen
=
0
;
if
(
len2
>
0
)
{
dbName
=
str
+
pos1
;
dbLen
=
len1
;
tbName
=
str
+
pos2
;
tbLen
=
len2
;
}
else
{
dbLen
=
strlen
(
db
);
tbName
=
str
+
pos1
;
tbLen
=
len1
;
}
if
(
tNameSetDbName
(
&
name
,
acctId
,
dbName
,
dbLen
))
{
return
-
1
;
}
if
(
tNameAddTbName
(
&
name
,
tbName
,
tbLen
))
{
return
-
1
;
}
taosArrayPush
(
pList
,
&
name
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
transferTableNameList
(
const
char
*
tbList
,
int32_t
acctId
,
char
*
dbName
,
SArray
**
pReq
)
{
*
pReq
=
taosArrayInit
(
10
,
sizeof
(
SName
));
if
(
NULL
==
*
pReq
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
terrno
;
}
bool
inEscape
=
false
;
int32_t
code
=
0
;
int32_t
vIdx
=
0
;
int32_t
vPos
[
2
];
int32_t
vLen
[
2
];
memset
(
vPos
,
-
1
,
sizeof
(
vPos
));
memset
(
vLen
,
0
,
sizeof
(
vLen
));
for
(
int32_t
i
=
0
;
;
++
i
)
{
if
(
0
==
*
(
tbList
+
i
))
{
if
(
vPos
[
vIdx
]
>=
0
&&
vLen
[
vIdx
]
<=
0
)
{
vLen
[
vIdx
]
=
i
-
vPos
[
vIdx
];
}
code
=
appendTbToReq
(
*
pReq
,
vPos
[
0
],
vLen
[
0
],
vPos
[
1
],
vLen
[
1
],
tbList
,
acctId
,
dbName
);
if
(
code
)
{
goto
_return
;
}
break
;
}
if
(
'`'
==
*
(
tbList
+
i
))
{
inEscape
=
!
inEscape
;
if
(
!
inEscape
)
{
if
(
vPos
[
vIdx
]
>=
0
)
{
vLen
[
vIdx
]
=
i
-
vPos
[
vIdx
];
}
else
{
goto
_return
;
}
}
continue
;
}
if
(
inEscape
)
{
if
(
vPos
[
vIdx
]
<
0
)
{
vPos
[
vIdx
]
=
i
;
}
continue
;
}
if
(
'.'
==
*
(
tbList
+
i
))
{
if
(
vPos
[
vIdx
]
<
0
)
{
goto
_return
;
}
if
(
vLen
[
vIdx
]
<=
0
)
{
vLen
[
vIdx
]
=
i
-
vPos
[
vIdx
];
}
vIdx
++
;
if
(
vIdx
>=
2
)
{
goto
_return
;
}
continue
;
}
if
(
','
==
*
(
tbList
+
i
))
{
if
(
vPos
[
vIdx
]
<
0
)
{
goto
_return
;
}
if
(
vLen
[
vIdx
]
<=
0
)
{
vLen
[
vIdx
]
=
i
-
vPos
[
vIdx
];
}
code
=
appendTbToReq
(
*
pReq
,
vPos
[
0
],
vLen
[
0
],
vPos
[
1
],
vLen
[
1
],
tbList
,
acctId
,
dbName
);
if
(
code
)
{
goto
_return
;
}
memset
(
vPos
,
-
1
,
sizeof
(
vPos
));
memset
(
vLen
,
0
,
sizeof
(
vLen
));
vIdx
=
0
;
continue
;
}
if
(
' '
==
*
(
tbList
+
i
)
||
'\r'
==
*
(
tbList
+
i
)
||
'\t'
==
*
(
tbList
+
i
)
||
'\n'
==
*
(
tbList
+
i
))
{
if
(
vPos
[
vIdx
]
>=
0
&&
vLen
[
vIdx
]
<=
0
)
{
vLen
[
vIdx
]
=
i
-
vPos
[
vIdx
];
}
continue
;
}
if
((
'a'
<=
*
(
tbList
+
i
)
&&
'z'
>=
*
(
tbList
+
i
))
||
(
'A'
<=
*
(
tbList
+
i
)
&&
'Z'
>=
*
(
tbList
+
i
))
||
(
'0'
<=
*
(
tbList
+
i
)
&&
'9'
>=
*
(
tbList
+
i
)))
{
if
(
vLen
[
vIdx
]
>
0
)
{
goto
_return
;
}
if
(
vPos
[
vIdx
]
<
0
)
{
vPos
[
vIdx
]
=
i
;
}
continue
;
}
goto
_return
;
}
return
TSDB_CODE_SUCCESS
;
_return:
terrno
=
TSDB_CODE_TSC_INVALID_OPERATION
;
taosArrayDestroy
(
*
pReq
);
*
pReq
=
NULL
;
return
terrno
;
}
void
syncCatalogFn
(
SMetaData
*
pResult
,
void
*
param
,
int32_t
code
)
{
SSyncQueryParam
*
pParam
=
param
;
pParam
->
pRequest
->
code
=
code
;
tsem_post
(
&
pParam
->
sem
);
}
void
syncQueryFn
(
void
*
param
,
void
*
res
,
int32_t
code
)
{
SSyncQueryParam
*
pParam
=
param
;
pParam
->
pRequest
=
res
;
pParam
->
pRequest
->
code
=
code
;
tsem_post
(
&
pParam
->
sem
);
}
void
taosAsyncQueryImpl
(
TAOS
*
taos
,
const
char
*
sql
,
__taos_async_fn_t
fp
,
void
*
param
,
bool
validateOnly
)
{
STscObj
*
pTscObj
=
acquireTscObj
(
*
(
int64_t
*
)
taos
);
if
(
pTscObj
==
NULL
||
sql
==
NULL
||
NULL
==
fp
)
{
terrno
=
TSDB_CODE_INVALID_PARA
;
if
(
pTscObj
)
{
releaseTscObj
(
*
(
int64_t
*
)
taos
);
}
else
{
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
}
fp
(
param
,
NULL
,
terrno
);
return
;
}
size_t
sqlLen
=
strlen
(
sql
);
if
(
sqlLen
>
(
size_t
)
TSDB_MAX_ALLOWED_SQL_LEN
)
{
tscError
(
"sql string exceeds max length:%d"
,
TSDB_MAX_ALLOWED_SQL_LEN
);
terrno
=
TSDB_CODE_TSC_EXCEED_SQL_LIMIT
;
fp
(
param
,
NULL
,
terrno
);
return
;
}
SRequestObj
*
pRequest
=
NULL
;
int32_t
code
=
buildRequest
(
pTscObj
,
sql
,
sqlLen
,
&
pRequest
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
terrno
=
code
;
fp
(
param
,
NULL
,
terrno
);
return
;
}
pRequest
->
validateOnly
=
validateOnly
;
pRequest
->
body
.
queryFp
=
fp
;
pRequest
->
body
.
param
=
param
;
doAsyncQuery
(
pRequest
,
false
);
}
TAOS_RES
*
taosQueryImpl
(
TAOS
*
taos
,
const
char
*
sql
,
bool
validateOnly
)
{
if
(
NULL
==
taos
)
{
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
return
NULL
;
}
STscObj
*
pTscObj
=
acquireTscObj
(
*
(
int64_t
*
)
taos
);
if
(
pTscObj
==
NULL
||
sql
==
NULL
)
{
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
return
NULL
;
}
#if SYNC_ON_TOP_OF_ASYNC
SSyncQueryParam
*
param
=
taosMemoryCalloc
(
1
,
sizeof
(
SSyncQueryParam
));
tsem_init
(
&
param
->
sem
,
0
,
0
);
taosAsyncQueryImpl
(
taos
,
sql
,
syncQueryFn
,
param
,
validateOnly
);
tsem_wait
(
&
param
->
sem
);
releaseTscObj
(
*
(
int64_t
*
)
taos
);
return
param
->
pRequest
;
#else
size_t
sqlLen
=
strlen
(
sql
);
if
(
sqlLen
>
(
size_t
)
TSDB_MAX_ALLOWED_SQL_LEN
)
{
releaseTscObj
(
*
(
int64_t
*
)
taos
);
tscError
(
"sql string exceeds max length:%d"
,
TSDB_MAX_ALLOWED_SQL_LEN
);
terrno
=
TSDB_CODE_TSC_EXCEED_SQL_LIMIT
;
return
NULL
;
}
TAOS_RES
*
pRes
=
execQuery
(
pTscObj
,
sql
,
sqlLen
,
validateOnly
);
releaseTscObj
(
*
(
int64_t
*
)
taos
);
return
pRes
;
#endif
}
source/client/src/clientMain.c
浏览文件 @
291aab04
...
@@ -81,12 +81,6 @@ void taos_cleanup(void) {
...
@@ -81,12 +81,6 @@ void taos_cleanup(void) {
taosCloseLog
();
taosCloseLog
();
}
}
setConfRet
taos_set_config
(
const
char
*
config
)
{
// TODO
setConfRet
ret
=
{
SET_CONF_RET_SUCC
,
{
0
}};
return
ret
;
}
TAOS
*
taos_connect
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
db
,
uint16_t
port
)
{
TAOS
*
taos_connect
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
db
,
uint16_t
port
)
{
tscDebug
(
"try to connect to %s:%u, user:%s db:%s"
,
ip
,
port
,
user
,
db
);
tscDebug
(
"try to connect to %s:%u, user:%s db:%s"
,
ip
,
port
,
user
,
db
);
if
(
user
==
NULL
)
{
if
(
user
==
NULL
)
{
...
@@ -205,51 +199,9 @@ TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) {
...
@@ -205,51 +199,9 @@ TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) {
return
pResInfo
->
userFields
;
return
pResInfo
->
userFields
;
}
}
static
void
syncQueryFn
(
void
*
param
,
void
*
res
,
int32_t
code
)
{
SSyncQueryParam
*
pParam
=
param
;
pParam
->
pRequest
=
res
;
pParam
->
pRequest
->
code
=
code
;
tsem_post
(
&
pParam
->
sem
);
}
TAOS_RES
*
taos_query
(
TAOS
*
taos
,
const
char
*
sql
)
{
TAOS_RES
*
taos_query
(
TAOS
*
taos
,
const
char
*
sql
)
{
if
(
NULL
==
taos
)
{
return
taosQueryImpl
(
taos
,
sql
,
false
);
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
return
NULL
;
}
STscObj
*
pTscObj
=
acquireTscObj
(
*
(
int64_t
*
)
taos
);
if
(
pTscObj
==
NULL
||
sql
==
NULL
)
{
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
return
NULL
;
}
#if SYNC_ON_TOP_OF_ASYNC
SSyncQueryParam
*
param
=
taosMemoryCalloc
(
1
,
sizeof
(
SSyncQueryParam
));
tsem_init
(
&
param
->
sem
,
0
,
0
);
taos_query_a
(
taos
,
sql
,
syncQueryFn
,
param
);
tsem_wait
(
&
param
->
sem
);
releaseTscObj
(
*
(
int64_t
*
)
taos
);
return
param
->
pRequest
;
#else
size_t
sqlLen
=
strlen
(
sql
);
if
(
sqlLen
>
(
size_t
)
TSDB_MAX_ALLOWED_SQL_LEN
)
{
releaseTscObj
(
*
(
int64_t
*
)
taos
);
tscError
(
"sql string exceeds max length:%d"
,
TSDB_MAX_ALLOWED_SQL_LEN
);
terrno
=
TSDB_CODE_TSC_EXCEED_SQL_LIMIT
;
return
NULL
;
}
TAOS_RES
*
pRes
=
execQuery
(
pTscObj
,
sql
,
sqlLen
);
releaseTscObj
(
*
(
int64_t
*
)
taos
);
return
pRes
;
#endif
}
}
TAOS_ROW
taos_fetch_row
(
TAOS_RES
*
res
)
{
TAOS_ROW
taos_fetch_row
(
TAOS_RES
*
res
)
{
...
@@ -641,7 +593,14 @@ int *taos_get_column_data_offset(TAOS_RES *res, int columnIndex) {
...
@@ -641,7 +593,14 @@ int *taos_get_column_data_offset(TAOS_RES *res, int columnIndex) {
return
pResInfo
->
pCol
[
columnIndex
].
offset
;
return
pResInfo
->
pCol
[
columnIndex
].
offset
;
}
}
int
taos_validate_sql
(
TAOS
*
taos
,
const
char
*
sql
)
{
return
true
;
}
int
taos_validate_sql
(
TAOS
*
taos
,
const
char
*
sql
)
{
TAOS_RES
*
pObj
=
taosQueryImpl
(
taos
,
sql
,
true
);
int
code
=
taos_errno
(
pObj
);
taos_free_result
(
pObj
);
return
code
;
}
void
taos_reset_current_db
(
TAOS
*
taos
)
{
void
taos_reset_current_db
(
TAOS
*
taos
)
{
STscObj
*
pTscObj
=
acquireTscObj
(
*
(
int64_t
*
)
taos
);
STscObj
*
pTscObj
=
acquireTscObj
(
*
(
int64_t
*
)
taos
);
...
@@ -731,38 +690,7 @@ void retrieveMetaCallback(SMetaData *pResultMeta, void *param, int32_t code) {
...
@@ -731,38 +690,7 @@ void retrieveMetaCallback(SMetaData *pResultMeta, void *param, int32_t code) {
}
}
void
taos_query_a
(
TAOS
*
taos
,
const
char
*
sql
,
__taos_async_fn_t
fp
,
void
*
param
)
{
void
taos_query_a
(
TAOS
*
taos
,
const
char
*
sql
,
__taos_async_fn_t
fp
,
void
*
param
)
{
STscObj
*
pTscObj
=
acquireTscObj
(
*
(
int64_t
*
)
taos
);
taosAsyncQueryImpl
(
taos
,
sql
,
fp
,
param
,
false
);
if
(
pTscObj
==
NULL
||
sql
==
NULL
||
NULL
==
fp
)
{
terrno
=
TSDB_CODE_INVALID_PARA
;
if
(
pTscObj
)
{
releaseTscObj
(
*
(
int64_t
*
)
taos
);
}
else
{
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
}
fp
(
param
,
NULL
,
terrno
);
return
;
}
size_t
sqlLen
=
strlen
(
sql
);
if
(
sqlLen
>
(
size_t
)
TSDB_MAX_ALLOWED_SQL_LEN
)
{
tscError
(
"sql string exceeds max length:%d"
,
TSDB_MAX_ALLOWED_SQL_LEN
);
terrno
=
TSDB_CODE_TSC_EXCEED_SQL_LIMIT
;
fp
(
param
,
NULL
,
terrno
);
return
;
}
SRequestObj
*
pRequest
=
NULL
;
int32_t
code
=
buildRequest
(
pTscObj
,
sql
,
sqlLen
,
&
pRequest
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
terrno
=
code
;
fp
(
param
,
NULL
,
terrno
);
return
;
}
pRequest
->
body
.
queryFp
=
fp
;
pRequest
->
body
.
param
=
param
;
doAsyncQuery
(
pRequest
,
false
);
}
}
int32_t
createParseContext
(
const
SRequestObj
*
pRequest
,
SParseContext
**
pCxt
)
{
int32_t
createParseContext
(
const
SRequestObj
*
pRequest
,
SParseContext
**
pCxt
)
{
...
@@ -955,10 +883,75 @@ void taos_unsubscribe(TAOS_SUB *tsub, int keepProgress) {
...
@@ -955,10 +883,75 @@ void taos_unsubscribe(TAOS_SUB *tsub, int keepProgress) {
}
}
int
taos_load_table_info
(
TAOS
*
taos
,
const
char
*
tableNameList
)
{
int
taos_load_table_info
(
TAOS
*
taos
,
const
char
*
tableNameList
)
{
// TODO
const
int32_t
MAX_TABLE_NAME_LENGTH
=
12
*
1024
*
1024
;
// 12MB list
return
-
1
;
int32_t
code
=
0
;
SRequestObj
*
pRequest
=
NULL
;
SCatalogReq
catalogReq
=
{
0
};
if
(
NULL
==
tableNameList
)
{
return
TSDB_CODE_SUCCESS
;
}
int32_t
length
=
(
int32_t
)
strlen
(
tableNameList
);
if
(
0
==
length
)
{
return
TSDB_CODE_SUCCESS
;
}
else
if
(
length
>
MAX_TABLE_NAME_LENGTH
)
{
tscError
(
"tableNameList too long, length:%d, maximum allowed:%d"
,
length
,
MAX_TABLE_NAME_LENGTH
);
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
STscObj
*
pTscObj
=
acquireTscObj
(
*
(
int64_t
*
)
taos
);
if
(
pTscObj
==
NULL
)
{
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
return
terrno
;
}
code
=
transferTableNameList
(
tableNameList
,
pTscObj
->
acctId
,
pTscObj
->
db
,
&
catalogReq
.
pTableMeta
);
if
(
code
)
{
goto
_return
;
}
SCatalog
*
pCtg
=
NULL
;
code
=
catalogGetHandle
(
pTscObj
->
pAppInfo
->
clusterId
,
&
pCtg
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_return
;
}
char
*
sql
=
"taos_load_table_info"
;
code
=
buildRequest
(
pTscObj
,
sql
,
strlen
(
sql
),
&
pRequest
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
terrno
=
code
;
goto
_return
;
}
SSyncQueryParam
param
=
{
0
};
tsem_init
(
&
param
.
sem
,
0
,
0
);
param
.
pRequest
=
pRequest
;
SRequestConnInfo
conn
=
{.
pTrans
=
pTscObj
->
pAppInfo
->
pTransporter
,
.
requestId
=
pRequest
->
requestId
,
.
requestObjRefId
=
pRequest
->
self
};
conn
.
mgmtEps
=
getEpSet_s
(
&
pTscObj
->
pAppInfo
->
mgmtEp
);
code
=
catalogAsyncGetAllMeta
(
pCtg
,
&
conn
,
pRequest
->
requestId
,
&
catalogReq
,
syncCatalogFn
,
&
param
,
NULL
);
if
(
code
)
{
goto
_return
;
}
tsem_wait
(
&
param
.
sem
);
_return:
taosArrayDestroy
(
catalogReq
.
pTableMeta
);
destroyRequest
(
pRequest
);
releaseTscObj
(
*
(
int64_t
*
)
taos
);
return
code
;
}
}
TAOS_STMT
*
taos_stmt_init
(
TAOS
*
taos
)
{
TAOS_STMT
*
taos_stmt_init
(
TAOS
*
taos
)
{
STscObj
*
pObj
=
acquireTscObj
(
*
(
int64_t
*
)
taos
);
STscObj
*
pObj
=
acquireTscObj
(
*
(
int64_t
*
)
taos
);
if
(
NULL
==
pObj
)
{
if
(
NULL
==
pObj
)
{
...
...
source/common/src/tdatablock.c
浏览文件 @
291aab04
...
@@ -263,7 +263,7 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, ui
...
@@ -263,7 +263,7 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, ui
pColumnInfoData
->
varmeta
.
length
=
len
+
oldLen
;
pColumnInfoData
->
varmeta
.
length
=
len
+
oldLen
;
}
else
{
}
else
{
if
(
finalNumOfRows
>
*
capacity
)
{
if
(
finalNumOfRows
>
*
capacity
)
{
ASSERT
(
finalNumOfRows
*
pColumnInfoData
->
info
.
bytes
);
ASSERT
(
finalNumOfRows
*
pColumnInfoData
->
info
.
bytes
);
char
*
tmp
=
taosMemoryRealloc
(
pColumnInfoData
->
pData
,
finalNumOfRows
*
pColumnInfoData
->
info
.
bytes
);
char
*
tmp
=
taosMemoryRealloc
(
pColumnInfoData
->
pData
,
finalNumOfRows
*
pColumnInfoData
->
info
.
bytes
);
if
(
tmp
==
NULL
)
{
if
(
tmp
==
NULL
)
{
return
TSDB_CODE_VND_OUT_OF_MEMORY
;
return
TSDB_CODE_VND_OUT_OF_MEMORY
;
...
@@ -293,7 +293,8 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, ui
...
@@ -293,7 +293,8 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, ui
return
numOfRow1
+
numOfRow2
;
return
numOfRow1
+
numOfRow2
;
}
}
int32_t
colDataAssign
(
SColumnInfoData
*
pColumnInfoData
,
const
SColumnInfoData
*
pSource
,
int32_t
numOfRows
,
const
SDataBlockInfo
*
pBlockInfo
)
{
int32_t
colDataAssign
(
SColumnInfoData
*
pColumnInfoData
,
const
SColumnInfoData
*
pSource
,
int32_t
numOfRows
,
const
SDataBlockInfo
*
pBlockInfo
)
{
ASSERT
(
pColumnInfoData
!=
NULL
&&
pSource
!=
NULL
&&
pColumnInfoData
->
info
.
type
==
pSource
->
info
.
type
);
ASSERT
(
pColumnInfoData
!=
NULL
&&
pSource
!=
NULL
&&
pColumnInfoData
->
info
.
type
==
pSource
->
info
.
type
);
if
(
numOfRows
<=
0
)
{
if
(
numOfRows
<=
0
)
{
return
numOfRows
;
return
numOfRows
;
...
@@ -327,9 +328,7 @@ int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* p
...
@@ -327,9 +328,7 @@ int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* p
return
0
;
return
0
;
}
}
size_t
blockDataGetNumOfCols
(
const
SSDataBlock
*
pBlock
)
{
size_t
blockDataGetNumOfCols
(
const
SSDataBlock
*
pBlock
)
{
return
taosArrayGetSize
(
pBlock
->
pDataBlock
);
}
return
taosArrayGetSize
(
pBlock
->
pDataBlock
);
}
size_t
blockDataGetNumOfRows
(
const
SSDataBlock
*
pBlock
)
{
return
pBlock
->
info
.
rows
;
}
size_t
blockDataGetNumOfRows
(
const
SSDataBlock
*
pBlock
)
{
return
pBlock
->
info
.
rows
;
}
...
@@ -396,7 +395,7 @@ int32_t blockDataSplitRows(SSDataBlock* pBlock, bool hasVarCol, int32_t startInd
...
@@ -396,7 +395,7 @@ int32_t blockDataSplitRows(SSDataBlock* pBlock, bool hasVarCol, int32_t startInd
int32_t
pageSize
)
{
int32_t
pageSize
)
{
ASSERT
(
pBlock
!=
NULL
&&
stopIndex
!=
NULL
);
ASSERT
(
pBlock
!=
NULL
&&
stopIndex
!=
NULL
);
size_t
numOfCols
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
size_t
numOfCols
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
int32_t
numOfRows
=
pBlock
->
info
.
rows
;
int32_t
numOfRows
=
pBlock
->
info
.
rows
;
int32_t
bitmapChar
=
1
;
int32_t
bitmapChar
=
1
;
...
@@ -512,7 +511,7 @@ int32_t blockDataToBuf(char* buf, const SSDataBlock* pBlock) {
...
@@ -512,7 +511,7 @@ int32_t blockDataToBuf(char* buf, const SSDataBlock* pBlock) {
// write the number of rows
// write the number of rows
*
(
uint32_t
*
)
buf
=
pBlock
->
info
.
rows
;
*
(
uint32_t
*
)
buf
=
pBlock
->
info
.
rows
;
size_t
numOfCols
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
size_t
numOfCols
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
int32_t
numOfRows
=
pBlock
->
info
.
rows
;
int32_t
numOfRows
=
pBlock
->
info
.
rows
;
char
*
pStart
=
buf
+
sizeof
(
uint32_t
);
char
*
pStart
=
buf
+
sizeof
(
uint32_t
);
...
@@ -542,7 +541,7 @@ int32_t blockDataToBuf(char* buf, const SSDataBlock* pBlock) {
...
@@ -542,7 +541,7 @@ int32_t blockDataToBuf(char* buf, const SSDataBlock* pBlock) {
int32_t
blockDataFromBuf
(
SSDataBlock
*
pBlock
,
const
char
*
buf
)
{
int32_t
blockDataFromBuf
(
SSDataBlock
*
pBlock
,
const
char
*
buf
)
{
pBlock
->
info
.
rows
=
*
(
int32_t
*
)
buf
;
pBlock
->
info
.
rows
=
*
(
int32_t
*
)
buf
;
size_t
numOfCols
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
size_t
numOfCols
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
const
char
*
pStart
=
buf
+
sizeof
(
uint32_t
);
const
char
*
pStart
=
buf
+
sizeof
(
uint32_t
);
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
...
@@ -734,7 +733,7 @@ int32_t dataBlockCompar(const void* p1, const void* p2, const void* param) {
...
@@ -734,7 +733,7 @@ int32_t dataBlockCompar(const void* p1, const void* p2, const void* param) {
static
int32_t
doAssignOneTuple
(
SColumnInfoData
*
pDstCols
,
int32_t
numOfRows
,
const
SSDataBlock
*
pSrcBlock
,
static
int32_t
doAssignOneTuple
(
SColumnInfoData
*
pDstCols
,
int32_t
numOfRows
,
const
SSDataBlock
*
pSrcBlock
,
int32_t
tupleIndex
)
{
int32_t
tupleIndex
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
size_t
numOfCols
=
taosArrayGetSize
(
pSrcBlock
->
pDataBlock
);
size_t
numOfCols
=
taosArrayGetSize
(
pSrcBlock
->
pDataBlock
);
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
*
pDst
=
&
pDstCols
[
i
];
SColumnInfoData
*
pDst
=
&
pDstCols
[
i
];
...
@@ -794,7 +793,7 @@ static int32_t blockDataAssign(SColumnInfoData* pCols, const SSDataBlock* pDataB
...
@@ -794,7 +793,7 @@ static int32_t blockDataAssign(SColumnInfoData* pCols, const SSDataBlock* pDataB
static
SColumnInfoData
*
createHelpColInfoData
(
const
SSDataBlock
*
pDataBlock
)
{
static
SColumnInfoData
*
createHelpColInfoData
(
const
SSDataBlock
*
pDataBlock
)
{
int32_t
rows
=
pDataBlock
->
info
.
rows
;
int32_t
rows
=
pDataBlock
->
info
.
rows
;
size_t
numOfCols
=
taosArrayGetSize
(
pDataBlock
->
pDataBlock
);
size_t
numOfCols
=
taosArrayGetSize
(
pDataBlock
->
pDataBlock
);
SColumnInfoData
*
pCols
=
taosMemoryCalloc
(
numOfCols
,
sizeof
(
SColumnInfoData
));
SColumnInfoData
*
pCols
=
taosMemoryCalloc
(
numOfCols
,
sizeof
(
SColumnInfoData
));
if
(
pCols
==
NULL
)
{
if
(
pCols
==
NULL
)
{
...
@@ -902,7 +901,6 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo) {
...
@@ -902,7 +901,6 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo) {
}
else
{
// var data type
}
else
{
// var data type
}
}
}
else
if
(
numOfCols
==
2
)
{
}
else
if
(
numOfCols
==
2
)
{
}
}
}
}
...
@@ -1103,14 +1101,14 @@ void blockDataCleanup(SSDataBlock* pDataBlock) {
...
@@ -1103,14 +1101,14 @@ void blockDataCleanup(SSDataBlock* pDataBlock) {
}
}
}
}
static
int32_t
doEnsureCapacity
(
SColumnInfoData
*
pColumn
,
const
SDataBlockInfo
*
pBlockInfo
,
uint32_t
numOfRows
)
{
static
int32_t
doEnsureCapacity
(
SColumnInfoData
*
pColumn
,
const
SDataBlockInfo
*
pBlockInfo
,
uint32_t
numOfRows
)
{
ASSERT
(
numOfRows
>
0
&&
pBlockInfo
->
capacity
>=
pBlockInfo
->
rows
);
ASSERT
(
numOfRows
>
0
&&
pBlockInfo
->
capacity
>=
pBlockInfo
->
rows
);
if
(
numOfRows
<
pBlockInfo
->
capacity
)
{
if
(
numOfRows
<
pBlockInfo
->
capacity
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
// todo temp disable it
// todo temp disable it
// ASSERT(pColumn->info.bytes != 0);
// ASSERT(pColumn->info.bytes != 0);
int32_t
existedRows
=
pBlockInfo
->
rows
;
int32_t
existedRows
=
pBlockInfo
->
rows
;
...
@@ -1141,7 +1139,7 @@ static int32_t doEnsureCapacity(SColumnInfoData* pColumn, const SDataBlockInfo *
...
@@ -1141,7 +1139,7 @@ static int32_t doEnsureCapacity(SColumnInfoData* pColumn, const SDataBlockInfo *
if
(
tmp
==
NULL
)
{
if
(
tmp
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
memset
(
tmp
+
pColumn
->
info
.
bytes
*
existedRows
,
0
,
pColumn
->
info
.
bytes
*
(
numOfRows
-
existedRows
));
memset
(
tmp
+
pColumn
->
info
.
bytes
*
existedRows
,
0
,
pColumn
->
info
.
bytes
*
(
numOfRows
-
existedRows
));
pColumn
->
pData
=
tmp
;
pColumn
->
pData
=
tmp
;
}
}
...
@@ -1197,6 +1195,40 @@ void* blockDataDestroy(SSDataBlock* pBlock) {
...
@@ -1197,6 +1195,40 @@ void* blockDataDestroy(SSDataBlock* pBlock) {
taosMemoryFreeClear
(
pBlock
);
taosMemoryFreeClear
(
pBlock
);
return
NULL
;
return
NULL
;
}
}
int32_t
assignOneDataBlock
(
SSDataBlock
*
dst
,
const
SSDataBlock
*
src
)
{
ASSERT
(
src
!=
NULL
);
dst
->
info
=
src
->
info
;
dst
->
info
.
rows
=
0
;
dst
->
info
.
capacity
=
0
;
size_t
numOfCols
=
taosArrayGetSize
(
src
->
pDataBlock
);
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
*
p
=
taosArrayGet
(
src
->
pDataBlock
,
i
);
SColumnInfoData
colInfo
=
{.
hasNull
=
true
,
.
info
=
p
->
info
};
blockDataAppendColInfo
(
dst
,
&
colInfo
);
}
int32_t
code
=
blockDataEnsureCapacity
(
dst
,
src
->
info
.
rows
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
terrno
=
code
;
return
-
1
;
}
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
*
pDst
=
taosArrayGet
(
dst
->
pDataBlock
,
i
);
SColumnInfoData
*
pSrc
=
taosArrayGet
(
src
->
pDataBlock
,
i
);
if
(
pSrc
->
pData
==
NULL
)
{
continue
;
}
colDataAssign
(
pDst
,
pSrc
,
src
->
info
.
rows
,
&
src
->
info
);
}
dst
->
info
.
rows
=
src
->
info
.
rows
;
dst
->
info
.
capacity
=
src
->
info
.
rows
;
return
0
;
}
SSDataBlock
*
createOneDataBlock
(
const
SSDataBlock
*
pDataBlock
,
bool
copyData
)
{
SSDataBlock
*
createOneDataBlock
(
const
SSDataBlock
*
pDataBlock
,
bool
copyData
)
{
if
(
pDataBlock
==
NULL
)
{
if
(
pDataBlock
==
NULL
)
{
...
@@ -1272,7 +1304,7 @@ int32_t blockDataAppendColInfo(SSDataBlock* pBlock, SColumnInfoData* pColInfoDat
...
@@ -1272,7 +1304,7 @@ int32_t blockDataAppendColInfo(SSDataBlock* pBlock, SColumnInfoData* pColInfoDat
}
}
// todo disable it temporarily
// todo disable it temporarily
// ASSERT(pColInfoData->info.type != 0);
// ASSERT(pColInfoData->info.type != 0);
if
(
IS_VAR_DATA_TYPE
(
pColInfoData
->
info
.
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pColInfoData
->
info
.
type
))
{
pBlock
->
info
.
hasVarCol
=
true
;
pBlock
->
info
.
hasVarCol
=
true
;
}
}
...
@@ -1284,7 +1316,7 @@ int32_t blockDataAppendColInfo(SSDataBlock* pBlock, SColumnInfoData* pColInfoDat
...
@@ -1284,7 +1316,7 @@ int32_t blockDataAppendColInfo(SSDataBlock* pBlock, SColumnInfoData* pColInfoDat
SColumnInfoData
createColumnInfoData
(
int16_t
type
,
int32_t
bytes
,
int16_t
colId
)
{
SColumnInfoData
createColumnInfoData
(
int16_t
type
,
int32_t
bytes
,
int16_t
colId
)
{
SColumnInfoData
col
=
{.
hasNull
=
true
};
SColumnInfoData
col
=
{.
hasNull
=
true
};
col
.
info
.
colId
=
colId
;
col
.
info
.
colId
=
colId
;
col
.
info
.
type
=
type
;
col
.
info
.
type
=
type
;
col
.
info
.
bytes
=
bytes
;
col
.
info
.
bytes
=
bytes
;
return
col
;
return
col
;
...
@@ -1552,9 +1584,9 @@ void blockDebugShowData(const SArray* dataBlocks, const char* flag) {
...
@@ -1552,9 +1584,9 @@ void blockDebugShowData(const SArray* dataBlocks, const char* flag) {
int32_t
sz
=
taosArrayGetSize
(
dataBlocks
);
int32_t
sz
=
taosArrayGetSize
(
dataBlocks
);
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SSDataBlock
*
pDataBlock
=
taosArrayGet
(
dataBlocks
,
i
);
SSDataBlock
*
pDataBlock
=
taosArrayGet
(
dataBlocks
,
i
);
size_t
numOfCols
=
taosArrayGetSize
(
pDataBlock
->
pDataBlock
);
size_t
numOfCols
=
taosArrayGetSize
(
pDataBlock
->
pDataBlock
);
int32_t
rows
=
pDataBlock
->
info
.
rows
;
int32_t
rows
=
pDataBlock
->
info
.
rows
;
printf
(
"%s |block type %d |child id %d|
\n
"
,
flag
,
(
int32_t
)
pDataBlock
->
info
.
type
,
pDataBlock
->
info
.
childId
);
printf
(
"%s |block type %d |child id %d|
\n
"
,
flag
,
(
int32_t
)
pDataBlock
->
info
.
type
,
pDataBlock
->
info
.
childId
);
for
(
int32_t
j
=
0
;
j
<
rows
;
j
++
)
{
for
(
int32_t
j
=
0
;
j
<
rows
;
j
++
)
{
printf
(
"%s |"
,
flag
);
printf
(
"%s |"
,
flag
);
...
@@ -1633,8 +1665,8 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SArray* pDataBlocks
...
@@ -1633,8 +1665,8 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SArray* pDataBlocks
SSDataBlock
*
pDataBlock
=
taosArrayGet
(
pDataBlocks
,
i
);
SSDataBlock
*
pDataBlock
=
taosArrayGet
(
pDataBlocks
,
i
);
int32_t
colNum
=
taosArrayGetSize
(
pDataBlock
->
pDataBlock
);
int32_t
colNum
=
taosArrayGetSize
(
pDataBlock
->
pDataBlock
);
int32_t
rows
=
pDataBlock
->
info
.
rows
;
int32_t
rows
=
pDataBlock
->
info
.
rows
;
// int32_t rowSize = pDataBlock->info.rowSize;
// int32_t rowSize = pDataBlock->info.rowSize;
// int64_t groupId = pDataBlock->info.groupId;
// int64_t groupId = pDataBlock->info.groupId;
if
(
colNum
<=
1
)
{
if
(
colNum
<=
1
)
{
// invalid if only with TS col
// invalid if only with TS col
...
...
source/common/src/tglobal.c
浏览文件 @
291aab04
...
@@ -636,6 +636,373 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
...
@@ -636,6 +636,373 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
return
0
;
return
0
;
}
}
int32_t
taosSetCfg
(
SConfig
*
pCfg
,
char
*
name
)
{
int32_t
len
=
strlen
(
name
);
char
lowcaseName
[
CFG_NAME_MAX_LEN
+
1
]
=
{
0
};
strntolower
(
lowcaseName
,
name
,
TMIN
(
CFG_NAME_MAX_LEN
,
len
));
switch
(
lowcaseName
[
0
])
{
case
'a'
:
{
if
(
strcasecmp
(
"asyncLog"
,
name
)
==
0
)
{
tsAsyncLog
=
cfgGetItem
(
pCfg
,
"asyncLog"
)
->
bval
;
}
break
;
}
case
'b'
:
{
if
(
strcasecmp
(
"bnodeShmSize"
,
name
)
==
0
)
{
tsBnodeShmSize
=
cfgGetItem
(
pCfg
,
"bnodeShmSize"
)
->
i32
;
}
break
;
}
case
'c'
:
{
if
(
strcasecmp
(
"charset"
,
name
)
==
0
)
{
const
char
*
locale
=
cfgGetItem
(
pCfg
,
"locale"
)
->
str
;
const
char
*
charset
=
cfgGetItem
(
pCfg
,
"charset"
)
->
str
;
taosSetSystemLocale
(
locale
,
charset
);
osSetSystemLocale
(
locale
,
charset
);
}
else
if
(
strcasecmp
(
"compressMsgSize"
,
name
)
==
0
)
{
tsCompressMsgSize
=
cfgGetItem
(
pCfg
,
"compressMsgSize"
)
->
i32
;
}
else
if
(
strcasecmp
(
"compressColData"
,
name
)
==
0
)
{
tsCompressColData
=
cfgGetItem
(
pCfg
,
"compressColData"
)
->
i32
;
}
else
if
(
strcasecmp
(
"countAlwaysReturnValue"
,
name
)
==
0
)
{
tsCountAlwaysReturnValue
=
cfgGetItem
(
pCfg
,
"countAlwaysReturnValue"
)
->
i32
;
}
else
if
(
strcasecmp
(
"cDebugFlag"
,
name
)
==
0
)
{
cDebugFlag
=
cfgGetItem
(
pCfg
,
"cDebugFlag"
)
->
i32
;
}
break
;
}
case
'd'
:
{
if
(
strcasecmp
(
"deadLockKillQuery"
,
name
)
==
0
)
{
tsDeadLockKillQuery
=
cfgGetItem
(
pCfg
,
"deadLockKillQuery"
)
->
i32
;
}
else
if
(
strcasecmp
(
"dDebugFlag"
,
name
)
==
0
)
{
dDebugFlag
=
cfgGetItem
(
pCfg
,
"dDebugFlag"
)
->
i32
;
}
break
;
}
case
'e'
:
{
if
(
strcasecmp
(
"enableCoreFile"
,
name
)
==
0
)
{
bool
enableCore
=
cfgGetItem
(
pCfg
,
"enableCoreFile"
)
->
bval
;
taosSetConsoleEcho
(
enableCore
);
}
break
;
}
case
'f'
:
{
if
(
strcasecmp
(
"fqdn"
,
name
)
==
0
)
{
tstrncpy
(
tsLocalFqdn
,
cfgGetItem
(
pCfg
,
"fqdn"
)
->
str
,
TSDB_FQDN_LEN
);
tsServerPort
=
(
uint16_t
)
cfgGetItem
(
pCfg
,
"serverPort"
)
->
i32
;
snprintf
(
tsLocalEp
,
sizeof
(
tsLocalEp
),
"%s:%u"
,
tsLocalFqdn
,
tsServerPort
);
char
defaultFirstEp
[
TSDB_EP_LEN
]
=
{
0
};
snprintf
(
defaultFirstEp
,
TSDB_EP_LEN
,
"%s:%u"
,
tsLocalFqdn
,
tsServerPort
);
SConfigItem
*
pFirstEpItem
=
cfgGetItem
(
pCfg
,
"firstEp"
);
SEp
firstEp
=
{
0
};
taosGetFqdnPortFromEp
(
strlen
(
pFirstEpItem
->
str
)
==
0
?
defaultFirstEp
:
pFirstEpItem
->
str
,
&
firstEp
);
snprintf
(
tsFirst
,
sizeof
(
tsFirst
),
"%s:%u"
,
firstEp
.
fqdn
,
firstEp
.
port
);
cfgSetItem
(
pCfg
,
"firstEp"
,
tsFirst
,
pFirstEpItem
->
stype
);
}
else
if
(
strcasecmp
(
"firstEp"
,
name
)
==
0
)
{
tstrncpy
(
tsLocalFqdn
,
cfgGetItem
(
pCfg
,
"fqdn"
)
->
str
,
TSDB_FQDN_LEN
);
tsServerPort
=
(
uint16_t
)
cfgGetItem
(
pCfg
,
"serverPort"
)
->
i32
;
snprintf
(
tsLocalEp
,
sizeof
(
tsLocalEp
),
"%s:%u"
,
tsLocalFqdn
,
tsServerPort
);
char
defaultFirstEp
[
TSDB_EP_LEN
]
=
{
0
};
snprintf
(
defaultFirstEp
,
TSDB_EP_LEN
,
"%s:%u"
,
tsLocalFqdn
,
tsServerPort
);
SConfigItem
*
pFirstEpItem
=
cfgGetItem
(
pCfg
,
"firstEp"
);
SEp
firstEp
=
{
0
};
taosGetFqdnPortFromEp
(
strlen
(
pFirstEpItem
->
str
)
==
0
?
defaultFirstEp
:
pFirstEpItem
->
str
,
&
firstEp
);
snprintf
(
tsFirst
,
sizeof
(
tsFirst
),
"%s:%u"
,
firstEp
.
fqdn
,
firstEp
.
port
);
cfgSetItem
(
pCfg
,
"firstEp"
,
tsFirst
,
pFirstEpItem
->
stype
);
}
else
if
(
strcasecmp
(
"fsDebugFlag"
,
name
)
==
0
)
{
fsDebugFlag
=
cfgGetItem
(
pCfg
,
"fsDebugFlag"
)
->
i32
;
}
else
if
(
strcasecmp
(
"fnDebugFlag"
,
name
)
==
0
)
{
fnDebugFlag
=
cfgGetItem
(
pCfg
,
"fnDebugFlag"
)
->
i32
;
}
break
;
}
case
'i'
:
{
if
(
strcasecmp
(
"idxDebugFlag"
,
name
)
==
0
)
{
idxDebugFlag
=
cfgGetItem
(
pCfg
,
"idxDebugFlag"
)
->
i32
;
}
break
;
}
case
'j'
:
{
if
(
strcasecmp
(
"jniDebugFlag"
,
name
)
==
0
)
{
jniDebugFlag
=
cfgGetItem
(
pCfg
,
"jniDebugFlag"
)
->
i32
;
}
break
;
}
case
'k'
:
{
if
(
strcasecmp
(
"keepColumnName"
,
name
)
==
0
)
{
tsKeepOriginalColumnName
=
cfgGetItem
(
pCfg
,
"keepColumnName"
)
->
bval
;
}
break
;
}
case
'l'
:
{
if
(
strcasecmp
(
"locale"
,
name
)
==
0
)
{
const
char
*
locale
=
cfgGetItem
(
pCfg
,
"locale"
)
->
str
;
const
char
*
charset
=
cfgGetItem
(
pCfg
,
"charset"
)
->
str
;
taosSetSystemLocale
(
locale
,
charset
);
osSetSystemLocale
(
locale
,
charset
);
}
else
if
(
strcasecmp
(
"logDir"
,
name
)
==
0
)
{
tstrncpy
(
tsLogDir
,
cfgGetItem
(
pCfg
,
"logDir"
)
->
str
,
PATH_MAX
);
taosExpandDir
(
tsLogDir
,
tsLogDir
,
PATH_MAX
);
}
else
if
(
strcasecmp
(
"logKeepDays"
,
name
)
==
0
)
{
tsLogKeepDays
=
cfgGetItem
(
pCfg
,
"logKeepDays"
)
->
i32
;
}
break
;
}
case
'm'
:
{
switch
(
lowcaseName
[
1
])
{
case
'a'
:
{
if
(
strcasecmp
(
"maxShellConns"
,
name
)
==
0
)
{
tsMaxShellConns
=
cfgGetItem
(
pCfg
,
"maxShellConns"
)
->
i32
;
}
else
if
(
strcasecmp
(
"maxNumOfDistinctRes"
,
name
)
==
0
)
{
tsMaxNumOfDistinctResults
=
cfgGetItem
(
pCfg
,
"maxNumOfDistinctRes"
)
->
i32
;
}
else
if
(
strcasecmp
(
"maxStreamCompDelay"
,
name
)
==
0
)
{
tsMaxStreamComputDelay
=
cfgGetItem
(
pCfg
,
"maxStreamCompDelay"
)
->
i32
;
}
else
if
(
strcasecmp
(
"maxFirstStreamCompDelay"
,
name
)
==
0
)
{
tsStreamCompStartDelay
=
cfgGetItem
(
pCfg
,
"maxFirstStreamCompDelay"
)
->
i32
;
}
break
;
}
case
'd'
:
{
if
(
strcasecmp
(
"mDebugFlag"
,
name
)
==
0
)
{
mDebugFlag
=
cfgGetItem
(
pCfg
,
"mDebugFlag"
)
->
i32
;
}
break
;
}
case
'i'
:
{
if
(
strcasecmp
(
"minimalTempDirGB"
,
name
)
==
0
)
{
tsTempSpace
.
reserved
=
cfgGetItem
(
pCfg
,
"minimalTempDirGB"
)
->
fval
;
}
else
if
(
strcasecmp
(
"minimalDataDirGB"
,
name
)
==
0
)
{
tsDataSpace
.
reserved
=
cfgGetItem
(
pCfg
,
"minimalDataDirGB"
)
->
fval
;
}
else
if
(
strcasecmp
(
"minSlidingTime"
,
name
)
==
0
)
{
tsMinSlidingTime
=
cfgGetItem
(
pCfg
,
"minSlidingTime"
)
->
i32
;
}
else
if
(
strcasecmp
(
"minIntervalTime"
,
name
)
==
0
)
{
tsMinIntervalTime
=
cfgGetItem
(
pCfg
,
"minIntervalTime"
)
->
i32
;
}
else
if
(
strcasecmp
(
"minimalLogDirGB"
,
name
)
==
0
)
{
tsLogSpace
.
reserved
=
cfgGetItem
(
pCfg
,
"minimalLogDirGB"
)
->
fval
;
}
break
;
}
case
'n'
:
{
if
(
strcasecmp
(
"mnodeShmSize"
,
name
)
==
0
)
{
tsMnodeShmSize
=
cfgGetItem
(
pCfg
,
"mnodeShmSize"
)
->
i32
;
}
break
;
}
case
'o'
:
{
if
(
strcasecmp
(
"monitor"
,
name
)
==
0
)
{
tsEnableMonitor
=
cfgGetItem
(
pCfg
,
"monitor"
)
->
bval
;
}
else
if
(
strcasecmp
(
"monitorInterval"
,
name
)
==
0
)
{
tsMonitorInterval
=
cfgGetItem
(
pCfg
,
"monitorInterval"
)
->
i32
;
}
else
if
(
strcasecmp
(
"monitorFqdn"
,
name
)
==
0
)
{
tstrncpy
(
tsMonitorFqdn
,
cfgGetItem
(
pCfg
,
"monitorFqdn"
)
->
str
,
TSDB_FQDN_LEN
);
}
else
if
(
strcasecmp
(
"monitorPort"
,
name
)
==
0
)
{
tsMonitorPort
=
(
uint16_t
)
cfgGetItem
(
pCfg
,
"monitorPort"
)
->
i32
;
}
else
if
(
strcasecmp
(
"monitorMaxLogs"
,
name
)
==
0
)
{
tsMonitorMaxLogs
=
cfgGetItem
(
pCfg
,
"monitorMaxLogs"
)
->
i32
;
}
else
if
(
strcasecmp
(
"monitorComp"
,
name
)
==
0
)
{
tsMonitorComp
=
cfgGetItem
(
pCfg
,
"monitorComp"
)
->
bval
;
}
break
;
}
case
'q'
:
{
if
(
strcasecmp
(
"mqRebalanceInterval"
,
name
)
==
0
)
{
tsMqRebalanceInterval
=
cfgGetItem
(
pCfg
,
"mqRebalanceInterval"
)
->
i32
;
}
break
;
}
case
'u'
:
{
if
(
strcasecmp
(
"multiProcess"
,
name
)
==
0
)
{
tsMultiProcess
=
cfgGetItem
(
pCfg
,
"multiProcess"
)
->
bval
;
}
break
;
}
default:
terrno
=
TSDB_CODE_CFG_NOT_FOUND
;
return
-
1
;
}
break
;
}
case
'n'
:
{
if
(
strcasecmp
(
"numOfTaskQueueThreads"
,
name
)
==
0
)
{
tsNumOfTaskQueueThreads
=
cfgGetItem
(
pCfg
,
"numOfTaskQueueThreads"
)
->
i32
;
}
else
if
(
strcasecmp
(
"numOfRpcThreads"
,
name
)
==
0
)
{
tsNumOfRpcThreads
=
cfgGetItem
(
pCfg
,
"numOfRpcThreads"
)
->
i32
;
}
else
if
(
strcasecmp
(
"numOfCommitThreads"
,
name
)
==
0
)
{
tsNumOfCommitThreads
=
cfgGetItem
(
pCfg
,
"numOfCommitThreads"
)
->
i32
;
}
else
if
(
strcasecmp
(
"numOfMnodeQueryThreads"
,
name
)
==
0
)
{
tsNumOfMnodeQueryThreads
=
cfgGetItem
(
pCfg
,
"numOfMnodeQueryThreads"
)
->
i32
;
}
else
if
(
strcasecmp
(
"numOfMnodeReadThreads"
,
name
)
==
0
)
{
tsNumOfMnodeReadThreads
=
cfgGetItem
(
pCfg
,
"numOfMnodeReadThreads"
)
->
i32
;
}
else
if
(
strcasecmp
(
"numOfVnodeQueryThreads"
,
name
)
==
0
)
{
tsNumOfVnodeQueryThreads
=
cfgGetItem
(
pCfg
,
"numOfVnodeQueryThreads"
)
->
i32
;
}
else
if
(
strcasecmp
(
"numOfVnodeFetchThreads"
,
name
)
==
0
)
{
tsNumOfVnodeFetchThreads
=
cfgGetItem
(
pCfg
,
"numOfVnodeFetchThreads"
)
->
i32
;
}
else
if
(
strcasecmp
(
"numOfVnodeWriteThreads"
,
name
)
==
0
)
{
tsNumOfVnodeWriteThreads
=
cfgGetItem
(
pCfg
,
"numOfVnodeWriteThreads"
)
->
i32
;
}
else
if
(
strcasecmp
(
"numOfVnodeSyncThreads"
,
name
)
==
0
)
{
tsNumOfVnodeSyncThreads
=
cfgGetItem
(
pCfg
,
"numOfVnodeSyncThreads"
)
->
i32
;
}
else
if
(
strcasecmp
(
"numOfVnodeMergeThreads"
,
name
)
==
0
)
{
tsNumOfVnodeMergeThreads
=
cfgGetItem
(
pCfg
,
"numOfVnodeMergeThreads"
)
->
i32
;
}
else
if
(
strcasecmp
(
"numOfQnodeQueryThreads"
,
name
)
==
0
)
{
tsNumOfQnodeQueryThreads
=
cfgGetItem
(
pCfg
,
"numOfQnodeQueryThreads"
)
->
i32
;
}
else
if
(
strcasecmp
(
"numOfQnodeFetchThreads"
,
name
)
==
0
)
{
tsNumOfQnodeFetchThreads
=
cfgGetItem
(
pCfg
,
"numOfQnodeFetchThreads"
)
->
i32
;
}
else
if
(
strcasecmp
(
"numOfSnodeSharedThreads"
,
name
)
==
0
)
{
tsNumOfSnodeSharedThreads
=
cfgGetItem
(
pCfg
,
"numOfSnodeSharedThreads"
)
->
i32
;
}
else
if
(
strcasecmp
(
"numOfSnodeUniqueThreads"
,
name
)
==
0
)
{
tsNumOfSnodeUniqueThreads
=
cfgGetItem
(
pCfg
,
"numOfSnodeUniqueThreads"
)
->
i32
;
}
else
if
(
strcasecmp
(
"numOfLogLines"
,
name
)
==
0
)
{
tsNumOfLogLines
=
cfgGetItem
(
pCfg
,
"numOfLogLines"
)
->
i32
;
}
break
;
}
case
'p'
:
{
if
(
strcasecmp
(
"printAuth"
,
name
)
==
0
)
{
tsPrintAuth
=
cfgGetItem
(
pCfg
,
"printAuth"
)
->
bval
;
}
break
;
}
case
'q'
:
{
if
(
strcasecmp
(
"queryPolicy"
,
name
)
==
0
)
{
tsQueryPolicy
=
cfgGetItem
(
pCfg
,
"queryPolicy"
)
->
i32
;
}
else
if
(
strcasecmp
(
"querySmaOptimize"
,
name
)
==
0
)
{
tsQuerySmaOptimize
=
cfgGetItem
(
pCfg
,
"querySmaOptimize"
)
->
i32
;
}
else
if
(
strcasecmp
(
"queryBufferSize"
,
name
)
==
0
)
{
tsQueryBufferSize
=
cfgGetItem
(
pCfg
,
"queryBufferSize"
)
->
i32
;
if
(
tsQueryBufferSize
>=
0
)
{
tsQueryBufferSizeBytes
=
tsQueryBufferSize
*
1048576UL
;
}
}
else
if
(
strcasecmp
(
"qnodeShmSize"
,
name
)
==
0
)
{
tsQnodeShmSize
=
cfgGetItem
(
pCfg
,
"qnodeShmSize"
)
->
i32
;
}
else
if
(
strcasecmp
(
"qDebugFlag"
,
name
)
==
0
)
{
qDebugFlag
=
cfgGetItem
(
pCfg
,
"qDebugFlag"
)
->
i32
;
}
break
;
}
case
'r'
:
{
if
(
strcasecmp
(
"retryStreamCompDelay"
,
name
)
==
0
)
{
tsRetryStreamCompDelay
=
cfgGetItem
(
pCfg
,
"retryStreamCompDelay"
)
->
i32
;
}
else
if
(
strcasecmp
(
"retrieveBlockingModel"
,
name
)
==
0
)
{
tsRetrieveBlockingModel
=
cfgGetItem
(
pCfg
,
"retrieveBlockingModel"
)
->
bval
;
}
else
if
(
strcasecmp
(
"rpcQueueMemoryAllowed"
,
name
)
==
0
)
{
tsRpcQueueMemoryAllowed
=
cfgGetItem
(
pCfg
,
"rpcQueueMemoryAllowed"
)
->
i64
;
}
else
if
(
strcasecmp
(
"rpcDebugFlag"
,
name
)
==
0
)
{
rpcDebugFlag
=
cfgGetItem
(
pCfg
,
"rpcDebugFlag"
)
->
i32
;
}
break
;
}
case
's'
:
{
if
(
strcasecmp
(
"secondEp"
,
name
)
==
0
)
{
SConfigItem
*
pSecondpItem
=
cfgGetItem
(
pCfg
,
"secondEp"
);
SEp
secondEp
=
{
0
};
taosGetFqdnPortFromEp
(
strlen
(
pSecondpItem
->
str
)
==
0
?
tsFirst
:
pSecondpItem
->
str
,
&
secondEp
);
snprintf
(
tsSecond
,
sizeof
(
tsSecond
),
"%s:%u"
,
secondEp
.
fqdn
,
secondEp
.
port
);
cfgSetItem
(
pCfg
,
"secondEp"
,
tsSecond
,
pSecondpItem
->
stype
);
}
else
if
(
strcasecmp
(
"smlChildTableName"
,
name
)
==
0
)
{
tstrncpy
(
tsSmlChildTableName
,
cfgGetItem
(
pCfg
,
"smlChildTableName"
)
->
str
,
TSDB_TABLE_NAME_LEN
);
}
else
if
(
strcasecmp
(
"smlTagName"
,
name
)
==
0
)
{
tstrncpy
(
tsSmlTagName
,
cfgGetItem
(
pCfg
,
"smlTagName"
)
->
str
,
TSDB_COL_NAME_LEN
);
}
else
if
(
strcasecmp
(
"smlDataFormat"
,
name
)
==
0
)
{
tsSmlDataFormat
=
cfgGetItem
(
pCfg
,
"smlDataFormat"
)
->
bval
;
}
else
if
(
strcasecmp
(
"shellActivityTimer"
,
name
)
==
0
)
{
tsShellActivityTimer
=
cfgGetItem
(
pCfg
,
"shellActivityTimer"
)
->
i32
;
}
else
if
(
strcasecmp
(
"supportVnodes"
,
name
)
==
0
)
{
tsNumOfSupportVnodes
=
cfgGetItem
(
pCfg
,
"supportVnodes"
)
->
i32
;
}
else
if
(
strcasecmp
(
"statusInterval"
,
name
)
==
0
)
{
tsStatusInterval
=
cfgGetItem
(
pCfg
,
"statusInterval"
)
->
i32
;
}
else
if
(
strcasecmp
(
"streamCompDelayRatio"
,
name
)
==
0
)
{
tsStreamComputDelayRatio
=
cfgGetItem
(
pCfg
,
"streamCompDelayRatio"
)
->
fval
;
}
else
if
(
strcasecmp
(
"slaveQuery"
,
name
)
==
0
)
{
tsEnableSlaveQuery
=
cfgGetItem
(
pCfg
,
"slaveQuery"
)
->
bval
;
}
else
if
(
strcasecmp
(
"snodeShmSize"
,
name
)
==
0
)
{
tsSnodeShmSize
=
cfgGetItem
(
pCfg
,
"snodeShmSize"
)
->
i32
;
}
else
if
(
strcasecmp
(
"serverPort"
,
name
)
==
0
)
{
tstrncpy
(
tsLocalFqdn
,
cfgGetItem
(
pCfg
,
"fqdn"
)
->
str
,
TSDB_FQDN_LEN
);
tsServerPort
=
(
uint16_t
)
cfgGetItem
(
pCfg
,
"serverPort"
)
->
i32
;
snprintf
(
tsLocalEp
,
sizeof
(
tsLocalEp
),
"%s:%u"
,
tsLocalFqdn
,
tsServerPort
);
char
defaultFirstEp
[
TSDB_EP_LEN
]
=
{
0
};
snprintf
(
defaultFirstEp
,
TSDB_EP_LEN
,
"%s:%u"
,
tsLocalFqdn
,
tsServerPort
);
SConfigItem
*
pFirstEpItem
=
cfgGetItem
(
pCfg
,
"firstEp"
);
SEp
firstEp
=
{
0
};
taosGetFqdnPortFromEp
(
strlen
(
pFirstEpItem
->
str
)
==
0
?
defaultFirstEp
:
pFirstEpItem
->
str
,
&
firstEp
);
snprintf
(
tsFirst
,
sizeof
(
tsFirst
),
"%s:%u"
,
firstEp
.
fqdn
,
firstEp
.
port
);
cfgSetItem
(
pCfg
,
"firstEp"
,
tsFirst
,
pFirstEpItem
->
stype
);
}
else
if
(
strcasecmp
(
"sDebugFlag"
,
name
)
==
0
)
{
sDebugFlag
=
cfgGetItem
(
pCfg
,
"sDebugFlag"
)
->
i32
;
}
else
if
(
strcasecmp
(
"smaDebugFlag"
,
name
)
==
0
)
{
smaDebugFlag
=
cfgGetItem
(
pCfg
,
"smaDebugFlag"
)
->
i32
;
}
break
;
}
case
't'
:
{
if
(
strcasecmp
(
"timezone"
,
name
)
==
0
)
{
SConfigItem
*
pItem
=
cfgGetItem
(
pCfg
,
"timezone"
);
osSetTimezone
(
pItem
->
str
);
uDebug
(
"timezone format changed from %s to %s"
,
pItem
->
str
,
tsTimezoneStr
);
cfgSetItem
(
pCfg
,
"timezone"
,
tsTimezoneStr
,
pItem
->
stype
);
}
else
if
(
strcasecmp
(
"tempDir"
,
name
)
==
0
)
{
tstrncpy
(
tsTempDir
,
cfgGetItem
(
pCfg
,
"tempDir"
)
->
str
,
PATH_MAX
);
taosExpandDir
(
tsTempDir
,
tsTempDir
,
PATH_MAX
);
if
(
taosMulMkDir
(
tsTempDir
)
!=
0
)
{
uError
(
"failed to create tempDir:%s since %s"
,
tsTempDir
,
terrstr
());
return
-
1
;
}
}
else
if
(
strcasecmp
(
"telemetryReporting"
,
name
)
==
0
)
{
tsEnableTelem
=
cfgGetItem
(
pCfg
,
"telemetryReporting"
)
->
bval
;
}
else
if
(
strcasecmp
(
"telemetryInterval"
,
name
)
==
0
)
{
tsTelemInterval
=
cfgGetItem
(
pCfg
,
"telemetryInterval"
)
->
i32
;
}
else
if
(
strcasecmp
(
"telemetryServer"
,
name
)
==
0
)
{
tstrncpy
(
tsTelemServer
,
cfgGetItem
(
pCfg
,
"telemetryServer"
)
->
str
,
TSDB_FQDN_LEN
);
}
else
if
(
strcasecmp
(
"telemetryPort"
,
name
)
==
0
)
{
tsTelemPort
=
(
uint16_t
)
cfgGetItem
(
pCfg
,
"telemetryPort"
)
->
i32
;
}
else
if
(
strcasecmp
(
"transPullupInterval"
,
name
)
==
0
)
{
tsTransPullupInterval
=
cfgGetItem
(
pCfg
,
"transPullupInterval"
)
->
i32
;
}
else
if
(
strcasecmp
(
"tmrDebugFlag"
,
name
)
==
0
)
{
tmrDebugFlag
=
cfgGetItem
(
pCfg
,
"tmrDebugFlag"
)
->
i32
;
}
else
if
(
strcasecmp
(
"tsdbDebugFlag"
,
name
)
==
0
)
{
tsdbDebugFlag
=
cfgGetItem
(
pCfg
,
"tsdbDebugFlag"
)
->
i32
;
}
else
if
(
strcasecmp
(
"tqDebugFlag"
,
name
)
==
0
)
{
tqDebugFlag
=
cfgGetItem
(
pCfg
,
"tqDebugFlag"
)
->
i32
;
}
break
;
}
case
'u'
:
{
if
(
strcasecmp
(
"udf"
,
name
)
==
0
)
{
tsStartUdfd
=
cfgGetItem
(
pCfg
,
"udf"
)
->
bval
;
}
else
if
(
strcasecmp
(
"uDebugFlag"
,
name
)
==
0
)
{
uDebugFlag
=
cfgGetItem
(
pCfg
,
"uDebugFlag"
)
->
i32
;
}
break
;
}
case
'v'
:
{
if
(
strcasecmp
(
"vnodeShmSize"
,
name
)
==
0
)
{
tsVnodeShmSize
=
cfgGetItem
(
pCfg
,
"vnodeShmSize"
)
->
i32
;
}
else
if
(
strcasecmp
(
"vDebugFlag"
,
name
)
==
0
)
{
vDebugFlag
=
cfgGetItem
(
pCfg
,
"vDebugFlag"
)
->
i32
;
}
break
;
}
case
'w'
:
{
if
(
strcasecmp
(
"wDebugFlag"
,
name
)
==
0
)
{
wDebugFlag
=
cfgGetItem
(
pCfg
,
"wDebugFlag"
)
->
i32
;
}
break
;
}
default:
terrno
=
TSDB_CODE_CFG_NOT_FOUND
;
return
-
1
;
}
return
0
;
}
int32_t
taosCreateLog
(
const
char
*
logname
,
int32_t
logFileNum
,
const
char
*
cfgDir
,
const
char
**
envCmd
,
int32_t
taosCreateLog
(
const
char
*
logname
,
int32_t
logFileNum
,
const
char
*
cfgDir
,
const
char
**
envCmd
,
const
char
*
envFile
,
char
*
apolloUrl
,
SArray
*
pArgs
,
bool
tsc
)
{
const
char
*
envFile
,
char
*
apolloUrl
,
SArray
*
pArgs
,
bool
tsc
)
{
if
(
tsCfg
==
NULL
)
osDefaultInit
();
if
(
tsCfg
==
NULL
)
osDefaultInit
();
...
...
source/common/src/tmsg.c
浏览文件 @
291aab04
...
@@ -539,7 +539,7 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
...
@@ -539,7 +539,7 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
const
char
*
pFunc
=
taosArrayGet
(
pReq
->
pFuncs
,
i
);
const
char
*
pFunc
=
taosArrayGet
(
pReq
->
pFuncs
,
i
);
if
(
tEncodeCStr
(
&
encoder
,
pFunc
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pFunc
)
<
0
)
return
-
1
;
}
}
tEndEncode
(
&
encoder
);
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
int32_t
tlen
=
encoder
.
pos
;
...
@@ -621,7 +621,7 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
...
@@ -621,7 +621,7 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
if
(
NULL
==
pReq
->
pFuncs
)
return
-
1
;
if
(
NULL
==
pReq
->
pFuncs
)
return
-
1
;
}
}
for
(
int32_t
i
=
0
;
i
<
numOfFuncs
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfFuncs
;
++
i
)
{
char
*
pFunc
=
NULL
;
char
*
pFunc
=
NULL
;
if
(
tDecodeCStrAlloc
(
&
decoder
,
&
pFunc
)
<
0
)
return
-
1
;
if
(
tDecodeCStrAlloc
(
&
decoder
,
&
pFunc
)
<
0
)
return
-
1
;
if
(
taosArrayPush
(
pReq
->
pFuncs
,
pFunc
)
==
NULL
)
{
if
(
taosArrayPush
(
pReq
->
pFuncs
,
pFunc
)
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
@@ -783,6 +783,8 @@ int32_t tSerializeSMCreateSmaReq(void *buf, int32_t bufLen, SMCreateSmaReq *pReq
...
@@ -783,6 +783,8 @@ int32_t tSerializeSMCreateSmaReq(void *buf, int32_t bufLen, SMCreateSmaReq *pReq
if
(
tEncodeI64
(
&
encoder
,
pReq
->
interval
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
interval
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
offset
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
offset
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
sliding
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
sliding
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
watermark
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
maxDelay
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
exprLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
exprLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
tagsFilterLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
tagsFilterLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
sqlLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
sqlLen
)
<
0
)
return
-
1
;
...
@@ -821,6 +823,8 @@ int32_t tDeserializeSMCreateSmaReq(void *buf, int32_t bufLen, SMCreateSmaReq *pR
...
@@ -821,6 +823,8 @@ int32_t tDeserializeSMCreateSmaReq(void *buf, int32_t bufLen, SMCreateSmaReq *pR
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
interval
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
interval
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
offset
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
offset
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
sliding
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
sliding
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
watermark
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
maxDelay
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
exprLen
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
exprLen
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
tagsFilterLen
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
tagsFilterLen
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
sqlLen
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
sqlLen
)
<
0
)
return
-
1
;
...
@@ -1868,7 +1872,7 @@ int32_t tSerializeSTableCfgRsp(void *buf, int32_t bufLen, STableCfgRsp *pRsp) {
...
@@ -1868,7 +1872,7 @@ int32_t tSerializeSTableCfgRsp(void *buf, int32_t bufLen, STableCfgRsp *pRsp) {
if
(
tEncodeI64
(
&
encoder
,
pRsp
->
watermark1
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pRsp
->
watermark1
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pRsp
->
watermark2
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pRsp
->
watermark2
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pRsp
->
ttl
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pRsp
->
ttl
)
<
0
)
return
-
1
;
int32_t
numOfFuncs
=
taosArrayGetSize
(
pRsp
->
pFuncs
);
int32_t
numOfFuncs
=
taosArrayGetSize
(
pRsp
->
pFuncs
);
if
(
tEncodeI32
(
&
encoder
,
numOfFuncs
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
numOfFuncs
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
numOfFuncs
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfFuncs
;
++
i
)
{
...
@@ -1876,19 +1880,19 @@ int32_t tSerializeSTableCfgRsp(void *buf, int32_t bufLen, STableCfgRsp *pRsp) {
...
@@ -1876,19 +1880,19 @@ int32_t tSerializeSTableCfgRsp(void *buf, int32_t bufLen, STableCfgRsp *pRsp) {
if
(
tEncodeCStr
(
&
encoder
,
pFunc
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pFunc
)
<
0
)
return
-
1
;
}
}
if
(
tEncodeI32
(
&
encoder
,
pRsp
->
commentLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pRsp
->
commentLen
)
<
0
)
return
-
1
;
if
(
pRsp
->
commentLen
>
0
)
{
if
(
pRsp
->
commentLen
>
0
)
{
if
(
tEncodeCStr
(
&
encoder
,
pRsp
->
pComment
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pRsp
->
pComment
)
<
0
)
return
-
1
;
}
}
for
(
int32_t
i
=
0
;
i
<
pRsp
->
numOfColumns
+
pRsp
->
numOfTags
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pRsp
->
numOfColumns
+
pRsp
->
numOfTags
;
++
i
)
{
SSchema
*
pSchema
=
&
pRsp
->
pSchemas
[
i
];
SSchema
*
pSchema
=
&
pRsp
->
pSchemas
[
i
];
if
(
tEncodeSSchema
(
&
encoder
,
pSchema
)
<
0
)
return
-
1
;
if
(
tEncodeSSchema
(
&
encoder
,
pSchema
)
<
0
)
return
-
1
;
}
}
if
(
tEncodeI32
(
&
encoder
,
pRsp
->
tagsLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pRsp
->
tagsLen
)
<
0
)
return
-
1
;
if
(
tEncodeBinary
(
&
encoder
,
pRsp
->
pTags
,
pRsp
->
tagsLen
)
<
0
)
return
-
1
;
if
(
tEncodeBinary
(
&
encoder
,
pRsp
->
pTags
,
pRsp
->
tagsLen
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
int32_t
tlen
=
encoder
.
pos
;
...
@@ -1945,7 +1949,7 @@ int32_t tDeserializeSTableCfgRsp(void *buf, int32_t bufLen, STableCfgRsp *pRsp)
...
@@ -1945,7 +1949,7 @@ int32_t tDeserializeSTableCfgRsp(void *buf, int32_t bufLen, STableCfgRsp *pRsp)
}
}
if
(
tDecodeI32
(
&
decoder
,
&
pRsp
->
tagsLen
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pRsp
->
tagsLen
)
<
0
)
return
-
1
;
if
(
tDecodeBinaryAlloc
(
&
decoder
,
(
void
**
)
&
pRsp
->
pTags
,
NULL
)
<
0
)
return
-
1
;
if
(
tDecodeBinaryAlloc
(
&
decoder
,
(
void
**
)
&
pRsp
->
pTags
,
NULL
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tEndDecode
(
&
decoder
);
...
@@ -1961,7 +1965,7 @@ void tFreeSTableCfgRsp(STableCfgRsp *pRsp) {
...
@@ -1961,7 +1965,7 @@ void tFreeSTableCfgRsp(STableCfgRsp *pRsp) {
taosMemoryFreeClear
(
pRsp
->
pComment
);
taosMemoryFreeClear
(
pRsp
->
pComment
);
taosMemoryFreeClear
(
pRsp
->
pSchemas
);
taosMemoryFreeClear
(
pRsp
->
pSchemas
);
taosMemoryFreeClear
(
pRsp
->
pTags
);
taosMemoryFreeClear
(
pRsp
->
pTags
);
taosArrayDestroy
(
pRsp
->
pFuncs
);
taosArrayDestroy
(
pRsp
->
pFuncs
);
}
}
...
...
source/common/src/tname.c
浏览文件 @
291aab04
...
@@ -214,6 +214,20 @@ int32_t tNameSetDbName(SName* dst, int32_t acct, const char* dbName, size_t name
...
@@ -214,6 +214,20 @@ int32_t tNameSetDbName(SName* dst, int32_t acct, const char* dbName, size_t name
return
0
;
return
0
;
}
}
int32_t
tNameAddTbName
(
SName
*
dst
,
const
char
*
tbName
,
size_t
nameLen
)
{
assert
(
dst
!=
NULL
&&
tbName
!=
NULL
&&
nameLen
>
0
);
// too long account id or too long db name
if
(
nameLen
>=
tListLen
(
dst
->
tname
)
||
nameLen
<=
0
)
{
return
-
1
;
}
dst
->
type
=
TSDB_TABLE_NAME_T
;
tstrncpy
(
dst
->
tname
,
tbName
,
nameLen
+
1
);
return
0
;
}
int32_t
tNameSetAcctId
(
SName
*
dst
,
int32_t
acctId
)
{
int32_t
tNameSetAcctId
(
SName
*
dst
,
int32_t
acctId
)
{
assert
(
dst
!=
NULL
);
assert
(
dst
!=
NULL
);
dst
->
acctId
=
acctId
;
dst
->
acctId
=
acctId
;
...
...
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
浏览文件 @
291aab04
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
#include "mmInt.h"
#include "mmInt.h"
void
mmGetMonitorInfo
(
SMnodeMgmt
*
pMgmt
,
SMonMmInfo
*
pInfo
)
{
void
mmGetMonitorInfo
(
SMnodeMgmt
*
pMgmt
,
SMonMmInfo
*
pInfo
)
{
mndGetMonitorInfo
(
pMgmt
->
pMnode
,
&
pInfo
->
cluster
,
&
pInfo
->
vgroup
,
&
pInfo
->
grant
);
mndGetMonitorInfo
(
pMgmt
->
pMnode
,
&
pInfo
->
cluster
,
&
pInfo
->
vgroup
,
&
pInfo
->
stb
,
&
pInfo
->
grant
);
}
}
int32_t
mmProcessGetMonitorInfoReq
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
int32_t
mmProcessGetMonitorInfoReq
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
...
...
source/dnode/mnode/impl/src/mndMain.c
浏览文件 @
291aab04
...
@@ -614,7 +614,7 @@ int64_t mndGenerateUid(char *name, int32_t len) {
...
@@ -614,7 +614,7 @@ int64_t mndGenerateUid(char *name, int32_t len) {
}
}
int32_t
mndGetMonitorInfo
(
SMnode
*
pMnode
,
SMonClusterInfo
*
pClusterInfo
,
SMonVgroupInfo
*
pVgroupInfo
,
int32_t
mndGetMonitorInfo
(
SMnode
*
pMnode
,
SMonClusterInfo
*
pClusterInfo
,
SMonVgroupInfo
*
pVgroupInfo
,
SMonGrantInfo
*
pGrantInfo
)
{
SMon
StbInfo
*
pStbInfo
,
SMon
GrantInfo
*
pGrantInfo
)
{
if
(
mndAcquireRpcRef
(
pMnode
)
!=
0
)
return
-
1
;
if
(
mndAcquireRpcRef
(
pMnode
)
!=
0
)
return
-
1
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
...
@@ -623,7 +623,9 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
...
@@ -623,7 +623,9 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
pClusterInfo
->
dnodes
=
taosArrayInit
(
sdbGetSize
(
pSdb
,
SDB_DNODE
),
sizeof
(
SMonDnodeDesc
));
pClusterInfo
->
dnodes
=
taosArrayInit
(
sdbGetSize
(
pSdb
,
SDB_DNODE
),
sizeof
(
SMonDnodeDesc
));
pClusterInfo
->
mnodes
=
taosArrayInit
(
sdbGetSize
(
pSdb
,
SDB_MNODE
),
sizeof
(
SMonMnodeDesc
));
pClusterInfo
->
mnodes
=
taosArrayInit
(
sdbGetSize
(
pSdb
,
SDB_MNODE
),
sizeof
(
SMonMnodeDesc
));
pVgroupInfo
->
vgroups
=
taosArrayInit
(
sdbGetSize
(
pSdb
,
SDB_VGROUP
),
sizeof
(
SMonVgroupDesc
));
pVgroupInfo
->
vgroups
=
taosArrayInit
(
sdbGetSize
(
pSdb
,
SDB_VGROUP
),
sizeof
(
SMonVgroupDesc
));
if
(
pClusterInfo
->
dnodes
==
NULL
||
pClusterInfo
->
mnodes
==
NULL
||
pVgroupInfo
->
vgroups
==
NULL
)
{
pStbInfo
->
stbs
=
taosArrayInit
(
sdbGetSize
(
pSdb
,
SDB_STB
),
sizeof
(
SMonStbDesc
));
if
(
pClusterInfo
->
dnodes
==
NULL
||
pClusterInfo
->
mnodes
==
NULL
||
pVgroupInfo
->
vgroups
==
NULL
||
pStbInfo
->
stbs
==
NULL
)
{
mndReleaseRpcRef
(
pMnode
);
mndReleaseRpcRef
(
pMnode
);
return
-
1
;
return
-
1
;
}
}
...
@@ -714,6 +716,27 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
...
@@ -714,6 +716,27 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
sdbRelease
(
pSdb
,
pVgroup
);
sdbRelease
(
pSdb
,
pVgroup
);
}
}
// stb info
pIter
=
NULL
;
while
(
1
)
{
SStbObj
*
pStb
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_STB
,
pIter
,
(
void
**
)
&
pStb
);
if
(
pIter
==
NULL
)
break
;
SMonStbDesc
desc
=
{
0
};
SName
name1
=
{
0
};
tNameFromString
(
&
name1
,
pStb
->
db
,
T_NAME_ACCT
|
T_NAME_DB
|
T_NAME_TABLE
);
tNameGetDbName
(
&
name1
,
desc
.
database_name
);
SName
name2
=
{
0
};
tNameFromString
(
&
name2
,
pStb
->
name
,
T_NAME_ACCT
|
T_NAME_DB
|
T_NAME_TABLE
);
tstrncpy
(
desc
.
stb_name
,
tNameGetTableName
(
&
name2
),
TSDB_TABLE_NAME_LEN
);
taosArrayPush
(
pStbInfo
->
stbs
,
&
desc
);
sdbRelease
(
pSdb
,
pStb
);
}
// grant info
// grant info
pGrantInfo
->
expire_time
=
(
pMnode
->
grant
.
expireTimeMS
-
ms
)
/
86400000
.
0
f
;
pGrantInfo
->
expire_time
=
(
pMnode
->
grant
.
expireTimeMS
-
ms
)
/
86400000
.
0
f
;
pGrantInfo
->
timeseries_total
=
pMnode
->
grant
.
timeseriesAllowed
;
pGrantInfo
->
timeseries_total
=
pMnode
->
grant
.
timeseriesAllowed
;
...
...
source/dnode/vnode/src/tq/tqExec.c
浏览文件 @
291aab04
...
@@ -66,6 +66,7 @@ int32_t tqScanSnapshot(STQ* pTq, const STqExecHandle* pExec, SMqDataBlkRsp* pRsp
...
@@ -66,6 +66,7 @@ int32_t tqScanSnapshot(STQ* pTq, const STqExecHandle* pExec, SMqDataBlkRsp* pRsp
if
(
qStreamScanSnapshot
(
task
)
<
0
)
{
if
(
qStreamScanSnapshot
(
task
)
<
0
)
{
ASSERT
(
0
);
ASSERT
(
0
);
}
}
// set version
while
(
1
)
{
while
(
1
)
{
SSDataBlock
*
pDataBlock
=
NULL
;
SSDataBlock
*
pDataBlock
=
NULL
;
uint64_t
ts
=
0
;
uint64_t
ts
=
0
;
...
...
source/dnode/vnode/src/tq/tqOffset.c
浏览文件 @
291aab04
...
@@ -44,6 +44,7 @@ STqOffsetStore* tqOffsetOpen(STQ* pTq) {
...
@@ -44,6 +44,7 @@ STqOffsetStore* tqOffsetOpen(STQ* pTq) {
}
}
char
*
fname
=
buildFileName
(
pStore
->
pTq
->
path
);
char
*
fname
=
buildFileName
(
pStore
->
pTq
->
path
);
TdFilePtr
pFile
=
taosOpenFile
(
fname
,
TD_FILE_READ
);
TdFilePtr
pFile
=
taosOpenFile
(
fname
,
TD_FILE_READ
);
taosMemoryFree
(
fname
);
if
(
pFile
!=
NULL
)
{
if
(
pFile
!=
NULL
)
{
STqOffsetHead
head
=
{
0
};
STqOffsetHead
head
=
{
0
};
int64_t
code
;
int64_t
code
;
...
@@ -77,7 +78,6 @@ STqOffsetStore* tqOffsetOpen(STQ* pTq) {
...
@@ -77,7 +78,6 @@ STqOffsetStore* tqOffsetOpen(STQ* pTq) {
}
}
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
taosMemoryFree
(
fname
);
}
}
return
pStore
;
return
pStore
;
}
}
...
@@ -102,6 +102,7 @@ int32_t tqOffsetSnapshot(STqOffsetStore* pStore) {
...
@@ -102,6 +102,7 @@ int32_t tqOffsetSnapshot(STqOffsetStore* pStore) {
// TODO file name should be with a version
// TODO file name should be with a version
char
*
fname
=
buildFileName
(
pStore
->
pTq
->
path
);
char
*
fname
=
buildFileName
(
pStore
->
pTq
->
path
);
TdFilePtr
pFile
=
taosOpenFile
(
fname
,
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_APPEND
);
TdFilePtr
pFile
=
taosOpenFile
(
fname
,
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_APPEND
);
taosMemoryFree
(
fname
);
if
(
pFile
==
NULL
)
{
if
(
pFile
==
NULL
)
{
ASSERT
(
0
);
ASSERT
(
0
);
return
-
1
;
return
-
1
;
...
@@ -140,6 +141,5 @@ int32_t tqOffsetSnapshot(STqOffsetStore* pStore) {
...
@@ -140,6 +141,5 @@ int32_t tqOffsetSnapshot(STqOffsetStore* pStore) {
}
}
// close and rename file
// close and rename file
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
taosMemoryFree
(
fname
);
return
0
;
return
0
;
}
}
source/dnode/vnode/src/tq/tqRead.c
浏览文件 @
291aab04
...
@@ -151,6 +151,7 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReadHandle* pHandle, uint64_
...
@@ -151,6 +151,7 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReadHandle* pHandle, uint64_
int32_t
sversion
=
htonl
(
pHandle
->
pBlock
->
sversion
);
int32_t
sversion
=
htonl
(
pHandle
->
pBlock
->
sversion
);
if
(
pHandle
->
cachedSchemaSuid
==
0
||
pHandle
->
cachedSchemaVer
!=
sversion
||
if
(
pHandle
->
cachedSchemaSuid
==
0
||
pHandle
->
cachedSchemaVer
!=
sversion
||
pHandle
->
cachedSchemaSuid
!=
pHandle
->
msgIter
.
suid
)
{
pHandle
->
cachedSchemaSuid
!=
pHandle
->
msgIter
.
suid
)
{
if
(
pHandle
->
pSchema
)
taosMemoryFree
(
pHandle
->
pSchema
);
pHandle
->
pSchema
=
metaGetTbTSchema
(
pHandle
->
pVnodeMeta
,
pHandle
->
msgIter
.
uid
,
sversion
);
pHandle
->
pSchema
=
metaGetTbTSchema
(
pHandle
->
pVnodeMeta
,
pHandle
->
msgIter
.
uid
,
sversion
);
if
(
pHandle
->
pSchema
==
NULL
)
{
if
(
pHandle
->
pSchema
==
NULL
)
{
tqWarn
(
"cannot found tsschema for table: uid: %ld (suid: %ld), version %d, possibly dropped table"
,
tqWarn
(
"cannot found tsschema for table: uid: %ld (suid: %ld), version %d, possibly dropped table"
,
...
@@ -161,6 +162,7 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReadHandle* pHandle, uint64_
...
@@ -161,6 +162,7 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReadHandle* pHandle, uint64_
}
}
// this interface use suid instead of uid
// this interface use suid instead of uid
if
(
pHandle
->
pSchemaWrapper
)
tDeleteSSchemaWrapper
(
pHandle
->
pSchemaWrapper
);
pHandle
->
pSchemaWrapper
=
metaGetTableSchema
(
pHandle
->
pVnodeMeta
,
pHandle
->
msgIter
.
uid
,
sversion
,
true
);
pHandle
->
pSchemaWrapper
=
metaGetTableSchema
(
pHandle
->
pVnodeMeta
,
pHandle
->
msgIter
.
uid
,
sversion
,
true
);
if
(
pHandle
->
pSchemaWrapper
==
NULL
)
{
if
(
pHandle
->
pSchemaWrapper
==
NULL
)
{
tqWarn
(
"cannot found schema wrapper for table: suid: %ld, version %d, possibly dropped table"
,
tqWarn
(
"cannot found schema wrapper for table: suid: %ld, version %d, possibly dropped table"
,
...
@@ -184,7 +186,7 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReadHandle* pHandle, uint64_
...
@@ -184,7 +186,7 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReadHandle* pHandle, uint64_
while
(
colMeta
<
pSchemaWrapper
->
nCols
)
{
while
(
colMeta
<
pSchemaWrapper
->
nCols
)
{
SSchema
*
pColSchema
=
&
pSchemaWrapper
->
pSchema
[
colMeta
];
SSchema
*
pColSchema
=
&
pSchemaWrapper
->
pSchema
[
colMeta
];
SColumnInfoData
colInfo
=
createColumnInfoData
(
pColSchema
->
type
,
pColSchema
->
bytes
,
pColSchema
->
colId
);
SColumnInfoData
colInfo
=
createColumnInfoData
(
pColSchema
->
type
,
pColSchema
->
bytes
,
pColSchema
->
colId
);
int32_t
code
=
blockDataAppendColInfo
(
pBlock
,
&
colInfo
);
int32_t
code
=
blockDataAppendColInfo
(
pBlock
,
&
colInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
FAIL
;
goto
FAIL
;
}
}
...
@@ -207,7 +209,7 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReadHandle* pHandle, uint64_
...
@@ -207,7 +209,7 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReadHandle* pHandle, uint64_
colNeed
++
;
colNeed
++
;
}
else
{
}
else
{
SColumnInfoData
colInfo
=
createColumnInfoData
(
pColSchema
->
type
,
pColSchema
->
bytes
,
pColSchema
->
colId
);
SColumnInfoData
colInfo
=
createColumnInfoData
(
pColSchema
->
type
,
pColSchema
->
bytes
,
pColSchema
->
colId
);
int32_t
code
=
blockDataAppendColInfo
(
pBlock
,
&
colInfo
);
int32_t
code
=
blockDataAppendColInfo
(
pBlock
,
&
colInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
FAIL
;
goto
FAIL
;
}
}
...
@@ -251,8 +253,8 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReadHandle* pHandle, uint64_
...
@@ -251,8 +253,8 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReadHandle* pHandle, uint64_
}
}
return
0
;
return
0
;
FAIL:
// todo refactor here
FAIL:
// todo refactor here
// if (*ppCols) taosArrayDestroy(*ppCols);
// if (*ppCols) taosArrayDestroy(*ppCols);
return
-
1
;
return
-
1
;
}
}
...
...
source/libs/command/src/command.c
浏览文件 @
291aab04
...
@@ -520,7 +520,17 @@ static int32_t execShowCreateSTable(SShowCreateTableStmt* pStmt, SRetrieveTableR
...
@@ -520,7 +520,17 @@ static int32_t execShowCreateSTable(SShowCreateTableStmt* pStmt, SRetrieveTableR
return
execShowCreateTable
(
pStmt
,
pRsp
);
return
execShowCreateTable
(
pStmt
,
pRsp
);
}
}
static
int32_t
execAlterLocal
(
SAlterLocalStmt
*
pStmt
)
{
return
TSDB_CODE_FAILED
;
}
static
int32_t
execAlterLocal
(
SAlterLocalStmt
*
pStmt
)
{
if
(
cfgSetItem
(
tsCfg
,
pStmt
->
config
,
pStmt
->
value
,
CFG_STYPE_ALTER_CMD
))
{
return
terrno
;
}
if
(
taosSetCfg
(
tsCfg
,
pStmt
->
config
))
{
return
terrno
;
}
return
TSDB_CODE_SUCCESS
;
}
static
SSDataBlock
*
buildLocalVariablesResultDataBlock
()
{
static
SSDataBlock
*
buildLocalVariablesResultDataBlock
()
{
SSDataBlock
*
pBlock
=
taosMemoryCalloc
(
1
,
sizeof
(
SSDataBlock
));
SSDataBlock
*
pBlock
=
taosMemoryCalloc
(
1
,
sizeof
(
SSDataBlock
));
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
291aab04
...
@@ -336,7 +336,6 @@ typedef struct SStreamBlockScanInfo {
...
@@ -336,7 +336,6 @@ typedef struct SStreamBlockScanInfo {
int32_t
numOfPseudoExpr
;
int32_t
numOfPseudoExpr
;
int32_t
primaryTsIndex
;
// primary time stamp slot id
int32_t
primaryTsIndex
;
// primary time stamp slot id
void
*
pDataReader
;
SReadHandle
readHandle
;
SReadHandle
readHandle
;
uint64_t
tableUid
;
// queried super table uid
uint64_t
tableUid
;
// queried super table uid
EStreamScanMode
scanMode
;
EStreamScanMode
scanMode
;
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
291aab04
...
@@ -1341,7 +1341,7 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowR
...
@@ -1341,7 +1341,7 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowR
}
}
if
(
rowRes
!=
NULL
)
{
if
(
rowRes
!=
NULL
)
{
int32_t
totalRows
=
pBlock
->
info
.
rows
;
int32_t
totalRows
=
pBlock
->
info
.
rows
;
SSDataBlock
*
px
=
createOneDataBlock
(
pBlock
,
true
);
SSDataBlock
*
px
=
createOneDataBlock
(
pBlock
,
true
);
size_t
numOfCols
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
size_t
numOfCols
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
...
@@ -3581,6 +3581,10 @@ static SArray* setRowTsColumnOutputInfo(SqlFunctionCtx* pCtx, int32_t numOfCols)
...
@@ -3581,6 +3581,10 @@ static SArray* setRowTsColumnOutputInfo(SqlFunctionCtx* pCtx, int32_t numOfCols)
return
pList
;
return
pList
;
}
}
static
int64_t
getLimit
(
SNode
*
pLimit
)
{
return
NULL
==
pLimit
?
-
1
:
((
SLimitNode
*
)
pLimit
)
->
limit
;
}
static
int64_t
getOffset
(
SNode
*
pLimit
)
{
return
NULL
==
pLimit
?
-
1
:
((
SLimitNode
*
)
pLimit
)
->
offset
;
}
SOperatorInfo
*
createProjectOperatorInfo
(
SOperatorInfo
*
downstream
,
SProjectPhysiNode
*
pProjPhyNode
,
SOperatorInfo
*
createProjectOperatorInfo
(
SOperatorInfo
*
downstream
,
SProjectPhysiNode
*
pProjPhyNode
,
SExecTaskInfo
*
pTaskInfo
)
{
SExecTaskInfo
*
pTaskInfo
)
{
SProjectOperatorInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SProjectOperatorInfo
));
SProjectOperatorInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SProjectOperatorInfo
));
...
@@ -3593,8 +3597,8 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhys
...
@@ -3593,8 +3597,8 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhys
SExprInfo
*
pExprInfo
=
createExprInfo
(
pProjPhyNode
->
pProjections
,
NULL
,
&
numOfCols
);
SExprInfo
*
pExprInfo
=
createExprInfo
(
pProjPhyNode
->
pProjections
,
NULL
,
&
numOfCols
);
SSDataBlock
*
pResBlock
=
createResDataBlock
(
pProjPhyNode
->
node
.
pOutputDataBlockDesc
);
SSDataBlock
*
pResBlock
=
createResDataBlock
(
pProjPhyNode
->
node
.
pOutputDataBlockDesc
);
SLimit
limit
=
{.
limit
=
pProjPhyNode
->
limit
,
.
offset
=
pProjPhyNode
->
offset
};
SLimit
limit
=
{.
limit
=
getLimit
(
pProjPhyNode
->
node
.
pLimit
),
.
offset
=
getOffset
(
pProjPhyNode
->
node
.
pLimit
)
};
SLimit
slimit
=
{.
limit
=
pProjPhyNode
->
slimit
,
.
offset
=
pProjPhyNode
->
soffset
};
SLimit
slimit
=
{.
limit
=
getLimit
(
pProjPhyNode
->
node
.
pSlimit
),
.
offset
=
getOffset
(
pProjPhyNode
->
node
.
pSlimit
)
};
pInfo
->
limit
=
limit
;
pInfo
->
limit
=
limit
;
pInfo
->
slimit
=
slimit
;
pInfo
->
slimit
=
slimit
;
...
@@ -3954,7 +3958,7 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle,
...
@@ -3954,7 +3958,7 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle,
}
}
}
}
}
}
int32_t
len
=
(
int32_t
)(
pStart
-
(
char
*
)
keyBuf
);
int32_t
len
=
(
int32_t
)(
pStart
-
(
char
*
)
keyBuf
);
uint64_t
*
pGroupId
=
taosHashGet
(
pTableListInfo
->
map
,
keyBuf
,
len
);
uint64_t
*
pGroupId
=
taosHashGet
(
pTableListInfo
->
map
,
keyBuf
,
len
);
...
@@ -3980,8 +3984,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
...
@@ -3980,8 +3984,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
if
(
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
==
type
)
{
if
(
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
==
type
)
{
STableScanPhysiNode
*
pTableScanNode
=
(
STableScanPhysiNode
*
)
pPhyNode
;
STableScanPhysiNode
*
pTableScanNode
=
(
STableScanPhysiNode
*
)
pPhyNode
;
tsdbReaderT
pDataReader
=
tsdbReaderT
pDataReader
=
doCreateDataReader
(
pTableScanNode
,
pHandle
,
pTableListInfo
,
(
uint64_t
)
queryId
,
taskId
);
doCreateDataReader
(
pTableScanNode
,
pHandle
,
pTableListInfo
,
(
uint64_t
)
queryId
,
taskId
);
if
(
pDataReader
==
NULL
&&
terrno
!=
0
)
{
if
(
pDataReader
==
NULL
&&
terrno
!=
0
)
{
pTaskInfo
->
code
=
terrno
;
pTaskInfo
->
code
=
terrno
;
return
NULL
;
return
NULL
;
...
@@ -4007,16 +4010,20 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
...
@@ -4007,16 +4010,20 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
STableScanInfo
*
pScanInfo
=
pOperator
->
info
;
STableScanInfo
*
pScanInfo
=
pOperator
->
info
;
pTaskInfo
->
cost
.
pRecoder
=
&
pScanInfo
->
readRecorder
;
pTaskInfo
->
cost
.
pRecoder
=
&
pScanInfo
->
readRecorder
;
return
pOperator
;
return
pOperator
;
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN
==
type
)
{
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN
==
type
)
{
STableMergeScanPhysiNode
*
pTableScanNode
=
(
STableMergeScanPhysiNode
*
)
pPhyNode
;
STableMergeScanPhysiNode
*
pTableScanNode
=
(
STableMergeScanPhysiNode
*
)
pPhyNode
;
createScanTableListInfo
(
pTableScanNode
,
pHandle
,
pTableListInfo
,
queryId
,
taskId
);
createScanTableListInfo
(
pTableScanNode
,
pHandle
,
pTableListInfo
,
queryId
,
taskId
);
extractTableSchemaVersion
(
pHandle
,
pTableScanNode
->
scan
.
uid
,
pTaskInfo
);
extractTableSchemaVersion
(
pHandle
,
pTableScanNode
->
scan
.
uid
,
pTaskInfo
);
SOperatorInfo
*
pOperator
=
createTableMergeScanOperatorInfo
(
pTableScanNode
,
pTableListInfo
,
pHandle
,
pTaskInfo
,
queryId
,
taskId
);
SOperatorInfo
*
pOperator
=
createTableMergeScanOperatorInfo
(
pTableScanNode
,
pTableListInfo
,
pHandle
,
pTaskInfo
,
queryId
,
taskId
);
STableScanInfo
*
pScanInfo
=
pOperator
->
info
;
STableScanInfo
*
pScanInfo
=
pOperator
->
info
;
pTaskInfo
->
cost
.
pRecoder
=
&
pScanInfo
->
readRecorder
;
pTaskInfo
->
cost
.
pRecoder
=
&
pScanInfo
->
readRecorder
;
return
pOperator
;
return
pOperator
;
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
==
type
)
{
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
==
type
)
{
return
createExchangeOperatorInfo
(
pHandle
->
pMsgCb
->
clientRpc
,
(
SExchangePhysiNode
*
)
pPhyNode
,
pTaskInfo
);
return
createExchangeOperatorInfo
(
pHandle
->
pMsgCb
->
clientRpc
,
(
SExchangePhysiNode
*
)
pPhyNode
,
pTaskInfo
);
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN
==
type
)
{
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN
==
type
)
{
SScanPhysiNode
*
pScanPhyNode
=
(
SScanPhysiNode
*
)
pPhyNode
;
// simple child table.
SScanPhysiNode
*
pScanPhyNode
=
(
SScanPhysiNode
*
)
pPhyNode
;
// simple child table.
STableScanPhysiNode
*
pTableScanNode
=
(
STableScanPhysiNode
*
)
pPhyNode
;
STableScanPhysiNode
*
pTableScanNode
=
(
STableScanPhysiNode
*
)
pPhyNode
;
...
@@ -4031,20 +4038,22 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
...
@@ -4031,20 +4038,22 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
if
(
pHandle
->
initTsdbReader
)
{
if
(
pHandle
->
initTsdbReader
)
{
// for stream
// for stream
ASSERT
(
pHandle
->
vnode
);
ASSERT
(
pHandle
->
vnode
);
pDataReader
=
pDataReader
=
doCreateDataReader
(
pTableScanNode
,
pHandle
,
pTableListInfo
,
(
uint64_t
)
queryId
,
taskId
);
doCreateDataReader
(
pTableScanNode
,
pHandle
,
pTableListInfo
,
(
uint64_t
)
queryId
,
taskId
);
}
else
{
}
else
{
// for tq
// for tq
ASSERT
(
pHandle
->
meta
);
ASSERT
(
pHandle
->
meta
);
getTableList
(
pHandle
->
meta
,
pScanPhyNode
,
pTableListInfo
);
getTableList
(
pHandle
->
meta
,
pScanPhyNode
,
pTableListInfo
);
}
}
}
}
#if 0
if (pDataReader == NULL && terrno != 0) {
if (pDataReader == NULL && terrno != 0) {
qDebug("%s pDataReader is NULL", GET_TASKID(pTaskInfo));
qDebug("%s pDataReader is NULL", GET_TASKID(pTaskInfo));
// return NULL;
// return NULL;
} else {
} else {
qDebug("%s pDataReader is not NULL", GET_TASKID(pTaskInfo));
qDebug("%s pDataReader is not NULL", GET_TASKID(pTaskInfo));
}
}
#endif
SArray
*
groupKeys
=
extractPartitionColInfo
(
pTableScanNode
->
pPartitionTags
);
SArray
*
groupKeys
=
extractPartitionColInfo
(
pTableScanNode
->
pPartitionTags
);
int32_t
code
=
generateGroupIdMap
(
pTableListInfo
,
pHandle
,
groupKeys
);
// todo for json
int32_t
code
=
generateGroupIdMap
(
pTableListInfo
,
pHandle
,
groupKeys
);
// todo for json
...
@@ -4057,9 +4066,11 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
...
@@ -4057,9 +4066,11 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
SOperatorInfo
*
pOperator
=
createStreamScanOperatorInfo
(
pDataReader
,
pHandle
,
pTableScanNode
,
pTaskInfo
,
&
twSup
);
SOperatorInfo
*
pOperator
=
createStreamScanOperatorInfo
(
pDataReader
,
pHandle
,
pTableScanNode
,
pTaskInfo
,
&
twSup
);
return
pOperator
;
return
pOperator
;
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN
==
type
)
{
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN
==
type
)
{
SSystemTableScanPhysiNode
*
pSysScanPhyNode
=
(
SSystemTableScanPhysiNode
*
)
pPhyNode
;
SSystemTableScanPhysiNode
*
pSysScanPhyNode
=
(
SSystemTableScanPhysiNode
*
)
pPhyNode
;
return
createSysTableScanOperatorInfo
(
pHandle
,
pSysScanPhyNode
,
pTaskInfo
);
return
createSysTableScanOperatorInfo
(
pHandle
,
pSysScanPhyNode
,
pTaskInfo
);
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN
==
type
)
{
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN
==
type
)
{
STagScanPhysiNode
*
pScanPhyNode
=
(
STagScanPhysiNode
*
)
pPhyNode
;
STagScanPhysiNode
*
pScanPhyNode
=
(
STagScanPhysiNode
*
)
pPhyNode
;
...
@@ -4070,6 +4081,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
...
@@ -4070,6 +4081,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
}
}
return
createTagScanOperatorInfo
(
pHandle
,
pScanPhyNode
,
pTableListInfo
,
pTaskInfo
);
return
createTagScanOperatorInfo
(
pHandle
,
pScanPhyNode
,
pTableListInfo
,
pTaskInfo
);
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN
==
type
)
{
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN
==
type
)
{
SBlockDistScanPhysiNode
*
pBlockNode
=
(
SBlockDistScanPhysiNode
*
)
pPhyNode
;
SBlockDistScanPhysiNode
*
pBlockNode
=
(
SBlockDistScanPhysiNode
*
)
pPhyNode
;
pTableListInfo
->
pTableList
=
taosArrayInit
(
4
,
sizeof
(
STableKeyInfo
));
pTableListInfo
->
pTableList
=
taosArrayInit
(
4
,
sizeof
(
STableKeyInfo
));
...
@@ -4343,7 +4355,7 @@ tsdbReaderT doCreateDataReader(STableScanPhysiNode* pTableScanNode, SReadHandle*
...
@@ -4343,7 +4355,7 @@ tsdbReaderT doCreateDataReader(STableScanPhysiNode* pTableScanNode, SReadHandle*
goto
_error
;
goto
_error
;
}
}
tsdbReaderT
*
pReader
=
tsdbReaderOpen
(
pHandle
->
vnode
,
&
cond
,
pTableListInfo
,
queryId
,
taskId
);
tsdbReaderT
pReader
=
tsdbReaderOpen
(
pHandle
->
vnode
,
&
cond
,
pTableListInfo
,
queryId
,
taskId
);
cleanupQueryTableDataCond
(
&
cond
);
cleanupQueryTableDataCond
(
&
cond
);
return
pReader
;
return
pReader
;
...
@@ -4487,18 +4499,14 @@ int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SRead
...
@@ -4487,18 +4499,14 @@ int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SRead
(
*
pTaskInfo
)
->
sql
=
sql
;
(
*
pTaskInfo
)
->
sql
=
sql
;
(
*
pTaskInfo
)
->
tableqinfoList
.
pTagCond
=
pPlan
->
pTagCond
;
(
*
pTaskInfo
)
->
tableqinfoList
.
pTagCond
=
pPlan
->
pTagCond
;
(
*
pTaskInfo
)
->
tableqinfoList
.
pTagIndexCond
=
pPlan
->
pTagIndexCond
;
(
*
pTaskInfo
)
->
tableqinfoList
.
pTagIndexCond
=
pPlan
->
pTagIndexCond
;
(
*
pTaskInfo
)
->
pRoot
=
createOperatorTree
(
pPlan
->
pNode
,
*
pTaskInfo
,
pHandle
,
queryId
,
taskId
,
(
*
pTaskInfo
)
->
pRoot
=
&
(
*
pTaskInfo
)
->
tableqinfoList
);
createOperatorTree
(
pPlan
->
pNode
,
*
pTaskInfo
,
pHandle
,
queryId
,
taskId
,
&
(
*
pTaskInfo
)
->
tableqinfoList
);
if
(
NULL
==
(
*
pTaskInfo
)
->
pRoot
)
{
if
(
NULL
==
(
*
pTaskInfo
)
->
pRoot
)
{
code
=
(
*
pTaskInfo
)
->
code
;
code
=
(
*
pTaskInfo
)
->
code
;
goto
_complete
;
goto
_complete
;
}
}
if
((
*
pTaskInfo
)
->
pRoot
==
NULL
)
{
code
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
goto
_complete
;
}
return
code
;
return
code
;
_complete:
_complete:
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
291aab04
...
@@ -967,9 +967,9 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
...
@@ -967,9 +967,9 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
while
(
tqNextDataBlock
(
pInfo
->
streamBlockReader
))
{
while
(
tqNextDataBlock
(
pInfo
->
streamBlockReader
))
{
SSDataBlock
block
=
{
0
};
SSDataBlock
block
=
{
0
};
uint64_t
groupId
=
0
;
uint64_t
groupId
=
0
;
uint64_t
uid
=
0
;
uint64_t
uid
=
0
;
int32_t
numOfRows
=
0
;
int32_t
numOfRows
=
0
;
// todo refactor
// todo refactor
int32_t
code
=
tqRetrieveDataBlock
(
&
block
,
pInfo
->
streamBlockReader
,
&
groupId
,
&
uid
,
&
numOfRows
);
int32_t
code
=
tqRetrieveDataBlock
(
&
block
,
pInfo
->
streamBlockReader
,
&
groupId
,
&
uid
,
&
numOfRows
);
...
@@ -1022,6 +1022,9 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
...
@@ -1022,6 +1022,9 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
}
}
}
}
// TODO refactor @liao
taosArrayDestroy
(
block
.
pDataBlock
);
if
(
pInfo
->
pRes
->
pDataBlock
==
NULL
)
{
if
(
pInfo
->
pRes
->
pDataBlock
==
NULL
)
{
// TODO add log
// TODO add log
pOperator
->
status
=
OP_EXEC_DONE
;
pOperator
->
status
=
OP_EXEC_DONE
;
...
@@ -1061,12 +1064,11 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
...
@@ -1061,12 +1064,11 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
}
}
return
(
pBlockInfo
->
rows
==
0
)
?
NULL
:
pInfo
->
pRes
;
return
(
pBlockInfo
->
rows
==
0
)
?
NULL
:
pInfo
->
pRes
;
}
else
if
(
pInfo
->
blockType
==
STREAM_DATA_TYPE_FROM_SNAPSHOT
)
{
}
else
if
(
pInfo
->
blockType
==
STREAM_DATA_TYPE_FROM_SNAPSHOT
)
{
SSDataBlock
*
pResult
=
doTableScan
(
pInfo
->
pSnapshotReadOp
);
SSDataBlock
*
pResult
=
doTableScan
(
pInfo
->
pSnapshotReadOp
);
if
(
pResult
)
{
return
pResult
&&
pResult
->
info
.
rows
>
0
?
pResult
:
NULL
;
return
pResult
->
info
.
rows
>
0
?
pResult
:
NULL
;
}
return
NULL
;
}
else
{
}
else
{
ASSERT
(
0
);
ASSERT
(
0
);
return
NULL
;
return
NULL
;
...
@@ -1161,7 +1163,6 @@ SOperatorInfo* createStreamScanOperatorInfo(void* pDataReader, SReadHandle* pHan
...
@@ -1161,7 +1163,6 @@ SOperatorInfo* createStreamScanOperatorInfo(void* pDataReader, SReadHandle* pHan
pInfo
->
pRes
=
createResDataBlock
(
pDescNode
);
pInfo
->
pRes
=
createResDataBlock
(
pDescNode
);
pInfo
->
pUpdateRes
=
createResDataBlock
(
pDescNode
);
pInfo
->
pUpdateRes
=
createResDataBlock
(
pDescNode
);
pInfo
->
pCondition
=
pScanPhyNode
->
node
.
pConditions
;
pInfo
->
pCondition
=
pScanPhyNode
->
node
.
pConditions
;
pInfo
->
pDataReader
=
pDataReader
;
pInfo
->
scanMode
=
STREAM_SCAN_FROM_READERHANDLE
;
pInfo
->
scanMode
=
STREAM_SCAN_FROM_READERHANDLE
;
pInfo
->
sessionSup
=
(
SessionWindowSupporter
){.
pStreamAggSup
=
NULL
,
.
gap
=
-
1
};
pInfo
->
sessionSup
=
(
SessionWindowSupporter
){.
pStreamAggSup
=
NULL
,
.
gap
=
-
1
};
pInfo
->
groupId
=
0
;
pInfo
->
groupId
=
0
;
...
@@ -1343,7 +1344,8 @@ static SSDataBlock* buildSysTableMetaBlock() {
...
@@ -1343,7 +1344,8 @@ static SSDataBlock* buildSysTableMetaBlock() {
SSDataBlock
*
pBlock
=
createDataBlock
();
SSDataBlock
*
pBlock
=
createDataBlock
();
for
(
int32_t
i
=
0
;
i
<
pMeta
[
index
].
colNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pMeta
[
index
].
colNum
;
++
i
)
{
SColumnInfoData
colInfoData
=
createColumnInfoData
(
pMeta
[
index
].
schema
[
i
].
type
,
pMeta
[
index
].
schema
[
i
].
bytes
,
i
+
1
);
SColumnInfoData
colInfoData
=
createColumnInfoData
(
pMeta
[
index
].
schema
[
i
].
type
,
pMeta
[
index
].
schema
[
i
].
bytes
,
i
+
1
);
blockDataAppendColInfo
(
pBlock
,
&
colInfoData
);
blockDataAppendColInfo
(
pBlock
,
&
colInfoData
);
}
}
...
...
source/libs/function/src/builtins.c
浏览文件 @
291aab04
...
@@ -79,7 +79,8 @@ static int32_t translateIn2NumOutDou(SFunctionNode* pFunc, char* pErrBuf, int32_
...
@@ -79,7 +79,8 @@ static int32_t translateIn2NumOutDou(SFunctionNode* pFunc, char* pErrBuf, int32_
uint8_t
para1Type
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
.
type
;
uint8_t
para1Type
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
.
type
;
uint8_t
para2Type
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
1
))
->
resType
.
type
;
uint8_t
para2Type
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
1
))
->
resType
.
type
;
if
(
!
IS_NUMERIC_TYPE
(
para1Type
)
||
!
IS_NUMERIC_TYPE
(
para2Type
))
{
if
((
!
IS_NUMERIC_TYPE
(
para1Type
)
&&
!
IS_NULL_TYPE
(
para1Type
))
||
(
!
IS_NUMERIC_TYPE
(
para2Type
)
&&
!
IS_NULL_TYPE
(
para2Type
)))
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
...
@@ -109,13 +110,13 @@ static int32_t translateLogarithm(SFunctionNode* pFunc, char* pErrBuf, int32_t l
...
@@ -109,13 +110,13 @@ static int32_t translateLogarithm(SFunctionNode* pFunc, char* pErrBuf, int32_t l
}
}
uint8_t
para1Type
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
.
type
;
uint8_t
para1Type
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
.
type
;
if
(
!
IS_NUMERIC_TYPE
(
para1Type
))
{
if
(
!
IS_NUMERIC_TYPE
(
para1Type
)
&&
!
IS_NULL_TYPE
(
para1Type
)
)
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
if
(
2
==
numOfParams
)
{
if
(
2
==
numOfParams
)
{
uint8_t
para2Type
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
1
))
->
resType
.
type
;
uint8_t
para2Type
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
1
))
->
resType
.
type
;
if
(
!
IS_NUMERIC_TYPE
(
para2Type
))
{
if
(
!
IS_NUMERIC_TYPE
(
para2Type
)
&&
!
IS_NULL_TYPE
(
para2Type
)
)
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
}
}
...
@@ -1856,7 +1857,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
...
@@ -1856,7 +1857,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{
{
.
name
=
"last_row"
,
.
name
=
"last_row"
,
.
type
=
FUNCTION_TYPE_LAST_ROW
,
.
type
=
FUNCTION_TYPE_LAST_ROW
,
.
classification
=
FUNC_MGT_AGG_FUNC
|
FUNC_MGT_MULTI_RES_FUNC
,
.
classification
=
FUNC_MGT_AGG_FUNC
|
FUNC_MGT_MULTI_RES_FUNC
|
FUNC_MGT_TIMELINE_FUNC
,
.
translateFunc
=
translateLastRow
,
.
translateFunc
=
translateLastRow
,
.
getEnvFunc
=
getMinmaxFuncEnv
,
.
getEnvFunc
=
getMinmaxFuncEnv
,
.
initFunc
=
minmaxFunctionSetup
,
.
initFunc
=
minmaxFunctionSetup
,
...
@@ -2023,7 +2024,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
...
@@ -2023,7 +2024,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{
{
.
name
=
"diff"
,
.
name
=
"diff"
,
.
type
=
FUNCTION_TYPE_DIFF
,
.
type
=
FUNCTION_TYPE_DIFF
,
.
classification
=
FUNC_MGT_INDEFINITE_ROWS_FUNC
|
FUNC_MGT_TIMELINE_FUNC
|
FUNC_MGT_FORBID_STREAM_FUNC
,
.
classification
=
FUNC_MGT_INDEFINITE_ROWS_FUNC
|
FUNC_MGT_TIMELINE_FUNC
|
FUNC_MGT_FORBID_STREAM_FUNC
|
FUNC_MGT_FORBID_WINDOW_FUNC
,
.
translateFunc
=
translateDiff
,
.
translateFunc
=
translateDiff
,
.
getEnvFunc
=
getDiffFuncEnv
,
.
getEnvFunc
=
getDiffFuncEnv
,
.
initFunc
=
diffFunctionSetup
,
.
initFunc
=
diffFunctionSetup
,
...
@@ -2033,7 +2034,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
...
@@ -2033,7 +2034,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{
{
.
name
=
"statecount"
,
.
name
=
"statecount"
,
.
type
=
FUNCTION_TYPE_STATE_COUNT
,
.
type
=
FUNCTION_TYPE_STATE_COUNT
,
.
classification
=
FUNC_MGT_INDEFINITE_ROWS_FUNC
|
FUNC_MGT_FORBID_STREAM_FUNC
,
.
classification
=
FUNC_MGT_INDEFINITE_ROWS_FUNC
|
FUNC_MGT_FORBID_STREAM_FUNC
|
FUNC_MGT_FORBID_WINDOW_FUNC
,
.
translateFunc
=
translateStateCount
,
.
translateFunc
=
translateStateCount
,
.
getEnvFunc
=
getStateFuncEnv
,
.
getEnvFunc
=
getStateFuncEnv
,
.
initFunc
=
functionSetup
,
.
initFunc
=
functionSetup
,
...
@@ -2043,7 +2044,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
...
@@ -2043,7 +2044,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{
{
.
name
=
"stateduration"
,
.
name
=
"stateduration"
,
.
type
=
FUNCTION_TYPE_STATE_DURATION
,
.
type
=
FUNCTION_TYPE_STATE_DURATION
,
.
classification
=
FUNC_MGT_INDEFINITE_ROWS_FUNC
|
FUNC_MGT_TIMELINE_FUNC
|
FUNC_MGT_FORBID_STREAM_FUNC
,
.
classification
=
FUNC_MGT_INDEFINITE_ROWS_FUNC
|
FUNC_MGT_TIMELINE_FUNC
|
FUNC_MGT_FORBID_STREAM_FUNC
|
FUNC_MGT_FORBID_WINDOW_FUNC
,
.
translateFunc
=
translateStateDuration
,
.
translateFunc
=
translateStateDuration
,
.
getEnvFunc
=
getStateFuncEnv
,
.
getEnvFunc
=
getStateFuncEnv
,
.
initFunc
=
functionSetup
,
.
initFunc
=
functionSetup
,
...
@@ -2053,7 +2054,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
...
@@ -2053,7 +2054,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{
{
.
name
=
"csum"
,
.
name
=
"csum"
,
.
type
=
FUNCTION_TYPE_CSUM
,
.
type
=
FUNCTION_TYPE_CSUM
,
.
classification
=
FUNC_MGT_INDEFINITE_ROWS_FUNC
|
FUNC_MGT_TIMELINE_FUNC
|
FUNC_MGT_FORBID_STREAM_FUNC
,
.
classification
=
FUNC_MGT_INDEFINITE_ROWS_FUNC
|
FUNC_MGT_TIMELINE_FUNC
|
FUNC_MGT_FORBID_STREAM_FUNC
|
FUNC_MGT_FORBID_WINDOW_FUNC
,
.
translateFunc
=
translateCsum
,
.
translateFunc
=
translateCsum
,
.
getEnvFunc
=
getCsumFuncEnv
,
.
getEnvFunc
=
getCsumFuncEnv
,
.
initFunc
=
functionSetup
,
.
initFunc
=
functionSetup
,
...
@@ -2063,7 +2064,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
...
@@ -2063,7 +2064,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{
{
.
name
=
"mavg"
,
.
name
=
"mavg"
,
.
type
=
FUNCTION_TYPE_MAVG
,
.
type
=
FUNCTION_TYPE_MAVG
,
.
classification
=
FUNC_MGT_INDEFINITE_ROWS_FUNC
|
FUNC_MGT_TIMELINE_FUNC
|
FUNC_MGT_FORBID_STREAM_FUNC
,
.
classification
=
FUNC_MGT_INDEFINITE_ROWS_FUNC
|
FUNC_MGT_TIMELINE_FUNC
|
FUNC_MGT_FORBID_STREAM_FUNC
|
FUNC_MGT_FORBID_WINDOW_FUNC
,
.
translateFunc
=
translateMavg
,
.
translateFunc
=
translateMavg
,
.
getEnvFunc
=
getMavgFuncEnv
,
.
getEnvFunc
=
getMavgFuncEnv
,
.
initFunc
=
mavgFunctionSetup
,
.
initFunc
=
mavgFunctionSetup
,
...
...
source/libs/monitor/src/monMain.c
浏览文件 @
291aab04
...
@@ -280,6 +280,27 @@ static void monGenVgroupJson(SMonInfo *pMonitor) {
...
@@ -280,6 +280,27 @@ static void monGenVgroupJson(SMonInfo *pMonitor) {
}
}
}
}
static
void
monGenStbJson
(
SMonInfo
*
pMonitor
)
{
SMonStbInfo
*
pInfo
=
&
pMonitor
->
mmInfo
.
stb
;
if
(
pMonitor
->
mmInfo
.
cluster
.
first_ep_dnode_id
==
0
)
return
;
SJson
*
pJson
=
tjsonAddArrayToObject
(
pMonitor
->
pJson
,
"stb_infos"
);
if
(
pJson
==
NULL
)
return
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pInfo
->
stbs
);
++
i
)
{
SJson
*
pStbJson
=
tjsonCreateObject
();
if
(
pStbJson
==
NULL
)
continue
;
if
(
tjsonAddItemToArray
(
pJson
,
pStbJson
)
!=
0
)
{
tjsonDelete
(
pStbJson
);
continue
;
}
SMonStbDesc
*
pStbDesc
=
taosArrayGet
(
pInfo
->
stbs
,
i
);
tjsonAddStringToObject
(
pStbJson
,
"stb_name"
,
pStbDesc
->
stb_name
);
tjsonAddStringToObject
(
pStbJson
,
"database_name"
,
pStbDesc
->
database_name
);
}
}
static
void
monGenGrantJson
(
SMonInfo
*
pMonitor
)
{
static
void
monGenGrantJson
(
SMonInfo
*
pMonitor
)
{
SMonGrantInfo
*
pInfo
=
&
pMonitor
->
mmInfo
.
grant
;
SMonGrantInfo
*
pInfo
=
&
pMonitor
->
mmInfo
.
grant
;
if
(
pMonitor
->
mmInfo
.
cluster
.
first_ep_dnode_id
==
0
)
return
;
if
(
pMonitor
->
mmInfo
.
cluster
.
first_ep_dnode_id
==
0
)
return
;
...
@@ -527,6 +548,7 @@ void monSendReport() {
...
@@ -527,6 +548,7 @@ void monSendReport() {
monGenBasicJson
(
pMonitor
);
monGenBasicJson
(
pMonitor
);
monGenClusterJson
(
pMonitor
);
monGenClusterJson
(
pMonitor
);
monGenVgroupJson
(
pMonitor
);
monGenVgroupJson
(
pMonitor
);
monGenStbJson
(
pMonitor
);
monGenGrantJson
(
pMonitor
);
monGenGrantJson
(
pMonitor
);
monGenDnodeJson
(
pMonitor
);
monGenDnodeJson
(
pMonitor
);
monGenDiskJson
(
pMonitor
);
monGenDiskJson
(
pMonitor
);
...
...
source/libs/monitor/src/monMsg.c
浏览文件 @
291aab04
...
@@ -209,6 +209,32 @@ int32_t tDecodeSMonVgroupInfo(SDecoder *decoder, SMonVgroupInfo *pInfo) {
...
@@ -209,6 +209,32 @@ int32_t tDecodeSMonVgroupInfo(SDecoder *decoder, SMonVgroupInfo *pInfo) {
return
0
;
return
0
;
}
}
int32_t
tEncodeSMonStbInfo
(
SEncoder
*
encoder
,
const
SMonStbInfo
*
pInfo
)
{
if
(
tEncodeI32
(
encoder
,
taosArrayGetSize
(
pInfo
->
stbs
))
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pInfo
->
stbs
);
++
i
)
{
SMonStbDesc
*
pDesc
=
taosArrayGet
(
pInfo
->
stbs
,
i
);
if
(
tEncodeCStr
(
encoder
,
pDesc
->
stb_name
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
encoder
,
pDesc
->
database_name
)
<
0
)
return
-
1
;
}
return
0
;
}
int32_t
tDecodeSMonStbInfo
(
SDecoder
*
decoder
,
SMonStbInfo
*
pInfo
)
{
int32_t
arraySize
=
0
;
if
(
tDecodeI32
(
decoder
,
&
arraySize
)
<
0
)
return
-
1
;
pInfo
->
stbs
=
taosArrayInit
(
arraySize
,
sizeof
(
SMonStbDesc
));
if
(
pInfo
->
stbs
==
NULL
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
arraySize
;
++
i
)
{
SMonStbDesc
desc
=
{
0
};
if
(
tDecodeCStrTo
(
decoder
,
desc
.
stb_name
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
decoder
,
desc
.
database_name
)
<
0
)
return
-
1
;
taosArrayPush
(
pInfo
->
stbs
,
&
desc
);
}
return
0
;
}
int32_t
tEncodeSMonGrantInfo
(
SEncoder
*
encoder
,
const
SMonGrantInfo
*
pInfo
)
{
int32_t
tEncodeSMonGrantInfo
(
SEncoder
*
encoder
,
const
SMonGrantInfo
*
pInfo
)
{
if
(
tEncodeI32
(
encoder
,
pInfo
->
expire_time
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
encoder
,
pInfo
->
expire_time
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
encoder
,
pInfo
->
timeseries_used
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
encoder
,
pInfo
->
timeseries_used
)
<
0
)
return
-
1
;
...
@@ -230,6 +256,7 @@ int32_t tSerializeSMonMmInfo(void *buf, int32_t bufLen, SMonMmInfo *pInfo) {
...
@@ -230,6 +256,7 @@ int32_t tSerializeSMonMmInfo(void *buf, int32_t bufLen, SMonMmInfo *pInfo) {
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeSMonClusterInfo
(
&
encoder
,
&
pInfo
->
cluster
)
<
0
)
return
-
1
;
if
(
tEncodeSMonClusterInfo
(
&
encoder
,
&
pInfo
->
cluster
)
<
0
)
return
-
1
;
if
(
tEncodeSMonVgroupInfo
(
&
encoder
,
&
pInfo
->
vgroup
)
<
0
)
return
-
1
;
if
(
tEncodeSMonVgroupInfo
(
&
encoder
,
&
pInfo
->
vgroup
)
<
0
)
return
-
1
;
if
(
tEncodeSMonStbInfo
(
&
encoder
,
&
pInfo
->
stb
)
<
0
)
return
-
1
;
if
(
tEncodeSMonGrantInfo
(
&
encoder
,
&
pInfo
->
grant
)
<
0
)
return
-
1
;
if
(
tEncodeSMonGrantInfo
(
&
encoder
,
&
pInfo
->
grant
)
<
0
)
return
-
1
;
if
(
tEncodeSMonSysInfo
(
&
encoder
,
&
pInfo
->
sys
)
<
0
)
return
-
1
;
if
(
tEncodeSMonSysInfo
(
&
encoder
,
&
pInfo
->
sys
)
<
0
)
return
-
1
;
if
(
tEncodeSMonLogs
(
&
encoder
,
&
pInfo
->
log
)
<
0
)
return
-
1
;
if
(
tEncodeSMonLogs
(
&
encoder
,
&
pInfo
->
log
)
<
0
)
return
-
1
;
...
@@ -247,6 +274,7 @@ int32_t tDeserializeSMonMmInfo(void *buf, int32_t bufLen, SMonMmInfo *pInfo) {
...
@@ -247,6 +274,7 @@ int32_t tDeserializeSMonMmInfo(void *buf, int32_t bufLen, SMonMmInfo *pInfo) {
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeSMonClusterInfo
(
&
decoder
,
&
pInfo
->
cluster
)
<
0
)
return
-
1
;
if
(
tDecodeSMonClusterInfo
(
&
decoder
,
&
pInfo
->
cluster
)
<
0
)
return
-
1
;
if
(
tDecodeSMonVgroupInfo
(
&
decoder
,
&
pInfo
->
vgroup
)
<
0
)
return
-
1
;
if
(
tDecodeSMonVgroupInfo
(
&
decoder
,
&
pInfo
->
vgroup
)
<
0
)
return
-
1
;
if
(
tDecodeSMonStbInfo
(
&
decoder
,
&
pInfo
->
stb
)
<
0
)
return
-
1
;
if
(
tDecodeSMonGrantInfo
(
&
decoder
,
&
pInfo
->
grant
)
<
0
)
return
-
1
;
if
(
tDecodeSMonGrantInfo
(
&
decoder
,
&
pInfo
->
grant
)
<
0
)
return
-
1
;
if
(
tDecodeSMonSysInfo
(
&
decoder
,
&
pInfo
->
sys
)
<
0
)
return
-
1
;
if
(
tDecodeSMonSysInfo
(
&
decoder
,
&
pInfo
->
sys
)
<
0
)
return
-
1
;
if
(
tDecodeSMonLogs
(
&
decoder
,
&
pInfo
->
log
)
<
0
)
return
-
1
;
if
(
tDecodeSMonLogs
(
&
decoder
,
&
pInfo
->
log
)
<
0
)
return
-
1
;
...
@@ -261,9 +289,11 @@ void tFreeSMonMmInfo(SMonMmInfo *pInfo) {
...
@@ -261,9 +289,11 @@ void tFreeSMonMmInfo(SMonMmInfo *pInfo) {
taosArrayDestroy
(
pInfo
->
cluster
.
mnodes
);
taosArrayDestroy
(
pInfo
->
cluster
.
mnodes
);
taosArrayDestroy
(
pInfo
->
cluster
.
dnodes
);
taosArrayDestroy
(
pInfo
->
cluster
.
dnodes
);
taosArrayDestroy
(
pInfo
->
vgroup
.
vgroups
);
taosArrayDestroy
(
pInfo
->
vgroup
.
vgroups
);
taosArrayDestroy
(
pInfo
->
stb
.
stbs
);
pInfo
->
cluster
.
mnodes
=
NULL
;
pInfo
->
cluster
.
mnodes
=
NULL
;
pInfo
->
cluster
.
dnodes
=
NULL
;
pInfo
->
cluster
.
dnodes
=
NULL
;
pInfo
->
vgroup
.
vgroups
=
NULL
;
pInfo
->
vgroup
.
vgroups
=
NULL
;
pInfo
->
stb
.
stbs
=
NULL
;
pInfo
->
log
.
logs
=
NULL
;
pInfo
->
log
.
logs
=
NULL
;
}
}
...
...
source/libs/nodes/src/nodesCloneFuncs.c
浏览文件 @
291aab04
此差异已折叠。
点击以展开。
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
291aab04
...
@@ -491,6 +491,8 @@ static int32_t jsonToTableMeta(const SJson* pJson, void* pObj) {
...
@@ -491,6 +491,8 @@ static int32_t jsonToTableMeta(const SJson* pJson, void* pObj) {
static
const
char
*
jkLogicPlanTargets
=
"Targets"
;
static
const
char
*
jkLogicPlanTargets
=
"Targets"
;
static
const
char
*
jkLogicPlanConditions
=
"Conditions"
;
static
const
char
*
jkLogicPlanConditions
=
"Conditions"
;
static
const
char
*
jkLogicPlanChildren
=
"Children"
;
static
const
char
*
jkLogicPlanChildren
=
"Children"
;
static
const
char
*
jkLogicPlanLimit
=
"Limit"
;
static
const
char
*
jkLogicPlanSlimit
=
"SLimit"
;
static
int32_t
logicPlanNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
static
int32_t
logicPlanNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SLogicNode
*
pNode
=
(
const
SLogicNode
*
)
pObj
;
const
SLogicNode
*
pNode
=
(
const
SLogicNode
*
)
pObj
;
...
@@ -502,6 +504,12 @@ static int32_t logicPlanNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -502,6 +504,12 @@ static int32_t logicPlanNodeToJson(const void* pObj, SJson* pJson) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodeListToJson
(
pJson
,
jkLogicPlanChildren
,
pNode
->
pChildren
);
code
=
nodeListToJson
(
pJson
,
jkLogicPlanChildren
,
pNode
->
pChildren
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddObject
(
pJson
,
jkLogicPlanLimit
,
nodeToJson
,
pNode
->
pLimit
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddObject
(
pJson
,
jkLogicPlanSlimit
,
nodeToJson
,
pNode
->
pSlimit
);
}
return
code
;
return
code
;
}
}
...
@@ -516,6 +524,12 @@ static int32_t jsonToLogicPlanNode(const SJson* pJson, void* pObj) {
...
@@ -516,6 +524,12 @@ static int32_t jsonToLogicPlanNode(const SJson* pJson, void* pObj) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkLogicPlanChildren
,
&
pNode
->
pChildren
);
code
=
jsonToNodeList
(
pJson
,
jkLogicPlanChildren
,
&
pNode
->
pChildren
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeObject
(
pJson
,
jkLogicPlanLimit
,
&
pNode
->
pLimit
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeObject
(
pJson
,
jkLogicPlanSlimit
,
&
pNode
->
pSlimit
);
}
return
code
;
return
code
;
}
}
...
@@ -581,10 +595,6 @@ static int32_t jsonToLogicScanNode(const SJson* pJson, void* pObj) {
...
@@ -581,10 +595,6 @@ static int32_t jsonToLogicScanNode(const SJson* pJson, void* pObj) {
}
}
static
const
char
*
jkProjectLogicPlanProjections
=
"Projections"
;
static
const
char
*
jkProjectLogicPlanProjections
=
"Projections"
;
static
const
char
*
jkProjectLogicPlanLimit
=
"Limit"
;
static
const
char
*
jkProjectLogicPlanOffset
=
"Offset"
;
static
const
char
*
jkProjectLogicPlanSlimit
=
"SLimit"
;
static
const
char
*
jkProjectLogicPlanSoffset
=
"SOffset"
;
static
int32_t
logicProjectNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
static
int32_t
logicProjectNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SProjectLogicNode
*
pNode
=
(
const
SProjectLogicNode
*
)
pObj
;
const
SProjectLogicNode
*
pNode
=
(
const
SProjectLogicNode
*
)
pObj
;
...
@@ -593,18 +603,6 @@ static int32_t logicProjectNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -593,18 +603,6 @@ static int32_t logicProjectNodeToJson(const void* pObj, SJson* pJson) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodeListToJson
(
pJson
,
jkProjectLogicPlanProjections
,
pNode
->
pProjections
);
code
=
nodeListToJson
(
pJson
,
jkProjectLogicPlanProjections
,
pNode
->
pProjections
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddIntegerToObject
(
pJson
,
jkProjectLogicPlanLimit
,
pNode
->
limit
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddIntegerToObject
(
pJson
,
jkProjectLogicPlanOffset
,
pNode
->
offset
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddIntegerToObject
(
pJson
,
jkProjectLogicPlanSlimit
,
pNode
->
slimit
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddIntegerToObject
(
pJson
,
jkProjectLogicPlanSoffset
,
pNode
->
soffset
);
}
return
code
;
return
code
;
}
}
...
@@ -616,18 +614,6 @@ static int32_t jsonToLogicProjectNode(const SJson* pJson, void* pObj) {
...
@@ -616,18 +614,6 @@ static int32_t jsonToLogicProjectNode(const SJson* pJson, void* pObj) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkProjectLogicPlanProjections
,
&
pNode
->
pProjections
);
code
=
jsonToNodeList
(
pJson
,
jkProjectLogicPlanProjections
,
&
pNode
->
pProjections
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetBigIntValue
(
pJson
,
jkProjectLogicPlanLimit
,
&
pNode
->
limit
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetBigIntValue
(
pJson
,
jkProjectLogicPlanOffset
,
&
pNode
->
offset
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetBigIntValue
(
pJson
,
jkProjectLogicPlanSlimit
,
&
pNode
->
slimit
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetBigIntValue
(
pJson
,
jkProjectLogicPlanSoffset
,
&
pNode
->
soffset
);
}
return
code
;
return
code
;
}
}
...
@@ -1283,6 +1269,8 @@ static int32_t logicJoinNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -1283,6 +1269,8 @@ static int32_t logicJoinNodeToJson(const void* pObj, SJson* pJson) {
static
const
char
*
jkPhysiPlanOutputDataBlockDesc
=
"OutputDataBlockDesc"
;
static
const
char
*
jkPhysiPlanOutputDataBlockDesc
=
"OutputDataBlockDesc"
;
static
const
char
*
jkPhysiPlanConditions
=
"Conditions"
;
static
const
char
*
jkPhysiPlanConditions
=
"Conditions"
;
static
const
char
*
jkPhysiPlanChildren
=
"Children"
;
static
const
char
*
jkPhysiPlanChildren
=
"Children"
;
static
const
char
*
jkPhysiPlanLimit
=
"Limit"
;
static
const
char
*
jkPhysiPlanSlimit
=
"SLimit"
;
static
int32_t
physicPlanNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
static
int32_t
physicPlanNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SPhysiNode
*
pNode
=
(
const
SPhysiNode
*
)
pObj
;
const
SPhysiNode
*
pNode
=
(
const
SPhysiNode
*
)
pObj
;
...
@@ -1294,6 +1282,12 @@ static int32_t physicPlanNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -1294,6 +1282,12 @@ static int32_t physicPlanNodeToJson(const void* pObj, SJson* pJson) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodeListToJson
(
pJson
,
jkPhysiPlanChildren
,
pNode
->
pChildren
);
code
=
nodeListToJson
(
pJson
,
jkPhysiPlanChildren
,
pNode
->
pChildren
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddObject
(
pJson
,
jkPhysiPlanLimit
,
nodeToJson
,
pNode
->
pLimit
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddObject
(
pJson
,
jkPhysiPlanSlimit
,
nodeToJson
,
pNode
->
pSlimit
);
}
return
code
;
return
code
;
}
}
...
@@ -1308,6 +1302,12 @@ static int32_t jsonToPhysicPlanNode(const SJson* pJson, void* pObj) {
...
@@ -1308,6 +1302,12 @@ static int32_t jsonToPhysicPlanNode(const SJson* pJson, void* pObj) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkPhysiPlanChildren
,
&
pNode
->
pChildren
);
code
=
jsonToNodeList
(
pJson
,
jkPhysiPlanChildren
,
&
pNode
->
pChildren
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeObject
(
pJson
,
jkPhysiPlanLimit
,
&
pNode
->
pLimit
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeObject
(
pJson
,
jkPhysiPlanSlimit
,
&
pNode
->
pSlimit
);
}
return
code
;
return
code
;
}
}
...
@@ -1590,10 +1590,6 @@ static int32_t jsonToPhysiSysTableScanNode(const SJson* pJson, void* pObj) {
...
@@ -1590,10 +1590,6 @@ static int32_t jsonToPhysiSysTableScanNode(const SJson* pJson, void* pObj) {
}
}
static
const
char
*
jkProjectPhysiPlanProjections
=
"Projections"
;
static
const
char
*
jkProjectPhysiPlanProjections
=
"Projections"
;
static
const
char
*
jkProjectPhysiPlanLimit
=
"Limit"
;
static
const
char
*
jkProjectPhysiPlanOffset
=
"Offset"
;
static
const
char
*
jkProjectPhysiPlanSlimit
=
"SLimit"
;
static
const
char
*
jkProjectPhysiPlanSoffset
=
"SOffset"
;
static
int32_t
physiProjectNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
static
int32_t
physiProjectNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SProjectPhysiNode
*
pNode
=
(
const
SProjectPhysiNode
*
)
pObj
;
const
SProjectPhysiNode
*
pNode
=
(
const
SProjectPhysiNode
*
)
pObj
;
...
@@ -1602,18 +1598,6 @@ static int32_t physiProjectNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -1602,18 +1598,6 @@ static int32_t physiProjectNodeToJson(const void* pObj, SJson* pJson) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodeListToJson
(
pJson
,
jkProjectPhysiPlanProjections
,
pNode
->
pProjections
);
code
=
nodeListToJson
(
pJson
,
jkProjectPhysiPlanProjections
,
pNode
->
pProjections
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddIntegerToObject
(
pJson
,
jkProjectPhysiPlanLimit
,
pNode
->
limit
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddIntegerToObject
(
pJson
,
jkProjectPhysiPlanOffset
,
pNode
->
offset
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddIntegerToObject
(
pJson
,
jkProjectPhysiPlanSlimit
,
pNode
->
slimit
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddIntegerToObject
(
pJson
,
jkProjectPhysiPlanSoffset
,
pNode
->
soffset
);
}
return
code
;
return
code
;
}
}
...
@@ -1625,18 +1609,6 @@ static int32_t jsonToPhysiProjectNode(const SJson* pJson, void* pObj) {
...
@@ -1625,18 +1609,6 @@ static int32_t jsonToPhysiProjectNode(const SJson* pJson, void* pObj) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkProjectPhysiPlanProjections
,
&
pNode
->
pProjections
);
code
=
jsonToNodeList
(
pJson
,
jkProjectPhysiPlanProjections
,
&
pNode
->
pProjections
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetBigIntValue
(
pJson
,
jkProjectPhysiPlanLimit
,
&
pNode
->
limit
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetBigIntValue
(
pJson
,
jkProjectPhysiPlanOffset
,
&
pNode
->
offset
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetBigIntValue
(
pJson
,
jkProjectPhysiPlanSlimit
,
&
pNode
->
slimit
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetBigIntValue
(
pJson
,
jkProjectPhysiPlanSoffset
,
&
pNode
->
soffset
);
}
return
code
;
return
code
;
}
}
...
@@ -3165,6 +3137,31 @@ static int32_t jsonToOrderByExprNode(const SJson* pJson, void* pObj) {
...
@@ -3165,6 +3137,31 @@ static int32_t jsonToOrderByExprNode(const SJson* pJson, void* pObj) {
return
code
;
return
code
;
}
}
static
const
char
*
jkLimitLimit
=
"Limit"
;
static
const
char
*
jkLimitOffset
=
"Offset"
;
static
int32_t
limitNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SLimitNode
*
pNode
=
(
const
SLimitNode
*
)
pObj
;
int32_t
code
=
tjsonAddIntegerToObject
(
pJson
,
jkLimitLimit
,
pNode
->
limit
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddIntegerToObject
(
pJson
,
jkLimitOffset
,
pNode
->
offset
);
}
return
code
;
}
static
int32_t
jsonToLimitNode
(
const
SJson
*
pJson
,
void
*
pObj
)
{
SLimitNode
*
pNode
=
(
SLimitNode
*
)
pObj
;
int32_t
code
=
tjsonGetBigIntValue
(
pJson
,
jkLimitLimit
,
&
pNode
->
limit
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetBigIntValue
(
pJson
,
jkLimitOffset
,
&
pNode
->
offset
);
}
return
code
;
}
static
const
char
*
jkStateWindowCol
=
"StateWindowCol"
;
static
const
char
*
jkStateWindowCol
=
"StateWindowCol"
;
static
const
char
*
jkStateWindowExpr
=
"StateWindowExpr"
;
static
const
char
*
jkStateWindowExpr
=
"StateWindowExpr"
;
...
@@ -4031,7 +4028,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -4031,7 +4028,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
case
QUERY_NODE_ORDER_BY_EXPR
:
case
QUERY_NODE_ORDER_BY_EXPR
:
return
orderByExprNodeToJson
(
pObj
,
pJson
);
return
orderByExprNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_LIMIT
:
case
QUERY_NODE_LIMIT
:
break
;
return
limitNodeToJson
(
pObj
,
pJson
)
;
case
QUERY_NODE_STATE_WINDOW
:
case
QUERY_NODE_STATE_WINDOW
:
return
stateWindowNodeToJson
(
pObj
,
pJson
);
return
stateWindowNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_SESSION_WINDOW
:
case
QUERY_NODE_SESSION_WINDOW
:
...
@@ -4191,6 +4188,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
...
@@ -4191,6 +4188,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
return
jsonToTempTableNode
(
pJson
,
pObj
);
return
jsonToTempTableNode
(
pJson
,
pObj
);
case
QUERY_NODE_ORDER_BY_EXPR
:
case
QUERY_NODE_ORDER_BY_EXPR
:
return
jsonToOrderByExprNode
(
pJson
,
pObj
);
return
jsonToOrderByExprNode
(
pJson
,
pObj
);
case
QUERY_NODE_LIMIT
:
return
jsonToLimitNode
(
pJson
,
pObj
);
case
QUERY_NODE_STATE_WINDOW
:
case
QUERY_NODE_STATE_WINDOW
:
return
jsonToStateWindowNode
(
pJson
,
pObj
);
return
jsonToStateWindowNode
(
pJson
,
pObj
);
case
QUERY_NODE_SESSION_WINDOW
:
case
QUERY_NODE_SESSION_WINDOW
:
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
291aab04
...
@@ -210,6 +210,7 @@ SNode* nodesMakeNode(ENodeType type) {
...
@@ -210,6 +210,7 @@ SNode* nodesMakeNode(ENodeType type) {
case
QUERY_NODE_SHOW_VARIABLES_STMT
:
case
QUERY_NODE_SHOW_VARIABLES_STMT
:
case
QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT
:
case
QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT
:
case
QUERY_NODE_SHOW_TRANSACTIONS_STMT
:
case
QUERY_NODE_SHOW_TRANSACTIONS_STMT
:
case
QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT
:
return
makeNode
(
type
,
sizeof
(
SShowStmt
));
return
makeNode
(
type
,
sizeof
(
SShowStmt
));
case
QUERY_NODE_SHOW_DNODE_VARIABLES_STMT
:
case
QUERY_NODE_SHOW_DNODE_VARIABLES_STMT
:
return
makeNode
(
type
,
sizeof
(
SShowDnodeVariablesStmt
));
return
makeNode
(
type
,
sizeof
(
SShowDnodeVariablesStmt
));
...
@@ -371,6 +372,8 @@ static void destroyScanPhysiNode(SScanPhysiNode* pNode) {
...
@@ -371,6 +372,8 @@ static void destroyScanPhysiNode(SScanPhysiNode* pNode) {
static
void
destroyDataSinkNode
(
SDataSinkNode
*
pNode
)
{
nodesDestroyNode
((
SNode
*
)
pNode
->
pInputDataBlockDesc
);
}
static
void
destroyDataSinkNode
(
SDataSinkNode
*
pNode
)
{
nodesDestroyNode
((
SNode
*
)
pNode
->
pInputDataBlockDesc
);
}
static
void
destroyExprNode
(
SExprNode
*
pExpr
)
{
taosArrayDestroy
(
pExpr
->
pAssociation
);
}
void
nodesDestroyNode
(
SNode
*
pNode
)
{
void
nodesDestroyNode
(
SNode
*
pNode
)
{
if
(
NULL
==
pNode
)
{
if
(
NULL
==
pNode
)
{
return
;
return
;
...
@@ -378,9 +381,11 @@ void nodesDestroyNode(SNode* pNode) {
...
@@ -378,9 +381,11 @@ void nodesDestroyNode(SNode* pNode) {
switch
(
nodeType
(
pNode
))
{
switch
(
nodeType
(
pNode
))
{
case
QUERY_NODE_COLUMN
:
// pProjectRef is weak reference, no need to release
case
QUERY_NODE_COLUMN
:
// pProjectRef is weak reference, no need to release
destroyExprNode
((
SExprNode
*
)
pNode
);
break
;
break
;
case
QUERY_NODE_VALUE
:
{
case
QUERY_NODE_VALUE
:
{
SValueNode
*
pValue
=
(
SValueNode
*
)
pNode
;
SValueNode
*
pValue
=
(
SValueNode
*
)
pNode
;
destroyExprNode
((
SExprNode
*
)
pNode
);
taosMemoryFreeClear
(
pValue
->
literal
);
taosMemoryFreeClear
(
pValue
->
literal
);
if
(
IS_VAR_DATA_TYPE
(
pValue
->
node
.
resType
.
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pValue
->
node
.
resType
.
type
))
{
taosMemoryFreeClear
(
pValue
->
datum
.
p
);
taosMemoryFreeClear
(
pValue
->
datum
.
p
);
...
@@ -389,14 +394,17 @@ void nodesDestroyNode(SNode* pNode) {
...
@@ -389,14 +394,17 @@ void nodesDestroyNode(SNode* pNode) {
}
}
case
QUERY_NODE_OPERATOR
:
{
case
QUERY_NODE_OPERATOR
:
{
SOperatorNode
*
pOp
=
(
SOperatorNode
*
)
pNode
;
SOperatorNode
*
pOp
=
(
SOperatorNode
*
)
pNode
;
destroyExprNode
((
SExprNode
*
)
pNode
);
nodesDestroyNode
(
pOp
->
pLeft
);
nodesDestroyNode
(
pOp
->
pLeft
);
nodesDestroyNode
(
pOp
->
pRight
);
nodesDestroyNode
(
pOp
->
pRight
);
break
;
break
;
}
}
case
QUERY_NODE_LOGIC_CONDITION
:
case
QUERY_NODE_LOGIC_CONDITION
:
destroyExprNode
((
SExprNode
*
)
pNode
);
nodesDestroyList
(((
SLogicConditionNode
*
)
pNode
)
->
pParameterList
);
nodesDestroyList
(((
SLogicConditionNode
*
)
pNode
)
->
pParameterList
);
break
;
break
;
case
QUERY_NODE_FUNCTION
:
case
QUERY_NODE_FUNCTION
:
destroyExprNode
((
SExprNode
*
)
pNode
);
nodesDestroyList
(((
SFunctionNode
*
)
pNode
)
->
pParameterList
);
nodesDestroyList
(((
SFunctionNode
*
)
pNode
)
->
pParameterList
);
break
;
break
;
case
QUERY_NODE_REAL_TABLE
:
{
case
QUERY_NODE_REAL_TABLE
:
{
...
@@ -644,7 +652,8 @@ void nodesDestroyNode(SNode* pNode) {
...
@@ -644,7 +652,8 @@ void nodesDestroyNode(SNode* pNode) {
case
QUERY_NODE_SHOW_SCORES_STMT
:
case
QUERY_NODE_SHOW_SCORES_STMT
:
case
QUERY_NODE_SHOW_VARIABLES_STMT
:
case
QUERY_NODE_SHOW_VARIABLES_STMT
:
case
QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT
:
case
QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT
:
case
QUERY_NODE_SHOW_TRANSACTIONS_STMT
:
{
case
QUERY_NODE_SHOW_TRANSACTIONS_STMT
:
case
QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT
:
{
SShowStmt
*
pStmt
=
(
SShowStmt
*
)
pNode
;
SShowStmt
*
pStmt
=
(
SShowStmt
*
)
pNode
;
nodesDestroyNode
(
pStmt
->
pDbName
);
nodesDestroyNode
(
pStmt
->
pDbName
);
nodesDestroyNode
(
pStmt
->
pTbName
);
nodesDestroyNode
(
pStmt
->
pTbName
);
...
@@ -831,6 +840,7 @@ void nodesDestroyNode(SNode* pNode) {
...
@@ -831,6 +840,7 @@ void nodesDestroyNode(SNode* pNode) {
destroyPhysiNode
((
SPhysiNode
*
)
pPhyNode
);
destroyPhysiNode
((
SPhysiNode
*
)
pPhyNode
);
nodesDestroyList
(
pPhyNode
->
pExprs
);
nodesDestroyList
(
pPhyNode
->
pExprs
);
nodesDestroyList
(
pPhyNode
->
pSortKeys
);
nodesDestroyList
(
pPhyNode
->
pSortKeys
);
nodesDestroyList
(
pPhyNode
->
pTargets
);
break
;
break
;
}
}
case
QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL
:
case
QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL
:
...
@@ -1094,6 +1104,16 @@ SNode* nodesListGetNode(SNodeList* pList, int32_t index) {
...
@@ -1094,6 +1104,16 @@ SNode* nodesListGetNode(SNodeList* pList, int32_t index) {
return
NULL
;
return
NULL
;
}
}
SListCell
*
nodesListGetCell
(
SNodeList
*
pList
,
int32_t
index
)
{
SNode
*
node
;
FOREACH
(
node
,
pList
)
{
if
(
0
==
index
--
)
{
return
cell
;
}
}
return
NULL
;
}
void
nodesDestroyList
(
SNodeList
*
pList
)
{
void
nodesDestroyList
(
SNodeList
*
pList
)
{
if
(
NULL
==
pList
)
{
if
(
NULL
==
pList
)
{
return
;
return
;
...
...
source/libs/parser/inc/parAst.h
浏览文件 @
291aab04
...
@@ -170,7 +170,8 @@ SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode);
...
@@ -170,7 +170,8 @@ SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode);
SNode
*
createAlterDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnode
,
const
SToken
*
pConfig
,
const
SToken
*
pValue
);
SNode
*
createAlterDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnode
,
const
SToken
*
pConfig
,
const
SToken
*
pValue
);
SNode
*
createCreateIndexStmt
(
SAstCreateContext
*
pCxt
,
EIndexType
type
,
bool
ignoreExists
,
SToken
*
pIndexName
,
SNode
*
createCreateIndexStmt
(
SAstCreateContext
*
pCxt
,
EIndexType
type
,
bool
ignoreExists
,
SToken
*
pIndexName
,
SToken
*
pTableName
,
SNodeList
*
pCols
,
SNode
*
pOptions
);
SToken
*
pTableName
,
SNodeList
*
pCols
,
SNode
*
pOptions
);
SNode
*
createIndexOption
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pFuncs
,
SNode
*
pInterval
,
SNode
*
pOffset
,
SNode
*
pSliding
);
SNode
*
createIndexOption
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pFuncs
,
SNode
*
pInterval
,
SNode
*
pOffset
,
SNode
*
pSliding
,
SNode
*
pStreamOptions
);
SNode
*
createDropIndexStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
SToken
*
pIndexName
);
SNode
*
createDropIndexStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
SToken
*
pIndexName
);
SNode
*
createCreateComponentNodeStmt
(
SAstCreateContext
*
pCxt
,
ENodeType
type
,
const
SToken
*
pDnodeId
);
SNode
*
createCreateComponentNodeStmt
(
SAstCreateContext
*
pCxt
,
ENodeType
type
,
const
SToken
*
pDnodeId
);
SNode
*
createDropComponentNodeStmt
(
SAstCreateContext
*
pCxt
,
ENodeType
type
,
const
SToken
*
pDnodeId
);
SNode
*
createDropComponentNodeStmt
(
SAstCreateContext
*
pCxt
,
ENodeType
type
,
const
SToken
*
pDnodeId
);
...
...
source/libs/parser/inc/sql.y
浏览文件 @
291aab04
...
@@ -388,6 +388,8 @@ cmd ::= SHOW SNODES.
...
@@ -388,6 +388,8 @@ cmd ::= SHOW SNODES.
cmd ::= SHOW CLUSTER. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT); }
cmd ::= SHOW CLUSTER. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT); }
cmd ::= SHOW TRANSACTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); }
cmd ::= SHOW TRANSACTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); }
cmd ::= SHOW TABLE DISTRIBUTED full_table_name(A). { pCxt->pRootNode = createShowTableDistributedStmt(pCxt, A); }
cmd ::= SHOW TABLE DISTRIBUTED full_table_name(A). { pCxt->pRootNode = createShowTableDistributedStmt(pCxt, A); }
cmd ::= SHOW CONSUMERS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); }
cmd ::= SHOW SUBSCRIPTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); }
db_name_cond_opt(A) ::= . { A = createDefaultDatabaseCondValue(pCxt); }
db_name_cond_opt(A) ::= . { A = createDefaultDatabaseCondValue(pCxt); }
db_name_cond_opt(A) ::= db_name(B) NK_DOT. { A = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); }
db_name_cond_opt(A) ::= db_name(B) NK_DOT. { A = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); }
...
@@ -407,11 +409,11 @@ cmd ::= CREATE SMA INDEX not_exists_opt(D)
...
@@ -407,11 +409,11 @@ cmd ::= CREATE SMA INDEX not_exists_opt(D)
// index_name(A) ON table_name(B) NK_LP col_name_list(C) NK_RP. { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, D, &A, &B, C, NULL); }
// index_name(A) ON table_name(B) NK_LP col_name_list(C) NK_RP. { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, D, &A, &B, C, NULL); }
cmd ::= DROP INDEX exists_opt(B) index_name(A). { pCxt->pRootNode = createDropIndexStmt(pCxt, B, &A); }
cmd ::= DROP INDEX exists_opt(B) index_name(A). { pCxt->pRootNode = createDropIndexStmt(pCxt, B, &A); }
index_options(A) ::= . { A = NULL; }
index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL
index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL
NK_LP duration_literal(C) NK_RP sliding_opt(D)
. { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), NULL, D
); }
NK_LP duration_literal(C) NK_RP sliding_opt(D)
sma_stream_opt(E). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), NULL, D, E
); }
index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL
index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL
NK_LP duration_literal(C) NK_COMMA duration_literal(D) NK_RP sliding_opt(E). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), releaseRawExprNode(pCxt, D), E); }
NK_LP duration_literal(C) NK_COMMA duration_literal(D) NK_RP sliding_opt(E)
sma_stream_opt(F). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), releaseRawExprNode(pCxt, D), E, F); }
%type func_list { SNodeList* }
%type func_list { SNodeList* }
%destructor func_list { nodesDestroyList($$); }
%destructor func_list { nodesDestroyList($$); }
...
@@ -420,6 +422,10 @@ func_list(A) ::= func_list(B) NK_COMMA func(C).
...
@@ -420,6 +422,10 @@ func_list(A) ::= func_list(B) NK_COMMA func(C).
func(A) ::= function_name(B) NK_LP expression_list(C) NK_RP. { A = createFunctionNode(pCxt, &B, C); }
func(A) ::= function_name(B) NK_LP expression_list(C) NK_RP. { A = createFunctionNode(pCxt, &B, C); }
sma_stream_opt(A) ::= . { A = createStreamOptions(pCxt); }
sma_stream_opt(A) ::= stream_options(B) WATERMARK duration_literal(C). { ((SStreamOptions*)B)->pWatermark = releaseRawExprNode(pCxt, C); A = B; }
sma_stream_opt(A) ::= stream_options(B) MAX_DELAY duration_literal(C). { ((SStreamOptions*)B)->pDelay = releaseRawExprNode(pCxt, C); A = B; }
/************************************************ create/drop topic ***************************************************/
/************************************************ create/drop topic ***************************************************/
cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS query_expression(C). { pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, A, &B, C); }
cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS query_expression(C). { pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, A, &B, C); }
cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS DATABASE db_name(C). { pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, A, &B, &C, false); }
cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS DATABASE db_name(C). { pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, A, &B, &C, false); }
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
291aab04
...
@@ -1317,8 +1317,8 @@ SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool igno
...
@@ -1317,8 +1317,8 @@ SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool igno
return
(
SNode
*
)
pStmt
;
return
(
SNode
*
)
pStmt
;
}
}
SNode
*
createIndexOption
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pFuncs
,
SNode
*
pInterval
,
SNode
*
pOffset
,
SNode
*
createIndexOption
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pFuncs
,
SNode
*
pInterval
,
SNode
*
pOffset
,
SNode
*
pSliding
,
SNode
*
pS
liding
)
{
SNode
*
pS
treamOptions
)
{
CHECK_PARSER_STATUS
(
pCxt
);
CHECK_PARSER_STATUS
(
pCxt
);
SIndexOptions
*
pOptions
=
(
SIndexOptions
*
)
nodesMakeNode
(
QUERY_NODE_INDEX_OPTIONS
);
SIndexOptions
*
pOptions
=
(
SIndexOptions
*
)
nodesMakeNode
(
QUERY_NODE_INDEX_OPTIONS
);
CHECK_OUT_OF_MEM
(
pOptions
);
CHECK_OUT_OF_MEM
(
pOptions
);
...
@@ -1326,6 +1326,7 @@ SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInt
...
@@ -1326,6 +1326,7 @@ SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInt
pOptions
->
pInterval
=
pInterval
;
pOptions
->
pInterval
=
pInterval
;
pOptions
->
pOffset
=
pOffset
;
pOptions
->
pOffset
=
pOffset
;
pOptions
->
pSliding
=
pSliding
;
pOptions
->
pSliding
=
pSliding
;
pOptions
->
pStreamOptions
=
pStreamOptions
;
return
(
SNode
*
)
pOptions
;
return
(
SNode
*
)
pOptions
;
}
}
...
...
source/libs/parser/src/parAstParser.c
浏览文件 @
291aab04
...
@@ -380,6 +380,11 @@ static int32_t collectMetaKeyFromShowTopics(SCollectMetaKeyCxt* pCxt, SShowStmt*
...
@@ -380,6 +380,11 @@ static int32_t collectMetaKeyFromShowTopics(SCollectMetaKeyCxt* pCxt, SShowStmt*
pCxt
->
pMetaCache
);
pCxt
->
pMetaCache
);
}
}
static
int32_t
collectMetaKeyFromShowConsumers
(
SCollectMetaKeyCxt
*
pCxt
,
SShowStmt
*
pStmt
)
{
return
reserveTableMetaInCache
(
pCxt
->
pParseCxt
->
acctId
,
TSDB_PERFORMANCE_SCHEMA_DB
,
TSDB_PERFS_TABLE_CONSUMERS
,
pCxt
->
pMetaCache
);
}
static
int32_t
collectMetaKeyFromShowConnections
(
SCollectMetaKeyCxt
*
pCxt
,
SShowStmt
*
pStmt
)
{
static
int32_t
collectMetaKeyFromShowConnections
(
SCollectMetaKeyCxt
*
pCxt
,
SShowStmt
*
pStmt
)
{
return
reserveTableMetaInCache
(
pCxt
->
pParseCxt
->
acctId
,
TSDB_PERFORMANCE_SCHEMA_DB
,
TSDB_PERFS_TABLE_CONNECTIONS
,
return
reserveTableMetaInCache
(
pCxt
->
pParseCxt
->
acctId
,
TSDB_PERFORMANCE_SCHEMA_DB
,
TSDB_PERFS_TABLE_CONNECTIONS
,
pCxt
->
pMetaCache
);
pCxt
->
pMetaCache
);
...
@@ -456,6 +461,11 @@ static int32_t collectMetaKeyFromShowBlockDist(SCollectMetaKeyCxt* pCxt, SShowTa
...
@@ -456,6 +461,11 @@ static int32_t collectMetaKeyFromShowBlockDist(SCollectMetaKeyCxt* pCxt, SShowTa
return
code
;
return
code
;
}
}
static
int32_t
collectMetaKeyFromShowSubscriptions
(
SCollectMetaKeyCxt
*
pCxt
,
SShowStmt
*
pStmt
)
{
return
reserveTableMetaInCache
(
pCxt
->
pParseCxt
->
acctId
,
TSDB_PERFORMANCE_SCHEMA_DB
,
TSDB_PERFS_TABLE_SUBSCRIPTIONS
,
pCxt
->
pMetaCache
);
}
static
int32_t
collectMetaKeyFromQuery
(
SCollectMetaKeyCxt
*
pCxt
,
SNode
*
pStmt
)
{
static
int32_t
collectMetaKeyFromQuery
(
SCollectMetaKeyCxt
*
pCxt
,
SNode
*
pStmt
)
{
pCxt
->
pStmt
=
pStmt
;
pCxt
->
pStmt
=
pStmt
;
switch
(
nodeType
(
pStmt
))
{
switch
(
nodeType
(
pStmt
))
{
...
@@ -517,6 +527,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
...
@@ -517,6 +527,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
return
collectMetaKeyFromShowVgroups
(
pCxt
,
(
SShowStmt
*
)
pStmt
);
return
collectMetaKeyFromShowVgroups
(
pCxt
,
(
SShowStmt
*
)
pStmt
);
case
QUERY_NODE_SHOW_TOPICS_STMT
:
case
QUERY_NODE_SHOW_TOPICS_STMT
:
return
collectMetaKeyFromShowTopics
(
pCxt
,
(
SShowStmt
*
)
pStmt
);
return
collectMetaKeyFromShowTopics
(
pCxt
,
(
SShowStmt
*
)
pStmt
);
case
QUERY_NODE_SHOW_CONSUMERS_STMT
:
return
collectMetaKeyFromShowConsumers
(
pCxt
,
(
SShowStmt
*
)
pStmt
);
case
QUERY_NODE_SHOW_CONNECTIONS_STMT
:
case
QUERY_NODE_SHOW_CONNECTIONS_STMT
:
return
collectMetaKeyFromShowConnections
(
pCxt
,
(
SShowStmt
*
)
pStmt
);
return
collectMetaKeyFromShowConnections
(
pCxt
,
(
SShowStmt
*
)
pStmt
);
case
QUERY_NODE_SHOW_QUERIES_STMT
:
case
QUERY_NODE_SHOW_QUERIES_STMT
:
...
@@ -538,6 +550,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
...
@@ -538,6 +550,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
return
collectMetaKeyFromDelete
(
pCxt
,
(
SDeleteStmt
*
)
pStmt
);
return
collectMetaKeyFromDelete
(
pCxt
,
(
SDeleteStmt
*
)
pStmt
);
case
QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT
:
case
QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT
:
return
collectMetaKeyFromShowBlockDist
(
pCxt
,
(
SShowTableDistributedStmt
*
)
pStmt
);
return
collectMetaKeyFromShowBlockDist
(
pCxt
,
(
SShowTableDistributedStmt
*
)
pStmt
);
case
QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT
:
return
collectMetaKeyFromShowSubscriptions
(
pCxt
,
(
SShowStmt
*
)
pStmt
);
default:
default:
break
;
break
;
}
}
...
...
source/libs/parser/src/parCalcConst.c
浏览文件 @
291aab04
...
@@ -175,17 +175,23 @@ static int32_t calcConstProject(SNode* pProject, SNode** pNew) {
...
@@ -175,17 +175,23 @@ static int32_t calcConstProject(SNode* pProject, SNode** pNew) {
}
}
}
}
char
aliasName
[
TSDB_COL_NAME_LEN
]
=
{
0
};
strcpy
(
aliasName
,
((
SExprNode
*
)
pProject
)
->
aliasName
);
int32_t
code
=
scalarCalculateConstants
(
pProject
,
pNew
);
int32_t
code
=
scalarCalculateConstants
(
pProject
,
pNew
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
QUERY_NODE_VALUE
==
nodeType
(
*
pNew
)
&&
NULL
!=
pAssociation
)
{
if
(
TSDB_CODE_SUCCESS
==
code
&&
QUERY_NODE_VALUE
==
nodeType
(
*
pNew
)
&&
NULL
!=
pAssociation
)
{
strcpy
(((
SExprNode
*
)
*
pNew
)
->
aliasName
,
aliasName
);
int32_t
size
=
taosArrayGetSize
(
pAssociation
);
int32_t
size
=
taosArrayGetSize
(
pAssociation
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SNode
**
pCol
=
taosArrayGetP
(
pAssociation
,
i
);
SNode
**
pCol
=
taosArrayGetP
(
pAssociation
,
i
);
nodesDestroyNode
(
*
pCol
);
*
pCol
=
nodesCloneNode
(
*
pNew
);
*
pCol
=
nodesCloneNode
(
*
pNew
);
if
(
NULL
==
*
pCol
)
{
if
(
NULL
==
*
pCol
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
break
;
}
}
}
}
}
}
taosArrayDestroy
(
pAssociation
);
return
code
;
return
code
;
}
}
...
@@ -196,6 +202,19 @@ static bool isUselessCol(bool hasSelectValFunc, SExprNode* pProj) {
...
@@ -196,6 +202,19 @@ static bool isUselessCol(bool hasSelectValFunc, SExprNode* pProj) {
return
NULL
==
((
SExprNode
*
)
pProj
)
->
pAssociation
;
return
NULL
==
((
SExprNode
*
)
pProj
)
->
pAssociation
;
}
}
static
SNode
*
createConstantValue
()
{
SValueNode
*
pVal
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
if
(
NULL
==
pVal
)
{
return
NULL
;
}
pVal
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_INT
;
pVal
->
node
.
resType
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_INT
].
bytes
;
const
int32_t
val
=
1
;
nodesSetValueNodeValue
(
pVal
,
(
void
*
)
&
val
);
pVal
->
translate
=
true
;
return
(
SNode
*
)
pVal
;
}
static
int32_t
calcConstProjections
(
SCalcConstContext
*
pCxt
,
SSelectStmt
*
pSelect
,
bool
subquery
)
{
static
int32_t
calcConstProjections
(
SCalcConstContext
*
pCxt
,
SSelectStmt
*
pSelect
,
bool
subquery
)
{
SNode
*
pProj
=
NULL
;
SNode
*
pProj
=
NULL
;
WHERE_EACH
(
pProj
,
pSelect
->
pProjectionList
)
{
WHERE_EACH
(
pProj
,
pSelect
->
pProjectionList
)
{
...
@@ -212,6 +231,9 @@ static int32_t calcConstProjections(SCalcConstContext* pCxt, SSelectStmt* pSelec
...
@@ -212,6 +231,9 @@ static int32_t calcConstProjections(SCalcConstContext* pCxt, SSelectStmt* pSelec
}
}
WHERE_NEXT
;
WHERE_NEXT
;
}
}
if
(
0
==
LIST_LENGTH
(
pSelect
->
pProjectionList
))
{
return
nodesListStrictAppend
(
pSelect
->
pProjectionList
,
createConstantValue
());
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
...
source/libs/parser/src/parTokenizer.c
浏览文件 @
291aab04
...
@@ -63,6 +63,7 @@ static SKeyword keywordTable[] = {
...
@@ -63,6 +63,7 @@ static SKeyword keywordTable[] = {
{
"CONNECTION"
,
TK_CONNECTION
},
{
"CONNECTION"
,
TK_CONNECTION
},
{
"CONNECTIONS"
,
TK_CONNECTIONS
},
{
"CONNECTIONS"
,
TK_CONNECTIONS
},
{
"CONSUMER"
,
TK_CONSUMER
},
{
"CONSUMER"
,
TK_CONSUMER
},
{
"CONSUMERS"
,
TK_CONSUMERS
},
{
"COUNT"
,
TK_COUNT
},
{
"COUNT"
,
TK_COUNT
},
{
"CREATE"
,
TK_CREATE
},
{
"CREATE"
,
TK_CREATE
},
{
"CONTAINS"
,
TK_CONTAINS
},
{
"CONTAINS"
,
TK_CONTAINS
},
...
@@ -188,6 +189,7 @@ static SKeyword keywordTable[] = {
...
@@ -188,6 +189,7 @@ static SKeyword keywordTable[] = {
{
"STREAM"
,
TK_STREAM
},
{
"STREAM"
,
TK_STREAM
},
{
"STREAMS"
,
TK_STREAMS
},
{
"STREAMS"
,
TK_STREAMS
},
{
"STRICT"
,
TK_STRICT
},
{
"STRICT"
,
TK_STRICT
},
{
"SUBSCRIPTIONS"
,
TK_SUBSCRIPTIONS
},
{
"SYNCDB"
,
TK_SYNCDB
},
{
"SYNCDB"
,
TK_SYNCDB
},
{
"SYSINFO"
,
TK_SYSINFO
},
{
"SYSINFO"
,
TK_SYSINFO
},
{
"TABLE"
,
TK_TABLE
},
{
"TABLE"
,
TK_TABLE
},
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
291aab04
...
@@ -517,8 +517,9 @@ static int32_t createColumnsByTable(STranslateContext* pCxt, const STableNode* p
...
@@ -517,8 +517,9 @@ static int32_t createColumnsByTable(STranslateContext* pCxt, const STableNode* p
if
(
NULL
==
pCol
)
{
if
(
NULL
==
pCol
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_OUT_OF_MEMORY
);
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_OUT_OF_MEMORY
);
}
}
setColumnInfoByExpr
(
pTable
,
(
SExprNode
*
)
pNode
,
&
pCol
);
nodesListAppend
(
pList
,
(
SNode
*
)
pCol
);
nodesListAppend
(
pList
,
(
SNode
*
)
pCol
);
SListCell
*
pCell
=
nodesListGetCell
(
pList
,
LIST_LENGTH
(
pList
)
-
1
);
setColumnInfoByExpr
(
pTable
,
(
SExprNode
*
)
pNode
,
(
SColumnNode
**
)
&
pCell
->
pNode
);
}
}
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -707,7 +708,11 @@ static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode** pCol) {
...
@@ -707,7 +708,11 @@ static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode** pCol) {
res
=
translateColumnUseAlias
(
pCxt
,
pCol
,
&
found
);
res
=
translateColumnUseAlias
(
pCxt
,
pCol
,
&
found
);
}
}
if
(
DEAL_RES_ERROR
!=
res
&&
!
found
)
{
if
(
DEAL_RES_ERROR
!=
res
&&
!
found
)
{
res
=
translateColumnWithoutPrefix
(
pCxt
,
pCol
);
if
(
NULL
!=
pCxt
->
pCurrSetOperator
)
{
res
=
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_COLUMN
,
(
*
pCol
)
->
colName
);
}
else
{
res
=
translateColumnWithoutPrefix
(
pCxt
,
pCol
);
}
}
}
}
}
return
res
;
return
res
;
...
@@ -2656,6 +2661,13 @@ static int32_t translateSetOperOrderBy(STranslateContext* pCxt, SSetOperator* pS
...
@@ -2656,6 +2661,13 @@ static int32_t translateSetOperOrderBy(STranslateContext* pCxt, SSetOperator* pS
return
code
;
return
code
;
}
}
static
int32_t
checkSetOperLimit
(
STranslateContext
*
pCxt
,
SLimitNode
*
pLimit
)
{
if
((
NULL
!=
pLimit
&&
pLimit
->
offset
<
0
))
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_OFFSET_LESS_ZERO
);
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
translateSetOperator
(
STranslateContext
*
pCxt
,
SSetOperator
*
pSetOperator
)
{
static
int32_t
translateSetOperator
(
STranslateContext
*
pCxt
,
SSetOperator
*
pSetOperator
)
{
int32_t
code
=
translateQuery
(
pCxt
,
pSetOperator
->
pLeft
);
int32_t
code
=
translateQuery
(
pCxt
,
pSetOperator
->
pLeft
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
@@ -2671,6 +2683,9 @@ static int32_t translateSetOperator(STranslateContext* pCxt, SSetOperator* pSetO
...
@@ -2671,6 +2683,9 @@ static int32_t translateSetOperator(STranslateContext* pCxt, SSetOperator* pSetO
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
translateSetOperOrderBy
(
pCxt
,
pSetOperator
);
code
=
translateSetOperOrderBy
(
pCxt
,
pSetOperator
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkSetOperLimit
(
pCxt
,
(
SLimitNode
*
)
pSetOperator
->
pLimit
);
}
return
code
;
return
code
;
}
}
...
@@ -3566,9 +3581,7 @@ static int32_t buildRollupFuncs(SNodeList* pFuncs, SArray** pArray) {
...
@@ -3566,9 +3581,7 @@ static int32_t buildRollupFuncs(SNodeList* pFuncs, SArray** pArray) {
}
}
*
pArray
=
taosArrayInit
(
LIST_LENGTH
(
pFuncs
),
TSDB_FUNC_NAME_LEN
);
*
pArray
=
taosArrayInit
(
LIST_LENGTH
(
pFuncs
),
TSDB_FUNC_NAME_LEN
);
SNode
*
pNode
;
SNode
*
pNode
;
FOREACH
(
pNode
,
pFuncs
)
{
FOREACH
(
pNode
,
pFuncs
)
{
taosArrayPush
(
*
pArray
,
((
SFunctionNode
*
)
pNode
)
->
functionName
);
}
taosArrayPush
(
*
pArray
,
((
SFunctionNode
*
)
pNode
)
->
functionName
);
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -3867,6 +3880,11 @@ static int32_t buildCreateSmaReq(STranslateContext* pCxt, SCreateIndexStmt* pStm
...
@@ -3867,6 +3880,11 @@ static int32_t buildCreateSmaReq(STranslateContext* pCxt, SCreateIndexStmt* pStm
(
NULL
!=
pStmt
->
pOptions
->
pSliding
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pSliding
)
->
datum
.
i
:
pReq
->
interval
);
(
NULL
!=
pStmt
->
pOptions
->
pSliding
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pSliding
)
->
datum
.
i
:
pReq
->
interval
);
pReq
->
slidingUnit
=
pReq
->
slidingUnit
=
(
NULL
!=
pStmt
->
pOptions
->
pSliding
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pSliding
)
->
unit
:
pReq
->
intervalUnit
);
(
NULL
!=
pStmt
->
pOptions
->
pSliding
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pSliding
)
->
unit
:
pReq
->
intervalUnit
);
if
(
NULL
!=
pStmt
->
pOptions
->
pStreamOptions
)
{
SStreamOptions
*
pStreamOpt
=
(
SStreamOptions
*
)
pStmt
->
pOptions
->
pStreamOptions
;
pReq
->
maxDelay
=
(
NULL
!=
pStreamOpt
->
pDelay
?
((
SValueNode
*
)
pStreamOpt
->
pDelay
)
->
datum
.
i
:
0
);
pReq
->
watermark
=
(
NULL
!=
pStreamOpt
->
pWatermark
?
((
SValueNode
*
)
pStreamOpt
->
pWatermark
)
->
datum
.
i
:
0
);
}
int32_t
code
=
getSmaIndexDstVgId
(
pCxt
,
pStmt
->
tableName
,
&
pReq
->
dstVgId
);
int32_t
code
=
getSmaIndexDstVgId
(
pCxt
,
pStmt
->
tableName
,
&
pReq
->
dstVgId
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
@@ -3888,6 +3906,18 @@ static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt
...
@@ -3888,6 +3906,18 @@ static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt
return
pCxt
->
errCode
;
return
pCxt
->
errCode
;
}
}
if
(
NULL
!=
pStmt
->
pOptions
->
pStreamOptions
)
{
SStreamOptions
*
pStreamOpt
=
(
SStreamOptions
*
)
pStmt
->
pOptions
->
pStreamOptions
;
if
(
NULL
!=
pStreamOpt
->
pWatermark
&&
(
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
(
SValueNode
*
)
pStreamOpt
->
pWatermark
)))
{
return
pCxt
->
errCode
;
}
if
(
NULL
!=
pStreamOpt
->
pDelay
&&
(
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
(
SValueNode
*
)
pStreamOpt
->
pDelay
)))
{
return
pCxt
->
errCode
;
}
}
SMCreateSmaReq
createSmaReq
=
{
0
};
SMCreateSmaReq
createSmaReq
=
{
0
};
int32_t
code
=
buildCreateSmaReq
(
pCxt
,
pStmt
,
&
createSmaReq
);
int32_t
code
=
buildCreateSmaReq
(
pCxt
,
pStmt
,
&
createSmaReq
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
@@ -4629,7 +4659,6 @@ static int32_t extractShowLocalVariablesResultSchema(int32_t* numOfCols, SSchema
...
@@ -4629,7 +4659,6 @@ static int32_t extractShowLocalVariablesResultSchema(int32_t* numOfCols, SSchema
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
extractResultSchema
(
const
SNode
*
pRoot
,
int32_t
*
numOfCols
,
SSchema
**
pSchema
)
{
int32_t
extractResultSchema
(
const
SNode
*
pRoot
,
int32_t
*
numOfCols
,
SSchema
**
pSchema
)
{
if
(
NULL
==
pRoot
)
{
if
(
NULL
==
pRoot
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -4683,6 +4712,8 @@ static const char* getSysDbName(ENodeType type) {
...
@@ -4683,6 +4712,8 @@ static const char* getSysDbName(ENodeType type) {
case
QUERY_NODE_SHOW_STREAMS_STMT
:
case
QUERY_NODE_SHOW_STREAMS_STMT
:
case
QUERY_NODE_SHOW_TRANSACTIONS_STMT
:
case
QUERY_NODE_SHOW_TRANSACTIONS_STMT
:
case
QUERY_NODE_SHOW_APPS_STMT
:
case
QUERY_NODE_SHOW_APPS_STMT
:
case
QUERY_NODE_SHOW_CONSUMERS_STMT
:
case
QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT
:
return
TSDB_PERFORMANCE_SCHEMA_DB
;
return
TSDB_PERFORMANCE_SCHEMA_DB
;
default:
default:
break
;
break
;
...
@@ -4738,6 +4769,10 @@ static const char* getSysTableName(ENodeType type) {
...
@@ -4738,6 +4769,10 @@ static const char* getSysTableName(ENodeType type) {
return
TSDB_PERFS_TABLE_APPS
;
return
TSDB_PERFS_TABLE_APPS
;
case
QUERY_NODE_SHOW_DNODE_VARIABLES_STMT
:
case
QUERY_NODE_SHOW_DNODE_VARIABLES_STMT
:
return
TSDB_INS_TABLE_DNODE_VARIABLES
;
return
TSDB_INS_TABLE_DNODE_VARIABLES
;
case
QUERY_NODE_SHOW_CONSUMERS_STMT
:
return
TSDB_PERFS_TABLE_CONSUMERS
;
case
QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT
:
return
TSDB_PERFS_TABLE_SUBSCRIPTIONS
;
default:
default:
break
;
break
;
}
}
...
@@ -5876,6 +5911,8 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) {
...
@@ -5876,6 +5911,8 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) {
case
QUERY_NODE_SHOW_TRANSACTIONS_STMT
:
case
QUERY_NODE_SHOW_TRANSACTIONS_STMT
:
case
QUERY_NODE_SHOW_VARIABLES_STMT
:
case
QUERY_NODE_SHOW_VARIABLES_STMT
:
case
QUERY_NODE_SHOW_APPS_STMT
:
case
QUERY_NODE_SHOW_APPS_STMT
:
case
QUERY_NODE_SHOW_CONSUMERS_STMT
:
case
QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT
:
code
=
rewriteShow
(
pCxt
,
pQuery
);
code
=
rewriteShow
(
pCxt
,
pQuery
);
break
;
break
;
case
QUERY_NODE_SHOW_DNODE_VARIABLES_STMT
:
case
QUERY_NODE_SHOW_DNODE_VARIABLES_STMT
:
...
...
source/libs/parser/src/parUtil.c
浏览文件 @
291aab04
...
@@ -897,7 +897,7 @@ STableCfg* tableCfgDup(STableCfg* pCfg) {
...
@@ -897,7 +897,7 @@ STableCfg* tableCfgDup(STableCfg* pCfg) {
if
(
pNew
->
pFuncs
)
{
if
(
pNew
->
pFuncs
)
{
pNew
->
pFuncs
=
taosArrayDup
(
pNew
->
pFuncs
);
pNew
->
pFuncs
=
taosArrayDup
(
pNew
->
pFuncs
);
}
}
int32_t
schemaSize
=
(
pCfg
->
numOfColumns
+
pCfg
->
numOfTags
)
*
sizeof
(
SSchema
);
int32_t
schemaSize
=
(
pCfg
->
numOfColumns
+
pCfg
->
numOfTags
)
*
sizeof
(
SSchema
);
SSchema
*
pSchema
=
taosMemoryMalloc
(
schemaSize
);
SSchema
*
pSchema
=
taosMemoryMalloc
(
schemaSize
);
...
@@ -912,7 +912,7 @@ int32_t getTableCfgFromCache(SParseMetaCache* pMetaCache, const SName* pName, ST
...
@@ -912,7 +912,7 @@ int32_t getTableCfgFromCache(SParseMetaCache* pMetaCache, const SName* pName, ST
char
fullName
[
TSDB_TABLE_FNAME_LEN
];
char
fullName
[
TSDB_TABLE_FNAME_LEN
];
tNameExtractFullName
(
pName
,
fullName
);
tNameExtractFullName
(
pName
,
fullName
);
STableCfg
*
pCfg
=
NULL
;
STableCfg
*
pCfg
=
NULL
;
int32_t
code
=
getMetaDataFromHash
(
fullName
,
strlen
(
fullName
),
pMetaCache
->
pTableCfg
,
(
void
**
)
&
pCfg
);
int32_t
code
=
getMetaDataFromHash
(
fullName
,
strlen
(
fullName
),
pMetaCache
->
pTableCfg
,
(
void
**
)
&
pCfg
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pOutput
=
tableCfgDup
(
pCfg
);
*
pOutput
=
tableCfgDup
(
pCfg
);
if
(
NULL
==
*
pOutput
)
{
if
(
NULL
==
*
pOutput
)
{
...
@@ -929,10 +929,10 @@ int32_t reserveDnodeRequiredInCache(SParseMetaCache* pMetaCache) {
...
@@ -929,10 +929,10 @@ int32_t reserveDnodeRequiredInCache(SParseMetaCache* pMetaCache) {
int32_t
getDnodeListFromCache
(
SParseMetaCache
*
pMetaCache
,
SArray
**
pDnodes
)
{
int32_t
getDnodeListFromCache
(
SParseMetaCache
*
pMetaCache
,
SArray
**
pDnodes
)
{
SMetaRes
*
pRes
=
taosArrayGet
(
pMetaCache
->
pDnodes
,
0
);
SMetaRes
*
pRes
=
taosArrayGet
(
pMetaCache
->
pDnodes
,
0
);
if
(
pRes
->
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
pRes
->
code
)
{
return
pRes
->
code
;
return
pRes
->
code
;
}
}
*
pDnodes
=
taosArrayDup
((
SArray
*
)
pRes
->
pRes
);
*
pDnodes
=
taosArrayDup
((
SArray
*
)
pRes
->
pRes
);
if
(
NULL
==
*
pDnodes
)
{
if
(
NULL
==
*
pDnodes
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
...
...
source/libs/parser/src/sql.c
浏览文件 @
291aab04
此差异已折叠。
点击以展开。
source/libs/parser/test/mockCatalog.cpp
浏览文件 @
291aab04
...
@@ -25,95 +25,125 @@
...
@@ -25,95 +25,125 @@
#ifdef WINDOWS
#ifdef WINDOWS
#define TD_USE_WINSOCK
#define TD_USE_WINSOCK
#endif
#endif
#include "mockCatalog.h"
#include "mockCatalog.h"
#include "systable.h"
namespace
{
namespace
{
void
generateInformationSchema
(
MockCatalogService
*
mcs
)
{
void
generateInformationSchema
(
MockCatalogService
*
mcs
)
{
{
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"dnodes"
,
TSDB_SYSTEM_TABLE
,
1
)
ITableBuilder
&
builder
=
.
addColumn
(
"id"
,
TSDB_DATA_TYPE_INT
);
mcs
->
createTableBuilder
(
TSDB_INFORMATION_SCHEMA_DB
,
TSDB_INS_TABLE_DNODES
,
TSDB_SYSTEM_TABLE
,
1
)
.
addColumn
(
"id"
,
TSDB_DATA_TYPE_INT
);
builder
.
done
();
builder
.
done
();
}
}
{
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"mnodes"
,
TSDB_SYSTEM_TABLE
,
1
)
ITableBuilder
&
builder
=
.
addColumn
(
"id"
,
TSDB_DATA_TYPE_INT
);
mcs
->
createTableBuilder
(
TSDB_INFORMATION_SCHEMA_DB
,
TSDB_INS_TABLE_MNODES
,
TSDB_SYSTEM_TABLE
,
1
)
.
addColumn
(
"id"
,
TSDB_DATA_TYPE_INT
);
builder
.
done
();
builder
.
done
();
}
}
{
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"modules"
,
TSDB_SYSTEM_TABLE
,
1
)
ITableBuilder
&
builder
=
.
addColumn
(
"id"
,
TSDB_DATA_TYPE_INT
);
mcs
->
createTableBuilder
(
TSDB_INFORMATION_SCHEMA_DB
,
TSDB_INS_TABLE_MODULES
,
TSDB_SYSTEM_TABLE
,
1
)
.
addColumn
(
"id"
,
TSDB_DATA_TYPE_INT
);
builder
.
done
();
builder
.
done
();
}
}
{
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"qnodes"
,
TSDB_SYSTEM_TABLE
,
1
)
ITableBuilder
&
builder
=
.
addColumn
(
"id"
,
TSDB_DATA_TYPE_INT
);
mcs
->
createTableBuilder
(
TSDB_INFORMATION_SCHEMA_DB
,
TSDB_INS_TABLE_QNODES
,
TSDB_SYSTEM_TABLE
,
1
)
.
addColumn
(
"id"
,
TSDB_DATA_TYPE_INT
);
builder
.
done
();
builder
.
done
();
}
}
{
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"user_databases"
,
TSDB_SYSTEM_TABLE
,
1
)
ITableBuilder
&
builder
=
.
addColumn
(
"name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
);
mcs
->
createTableBuilder
(
TSDB_INFORMATION_SCHEMA_DB
,
TSDB_INS_TABLE_USER_DATABASES
,
TSDB_SYSTEM_TABLE
,
1
)
.
addColumn
(
"name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
);
builder
.
done
();
builder
.
done
();
}
}
{
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"user_functions"
,
TSDB_SYSTEM_TABLE
,
1
)
ITableBuilder
&
builder
=
.
addColumn
(
"name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_FUNC_NAME_LEN
);
mcs
->
createTableBuilder
(
TSDB_INFORMATION_SCHEMA_DB
,
TSDB_INS_TABLE_USER_FUNCTIONS
,
TSDB_SYSTEM_TABLE
,
1
)
.
addColumn
(
"name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_FUNC_NAME_LEN
);
builder
.
done
();
builder
.
done
();
}
}
{
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"user_indexes"
,
TSDB_SYSTEM_TABLE
,
2
)
ITableBuilder
&
builder
=
.
addColumn
(
"db_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
)
mcs
->
createTableBuilder
(
TSDB_INFORMATION_SCHEMA_DB
,
TSDB_INS_TABLE_USER_INDEXES
,
TSDB_SYSTEM_TABLE
,
2
)
.
addColumn
(
"table_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_TABLE_NAME_LEN
);
.
addColumn
(
"db_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
)
.
addColumn
(
"table_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_TABLE_NAME_LEN
);
builder
.
done
();
builder
.
done
();
}
}
{
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"user_stables"
,
TSDB_SYSTEM_TABLE
,
2
)
ITableBuilder
&
builder
=
.
addColumn
(
"db_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
)
mcs
->
createTableBuilder
(
TSDB_INFORMATION_SCHEMA_DB
,
TSDB_INS_TABLE_USER_STABLES
,
TSDB_SYSTEM_TABLE
,
2
)
.
addColumn
(
"stable_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_TABLE_NAME_LEN
);
.
addColumn
(
"db_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
)
.
addColumn
(
"stable_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_TABLE_NAME_LEN
);
builder
.
done
();
builder
.
done
();
}
}
{
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"user_tables"
,
TSDB_SYSTEM_TABLE
,
2
)
ITableBuilder
&
builder
=
.
addColumn
(
"db_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
)
mcs
->
createTableBuilder
(
TSDB_INFORMATION_SCHEMA_DB
,
TSDB_INS_TABLE_USER_TABLES
,
TSDB_SYSTEM_TABLE
,
2
)
.
addColumn
(
"table_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_TABLE_NAME_LEN
);
.
addColumn
(
"db_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
)
.
addColumn
(
"table_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_TABLE_NAME_LEN
);
builder
.
done
();
builder
.
done
();
}
}
{
{
ITableBuilder
&
builder
=
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"user_table_distributed"
,
TSDB_SYSTEM_TABLE
,
1
)
mcs
->
createTableBuilder
(
TSDB_INFORMATION_SCHEMA_DB
,
TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED
,
TSDB_SYSTEM_TABLE
,
1
)
.
addColumn
(
"db_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
);
.
addColumn
(
"db_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
);
builder
.
done
();
builder
.
done
();
}
}
{
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"user_users"
,
TSDB_SYSTEM_TABLE
,
1
)
ITableBuilder
&
builder
=
.
addColumn
(
"user_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_USER_LEN
);
mcs
->
createTableBuilder
(
TSDB_INFORMATION_SCHEMA_DB
,
TSDB_INS_TABLE_USER_USERS
,
TSDB_SYSTEM_TABLE
,
1
)
.
addColumn
(
"user_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_USER_LEN
);
builder
.
done
();
builder
.
done
();
}
}
{
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"vgroups"
,
TSDB_SYSTEM_TABLE
,
1
)
ITableBuilder
&
builder
=
.
addColumn
(
"db_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
);
mcs
->
createTableBuilder
(
TSDB_INFORMATION_SCHEMA_DB
,
TSDB_INS_TABLE_VGROUPS
,
TSDB_SYSTEM_TABLE
,
1
)
.
addColumn
(
"db_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
);
builder
.
done
();
builder
.
done
();
}
}
{
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"configs"
,
TSDB_SYSTEM_TABLE
,
1
)
ITableBuilder
&
builder
=
.
addColumn
(
"name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_CONFIG_OPTION_LEN
);
mcs
->
createTableBuilder
(
TSDB_INFORMATION_SCHEMA_DB
,
TSDB_INS_TABLE_CONFIGS
,
TSDB_SYSTEM_TABLE
,
1
)
.
addColumn
(
"name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_CONFIG_OPTION_LEN
);
builder
.
done
();
builder
.
done
();
}
}
{
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"information_schema"
,
"dnode_variables"
,
TSDB_SYSTEM_TABLE
,
1
)
ITableBuilder
&
builder
=
.
addColumn
(
"dnode_id"
,
TSDB_DATA_TYPE_INT
);
mcs
->
createTableBuilder
(
TSDB_INFORMATION_SCHEMA_DB
,
TSDB_INS_TABLE_DNODE_VARIABLES
,
TSDB_SYSTEM_TABLE
,
1
)
.
addColumn
(
"dnode_id"
,
TSDB_DATA_TYPE_INT
);
builder
.
done
();
builder
.
done
();
}
}
}
}
void
generatePerformanceSchema
(
MockCatalogService
*
mcs
)
{
void
generatePerformanceSchema
(
MockCatalogService
*
mcs
)
{
{
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"performance_schema"
,
"trans"
,
TSDB_SYSTEM_TABLE
,
1
)
ITableBuilder
&
builder
=
.
addColumn
(
"id"
,
TSDB_DATA_TYPE_INT
);
mcs
->
createTableBuilder
(
TSDB_PERFORMANCE_SCHEMA_DB
,
TSDB_PERFS_TABLE_TRANS
,
TSDB_SYSTEM_TABLE
,
1
)
.
addColumn
(
"id"
,
TSDB_DATA_TYPE_INT
);
builder
.
done
();
builder
.
done
();
}
}
{
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"performance_schema"
,
"streams"
,
TSDB_SYSTEM_TABLE
,
1
)
ITableBuilder
&
builder
=
.
addColumn
(
"stream_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_TABLE_NAME_LEN
);
mcs
->
createTableBuilder
(
TSDB_PERFORMANCE_SCHEMA_DB
,
TSDB_PERFS_TABLE_STREAMS
,
TSDB_SYSTEM_TABLE
,
1
)
.
addColumn
(
"stream_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_TABLE_NAME_LEN
);
builder
.
done
();
}
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
TSDB_PERFORMANCE_SCHEMA_DB
,
TSDB_PERFS_TABLE_CONSUMERS
,
TSDB_SYSTEM_TABLE
,
1
)
.
addColumn
(
"stream_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_TABLE_NAME_LEN
);
builder
.
done
();
}
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
TSDB_PERFORMANCE_SCHEMA_DB
,
TSDB_PERFS_TABLE_SUBSCRIPTIONS
,
TSDB_SYSTEM_TABLE
,
1
)
.
addColumn
(
"stream_name"
,
TSDB_DATA_TYPE_BINARY
,
TSDB_TABLE_NAME_LEN
);
builder
.
done
();
builder
.
done
();
}
}
}
}
...
@@ -261,7 +291,8 @@ int32_t __catalogGetDnodeList(SCatalog* pCatalog, SRequestConnInfo* pConn, SArra
...
@@ -261,7 +291,8 @@ int32_t __catalogGetDnodeList(SCatalog* pCatalog, SRequestConnInfo* pConn, SArra
return
g_mockCatalogService
->
catalogGetDnodeList
(
pDnodeList
);
return
g_mockCatalogService
->
catalogGetDnodeList
(
pDnodeList
);
}
}
int32_t
__catalogRefreshGetTableCfg
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableCfg
**
pCfg
)
{
int32_t
__catalogRefreshGetTableCfg
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableCfg
**
pCfg
)
{
*
pCfg
=
(
STableCfg
*
)
taosMemoryCalloc
(
1
,
sizeof
(
STableCfg
));
*
pCfg
=
(
STableCfg
*
)
taosMemoryCalloc
(
1
,
sizeof
(
STableCfg
));
return
0
;
return
0
;
}
}
...
...
source/libs/parser/test/mockCatalogService.cpp
浏览文件 @
291aab04
...
@@ -166,13 +166,10 @@ class MockCatalogServiceImpl {
...
@@ -166,13 +166,10 @@ class MockCatalogServiceImpl {
}
}
int32_t
catalogGetDnodeList
(
SArray
**
pDnodes
)
const
{
int32_t
catalogGetDnodeList
(
SArray
**
pDnodes
)
const
{
SMetaRes
res
=
{
0
};
*
pDnodes
=
taosArrayInit
(
dnode_
.
size
(),
sizeof
(
SEpSet
));
res
.
pRes
=
taosArrayInit
(
dnode_
.
size
(),
sizeof
(
SEpSet
));
for
(
const
auto
&
dnode
:
dnode_
)
{
for
(
const
auto
&
dnode
:
dnode_
)
{
taosArrayPush
(
(
SArray
*
)
res
.
pR
es
,
&
dnode
.
second
);
taosArrayPush
(
*
pDnod
es
,
&
dnode
.
second
);
}
}
*
pDnodes
=
taosArrayInit
(
1
,
sizeof
(
SMetaRes
));
taosArrayPush
(
*
pDnodes
,
&
res
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -200,7 +197,7 @@ class MockCatalogServiceImpl {
...
@@ -200,7 +197,7 @@ class MockCatalogServiceImpl {
code
=
getAllTableIndex
(
pCatalogReq
->
pTableIndex
,
&
pMetaData
->
pTableIndex
);
code
=
getAllTableIndex
(
pCatalogReq
->
pTableIndex
,
&
pMetaData
->
pTableIndex
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
pCatalogReq
->
dNodeRequired
)
{
if
(
TSDB_CODE_SUCCESS
==
code
&&
pCatalogReq
->
dNodeRequired
)
{
code
=
catalogGet
DnodeList
(
&
pMetaData
->
pDnodeList
);
code
=
getAll
DnodeList
(
&
pMetaData
->
pDnodeList
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
getAllTableCfg
(
pCatalogReq
->
pTableCfg
,
&
pMetaData
->
pTableCfg
);
code
=
getAllTableCfg
(
pCatalogReq
->
pTableCfg
,
&
pMetaData
->
pTableCfg
);
...
@@ -565,6 +562,14 @@ class MockCatalogServiceImpl {
...
@@ -565,6 +562,14 @@ class MockCatalogServiceImpl {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
getAllDnodeList
(
SArray
**
pDnodes
)
const
{
SMetaRes
res
=
{
0
};
catalogGetDnodeList
((
SArray
**
)
&
res
.
pRes
);
*
pDnodes
=
taosArrayInit
(
1
,
sizeof
(
SMetaRes
));
taosArrayPush
(
*
pDnodes
,
&
res
);
return
TSDB_CODE_SUCCESS
;
}
uint64_t
id_
;
uint64_t
id_
;
std
::
unique_ptr
<
TableBuilder
>
builder_
;
std
::
unique_ptr
<
TableBuilder
>
builder_
;
DbMetaCache
meta_
;
DbMetaCache
meta_
;
...
...
source/libs/parser/test/parSelectTest.cpp
浏览文件 @
291aab04
...
@@ -144,15 +144,17 @@ TEST_F(ParserSelectTest, IndefiniteRowsFunc) {
...
@@ -144,15 +144,17 @@ TEST_F(ParserSelectTest, IndefiniteRowsFunc) {
TEST_F
(
ParserSelectTest
,
IndefiniteRowsFuncSemanticCheck
)
{
TEST_F
(
ParserSelectTest
,
IndefiniteRowsFuncSemanticCheck
)
{
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
run
(
"SELECT DIFF(c1), c2 FROM t1"
,
TSDB_CODE_PAR_NOT_ALLOWED_FUNC
,
PARSER_STAGE_TRANSLATE
);
run
(
"SELECT DIFF(c1), c2 FROM t1"
,
TSDB_CODE_PAR_NOT_ALLOWED_FUNC
);
run
(
"SELECT DIFF(c1), tbname FROM t1"
,
TSDB_CODE_PAR_NOT_ALLOWED_FUNC
,
PARSER_STAGE_TRANSLATE
);
run
(
"SELECT DIFF(c1), tbname FROM t1"
,
TSDB_CODE_PAR_NOT_ALLOWED_FUNC
);
run
(
"SELECT DIFF(c1), count(*) FROM t1"
,
TSDB_CODE_PAR_NOT_ALLOWED_FUNC
,
PARSER_STAGE_TRANSLATE
);
run
(
"SELECT DIFF(c1), count(*) FROM t1"
,
TSDB_CODE_PAR_NOT_ALLOWED_FUNC
);
run
(
"SELECT DIFF(c1), CSUM(c1) FROM t1"
,
TSDB_CODE_PAR_NOT_ALLOWED_FUNC
,
PARSER_STAGE_TRANSLATE
);
run
(
"SELECT DIFF(c1), CSUM(c1) FROM t1"
,
TSDB_CODE_PAR_NOT_ALLOWED_FUNC
);
// run("SELECT DIFF(c1) FROM t1 INTERVAL(10s)");
run
(
"SELECT CSUM(c3) FROM t1 STATE_WINDOW(c1)"
,
TSDB_CODE_PAR_WINDOW_NOT_ALLOWED_FUNC
);
run
(
"SELECT DIFF(c1) FROM t1 INTERVAL(10s)"
,
TSDB_CODE_PAR_WINDOW_NOT_ALLOWED_FUNC
);
}
}
TEST_F
(
ParserSelectTest
,
useDefinedFunc
)
{
TEST_F
(
ParserSelectTest
,
useDefinedFunc
)
{
...
@@ -384,6 +386,12 @@ TEST_F(ParserSelectTest, setOperator) {
...
@@ -384,6 +386,12 @@ TEST_F(ParserSelectTest, setOperator) {
run
(
"SELECT c1, c2 FROM t1 UNION ALL SELECT c1 as a, c2 as b FROM t1 ORDER BY c1"
);
run
(
"SELECT c1, c2 FROM t1 UNION ALL SELECT c1 as a, c2 as b FROM t1 ORDER BY c1"
);
}
}
TEST_F
(
ParserSelectTest
,
setOperatorSemanticCheck
)
{
useDb
(
"root"
,
"test"
);
run
(
"SELECT c1, c2 FROM t1 UNION ALL SELECT c1, c2 FROM t1 ORDER BY ts"
,
TSDB_CODE_PAR_INVALID_COLUMN
);
}
TEST_F
(
ParserSelectTest
,
informationSchema
)
{
TEST_F
(
ParserSelectTest
,
informationSchema
)
{
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
...
...
source/libs/parser/test/parShowToUse.cpp
浏览文件 @
291aab04
...
@@ -25,6 +25,15 @@ class ParserShowToUseTest : public ParserDdlTest {};
...
@@ -25,6 +25,15 @@ class ParserShowToUseTest : public ParserDdlTest {};
// todo SHOW apps
// todo SHOW apps
// todo SHOW connections
// todo SHOW connections
TEST_F
(
ParserShowToUseTest
,
showConsumers
)
{
useDb
(
"root"
,
"test"
);
setCheckDdlFunc
(
[
&
](
const
SQuery
*
pQuery
,
ParserStage
stage
)
{
ASSERT_EQ
(
nodeType
(
pQuery
->
pRoot
),
QUERY_NODE_SELECT_STMT
);
});
run
(
"SHOW CONSUMERS"
);
}
TEST_F
(
ParserShowToUseTest
,
showCreateDatabase
)
{
TEST_F
(
ParserShowToUseTest
,
showCreateDatabase
)
{
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
...
@@ -143,6 +152,15 @@ TEST_F(ParserShowToUseTest, showStreams) {
...
@@ -143,6 +152,15 @@ TEST_F(ParserShowToUseTest, showStreams) {
run
(
"SHOW streams"
);
run
(
"SHOW streams"
);
}
}
TEST_F
(
ParserShowToUseTest
,
showSubscriptions
)
{
useDb
(
"root"
,
"test"
);
setCheckDdlFunc
(
[
&
](
const
SQuery
*
pQuery
,
ParserStage
stage
)
{
ASSERT_EQ
(
nodeType
(
pQuery
->
pRoot
),
QUERY_NODE_SELECT_STMT
);
});
run
(
"SHOW SUBSCRIPTIONS"
);
}
TEST_F
(
ParserShowToUseTest
,
showTransactions
)
{
TEST_F
(
ParserShowToUseTest
,
showTransactions
)
{
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
...
...
source/libs/planner/src/planLogicCreater.c
浏览文件 @
291aab04
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
typedef
struct
SLogicPlanContext
{
typedef
struct
SLogicPlanContext
{
SPlanContext
*
pPlanCxt
;
SPlanContext
*
pPlanCxt
;
SLogicNode
*
pCurrRoot
;
}
SLogicPlanContext
;
}
SLogicPlanContext
;
typedef
int32_t
(
*
FCreateLogicNode
)(
SLogicPlanContext
*
,
void
*
,
SLogicNode
**
);
typedef
int32_t
(
*
FCreateLogicNode
)(
SLogicPlanContext
*
,
void
*
,
SLogicNode
**
);
...
@@ -140,6 +141,7 @@ static int32_t createRootLogicNode(SLogicPlanContext* pCxt, void* pStmt, uint8_t
...
@@ -140,6 +141,7 @@ static int32_t createRootLogicNode(SLogicPlanContext* pCxt, void* pStmt, uint8_t
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pNode
)
{
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pNode
)
{
pNode
->
precision
=
precision
;
pNode
->
precision
=
precision
;
code
=
pushLogicNode
(
pCxt
,
pRoot
,
pNode
);
code
=
pushLogicNode
(
pCxt
,
pRoot
,
pNode
);
pCxt
->
pCurrRoot
=
pNode
;
}
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
nodesDestroyNode
((
SNode
*
)
pNode
);
nodesDestroyNode
((
SNode
*
)
pNode
);
...
@@ -152,12 +154,16 @@ static int32_t createSelectRootLogicNode(SLogicPlanContext* pCxt, SSelectStmt* p
...
@@ -152,12 +154,16 @@ static int32_t createSelectRootLogicNode(SLogicPlanContext* pCxt, SSelectStmt* p
return
createRootLogicNode
(
pCxt
,
pSelect
,
pSelect
->
precision
,
(
FCreateLogicNode
)
func
,
pRoot
);
return
createRootLogicNode
(
pCxt
,
pSelect
,
pSelect
->
precision
,
(
FCreateLogicNode
)
func
,
pRoot
);
}
}
static
EScanType
getScanType
(
SLogicPlanContext
*
pCxt
,
S
NodeList
*
pScanPseudoCols
,
SNodeList
*
pScan
Cols
,
static
EScanType
getScanType
(
SLogicPlanContext
*
pCxt
,
S
SelectStmt
*
pSelect
,
SNodeList
*
pScanPseudo
Cols
,
int8_t
tableType
)
{
SNodeList
*
pScanCols
,
int8_t
tableType
)
{
if
(
pCxt
->
pPlanCxt
->
topicQuery
||
pCxt
->
pPlanCxt
->
streamQuery
)
{
if
(
pCxt
->
pPlanCxt
->
topicQuery
||
pCxt
->
pPlanCxt
->
streamQuery
)
{
return
SCAN_TYPE_STREAM
;
return
SCAN_TYPE_STREAM
;
}
}
if
(
pSelect
->
hasLastRowFunc
)
{
return
SCAN_TYPE_LAST_ROW
;
}
if
(
NULL
==
pScanCols
)
{
if
(
NULL
==
pScanCols
)
{
// select count(*) from t
// select count(*) from t
return
NULL
==
pScanPseudoCols
return
NULL
==
pScanPseudoCols
...
@@ -273,7 +279,7 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
...
@@ -273,7 +279,7 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
code
=
rewriteExprsForSelect
(
pScan
->
pScanPseudoCols
,
pSelect
,
SQL_CLAUSE_FROM
);
code
=
rewriteExprsForSelect
(
pScan
->
pScanPseudoCols
,
pSelect
,
SQL_CLAUSE_FROM
);
}
}
pScan
->
scanType
=
getScanType
(
pCxt
,
pScan
->
pScanPseudoCols
,
pScan
->
pScanCols
,
pScan
->
tableType
);
pScan
->
scanType
=
getScanType
(
pCxt
,
pS
elect
,
pS
can
->
pScanPseudoCols
,
pScan
->
pScanCols
,
pScan
->
tableType
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
addPrimaryKeyCol
(
pScan
->
tableId
,
&
pScan
->
pScanCols
);
code
=
addPrimaryKeyCol
(
pScan
->
tableId
,
&
pScan
->
pScanCols
);
...
@@ -319,36 +325,6 @@ static int32_t createColumnByLastRow(SNodeList* pFuncs, SNodeList** pOutput) {
...
@@ -319,36 +325,6 @@ static int32_t createColumnByLastRow(SNodeList* pFuncs, SNodeList** pOutput) {
return
code
;
return
code
;
}
}
static
int32_t
createLastRowScanLogicNode
(
SLogicPlanContext
*
pCxt
,
SSelectStmt
*
pSelect
,
SRealTableNode
*
pRealTable
,
SLogicNode
**
pLogicNode
)
{
SScanLogicNode
*
pScan
=
NULL
;
int32_t
code
=
makeScanLogicNode
(
pCxt
,
pRealTable
,
false
,
(
SLogicNode
**
)
&
pScan
);
SNodeList
*
pFuncs
=
NULL
;
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pScan
->
scanType
=
SCAN_TYPE_LAST_ROW
;
code
=
nodesCollectFuncs
(
pSelect
,
SQL_CLAUSE_FROM
,
fmIsLastRowFunc
,
&
pFuncs
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
rewriteExprsForSelect
(
pFuncs
,
pSelect
,
SQL_CLAUSE_FROM
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createColumnByLastRow
(
pFuncs
,
&
pScan
->
pScanCols
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createColumnByRewriteExprs
(
pScan
->
pScanCols
,
&
pScan
->
node
.
pTargets
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pLogicNode
=
(
SLogicNode
*
)
pScan
;
}
else
{
nodesDestroyNode
((
SNode
*
)
pScan
);
}
nodesDestroyList
(
pFuncs
);
return
code
;
}
static
int32_t
createSubqueryLogicNode
(
SLogicPlanContext
*
pCxt
,
SSelectStmt
*
pSelect
,
STempTableNode
*
pTable
,
static
int32_t
createSubqueryLogicNode
(
SLogicPlanContext
*
pCxt
,
SSelectStmt
*
pSelect
,
STempTableNode
*
pTable
,
SLogicNode
**
pLogicNode
)
{
SLogicNode
**
pLogicNode
)
{
return
createQueryLogicNode
(
pCxt
,
pTable
->
pSubquery
,
pLogicNode
);
return
createQueryLogicNode
(
pCxt
,
pTable
->
pSubquery
,
pLogicNode
);
...
@@ -420,11 +396,7 @@ static int32_t doCreateLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pS
...
@@ -420,11 +396,7 @@ static int32_t doCreateLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pS
SLogicNode
**
pLogicNode
)
{
SLogicNode
**
pLogicNode
)
{
switch
(
nodeType
(
pTable
))
{
switch
(
nodeType
(
pTable
))
{
case
QUERY_NODE_REAL_TABLE
:
case
QUERY_NODE_REAL_TABLE
:
if
(
pSelect
->
hasLastRowFunc
)
{
return
createScanLogicNode
(
pCxt
,
pSelect
,
(
SRealTableNode
*
)
pTable
,
pLogicNode
);
return
createLastRowScanLogicNode
(
pCxt
,
pSelect
,
(
SRealTableNode
*
)
pTable
,
pLogicNode
);
}
else
{
return
createScanLogicNode
(
pCxt
,
pSelect
,
(
SRealTableNode
*
)
pTable
,
pLogicNode
);
}
case
QUERY_NODE_TEMP_TABLE
:
case
QUERY_NODE_TEMP_TABLE
:
return
createSubqueryLogicNode
(
pCxt
,
pSelect
,
(
STempTableNode
*
)
pTable
,
pLogicNode
);
return
createSubqueryLogicNode
(
pCxt
,
pSelect
,
(
STempTableNode
*
)
pTable
,
pLogicNode
);
case
QUERY_NODE_JOIN_TABLE
:
case
QUERY_NODE_JOIN_TABLE
:
...
@@ -447,6 +419,7 @@ static int32_t createLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pSel
...
@@ -447,6 +419,7 @@ static int32_t createLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pSel
}
}
pNode
->
precision
=
pSelect
->
precision
;
pNode
->
precision
=
pSelect
->
precision
;
*
pLogicNode
=
pNode
;
*
pLogicNode
=
pNode
;
pCxt
->
pCurrRoot
=
pNode
;
}
}
return
code
;
return
code
;
}
}
...
@@ -728,6 +701,10 @@ static int32_t createFillLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
...
@@ -728,6 +701,10 @@ static int32_t createFillLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
}
}
int32_t
code
=
nodesCollectColumns
(
pSelect
,
SQL_CLAUSE_WINDOW
,
NULL
,
COLLECT_COL_TYPE_ALL
,
&
pFill
->
node
.
pTargets
);
int32_t
code
=
nodesCollectColumns
(
pSelect
,
SQL_CLAUSE_WINDOW
,
NULL
,
COLLECT_COL_TYPE_ALL
,
&
pFill
->
node
.
pTargets
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
==
pFill
->
node
.
pTargets
)
{
code
=
nodesListMakeStrictAppend
(
&
pFill
->
node
.
pTargets
,
nodesCloneNode
(
nodesListGetNode
(
pCxt
->
pCurrRoot
->
pTargets
,
0
)));
}
pFill
->
mode
=
pFillNode
->
mode
;
pFill
->
mode
=
pFillNode
->
mode
;
pFill
->
timeRange
=
pFillNode
->
timeRange
;
pFill
->
timeRange
=
pFillNode
->
timeRange
;
...
@@ -757,6 +734,10 @@ static int32_t createSortLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
...
@@ -757,6 +734,10 @@ static int32_t createSortLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
}
}
int32_t
code
=
nodesCollectColumns
(
pSelect
,
SQL_CLAUSE_ORDER_BY
,
NULL
,
COLLECT_COL_TYPE_ALL
,
&
pSort
->
node
.
pTargets
);
int32_t
code
=
nodesCollectColumns
(
pSelect
,
SQL_CLAUSE_ORDER_BY
,
NULL
,
COLLECT_COL_TYPE_ALL
,
&
pSort
->
node
.
pTargets
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
==
pSort
->
node
.
pTargets
)
{
code
=
nodesListMakeStrictAppend
(
&
pSort
->
node
.
pTargets
,
nodesCloneNode
(
nodesListGetNode
(
pCxt
->
pCurrRoot
->
pTargets
,
0
)));
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pSort
->
pSortKeys
=
nodesCloneList
(
pSelect
->
pOrderByList
);
pSort
->
pSortKeys
=
nodesCloneList
(
pSelect
->
pOrderByList
);
...
@@ -799,21 +780,8 @@ static int32_t createProjectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSel
...
@@ -799,21 +780,8 @@ static int32_t createProjectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSel
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
if
(
NULL
!=
pSelect
->
pLimit
)
{
pProject
->
node
.
pLimit
=
(
SNode
*
)
pSelect
->
pLimit
;
pProject
->
limit
=
pSelect
->
pLimit
->
limit
;
pProject
->
node
.
pSlimit
=
(
SNode
*
)
pSelect
->
pSlimit
;
pProject
->
offset
=
pSelect
->
pLimit
->
offset
;
}
else
{
pProject
->
limit
=
-
1
;
pProject
->
offset
=
-
1
;
}
if
(
NULL
!=
pSelect
->
pSlimit
)
{
pProject
->
slimit
=
((
SLimitNode
*
)
pSelect
->
pSlimit
)
->
limit
;
pProject
->
soffset
=
((
SLimitNode
*
)
pSelect
->
pSlimit
)
->
offset
;
}
else
{
pProject
->
slimit
=
-
1
;
pProject
->
soffset
=
-
1
;
}
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
...
@@ -848,6 +816,9 @@ static int32_t createPartitionLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pS
...
@@ -848,6 +816,9 @@ static int32_t createPartitionLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pS
int32_t
code
=
int32_t
code
=
nodesCollectColumns
(
pSelect
,
SQL_CLAUSE_PARTITION_BY
,
NULL
,
COLLECT_COL_TYPE_ALL
,
&
pPartition
->
node
.
pTargets
);
nodesCollectColumns
(
pSelect
,
SQL_CLAUSE_PARTITION_BY
,
NULL
,
COLLECT_COL_TYPE_ALL
,
&
pPartition
->
node
.
pTargets
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
==
pPartition
->
node
.
pTargets
)
{
code
=
nodesListMakeStrictAppend
(
&
pPartition
->
node
.
pTargets
,
nodesListGetNode
(
pCxt
->
pCurrRoot
->
pTargets
,
0
));
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pPartition
->
pPartitionKeys
=
nodesCloneList
(
pSelect
->
pPartitionByList
);
pPartition
->
pPartitionKeys
=
nodesCloneList
(
pSelect
->
pPartitionByList
);
...
@@ -969,6 +940,8 @@ static int32_t createSetOpSortLogicNode(SLogicPlanContext* pCxt, SSetOperator* p
...
@@ -969,6 +940,8 @@ static int32_t createSetOpSortLogicNode(SLogicPlanContext* pCxt, SSetOperator* p
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
pSort
->
node
.
pLimit
=
pSetOperator
->
pLimit
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
pSort
->
node
.
pTargets
=
nodesCloneList
(
pSetOperator
->
pProjectionList
);
pSort
->
node
.
pTargets
=
nodesCloneList
(
pSetOperator
->
pProjectionList
);
...
@@ -999,12 +972,8 @@ static int32_t createSetOpProjectLogicNode(SLogicPlanContext* pCxt, SSetOperator
...
@@ -999,12 +972,8 @@ static int32_t createSetOpProjectLogicNode(SLogicPlanContext* pCxt, SSetOperator
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
if
(
NULL
!=
pSetOperator
->
pLimit
)
{
if
(
NULL
==
pSetOperator
->
pOrderByList
)
{
pProject
->
limit
=
((
SLimitNode
*
)
pSetOperator
->
pLimit
)
->
limit
;
pProject
->
node
.
pLimit
=
pSetOperator
->
pLimit
;
pProject
->
offset
=
((
SLimitNode
*
)
pSetOperator
->
pLimit
)
->
offset
;
}
else
{
pProject
->
limit
=
-
1
;
pProject
->
offset
=
-
1
;
}
}
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
...
@@ -1034,6 +1003,10 @@ static int32_t createSetOpAggLogicNode(SLogicPlanContext* pCxt, SSetOperator* pS
...
@@ -1034,6 +1003,10 @@ static int32_t createSetOpAggLogicNode(SLogicPlanContext* pCxt, SSetOperator* pS
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
if
(
NULL
==
pSetOperator
->
pOrderByList
)
{
pAgg
->
node
.
pLimit
=
pSetOperator
->
pLimit
;
}
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
pAgg
->
pGroupKeys
=
nodesCloneList
(
pSetOperator
->
pProjectionList
);
pAgg
->
pGroupKeys
=
nodesCloneList
(
pSetOperator
->
pProjectionList
);
if
(
NULL
==
pAgg
->
pGroupKeys
)
{
if
(
NULL
==
pAgg
->
pGroupKeys
)
{
...
...
source/libs/planner/src/planOptimizer.c
浏览文件 @
291aab04
...
@@ -1117,8 +1117,7 @@ static bool eliminateProjOptMayBeOptimized(SLogicNode* pNode) {
...
@@ -1117,8 +1117,7 @@ static bool eliminateProjOptMayBeOptimized(SLogicNode* pNode) {
}
}
SProjectLogicNode
*
pProjectNode
=
(
SProjectLogicNode
*
)
pNode
;
SProjectLogicNode
*
pProjectNode
=
(
SProjectLogicNode
*
)
pNode
;
if
(
-
1
!=
pProjectNode
->
limit
||
-
1
!=
pProjectNode
->
slimit
||
-
1
!=
pProjectNode
->
offset
||
if
(
NULL
!=
pProjectNode
->
node
.
pLimit
||
NULL
!=
pProjectNode
->
node
.
pSlimit
)
{
-
1
!=
pProjectNode
->
soffset
)
{
return
false
;
return
false
;
}
}
...
...
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
291aab04
...
@@ -348,6 +348,9 @@ static SPhysiNode* makePhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode
...
@@ -348,6 +348,9 @@ static SPhysiNode* makePhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode
return
NULL
;
return
NULL
;
}
}
pPhysiNode
->
pLimit
=
pLogicNode
->
pLimit
;
pPhysiNode
->
pSlimit
=
pLogicNode
->
pSlimit
;
int32_t
code
=
createDataBlockDesc
(
pCxt
,
pLogicNode
->
pTargets
,
&
pPhysiNode
->
pOutputDataBlockDesc
);
int32_t
code
=
createDataBlockDesc
(
pCxt
,
pLogicNode
->
pTargets
,
&
pPhysiNode
->
pOutputDataBlockDesc
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
nodesDestroyNode
((
SNode
*
)
pPhysiNode
);
nodesDestroyNode
((
SNode
*
)
pPhysiNode
);
...
@@ -921,11 +924,6 @@ static int32_t createProjectPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChild
...
@@ -921,11 +924,6 @@ static int32_t createProjectPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChild
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
pProject
->
limit
=
pProjectLogicNode
->
limit
;
pProject
->
offset
=
pProjectLogicNode
->
offset
;
pProject
->
slimit
=
pProjectLogicNode
->
slimit
;
pProject
->
soffset
=
pProjectLogicNode
->
soffset
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
(
0
==
LIST_LENGTH
(
pChildren
))
{
if
(
0
==
LIST_LENGTH
(
pChildren
))
{
pProject
->
pProjections
=
nodesCloneList
(
pProjectLogicNode
->
pProjections
);
pProject
->
pProjections
=
nodesCloneList
(
pProjectLogicNode
->
pProjections
);
...
@@ -1199,6 +1197,9 @@ static int32_t createSortPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren
...
@@ -1199,6 +1197,9 @@ static int32_t createSortPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren
nodesDestroyNode
((
SNode
*
)
pSort
);
nodesDestroyNode
((
SNode
*
)
pSort
);
}
}
nodesDestroyList
(
pPrecalcExprs
);
nodesDestroyList
(
pSortKeys
);
return
code
;
return
code
;
}
}
...
...
source/libs/planner/src/planSpliter.c
浏览文件 @
291aab04
...
@@ -1040,6 +1040,7 @@ static int32_t unAllSplCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pS
...
@@ -1040,6 +1040,7 @@ static int32_t unAllSplCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pS
if
(
NULL
==
pExchange
->
node
.
pTargets
)
{
if
(
NULL
==
pExchange
->
node
.
pTargets
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
TSWAP
(
pExchange
->
node
.
pLimit
,
pProject
->
node
.
pLimit
);
pSubplan
->
subplanType
=
SUBPLAN_TYPE_MERGE
;
pSubplan
->
subplanType
=
SUBPLAN_TYPE_MERGE
;
...
...
source/libs/planner/test/planBasicTest.cpp
浏览文件 @
291aab04
...
@@ -37,13 +37,6 @@ TEST_F(PlanBasicTest, whereClause) {
...
@@ -37,13 +37,6 @@ TEST_F(PlanBasicTest, whereClause) {
run
(
"SELECT * FROM t1 WHERE ts > TIMESTAMP '2022-04-01 00:00:00' and ts < TIMESTAMP '2022-04-30 23:59:59'"
);
run
(
"SELECT * FROM t1 WHERE ts > TIMESTAMP '2022-04-01 00:00:00' and ts < TIMESTAMP '2022-04-30 23:59:59'"
);
}
}
TEST_F
(
PlanBasicTest
,
joinClause
)
{
useDb
(
"root"
,
"test"
);
run
(
"SELECT t1.c1, t2.c2 FROM st1s1 t1, st1s2 t2 WHERE t1.ts = t2.ts"
);
run
(
"SELECT t1.c1, t2.c2 FROM st1s1 t1 JOIN st1s2 t2 ON t1.ts = t2.ts"
);
}
TEST_F
(
PlanBasicTest
,
func
)
{
TEST_F
(
PlanBasicTest
,
func
)
{
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
...
...
source/libs/planner/test/planOrderByTest.cpp
浏览文件 @
291aab04
...
@@ -31,6 +31,8 @@ TEST_F(PlanOrderByTest, basic) {
...
@@ -31,6 +31,8 @@ TEST_F(PlanOrderByTest, basic) {
run
(
"SELECT c1 AS a FROM t1 ORDER BY a"
);
run
(
"SELECT c1 AS a FROM t1 ORDER BY a"
);
run
(
"SELECT c1 + 10 AS a FROM t1 ORDER BY a"
);
run
(
"SELECT c1 + 10 AS a FROM t1 ORDER BY a"
);
run
(
"SELECT 1 FROM t1 ORDER BY c1"
);
}
}
TEST_F
(
PlanOrderByTest
,
expr
)
{
TEST_F
(
PlanOrderByTest
,
expr
)
{
...
...
source/libs/planner/test/planSetOpTest.cpp
浏览文件 @
291aab04
...
@@ -54,6 +54,14 @@ TEST_F(PlanSetOpTest, unionAllWithOrderBy) {
...
@@ -54,6 +54,14 @@ TEST_F(PlanSetOpTest, unionAllWithOrderBy) {
run
(
"SELECT c1, c2 FROM t1 WHERE c1 > 10 UNION ALL SELECT c1, c2 FROM t1 WHERE c1 > 20 ORDER BY 1"
);
run
(
"SELECT c1, c2 FROM t1 WHERE c1 > 10 UNION ALL SELECT c1, c2 FROM t1 WHERE c1 > 20 ORDER BY 1"
);
}
}
TEST_F
(
PlanSetOpTest
,
unionAllWithLimit
)
{
useDb
(
"root"
,
"test"
);
run
(
"SELECT c1, c2 FROM t1 WHERE c1 > 10 UNION ALL SELECT c1, c2 FROM t1 WHERE c1 > 20 LIMIT 10, 20"
);
run
(
"SELECT c1, c2 FROM t1 WHERE c1 > 10 UNION ALL SELECT c1, c2 FROM t1 WHERE c1 > 20 ORDER BY 1 LIMIT 10, 20"
);
}
TEST_F
(
PlanSetOpTest
,
union
)
{
TEST_F
(
PlanSetOpTest
,
union
)
{
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
...
@@ -65,6 +73,14 @@ TEST_F(PlanSetOpTest, union) {
...
@@ -65,6 +73,14 @@ TEST_F(PlanSetOpTest, union) {
"UNION SELECT c1, c2 FROM t1 WHERE c1 > 30"
);
"UNION SELECT c1, c2 FROM t1 WHERE c1 > 30"
);
}
}
TEST_F
(
PlanSetOpTest
,
unionWithLimit
)
{
useDb
(
"root"
,
"test"
);
run
(
"SELECT c1, c2 FROM t1 WHERE c1 > 10 UNION SELECT c1, c2 FROM t1 WHERE c1 > 20 LIMIT 10, 20"
);
run
(
"SELECT c1, c2 FROM t1 WHERE c1 > 10 UNION SELECT c1, c2 FROM t1 WHERE c1 > 20 ORDER BY 1 LIMIT 10, 20"
);
}
TEST_F
(
PlanSetOpTest
,
unionContainJoin
)
{
TEST_F
(
PlanSetOpTest
,
unionContainJoin
)
{
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
...
...
source/libs/planner/test/planSubqueryTest.cpp
浏览文件 @
291aab04
...
@@ -33,7 +33,9 @@ TEST_F(PlanSubqeuryTest, basic) {
...
@@ -33,7 +33,9 @@ TEST_F(PlanSubqeuryTest, basic) {
run
(
"SELECT NOW() FROM (SELECT * FROM t1)"
);
run
(
"SELECT NOW() FROM (SELECT * FROM t1)"
);
// run("SELECT NOW() FROM (SELECT * FROM t1) ORDER BY ts");
run
(
"SELECT * FROM (SELECT NOW() FROM t1)"
);
run
(
"SELECT NOW() FROM (SELECT * FROM t1) ORDER BY ts"
);
}
}
TEST_F
(
PlanSubqeuryTest
,
doubleGroupBy
)
{
TEST_F
(
PlanSubqeuryTest
,
doubleGroupBy
)
{
...
...
source/libs/planner/test/planTestMain.cpp
浏览文件 @
291aab04
...
@@ -16,9 +16,11 @@
...
@@ -16,9 +16,11 @@
#include <string>
#include <string>
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#include "functionMgt.h"
#include "functionMgt.h"
#include "getopt.h"
#include "getopt.h"
#include "mockCatalog.h"
#include "mockCatalog.h"
#include "parser.h"
#include "planTestUtil.h"
#include "planTestUtil.h"
class
PlannerEnv
:
public
testing
::
Environment
{
class
PlannerEnv
:
public
testing
::
Environment
{
...
@@ -30,7 +32,12 @@ class PlannerEnv : public testing::Environment {
...
@@ -30,7 +32,12 @@ class PlannerEnv : public testing::Environment {
initLog
(
TD_TMP_DIR_PATH
"td"
);
initLog
(
TD_TMP_DIR_PATH
"td"
);
}
}
virtual
void
TearDown
()
{
destroyMetaDataEnv
();
}
virtual
void
TearDown
()
{
destroyMetaDataEnv
();
qCleanupKeywordsTable
();
fmFuncMgtDestroy
();
taosCloseLog
();
}
PlannerEnv
()
{}
PlannerEnv
()
{}
virtual
~
PlannerEnv
()
{}
virtual
~
PlannerEnv
()
{}
...
...
source/libs/planner/test/planTestUtil.cpp
浏览文件 @
291aab04
...
@@ -102,12 +102,15 @@ class PlannerTestBaseImpl {
...
@@ -102,12 +102,15 @@ class PlannerTestBaseImpl {
try
{
try
{
SQuery
*
pQuery
=
nullptr
;
SQuery
*
pQuery
=
nullptr
;
doParseSql
(
sql
,
&
pQuery
);
doParseSql
(
sql
,
&
pQuery
);
unique_ptr
<
SQuery
,
void
(
*
)(
SQuery
*
)
>
query
(
pQuery
,
qDestroyQuery
);
SPlanContext
cxt
=
{
0
};
SPlanContext
cxt
=
{
0
};
setPlanContext
(
pQuery
,
&
cxt
);
setPlanContext
(
pQuery
,
&
cxt
);
SLogicSubplan
*
pLogicSubplan
=
nullptr
;
SLogicSubplan
*
pLogicSubplan
=
nullptr
;
doCreateLogicPlan
(
&
cxt
,
&
pLogicSubplan
);
doCreateLogicPlan
(
&
cxt
,
&
pLogicSubplan
);
unique_ptr
<
SLogicSubplan
,
void
(
*
)(
SLogicSubplan
*
)
>
logicSubplan
(
pLogicSubplan
,
(
void
(
*
)(
SLogicSubplan
*
))
nodesDestroyNode
);
doOptimizeLogicPlan
(
&
cxt
,
pLogicSubplan
);
doOptimizeLogicPlan
(
&
cxt
,
pLogicSubplan
);
...
@@ -115,9 +118,12 @@ class PlannerTestBaseImpl {
...
@@ -115,9 +118,12 @@ class PlannerTestBaseImpl {
SQueryLogicPlan
*
pLogicPlan
=
nullptr
;
SQueryLogicPlan
*
pLogicPlan
=
nullptr
;
doScaleOutLogicPlan
(
&
cxt
,
pLogicSubplan
,
&
pLogicPlan
);
doScaleOutLogicPlan
(
&
cxt
,
pLogicSubplan
,
&
pLogicPlan
);
unique_ptr
<
SQueryLogicPlan
,
void
(
*
)(
SQueryLogicPlan
*
)
>
logicPlan
(
pLogicPlan
,
(
void
(
*
)(
SQueryLogicPlan
*
))
nodesDestroyNode
);
SQueryPlan
*
pPlan
=
nullptr
;
SQueryPlan
*
pPlan
=
nullptr
;
doCreatePhysiPlan
(
&
cxt
,
pLogicPlan
,
&
pPlan
);
doCreatePhysiPlan
(
&
cxt
,
pLogicPlan
,
&
pPlan
);
unique_ptr
<
SQueryPlan
,
void
(
*
)(
SQueryPlan
*
)
>
plan
(
pPlan
,
(
void
(
*
)(
SQueryPlan
*
))
nodesDestroyNode
);
dump
(
g_dumpModule
);
dump
(
g_dumpModule
);
}
catch
(...)
{
}
catch
(...)
{
...
@@ -345,8 +351,9 @@ class PlannerTestBaseImpl {
...
@@ -345,8 +351,9 @@ class PlannerTestBaseImpl {
}
}
void
doCreatePhysiPlan
(
SPlanContext
*
pCxt
,
SQueryLogicPlan
*
pLogicPlan
,
SQueryPlan
**
pPlan
)
{
void
doCreatePhysiPlan
(
SPlanContext
*
pCxt
,
SQueryLogicPlan
*
pLogicPlan
,
SQueryPlan
**
pPlan
)
{
SArray
*
pExecNodeList
=
taosArrayInit
(
TARRAY_MIN_SIZE
,
sizeof
(
SQueryNodeAddr
));
unique_ptr
<
SArray
,
void
(
*
)(
SArray
*
)
>
execNodeList
((
SArray
*
)
taosArrayInit
(
TARRAY_MIN_SIZE
,
sizeof
(
SQueryNodeAddr
)),
DO_WITH_THROW
(
createPhysiPlan
,
pCxt
,
pLogicPlan
,
pPlan
,
pExecNodeList
);
(
void
(
*
)(
SArray
*
))
taosArrayDestroy
);
DO_WITH_THROW
(
createPhysiPlan
,
pCxt
,
pLogicPlan
,
pPlan
,
execNodeList
.
get
());
res_
.
physiPlan_
=
toString
((
SNode
*
)(
*
pPlan
));
res_
.
physiPlan_
=
toString
((
SNode
*
)(
*
pPlan
));
SNode
*
pNode
;
SNode
*
pNode
;
FOREACH
(
pNode
,
(
*
pPlan
)
->
pSubplans
)
{
FOREACH
(
pNode
,
(
*
pPlan
)
->
pSubplans
)
{
...
...
source/libs/scalar/src/sclfunc.c
浏览文件 @
291aab04
...
@@ -36,9 +36,6 @@ int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu
...
@@ -36,9 +36,6 @@ int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu
SColumnInfoData
*
pOutputData
=
pOutput
->
columnData
;
SColumnInfoData
*
pOutputData
=
pOutput
->
columnData
;
int32_t
type
=
GET_PARAM_TYPE
(
pInput
);
int32_t
type
=
GET_PARAM_TYPE
(
pInput
);
if
(
!
IS_NUMERIC_TYPE
(
type
))
{
return
TSDB_CODE_FAILED
;
}
switch
(
type
)
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_FLOAT
:
{
case
TSDB_DATA_TYPE_FLOAT
:
{
...
@@ -119,6 +116,13 @@ int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu
...
@@ -119,6 +116,13 @@ int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu
break
;
break
;
}
}
case
TSDB_DATA_TYPE_NULL
:
{
for
(
int32_t
i
=
0
;
i
<
pInput
->
numOfRows
;
++
i
)
{
colDataAppendNULL
(
pOutputData
,
i
);
}
break
;
}
default:
{
default:
{
colDataAssign
(
pOutputData
,
pInputData
,
pInput
->
numOfRows
,
NULL
);
colDataAssign
(
pOutputData
,
pInputData
,
pInput
->
numOfRows
,
NULL
);
}
}
...
@@ -130,9 +134,6 @@ int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu
...
@@ -130,9 +134,6 @@ int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu
static
int32_t
doScalarFunctionUnique
(
SScalarParam
*
pInput
,
int32_t
inputNum
,
SScalarParam
*
pOutput
,
_double_fn
valFn
)
{
static
int32_t
doScalarFunctionUnique
(
SScalarParam
*
pInput
,
int32_t
inputNum
,
SScalarParam
*
pOutput
,
_double_fn
valFn
)
{
int32_t
type
=
GET_PARAM_TYPE
(
pInput
);
int32_t
type
=
GET_PARAM_TYPE
(
pInput
);
if
(
inputNum
!=
1
||
!
IS_NUMERIC_TYPE
(
type
))
{
return
TSDB_CODE_FAILED
;
}
SColumnInfoData
*
pInputData
=
pInput
->
columnData
;
SColumnInfoData
*
pInputData
=
pInput
->
columnData
;
SColumnInfoData
*
pOutputData
=
pOutput
->
columnData
;
SColumnInfoData
*
pOutputData
=
pOutput
->
columnData
;
...
@@ -142,7 +143,7 @@ static int32_t doScalarFunctionUnique(SScalarParam *pInput, int32_t inputNum, SS
...
@@ -142,7 +143,7 @@ static int32_t doScalarFunctionUnique(SScalarParam *pInput, int32_t inputNum, SS
double
*
out
=
(
double
*
)
pOutputData
->
pData
;
double
*
out
=
(
double
*
)
pOutputData
->
pData
;
for
(
int32_t
i
=
0
;
i
<
pInput
->
numOfRows
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pInput
->
numOfRows
;
++
i
)
{
if
(
colDataIsNull_s
(
pInputData
,
i
))
{
if
(
colDataIsNull_s
(
pInputData
,
i
)
||
IS_NULL_TYPE
(
type
)
)
{
colDataAppendNULL
(
pOutputData
,
i
);
colDataAppendNULL
(
pOutputData
,
i
);
continue
;
continue
;
}
}
...
@@ -159,10 +160,6 @@ static int32_t doScalarFunctionUnique(SScalarParam *pInput, int32_t inputNum, SS
...
@@ -159,10 +160,6 @@ static int32_t doScalarFunctionUnique(SScalarParam *pInput, int32_t inputNum, SS
}
}
static
int32_t
doScalarFunctionUnique2
(
SScalarParam
*
pInput
,
int32_t
inputNum
,
SScalarParam
*
pOutput
,
_double_fn_2
valFn
)
{
static
int32_t
doScalarFunctionUnique2
(
SScalarParam
*
pInput
,
int32_t
inputNum
,
SScalarParam
*
pOutput
,
_double_fn_2
valFn
)
{
if
(
inputNum
!=
2
||
!
IS_NUMERIC_TYPE
(
GET_PARAM_TYPE
(
&
pInput
[
0
]))
||
!
IS_NUMERIC_TYPE
(
GET_PARAM_TYPE
(
&
pInput
[
1
])))
{
return
TSDB_CODE_FAILED
;
}
SColumnInfoData
*
pInputData
[
2
];
SColumnInfoData
*
pInputData
[
2
];
SColumnInfoData
*
pOutputData
=
pOutput
->
columnData
;
SColumnInfoData
*
pOutputData
=
pOutput
->
columnData
;
_getDoubleValue_fn_t
getValueFn
[
2
];
_getDoubleValue_fn_t
getValueFn
[
2
];
...
@@ -175,11 +172,15 @@ static int32_t doScalarFunctionUnique2(SScalarParam *pInput, int32_t inputNum, S
...
@@ -175,11 +172,15 @@ static int32_t doScalarFunctionUnique2(SScalarParam *pInput, int32_t inputNum, S
double
*
out
=
(
double
*
)
pOutputData
->
pData
;
double
*
out
=
(
double
*
)
pOutputData
->
pData
;
double
result
;
double
result
;
bool
hasNullType
=
(
IS_NULL_TYPE
(
GET_PARAM_TYPE
(
&
pInput
[
0
]))
||
IS_NULL_TYPE
(
GET_PARAM_TYPE
(
&
pInput
[
1
])));
int32_t
numOfRows
=
TMAX
(
pInput
[
0
].
numOfRows
,
pInput
[
1
].
numOfRows
);
int32_t
numOfRows
=
TMAX
(
pInput
[
0
].
numOfRows
,
pInput
[
1
].
numOfRows
);
if
(
pInput
[
0
].
numOfRows
==
pInput
[
1
].
numOfRows
)
{
if
(
pInput
[
0
].
numOfRows
==
pInput
[
1
].
numOfRows
)
{
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
if
(
colDataIsNull_s
(
pInputData
[
0
],
i
)
||
if
(
colDataIsNull_s
(
pInputData
[
0
],
i
)
||
colDataIsNull_s
(
pInputData
[
1
],
i
))
{
colDataIsNull_s
(
pInputData
[
1
],
i
)
||
hasNullType
)
{
colDataAppendNULL
(
pOutputData
,
i
);
colDataAppendNULL
(
pOutputData
,
i
);
continue
;
continue
;
}
}
...
@@ -191,7 +192,7 @@ static int32_t doScalarFunctionUnique2(SScalarParam *pInput, int32_t inputNum, S
...
@@ -191,7 +192,7 @@ static int32_t doScalarFunctionUnique2(SScalarParam *pInput, int32_t inputNum, S
}
}
}
}
}
else
if
(
pInput
[
0
].
numOfRows
==
1
)
{
//left operand is constant
}
else
if
(
pInput
[
0
].
numOfRows
==
1
)
{
//left operand is constant
if
(
colDataIsNull_s
(
pInputData
[
0
],
0
))
{
if
(
colDataIsNull_s
(
pInputData
[
0
],
0
)
||
hasNullType
)
{
colDataAppendNNULL
(
pOutputData
,
0
,
pInput
[
1
].
numOfRows
);
colDataAppendNNULL
(
pOutputData
,
0
,
pInput
[
1
].
numOfRows
);
}
else
{
}
else
{
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
...
@@ -210,7 +211,7 @@ static int32_t doScalarFunctionUnique2(SScalarParam *pInput, int32_t inputNum, S
...
@@ -210,7 +211,7 @@ static int32_t doScalarFunctionUnique2(SScalarParam *pInput, int32_t inputNum, S
}
}
}
}
}
else
if
(
pInput
[
1
].
numOfRows
==
1
)
{
}
else
if
(
pInput
[
1
].
numOfRows
==
1
)
{
if
(
colDataIsNull_s
(
pInputData
[
1
],
0
))
{
if
(
colDataIsNull_s
(
pInputData
[
1
],
0
)
||
hasNullType
)
{
colDataAppendNNULL
(
pOutputData
,
0
,
pInput
[
0
].
numOfRows
);
colDataAppendNNULL
(
pOutputData
,
0
,
pInput
[
0
].
numOfRows
);
}
else
{
}
else
{
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
...
@@ -236,9 +237,6 @@ static int32_t doScalarFunctionUnique2(SScalarParam *pInput, int32_t inputNum, S
...
@@ -236,9 +237,6 @@ static int32_t doScalarFunctionUnique2(SScalarParam *pInput, int32_t inputNum, S
static
int32_t
doScalarFunction
(
SScalarParam
*
pInput
,
int32_t
inputNum
,
SScalarParam
*
pOutput
,
_float_fn
f1
,
_double_fn
d1
)
{
static
int32_t
doScalarFunction
(
SScalarParam
*
pInput
,
int32_t
inputNum
,
SScalarParam
*
pOutput
,
_float_fn
f1
,
_double_fn
d1
)
{
int32_t
type
=
GET_PARAM_TYPE
(
pInput
);
int32_t
type
=
GET_PARAM_TYPE
(
pInput
);
if
(
inputNum
!=
1
||
!
IS_NUMERIC_TYPE
(
type
))
{
return
TSDB_CODE_FAILED
;
}
SColumnInfoData
*
pInputData
=
pInput
->
columnData
;
SColumnInfoData
*
pInputData
=
pInput
->
columnData
;
SColumnInfoData
*
pOutputData
=
pOutput
->
columnData
;
SColumnInfoData
*
pOutputData
=
pOutput
->
columnData
;
...
@@ -272,6 +270,13 @@ static int32_t doScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarP
...
@@ -272,6 +270,13 @@ static int32_t doScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarP
break
;
break
;
}
}
case
TSDB_DATA_TYPE_NULL
:
{
for
(
int32_t
i
=
0
;
i
<
pInput
->
numOfRows
;
++
i
)
{
colDataAppendNULL
(
pOutputData
,
i
);
}
break
;
}
default:
{
default:
{
colDataAssign
(
pOutputData
,
pInputData
,
pInput
->
numOfRows
,
NULL
);
colDataAssign
(
pOutputData
,
pInputData
,
pInput
->
numOfRows
,
NULL
);
}
}
...
...
source/libs/stream/inc/streamInc.h
浏览文件 @
291aab04
...
@@ -34,7 +34,7 @@ int32_t streamExec(SStreamTask* pTask, SMsgCb* pMsgCb);
...
@@ -34,7 +34,7 @@ int32_t streamExec(SStreamTask* pTask, SMsgCb* pMsgCb);
int32_t
streamDispatch
(
SStreamTask
*
pTask
,
SMsgCb
*
pMsgCb
);
int32_t
streamDispatch
(
SStreamTask
*
pTask
,
SMsgCb
*
pMsgCb
);
int32_t
streamDispatchReqToData
(
const
SStreamDispatchReq
*
pReq
,
SStreamDataBlock
*
pData
);
int32_t
streamDispatchReqToData
(
const
SStreamDispatchReq
*
pReq
,
SStreamDataBlock
*
pData
);
int32_t
streamRetrieveReqToData
(
const
SStreamRetrieveReq
*
pReq
,
SStreamDataBlock
*
pData
);
int32_t
streamRetrieveReqToData
(
const
SStreamRetrieveReq
*
pReq
,
SStreamDataBlock
*
pData
);
int32_t
streamBuildDispatchMsg
(
SStreamTask
*
pTask
,
SStreamDataBlock
*
data
,
SRpcMsg
*
pMsg
,
SEpSet
**
ppEpSet
);
int32_t
streamBuildDispatchMsg
(
SStreamTask
*
pTask
,
const
SStreamDataBlock
*
data
,
SRpcMsg
*
pMsg
,
SEpSet
**
ppEpSet
);
int32_t
streamBroadcastToChildren
(
SStreamTask
*
pTask
,
const
SSDataBlock
*
pBlock
);
int32_t
streamBroadcastToChildren
(
SStreamTask
*
pTask
,
const
SSDataBlock
*
pBlock
);
...
...
source/libs/stream/src/streamDispatch.c
浏览文件 @
291aab04
...
@@ -172,7 +172,7 @@ static int32_t streamAddBlockToDispatchMsg(const SSDataBlock* pBlock, SStreamDis
...
@@ -172,7 +172,7 @@ static int32_t streamAddBlockToDispatchMsg(const SSDataBlock* pBlock, SStreamDis
pRetrieve
->
streamBlockType
=
pBlock
->
info
.
type
;
pRetrieve
->
streamBlockType
=
pBlock
->
info
.
type
;
pRetrieve
->
numOfRows
=
htonl
(
pBlock
->
info
.
rows
);
pRetrieve
->
numOfRows
=
htonl
(
pBlock
->
info
.
rows
);
int32_t
numOfCols
=
(
int32_t
)
taosArrayGetSize
(
pBlock
->
pDataBlock
);
int32_t
numOfCols
=
(
int32_t
)
taosArrayGetSize
(
pBlock
->
pDataBlock
);
pRetrieve
->
numOfCols
=
htonl
(
numOfCols
);
pRetrieve
->
numOfCols
=
htonl
(
numOfCols
);
int32_t
actualLen
=
0
;
int32_t
actualLen
=
0
;
...
@@ -185,7 +185,7 @@ static int32_t streamAddBlockToDispatchMsg(const SSDataBlock* pBlock, SStreamDis
...
@@ -185,7 +185,7 @@ static int32_t streamAddBlockToDispatchMsg(const SSDataBlock* pBlock, SStreamDis
return
0
;
return
0
;
}
}
int32_t
streamBuildDispatchMsg
(
SStreamTask
*
pTask
,
SStreamDataBlock
*
data
,
SRpcMsg
*
pMsg
,
SEpSet
**
ppEpSet
)
{
int32_t
streamBuildDispatchMsg
(
SStreamTask
*
pTask
,
const
SStreamDataBlock
*
data
,
SRpcMsg
*
pMsg
,
SEpSet
**
ppEpSet
)
{
void
*
buf
=
NULL
;
void
*
buf
=
NULL
;
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
int32_t
blockNum
=
taosArrayGetSize
(
data
->
blocks
);
int32_t
blockNum
=
taosArrayGetSize
(
data
->
blocks
);
...
@@ -307,6 +307,8 @@ int32_t streamDispatch(SStreamTask* pTask, SMsgCb* pMsgCb) {
...
@@ -307,6 +307,8 @@ int32_t streamDispatch(SStreamTask* pTask, SMsgCb* pMsgCb) {
atomic_store_8
(
&
pTask
->
outputStatus
,
TASK_OUTPUT_STATUS__NORMAL
);
atomic_store_8
(
&
pTask
->
outputStatus
,
TASK_OUTPUT_STATUS__NORMAL
);
return
-
1
;
return
-
1
;
}
}
taosArrayDestroyEx
(
pBlock
->
blocks
,
(
FDelete
)
tDeleteSSDataBlock
);
taosFreeQitem
(
pBlock
);
tmsgSendReq
(
pEpSet
,
&
dispatchMsg
);
tmsgSendReq
(
pEpSet
,
&
dispatchMsg
);
return
0
;
return
0
;
...
...
source/libs/stream/src/streamExec.c
浏览文件 @
291aab04
...
@@ -53,9 +53,13 @@ static int32_t streamTaskExecImpl(SStreamTask* pTask, void* data, SArray* pRes)
...
@@ -53,9 +53,13 @@ static int32_t streamTaskExecImpl(SStreamTask* pTask, void* data, SArray* pRes)
}
}
// TODO: do we need free memory?
// TODO: do we need free memory?
SSDataBlock
*
outputCopy
=
createOneDataBlock
(
output
,
true
);
SSDataBlock
block
=
{
0
};
outputCopy
->
info
.
childId
=
pTask
->
selfChildId
;
assignOneDataBlock
(
&
block
,
output
);
taosArrayPush
(
pRes
,
outputCopy
);
block
.
info
.
childId
=
pTask
->
selfChildId
;
taosArrayPush
(
pRes
,
&
block
);
/*SSDataBlock* outputCopy = createOneDataBlock(output, true);*/
/*outputCopy->info.childId = pTask->selfChildId;*/
/*taosArrayPush(pRes, outputCopy);*/
}
}
return
0
;
return
0
;
}
}
...
@@ -68,6 +72,7 @@ static SArray* streamExecForQall(SStreamTask* pTask, SArray* pRes) {
...
@@ -68,6 +72,7 @@ static SArray* streamExecForQall(SStreamTask* pTask, SArray* pRes) {
streamTaskExecImpl
(
pTask
,
data
,
pRes
);
streamTaskExecImpl
(
pTask
,
data
,
pRes
);
if
(
pTask
->
taskStatus
==
TASK_STATUS__DROPPING
)
{
if
(
pTask
->
taskStatus
==
TASK_STATUS__DROPPING
)
{
taosArrayDestroyEx
(
pRes
,
(
FDelete
)
tDeleteSSDataBlock
);
return
NULL
;
return
NULL
;
}
}
...
@@ -82,25 +87,25 @@ static SArray* streamExecForQall(SStreamTask* pTask, SArray* pRes) {
...
@@ -82,25 +87,25 @@ static SArray* streamExecForQall(SStreamTask* pTask, SArray* pRes) {
qRes
->
blocks
=
pRes
;
qRes
->
blocks
=
pRes
;
if
(
streamTaskOutput
(
pTask
,
qRes
)
<
0
)
{
if
(
streamTaskOutput
(
pTask
,
qRes
)
<
0
)
{
streamQueueProcessFail
(
pTask
->
inputQueue
);
streamQueueProcessFail
(
pTask
->
inputQueue
);
taosArrayDestroy
(
pRes
);
taosArrayDestroy
Ex
(
pRes
,
(
FDelete
)
tDeleteSSDataBlock
);
taosFreeQitem
(
qRes
);
taosFreeQitem
(
qRes
);
return
NULL
;
return
NULL
;
}
}
int8_t
type
=
((
SStreamQueueItem
*
)
data
)
->
type
;
if
(
type
==
STREAM_INPUT__TRIGGER
)
{
blockDataDestroy
(((
SStreamTrigger
*
)
data
)
->
pBlock
);
taosFreeQitem
(
data
);
}
else
if
(
type
==
STREAM_INPUT__DATA_BLOCK
)
{
taosArrayDestroyEx
(((
SStreamDataBlock
*
)
data
)
->
blocks
,
(
FDelete
)
tDeleteSSDataBlock
);
taosFreeQitem
(
data
);
}
else
if
(
type
==
STREAM_INPUT__DATA_SUBMIT
)
{
ASSERT
(
pTask
->
isDataScan
);
streamDataSubmitRefDec
((
SStreamDataSubmit
*
)
data
);
taosFreeQitem
(
data
);
}
streamQueueProcessSuccess
(
pTask
->
inputQueue
);
streamQueueProcessSuccess
(
pTask
->
inputQueue
);
return
taosArrayInit
(
0
,
sizeof
(
SSDataBlock
));
pRes
=
taosArrayInit
(
0
,
sizeof
(
SSDataBlock
));
}
int8_t
type
=
((
SStreamQueueItem
*
)
data
)
->
type
;
if
(
type
==
STREAM_INPUT__TRIGGER
)
{
blockDataDestroy
(((
SStreamTrigger
*
)
data
)
->
pBlock
);
taosFreeQitem
(
data
);
}
else
if
(
type
==
STREAM_INPUT__DATA_BLOCK
)
{
taosArrayDestroyEx
(((
SStreamDataBlock
*
)
data
)
->
blocks
,
(
FDelete
)
tDeleteSSDataBlock
);
taosFreeQitem
(
data
);
}
else
if
(
type
==
STREAM_INPUT__DATA_SUBMIT
)
{
ASSERT
(
pTask
->
isDataScan
);
streamDataSubmitRefDec
((
SStreamDataSubmit
*
)
data
);
taosFreeQitem
(
data
);
}
}
}
}
return
pRes
;
return
pRes
;
...
@@ -125,14 +130,14 @@ int32_t streamExec(SStreamTask* pTask, SMsgCb* pMsgCb) {
...
@@ -125,14 +130,14 @@ int32_t streamExec(SStreamTask* pTask, SMsgCb* pMsgCb) {
pRes
=
streamExecForQall
(
pTask
,
pRes
);
pRes
=
streamExecForQall
(
pTask
,
pRes
);
if
(
pRes
==
NULL
)
goto
FAIL
;
if
(
pRes
==
NULL
)
goto
FAIL
;
taosArrayDestroy
(
pRes
);
taosArrayDestroy
Ex
(
pRes
,
(
FDelete
)
tDeleteSSDataBlock
);
atomic_store_8
(
&
pTask
->
execStatus
,
TASK_EXEC_STATUS__IDLE
);
atomic_store_8
(
&
pTask
->
execStatus
,
TASK_EXEC_STATUS__IDLE
);
return
0
;
return
0
;
}
else
if
(
execStatus
==
TASK_EXEC_STATUS__CLOSING
)
{
}
else
if
(
execStatus
==
TASK_EXEC_STATUS__CLOSING
)
{
continue
;
continue
;
}
else
if
(
execStatus
==
TASK_EXEC_STATUS__EXECUTING
)
{
}
else
if
(
execStatus
==
TASK_EXEC_STATUS__EXECUTING
)
{
ASSERT
(
taosArrayGetSize
(
pRes
)
==
0
);
ASSERT
(
taosArrayGetSize
(
pRes
)
==
0
);
taosArrayDestroy
(
pRes
);
taosArrayDestroy
Ex
(
pRes
,
(
FDelete
)
tDeleteSSDataBlock
);
return
0
;
return
0
;
}
else
{
}
else
{
ASSERT
(
0
);
ASSERT
(
0
);
...
...
source/libs/sync/inc/syncEnv.h
浏览文件 @
291aab04
...
@@ -28,13 +28,13 @@ extern "C" {
...
@@ -28,13 +28,13 @@ extern "C" {
#include "trpc.h"
#include "trpc.h"
#include "ttimer.h"
#include "ttimer.h"
#define TIMER_MAX_MS 0x7FFFFFFF
#define TIMER_MAX_MS
0x7FFFFFFF
#define ENV_TICK_TIMER_MS 1000
#define ENV_TICK_TIMER_MS
1000
#define PING_TIMER_MS 1000
#define PING_TIMER_MS
1000
#define ELECT_TIMER_MS_MIN
5
00
#define ELECT_TIMER_MS_MIN
13
00
#define ELECT_TIMER_MS_MAX (ELECT_TIMER_MS_MIN * 2)
#define ELECT_TIMER_MS_MAX
(ELECT_TIMER_MS_MIN * 2)
#define ELECT_TIMER_MS_RANGE (ELECT_TIMER_MS_MAX - ELECT_TIMER_MS_MIN)
#define ELECT_TIMER_MS_RANGE (ELECT_TIMER_MS_MAX - ELECT_TIMER_MS_MIN)
#define HEARTBEAT_TIMER_MS
1
00
#define HEARTBEAT_TIMER_MS
9
00
#define EMPTY_RAFT_ID ((SRaftId){.addr = 0, .vgId = 0})
#define EMPTY_RAFT_ID ((SRaftId){.addr = 0, .vgId = 0})
...
...
source/libs/sync/inc/syncRaftLog.h
浏览文件 @
291aab04
...
@@ -26,11 +26,13 @@ extern "C" {
...
@@ -26,11 +26,13 @@ extern "C" {
#include "syncInt.h"
#include "syncInt.h"
#include "syncRaftEntry.h"
#include "syncRaftEntry.h"
#include "taosdef.h"
#include "taosdef.h"
#include "wal.h"
typedef
struct
SSyncLogStoreData
{
typedef
struct
SSyncLogStoreData
{
SSyncNode
*
pSyncNode
;
SSyncNode
*
pSyncNode
;
SWal
*
pWal
;
SWal
*
pWal
;
SyncIndex
beginIndex
;
// valid begin index, default 0, may be set beginIndex > 0
SWalReadHandle
*
pWalHandle
;
// SyncIndex beginIndex; // valid begin index, default 0, may be set beginIndex > 0
}
SSyncLogStoreData
;
}
SSyncLogStoreData
;
SSyncLogStore
*
logStoreCreate
(
SSyncNode
*
pSyncNode
);
SSyncLogStore
*
logStoreCreate
(
SSyncNode
*
pSyncNode
);
...
...
source/libs/sync/src/syncAppendEntries.c
浏览文件 @
291aab04
...
@@ -420,44 +420,26 @@ static int32_t syncNodePreCommit(SSyncNode* ths, SSyncRaftEntry* pEntry) {
...
@@ -420,44 +420,26 @@ static int32_t syncNodePreCommit(SSyncNode* ths, SSyncRaftEntry* pEntry) {
// prevLogIndex == -1
// prevLogIndex == -1
static
bool
syncNodeOnAppendEntriesLogOK
(
SSyncNode
*
pSyncNode
,
SyncAppendEntries
*
pMsg
)
{
static
bool
syncNodeOnAppendEntriesLogOK
(
SSyncNode
*
pSyncNode
,
SyncAppendEntries
*
pMsg
)
{
if
(
pMsg
->
prevLogIndex
==
SYNC_INDEX_INVALID
)
{
if
(
pMsg
->
prevLogIndex
==
SYNC_INDEX_INVALID
)
{
if
(
gRaftDetailLog
)
{
sTrace
(
"syncNodeOnAppendEntriesLogOK true, pMsg->prevLogIndex:%ld"
,
pMsg
->
prevLogIndex
);
}
return
true
;
return
true
;
}
}
SyncIndex
myLastIndex
=
syncNodeGetLastIndex
(
pSyncNode
);
SyncIndex
myLastIndex
=
syncNodeGetLastIndex
(
pSyncNode
);
if
(
pMsg
->
prevLogIndex
>
myLastIndex
)
{
if
(
pMsg
->
prevLogIndex
>
myLastIndex
)
{
if
(
gRaftDetailLog
)
{
sDebug
(
"vgId:%d sync log not ok, preindex:%ld"
,
pSyncNode
->
vgId
,
pMsg
->
prevLogIndex
);
sTrace
(
"syncNodeOnAppendEntriesLogOK false, pMsg->prevLogIndex:%ld, myLastIndex:%ld"
,
pMsg
->
prevLogIndex
,
myLastIndex
);
}
return
false
;
return
false
;
}
}
SyncTerm
myPreLogTerm
=
syncNodeGetPreTerm
(
pSyncNode
,
pMsg
->
prevLogIndex
+
1
);
SyncTerm
myPreLogTerm
=
syncNodeGetPreTerm
(
pSyncNode
,
pMsg
->
prevLogIndex
+
1
);
if
(
myPreLogTerm
==
SYNC_TERM_INVALID
)
{
if
(
myPreLogTerm
==
SYNC_TERM_INVALID
)
{
s
Error
(
"vgId:%d sync get pre term error
, preindex:%ld"
,
pSyncNode
->
vgId
,
pMsg
->
prevLogIndex
);
s
Debug
(
"vgId:%d sync log not ok2
, preindex:%ld"
,
pSyncNode
->
vgId
,
pMsg
->
prevLogIndex
);
return
false
;
return
false
;
}
}
if
(
pMsg
->
prevLogIndex
<=
myLastIndex
&&
pMsg
->
prevLogTerm
==
myPreLogTerm
)
{
if
(
pMsg
->
prevLogIndex
<=
myLastIndex
&&
pMsg
->
prevLogTerm
==
myPreLogTerm
)
{
if
(
gRaftDetailLog
)
{
sTrace
(
"syncNodeOnAppendEntriesLogOK true, pMsg->prevLogIndex:%ld, myLastIndex:%ld, pMsg->prevLogTerm:%lu, "
"myPreLogTerm:%lu"
,
pMsg
->
prevLogIndex
,
myLastIndex
,
pMsg
->
prevLogTerm
,
myPreLogTerm
);
}
return
true
;
return
true
;
}
}
if
(
gRaftDetailLog
)
{
sDebug
(
"vgId:%d sync log not ok3, preindex:%ld"
,
pSyncNode
->
vgId
,
pMsg
->
prevLogIndex
);
sTrace
(
"syncNodeOnAppendEntriesLogOK false, pMsg->prevLogIndex:%ld, myLastIndex:%ld, pMsg->prevLogTerm:%lu, "
"myPreLogTerm:%lu"
,
pMsg
->
prevLogIndex
,
myLastIndex
,
pMsg
->
prevLogTerm
,
myPreLogTerm
);
}
return
false
;
return
false
;
}
}
...
@@ -466,14 +448,11 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
...
@@ -466,14 +448,11 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
int32_t
code
=
0
;
int32_t
code
=
0
;
// print log
// print log
char
logBuf
[
128
]
=
{
0
};
syncAppendEntriesLog2
(
"==syncNodeOnAppendEntriesSnapshotCb=="
,
pMsg
);
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"recv SyncAppendEntries, vgId:%d, term:%lu"
,
ths
->
vgId
,
ths
->
pRaftStore
->
currentTerm
);
syncAppendEntriesLog2
(
logBuf
,
pMsg
);
// if already drop replica, do not process
// if already drop replica, do not process
if
(
!
syncNodeInRaftGroup
(
ths
,
&
(
pMsg
->
srcId
))
&&
!
ths
->
pRaftCfg
->
isStandBy
)
{
if
(
!
syncNodeInRaftGroup
(
ths
,
&
(
pMsg
->
srcId
))
&&
!
ths
->
pRaftCfg
->
isStandBy
)
{
s
Info
(
"recv SyncAppendEntries
maybe replica already dropped"
);
s
yncNodeEventLog
(
ths
,
"recv sync-append-entries,
maybe replica already dropped"
);
return
ret
;
return
ret
;
}
}
...
@@ -497,7 +476,7 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
...
@@ -497,7 +476,7 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
do
{
do
{
bool
condition
=
pMsg
->
term
==
ths
->
pRaftStore
->
currentTerm
&&
ths
->
state
==
TAOS_SYNC_STATE_CANDIDATE
;
bool
condition
=
pMsg
->
term
==
ths
->
pRaftStore
->
currentTerm
&&
ths
->
state
==
TAOS_SYNC_STATE_CANDIDATE
;
if
(
condition
)
{
if
(
condition
)
{
s
Trace
(
"recv SyncAppendE
ntries, candidate to follower"
);
s
yncNodeEventLog
(
ths
,
"recv sync-append-e
ntries, candidate to follower"
);
syncNodeBecomeFollower
(
ths
,
"from candidate by append entries"
);
syncNodeBecomeFollower
(
ths
,
"from candidate by append entries"
);
// do not reply?
// do not reply?
...
@@ -505,6 +484,7 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
...
@@ -505,6 +484,7 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
}
}
}
while
(
0
);
}
while
(
0
);
#if 0
// fake match
// fake match
//
//
// condition1:
// condition1:
...
@@ -530,7 +510,7 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
...
@@ -530,7 +510,7 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
bool condition0 = (pMsg->term == ths->pRaftStore->currentTerm) && (ths->state == TAOS_SYNC_STATE_FOLLOWER) &&
bool condition0 = (pMsg->term == ths->pRaftStore->currentTerm) && (ths->state == TAOS_SYNC_STATE_FOLLOWER) &&
syncNodeHasSnapshot(ths);
syncNodeHasSnapshot(ths);
bool condition1 =
bool condition1 =
condition0
&&
(
ths
->
pLogStore
->
syncLogEntryCount
(
ths
->
pLogStore
)
==
0
)
&&
(
pMsg
->
prevLogIndex
>
myLastIndex
);
condition0 && (ths->pLogStore->syncLogEntryCount(ths->pLogStore) == 0) && (pMsg->prevLogIndex > myLastIndex);
// donot use syncLogEntryCount!!! use isEmpty
bool condition2 = condition0 && (ths->pLogStore->syncLogLastIndex(ths->pLogStore) <= snapshot.lastApplyIndex) &&
bool condition2 = condition0 && (ths->pLogStore->syncLogLastIndex(ths->pLogStore) <= snapshot.lastApplyIndex) &&
(pMsg->prevLogIndex > myLastIndex);
(pMsg->prevLogIndex > myLastIndex);
bool condition3 = condition0 && (pMsg->prevLogIndex < snapshot.lastApplyIndex);
bool condition3 = condition0 && (pMsg->prevLogIndex < snapshot.lastApplyIndex);
...
@@ -538,11 +518,10 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
...
@@ -538,11 +518,10 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
bool condition = condition1 || condition2 || condition3 || condition4;
bool condition = condition1 || condition2 || condition3 || condition4;
if (condition) {
if (condition) {
sTrace
(
char logBuf[128];
"recv SyncAppendEntries, fake match, myLastIndex:%ld, syncLogBeginIndex:%ld, syncLogEndIndex:%ld, "
snprintf(logBuf, sizeof(logBuf), "recv sync-append-entries, fake match, pre-index:%ld, pre-term:%lu",
"condition1:%d, condition2:%d, condition3:%d, condition4:%d"
,
pMsg->prevLogIndex, pMsg->prevLogTerm);
myLastIndex
,
ths
->
pLogStore
->
syncLogBeginIndex
(
ths
->
pLogStore
),
syncNodeEventLog(ths, logBuf);
ths
->
pLogStore
->
syncLogEndIndex
(
ths
->
pLogStore
),
condition1
,
condition2
,
condition3
,
condition4
);
// prepare response msg
// prepare response msg
SyncAppendEntriesReply* pReply = syncAppendEntriesReplyBuild(ths->vgId);
SyncAppendEntriesReply* pReply = syncAppendEntriesReplyBuild(ths->vgId);
...
@@ -562,6 +541,7 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
...
@@ -562,6 +541,7 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
return ret;
return ret;
}
}
} while (0);
} while (0);
#endif
// fake match2
// fake match2
//
//
...
@@ -576,8 +556,13 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
...
@@ -576,8 +556,13 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
bool
condition
=
(
pMsg
->
term
==
ths
->
pRaftStore
->
currentTerm
)
&&
(
ths
->
state
==
TAOS_SYNC_STATE_FOLLOWER
)
&&
bool
condition
=
(
pMsg
->
term
==
ths
->
pRaftStore
->
currentTerm
)
&&
(
ths
->
state
==
TAOS_SYNC_STATE_FOLLOWER
)
&&
(
pMsg
->
prevLogIndex
<=
ths
->
commitIndex
);
(
pMsg
->
prevLogIndex
<=
ths
->
commitIndex
);
if
(
condition
)
{
if
(
condition
)
{
sTrace
(
"recv SyncAppendEntries, fake match2, msg-prevLogIndex:%ld, my-commitIndex:%ld"
,
pMsg
->
prevLogIndex
,
do
{
ths
->
commitIndex
);
char
logBuf
[
128
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"recv sync-append-entries, fake match2, pre-index:%ld, pre-term:%lu, datalen:%d"
,
pMsg
->
prevLogIndex
,
pMsg
->
prevLogTerm
,
pMsg
->
dataLen
);
syncNodeEventLog
(
ths
,
logBuf
);
}
while
(
0
);
SyncIndex
matchIndex
=
ths
->
commitIndex
;
SyncIndex
matchIndex
=
ths
->
commitIndex
;
bool
hasAppendEntries
=
pMsg
->
dataLen
>
0
;
bool
hasAppendEntries
=
pMsg
->
dataLen
>
0
;
...
@@ -605,6 +590,7 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
...
@@ -605,6 +590,7 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
code
=
syncNodePreCommit
(
ths
,
pAppendEntry
);
code
=
syncNodePreCommit
(
ths
,
pAppendEntry
);
ASSERT
(
code
==
0
);
ASSERT
(
code
==
0
);
// update match index
matchIndex
=
pMsg
->
prevLogIndex
+
1
;
matchIndex
=
pMsg
->
prevLogIndex
+
1
;
syncEntryDestory
(
pAppendEntry
);
syncEntryDestory
(
pAppendEntry
);
...
@@ -650,11 +636,10 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
...
@@ -650,11 +636,10 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
bool
condition
=
condition1
||
condition2
;
bool
condition
=
condition1
||
condition2
;
if
(
condition
)
{
if
(
condition
)
{
sTrace
(
char
logBuf
[
128
];
"recv SyncAppendEntries, not match, syncLogBeginIndex:%ld, syncLogEndIndex:%ld, condition1:%d, "
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"recv sync-append-entries, not match, pre-index:%ld, pre-term:%lu, datalen:%d"
,
"condition2:%d, logOK:%d"
,
pMsg
->
prevLogIndex
,
pMsg
->
prevLogTerm
,
pMsg
->
dataLen
);
ths
->
pLogStore
->
syncLogBeginIndex
(
ths
->
pLogStore
),
ths
->
pLogStore
->
syncLogEndIndex
(
ths
->
pLogStore
),
syncNodeEventLog
(
ths
,
logBuf
);
condition1
,
condition2
,
logOK
);
// prepare response msg
// prepare response msg
SyncAppendEntriesReply
*
pReply
=
syncAppendEntriesReplyBuild
(
ths
->
vgId
);
SyncAppendEntriesReply
*
pReply
=
syncAppendEntriesReplyBuild
(
ths
->
vgId
);
...
@@ -693,8 +678,10 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
...
@@ -693,8 +678,10 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
// has entries in SyncAppendEntries msg
// has entries in SyncAppendEntries msg
bool
hasAppendEntries
=
pMsg
->
dataLen
>
0
;
bool
hasAppendEntries
=
pMsg
->
dataLen
>
0
;
sTrace
(
"recv SyncAppendEntries, match, myLastIndex:%ld, hasExtraEntries:%d, hasAppendEntries:%d"
,
myLastIndex
,
char
logBuf
[
128
];
hasExtraEntries
,
hasAppendEntries
);
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"recv sync-append-entries, match, pre-index:%ld, pre-term:%lu, datalen:%d"
,
pMsg
->
prevLogIndex
,
pMsg
->
prevLogTerm
,
pMsg
->
dataLen
);
syncNodeEventLog
(
ths
,
logBuf
);
if
(
hasExtraEntries
)
{
if
(
hasExtraEntries
)
{
// make log same, rollback deleted entries
// make log same, rollback deleted entries
...
...
source/libs/sync/src/syncAppendEntriesReply.c
浏览文件 @
291aab04
...
@@ -101,32 +101,27 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries
...
@@ -101,32 +101,27 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries
int32_t
ret
=
0
;
int32_t
ret
=
0
;
// print log
// print log
char
logBuf
[
128
]
=
{
0
};
syncAppendEntriesReplyLog2
(
"==syncNodeOnAppendEntriesReplySnapshotCb=="
,
pMsg
);
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"recv SyncAppendEntriesReply, vgId:%d, term:%lu"
,
ths
->
vgId
,
ths
->
pRaftStore
->
currentTerm
);
syncAppendEntriesReplyLog2
(
logBuf
,
pMsg
);
// if already drop replica, do not process
// if already drop replica, do not process
if
(
!
syncNodeInRaftGroup
(
ths
,
&
(
pMsg
->
srcId
))
&&
!
ths
->
pRaftCfg
->
isStandBy
)
{
if
(
!
syncNodeInRaftGroup
(
ths
,
&
(
pMsg
->
srcId
))
&&
!
ths
->
pRaftCfg
->
isStandBy
)
{
s
Info
(
"recv SyncAppendEntriesR
eply, maybe replica already dropped"
);
s
yncNodeEventLog
(
ths
,
"recv sync-append-entries-r
eply, maybe replica already dropped"
);
return
ret
;
return
0
;
}
}
// drop stale response
// drop stale response
if
(
pMsg
->
term
<
ths
->
pRaftStore
->
currentTerm
)
{
if
(
pMsg
->
term
<
ths
->
pRaftStore
->
currentTerm
)
{
sTrace
(
"recv SyncAppendEntriesReply, drop stale response, receive_term:%lu current_term:%lu"
,
pMsg
->
term
,
char
logBuf
[
128
];
ths
->
pRaftStore
->
currentTerm
);
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"recv sync-append-entries-reply, recv-term:%lu, drop stale response"
,
pMsg
->
term
);
return
ret
;
syncNodeEventLog
(
ths
,
logBuf
);
return
0
;
}
}
syncIndexMgrLog2
(
"recv SyncAppendEntriesReply, before pNextIndex:"
,
ths
->
pNextIndex
);
syncIndexMgrLog2
(
"recv SyncAppendEntriesReply, before pMatchIndex:"
,
ths
->
pMatchIndex
);
if
(
gRaftDetailLog
)
{
if
(
gRaftDetailLog
)
{
SSnapshot
snapshot
;
syncNodeEventLog
(
ths
,
"recv sync-append-entries-reply, before"
);
ths
->
pFsm
->
FpGetSnapshotInfo
(
ths
->
pFsm
,
&
snapshot
);
sTrace
(
"recv SyncAppendEntriesReply, before snapshot.lastApplyIndex:%ld, snapshot.lastApplyTerm:%lu"
,
snapshot
.
lastApplyIndex
,
snapshot
.
lastApplyTerm
);
}
}
syncIndexMgrLog2
(
"recv sync-append-entries-reply, before pNextIndex:"
,
ths
->
pNextIndex
);
syncIndexMgrLog2
(
"recv sync-append-entries-reply, before pMatchIndex:"
,
ths
->
pMatchIndex
);
// no need this code, because if I receive reply.term, then I must have sent for that term.
// no need this code, because if I receive reply.term, then I must have sent for that term.
// if (pMsg->term > ths->pRaftStore->currentTerm) {
// if (pMsg->term > ths->pRaftStore->currentTerm) {
...
@@ -134,12 +129,10 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries
...
@@ -134,12 +129,10 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries
// }
// }
if
(
pMsg
->
term
>
ths
->
pRaftStore
->
currentTerm
)
{
if
(
pMsg
->
term
>
ths
->
pRaftStore
->
currentTerm
)
{
char
logBuf
[
128
]
=
{
0
};
char
logBuf
[
128
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"recv SyncAppendEntriesReply, error term, receive_term:%lu current_term:%lu"
,
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"recv sync-append-entries-reply, error term, recv-term:%lu"
,
pMsg
->
term
);
pMsg
->
term
,
ths
->
pRaftStore
->
currentTerm
);
syncNodeErrorLog
(
ths
,
logBuf
);
syncNodeLog2
(
logBuf
,
ths
);
return
-
1
;
sError
(
"%s"
,
logBuf
);
return
ret
;
}
}
ASSERT
(
pMsg
->
term
==
ths
->
pRaftStore
->
currentTerm
);
ASSERT
(
pMsg
->
term
==
ths
->
pRaftStore
->
currentTerm
);
...
@@ -228,8 +221,11 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries
...
@@ -228,8 +221,11 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries
}
}
}
}
syncIndexMgrLog2
(
"recv SyncAppendEntriesReply, after pNextIndex:"
,
ths
->
pNextIndex
);
if
(
gRaftDetailLog
)
{
syncIndexMgrLog2
(
"recv SyncAppendEntriesReply, after pMatchIndex:"
,
ths
->
pMatchIndex
);
syncNodeEventLog
(
ths
,
"recv sync-append-entries-reply, after"
);
}
syncIndexMgrLog2
(
"recv sync-append-entries-reply, after pNextIndex:"
,
ths
->
pNextIndex
);
syncIndexMgrLog2
(
"recv sync-append-entries-reply, after pMatchIndex:"
,
ths
->
pMatchIndex
);
return
ret
;
return
ret
;
}
}
\ No newline at end of file
source/libs/sync/src/syncMain.c
浏览文件 @
291aab04
...
@@ -416,7 +416,7 @@ int32_t syncGetSnapshotMetaByIndex(int64_t rid, SyncIndex snapshotIndex, struct
...
@@ -416,7 +416,7 @@ int32_t syncGetSnapshotMetaByIndex(int64_t rid, SyncIndex snapshotIndex, struct
}
}
}
}
sMeta
->
lastConfigIndex
=
lastIndex
;
sMeta
->
lastConfigIndex
=
lastIndex
;
sTrace
(
"vgId:%d, get snapshot meta by index:%"
PRId64
" l
astConfigI
ndex:%"
PRId64
,
pSyncNode
->
vgId
,
snapshotIndex
,
sTrace
(
"vgId:%d, get snapshot meta by index:%"
PRId64
" l
ci
ndex:%"
PRId64
,
pSyncNode
->
vgId
,
snapshotIndex
,
sMeta
->
lastConfigIndex
);
sMeta
->
lastConfigIndex
);
taosReleaseRef
(
tsNodeRefId
,
pSyncNode
->
rid
);
taosReleaseRef
(
tsNodeRefId
,
pSyncNode
->
rid
);
...
@@ -433,8 +433,9 @@ SyncIndex syncNodeGetSnapshotConfigIndex(SSyncNode* pSyncNode, SyncIndex snapsho
...
@@ -433,8 +433,9 @@ SyncIndex syncNodeGetSnapshotConfigIndex(SSyncNode* pSyncNode, SyncIndex snapsho
lastIndex
=
(
pSyncNode
->
pRaftCfg
->
configIndexArr
)[
i
];
lastIndex
=
(
pSyncNode
->
pRaftCfg
->
configIndexArr
)[
i
];
}
}
}
}
sTrace
(
"vgId:%d, sync get snapshot last config index, index:%ld lcindex:%ld"
,
pSyncNode
->
vgId
,
snapshotLastApplyIndex
,
lastIndex
);
sTrace
(
"sync syncNodeGetSnapshotConfigIndex index:%ld lastConfigIndex:%ld"
,
snapshotLastApplyIndex
,
lastIndex
);
return
lastIndex
;
return
lastIndex
;
}
}
...
@@ -1310,6 +1311,10 @@ void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) {
...
@@ -1310,6 +1311,10 @@ void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) {
SyncIndex
logBeginIndex
=
pSyncNode
->
pLogStore
->
syncLogBeginIndex
(
pSyncNode
->
pLogStore
);
SyncIndex
logBeginIndex
=
pSyncNode
->
pLogStore
->
syncLogBeginIndex
(
pSyncNode
->
pLogStore
);
char
*
pCfgStr
=
syncCfg2SimpleStr
(
&
(
pSyncNode
->
pRaftCfg
->
cfg
));
char
*
pCfgStr
=
syncCfg2SimpleStr
(
&
(
pSyncNode
->
pRaftCfg
->
cfg
));
char
*
printStr
=
""
;
if
(
pCfgStr
!=
NULL
)
{
printStr
=
pCfgStr
;
}
if
(
userStrLen
<
256
)
{
if
(
userStrLen
<
256
)
{
char
logBuf
[
256
+
256
];
char
logBuf
[
256
+
256
];
...
@@ -1317,11 +1322,11 @@ void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) {
...
@@ -1317,11 +1322,11 @@ void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) {
snprintf
(
logBuf
,
sizeof
(
logBuf
),
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"vgId:%d, sync %s %s, term:%lu, commit:%ld, beginlog:%ld, lastlog:%ld, lastsnapshot:%ld, standby:%d, "
"vgId:%d, sync %s %s, term:%lu, commit:%ld, beginlog:%ld, lastlog:%ld, lastsnapshot:%ld, standby:%d, "
"replica-num:%d, "
"replica-num:%d, "
"lconfig:%ld, changing:%d, %s"
,
"lconfig:%ld, changing:%d,
restore:%d,
%s"
,
pSyncNode
->
vgId
,
syncUtilState2String
(
pSyncNode
->
state
),
str
,
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
vgId
,
syncUtilState2String
(
pSyncNode
->
state
),
str
,
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
commitIndex
,
logBeginIndex
,
logLastIndex
,
snapshot
.
lastApplyIndex
,
pSyncNode
->
commitIndex
,
logBeginIndex
,
logLastIndex
,
snapshot
.
lastApplyIndex
,
pSyncNode
->
pRaftCfg
->
isStandBy
,
pSyncNode
->
replicaNum
,
pSyncNode
->
pRaftCfg
->
lastConfigIndex
,
pSyncNode
->
pRaftCfg
->
isStandBy
,
pSyncNode
->
replicaNum
,
pSyncNode
->
pRaftCfg
->
lastConfigIndex
,
pSyncNode
->
changing
,
p
Cfg
Str
);
pSyncNode
->
changing
,
p
SyncNode
->
restoreFinish
,
print
Str
);
}
else
{
}
else
{
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"%s"
,
str
);
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"%s"
,
str
);
}
}
...
@@ -1334,11 +1339,11 @@ void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) {
...
@@ -1334,11 +1339,11 @@ void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) {
snprintf
(
s
,
len
,
snprintf
(
s
,
len
,
"vgId:%d, sync %s %s, term:%lu, commit:%ld, beginlog:%ld, lastlog:%ld, lastsnapshot:%ld, standby:%d, "
"vgId:%d, sync %s %s, term:%lu, commit:%ld, beginlog:%ld, lastlog:%ld, lastsnapshot:%ld, standby:%d, "
"replica-num:%d, "
"replica-num:%d, "
"lconfig:%ld, changing:%d, %s"
,
"lconfig:%ld, changing:%d,
restore:%d,
%s"
,
pSyncNode
->
vgId
,
syncUtilState2String
(
pSyncNode
->
state
),
str
,
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
vgId
,
syncUtilState2String
(
pSyncNode
->
state
),
str
,
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
commitIndex
,
logBeginIndex
,
logLastIndex
,
snapshot
.
lastApplyIndex
,
pSyncNode
->
commitIndex
,
logBeginIndex
,
logLastIndex
,
snapshot
.
lastApplyIndex
,
pSyncNode
->
pRaftCfg
->
isStandBy
,
pSyncNode
->
replicaNum
,
pSyncNode
->
pRaftCfg
->
lastConfigIndex
,
pSyncNode
->
pRaftCfg
->
isStandBy
,
pSyncNode
->
replicaNum
,
pSyncNode
->
pRaftCfg
->
lastConfigIndex
,
pSyncNode
->
changing
,
p
Cfg
Str
);
pSyncNode
->
changing
,
p
SyncNode
->
restoreFinish
,
print
Str
);
}
else
{
}
else
{
snprintf
(
s
,
len
,
"%s"
,
str
);
snprintf
(
s
,
len
,
"%s"
,
str
);
}
}
...
@@ -1398,14 +1403,34 @@ void syncNodeErrorLog(const SSyncNode* pSyncNode, char* str) {
...
@@ -1398,14 +1403,34 @@ void syncNodeErrorLog(const SSyncNode* pSyncNode, char* str) {
char
*
syncNode2SimpleStr
(
const
SSyncNode
*
pSyncNode
)
{
char
*
syncNode2SimpleStr
(
const
SSyncNode
*
pSyncNode
)
{
int
len
=
256
;
int
len
=
256
;
char
*
s
=
(
char
*
)
taosMemoryMalloc
(
len
);
char
*
s
=
(
char
*
)
taosMemoryMalloc
(
len
);
SSnapshot
snapshot
=
{.
data
=
NULL
,
.
lastApplyIndex
=
-
1
,
.
lastApplyTerm
=
0
};
if
(
pSyncNode
->
pFsm
->
FpGetSnapshotInfo
!=
NULL
)
{
pSyncNode
->
pFsm
->
FpGetSnapshotInfo
(
pSyncNode
->
pFsm
,
&
snapshot
);
}
SyncIndex
logLastIndex
=
pSyncNode
->
pLogStore
->
syncLogLastIndex
(
pSyncNode
->
pLogStore
);
SyncIndex
logBeginIndex
=
pSyncNode
->
pLogStore
->
syncLogBeginIndex
(
pSyncNode
->
pLogStore
);
snprintf
(
s
,
len
,
snprintf
(
s
,
len
,
"syncNode: vgId:%d, currentTerm:%lu, commitIndex:%ld, state:%d %s, isStandBy:%d, "
"vgId:%d, sync %s, term:%lu, commit:%ld, beginlog:%ld, lastlog:%ld, lastsnapshot:%ld, standby:%d, "
"electTimerLogicClock:%lu, "
"replica-num:%d, "
"electTimerLogicClockUser:%lu, "
"lconfig:%ld, changing:%d, restore:%d"
,
"electTimerMS:%d, replicaNum:%d"
,
pSyncNode
->
vgId
,
syncUtilState2String
(
pSyncNode
->
state
),
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
vgId
,
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
commitIndex
,
pSyncNode
->
state
,
pSyncNode
->
commitIndex
,
logBeginIndex
,
logLastIndex
,
snapshot
.
lastApplyIndex
,
pSyncNode
->
pRaftCfg
->
isStandBy
,
syncUtilState2String
(
pSyncNode
->
state
),
pSyncNode
->
pRaftCfg
->
isStandBy
,
pSyncNode
->
electTimerLogicClock
,
pSyncNode
->
replicaNum
,
pSyncNode
->
pRaftCfg
->
lastConfigIndex
,
pSyncNode
->
changing
,
pSyncNode
->
restoreFinish
);
pSyncNode
->
electTimerLogicClockUser
,
pSyncNode
->
electTimerMS
,
pSyncNode
->
replicaNum
);
/*
snprintf(s, len,
"syncNode: vgId:%d, term:%lu, commit:%ld, state:%d %s, standby:%d, "
"lc:%lu, "
"lc-user:%lu, "
"ems:%d, replica-num:%d, restore:%d, changing:%d",
pSyncNode->vgId, pSyncNode->pRaftStore->currentTerm, pSyncNode->commitIndex, pSyncNode->state,
syncUtilState2String(pSyncNode->state), pSyncNode->pRaftCfg->isStandBy, pSyncNode->electTimerLogicClock,
pSyncNode->electTimerLogicClockUser, pSyncNode->electTimerMS, pSyncNode->replicaNum,
pSyncNode->restoreFinish, pSyncNode->changing);
*/
return
s
;
return
s
;
}
}
...
@@ -1957,17 +1982,21 @@ SyncTerm syncNodeGetPreTerm(SSyncNode* pSyncNode, SyncIndex index) {
...
@@ -1957,17 +1982,21 @@ SyncTerm syncNodeGetPreTerm(SSyncNode* pSyncNode, SyncIndex index) {
taosMemoryFree
(
pPreEntry
);
taosMemoryFree
(
pPreEntry
);
return
preTerm
;
return
preTerm
;
}
else
{
}
else
{
if
(
terrno
==
TSDB_CODE_WAL_LOG_NOT_EXIST
)
{
SSnapshot
snapshot
=
{.
data
=
NULL
,
.
lastApplyIndex
=
-
1
,
.
lastApplyTerm
=
0
,
.
lastConfigIndex
=
-
1
};
SSnapshot
snapshot
=
{.
data
=
NULL
,
.
lastApplyIndex
=
-
1
,
.
lastApplyTerm
=
0
,
.
lastConfigIndex
=
-
1
};
if
(
pSyncNode
->
pFsm
->
FpGetSnapshotInfo
!=
NULL
)
{
if
(
pSyncNode
->
pFsm
->
FpGetSnapshotInfo
!=
NULL
)
{
pSyncNode
->
pFsm
->
FpGetSnapshotInfo
(
pSyncNode
->
pFsm
,
&
snapshot
);
pSyncNode
->
pFsm
->
FpGetSnapshotInfo
(
pSyncNode
->
pFsm
,
&
snapshot
);
if
(
snapshot
.
lastApplyIndex
==
preIndex
)
{
if
(
snapshot
.
lastApplyIndex
==
preIndex
)
{
return
snapshot
.
lastApplyTerm
;
return
snapshot
.
lastApplyTerm
;
}
}
}
}
}
}
}
do
{
char
logBuf
[
128
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"sync node get pre term error, index:%ld"
,
index
);
syncNodeErrorLog
(
pSyncNode
,
logBuf
);
}
while
(
0
);
return
SYNC_TERM_INVALID
;
return
SYNC_TERM_INVALID
;
}
}
...
...
source/libs/sync/src/syncRaftCfg.c
浏览文件 @
291aab04
...
@@ -107,26 +107,30 @@ char *syncCfg2Str(SSyncCfg *pSyncCfg) {
...
@@ -107,26 +107,30 @@ char *syncCfg2Str(SSyncCfg *pSyncCfg) {
}
}
char
*
syncCfg2SimpleStr
(
SSyncCfg
*
pSyncCfg
)
{
char
*
syncCfg2SimpleStr
(
SSyncCfg
*
pSyncCfg
)
{
int32_t
len
=
512
;
if
(
pSyncCfg
!=
NULL
)
{
char
*
s
=
taosMemoryMalloc
(
len
);
int32_t
len
=
512
;
memset
(
s
,
0
,
len
);
char
*
s
=
taosMemoryMalloc
(
len
);
memset
(
s
,
0
,
len
);
snprintf
(
s
,
len
,
"{replica-num:%d, my-index:%d, "
,
pSyncCfg
->
replicaNum
,
pSyncCfg
->
myIndex
);
char
*
p
=
s
+
strlen
(
s
);
snprintf
(
s
,
len
,
"{replica-num:%d, my-index:%d, "
,
pSyncCfg
->
replicaNum
,
pSyncCfg
->
myIndex
);
for
(
int
i
=
0
;
i
<
pSyncCfg
->
replicaNum
;
++
i
)
{
char
*
p
=
s
+
strlen
(
s
);
/*
for
(
int
i
=
0
;
i
<
pSyncCfg
->
replicaNum
;
++
i
)
{
if (p + 128 + 32 > s + len) {
/*
break;
if (p + 128 + 32 > s + len) {
break;
}
*/
char
buf
[
128
+
32
];
snprintf
(
buf
,
sizeof
(
buf
),
"%s:%d, "
,
pSyncCfg
->
nodeInfo
[
i
].
nodeFqdn
,
pSyncCfg
->
nodeInfo
[
i
].
nodePort
);
strncpy
(
p
,
buf
,
sizeof
(
buf
));
p
=
s
+
strlen
(
s
);
}
}
*/
strcpy
(
p
-
2
,
"}"
);
char
buf
[
128
+
32
];
snprintf
(
buf
,
sizeof
(
buf
),
"%s:%d, "
,
pSyncCfg
->
nodeInfo
[
i
].
nodeFqdn
,
pSyncCfg
->
nodeInfo
[
i
].
nodePort
);
return
s
;
strncpy
(
p
,
buf
,
sizeof
(
buf
));
p
=
s
+
strlen
(
s
);
}
}
strcpy
(
p
-
2
,
"}"
);
return
s
;
return
NULL
;
}
}
int32_t
syncCfgFromJson
(
const
cJSON
*
pRoot
,
SSyncCfg
*
pSyncCfg
)
{
int32_t
syncCfgFromJson
(
const
cJSON
*
pRoot
,
SSyncCfg
*
pSyncCfg
)
{
...
...
source/libs/sync/src/syncRaftLog.c
浏览文件 @
291aab04
此差异已折叠。
点击以展开。
source/libs/sync/src/syncReplication.c
浏览文件 @
291aab04
...
@@ -219,6 +219,17 @@ int32_t syncNodeReplicate(SSyncNode* pSyncNode) {
...
@@ -219,6 +219,17 @@ int32_t syncNodeReplicate(SSyncNode* pSyncNode) {
int32_t
syncNodeAppendEntries
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
destRaftId
,
const
SyncAppendEntries
*
pMsg
)
{
int32_t
syncNodeAppendEntries
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
destRaftId
,
const
SyncAppendEntries
*
pMsg
)
{
int32_t
ret
=
0
;
int32_t
ret
=
0
;
do
{
char
host
[
128
];
uint16_t
port
;
syncUtilU642Addr
(
destRaftId
->
addr
,
host
,
sizeof
(
host
),
&
port
);
sDebug
(
"vgId:%d, send sync-append-entries to %s:%d, term:%lu, pre-index:%ld, pre-term:%lu, pterm:%lu, commit:%ld, "
"datalen:%d"
,
pSyncNode
->
vgId
,
host
,
port
,
pMsg
->
term
,
pMsg
->
prevLogIndex
,
pMsg
->
prevLogTerm
,
pMsg
->
privateTerm
,
pMsg
->
commitIndex
,
pMsg
->
dataLen
);
}
while
(
0
);
SRpcMsg
rpcMsg
;
SRpcMsg
rpcMsg
;
syncAppendEntries2RpcMsg
(
pMsg
,
&
rpcMsg
);
syncAppendEntries2RpcMsg
(
pMsg
,
&
rpcMsg
);
syncNodeSendMsgById
(
destRaftId
,
pSyncNode
,
&
rpcMsg
);
syncNodeSendMsgById
(
destRaftId
,
pSyncNode
,
&
rpcMsg
);
...
...
source/libs/sync/src/syncSnapshot.c
浏览文件 @
291aab04
...
@@ -545,7 +545,8 @@ int32_t syncNodeOnSnapshotSendCb(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) {
...
@@ -545,7 +545,8 @@ int32_t syncNodeOnSnapshotSendCb(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) {
pReceiver
->
pSyncNode
->
commitIndex
=
pReceiver
->
snapshot
.
lastApplyIndex
;
pReceiver
->
pSyncNode
->
commitIndex
=
pReceiver
->
snapshot
.
lastApplyIndex
;
}
}
pSyncNode
->
pLogStore
->
syncLogSetBeginIndex
(
pSyncNode
->
pLogStore
,
pMsg
->
lastIndex
+
1
);
// pSyncNode->pLogStore->syncLogSetBeginIndex(pSyncNode->pLogStore, pMsg->lastIndex + 1);
pSyncNode
->
pLogStore
->
syncLogRestoreFromSnapshot
(
pSyncNode
->
pLogStore
,
pMsg
->
lastIndex
);
// maybe update lastconfig
// maybe update lastconfig
if
(
pMsg
->
lastConfigIndex
>=
SYNC_INDEX_BEGIN
)
{
if
(
pMsg
->
lastConfigIndex
>=
SYNC_INDEX_BEGIN
)
{
...
...
source/libs/sync/test/syncRaftLogTest2.cpp
浏览文件 @
291aab04
...
@@ -113,7 +113,8 @@ void test2() {
...
@@ -113,7 +113,8 @@ void test2() {
pLogStore
=
logStoreCreate
(
pSyncNode
);
pLogStore
=
logStoreCreate
(
pSyncNode
);
assert
(
pLogStore
);
assert
(
pLogStore
);
pSyncNode
->
pLogStore
=
pLogStore
;
pSyncNode
->
pLogStore
=
pLogStore
;
pLogStore
->
syncLogSetBeginIndex
(
pLogStore
,
5
);
//pLogStore->syncLogSetBeginIndex(pLogStore, 5);
pLogStore
->
syncLogRestoreFromSnapshot
(
pLogStore
,
4
);
logStoreLog2
((
char
*
)
"
\n\n\n
test2 ----- "
,
pLogStore
);
logStoreLog2
((
char
*
)
"
\n\n\n
test2 ----- "
,
pLogStore
);
if
(
gAssert
)
{
if
(
gAssert
)
{
...
@@ -228,7 +229,8 @@ void test4() {
...
@@ -228,7 +229,8 @@ void test4() {
assert
(
pLogStore
);
assert
(
pLogStore
);
pSyncNode
->
pLogStore
=
pLogStore
;
pSyncNode
->
pLogStore
=
pLogStore
;
logStoreLog2
((
char
*
)
"
\n\n\n
test4 ----- "
,
pLogStore
);
logStoreLog2
((
char
*
)
"
\n\n\n
test4 ----- "
,
pLogStore
);
pLogStore
->
syncLogSetBeginIndex
(
pLogStore
,
5
);
//pLogStore->syncLogSetBeginIndex(pLogStore, 5);
pLogStore
->
syncLogRestoreFromSnapshot
(
pLogStore
,
4
);
for
(
int
i
=
5
;
i
<=
9
;
++
i
)
{
for
(
int
i
=
5
;
i
<=
9
;
++
i
)
{
int32_t
dataLen
=
10
;
int32_t
dataLen
=
10
;
...
@@ -289,7 +291,8 @@ void test5() {
...
@@ -289,7 +291,8 @@ void test5() {
assert
(
pLogStore
);
assert
(
pLogStore
);
pSyncNode
->
pLogStore
=
pLogStore
;
pSyncNode
->
pLogStore
=
pLogStore
;
logStoreLog2
((
char
*
)
"
\n\n\n
test5 ----- "
,
pLogStore
);
logStoreLog2
((
char
*
)
"
\n\n\n
test5 ----- "
,
pLogStore
);
pLogStore
->
syncLogSetBeginIndex
(
pLogStore
,
5
);
//pLogStore->syncLogSetBeginIndex(pLogStore, 5);
pLogStore
->
syncLogRestoreFromSnapshot
(
pLogStore
,
4
);
for
(
int
i
=
5
;
i
<=
9
;
++
i
)
{
for
(
int
i
=
5
;
i
<=
9
;
++
i
)
{
int32_t
dataLen
=
10
;
int32_t
dataLen
=
10
;
...
@@ -363,7 +366,8 @@ void test6() {
...
@@ -363,7 +366,8 @@ void test6() {
assert
(
pLogStore
);
assert
(
pLogStore
);
pSyncNode
->
pLogStore
=
pLogStore
;
pSyncNode
->
pLogStore
=
pLogStore
;
logStoreLog2
((
char
*
)
"
\n\n\n
test6 ----- "
,
pLogStore
);
logStoreLog2
((
char
*
)
"
\n\n\n
test6 ----- "
,
pLogStore
);
pLogStore
->
syncLogSetBeginIndex
(
pLogStore
,
5
);
// pLogStore->syncLogSetBeginIndex(pLogStore, 5);
pLogStore
->
syncLogRestoreFromSnapshot
(
pLogStore
,
4
);
for
(
int
i
=
5
;
i
<=
9
;
++
i
)
{
for
(
int
i
=
5
;
i
<=
9
;
++
i
)
{
int32_t
dataLen
=
10
;
int32_t
dataLen
=
10
;
...
@@ -405,14 +409,32 @@ void test6() {
...
@@ -405,14 +409,32 @@ void test6() {
assert
(
pLogStore
->
syncLogLastTerm
(
pLogStore
)
==
0
);
assert
(
pLogStore
->
syncLogLastTerm
(
pLogStore
)
==
0
);
}
}
do
{
SyncIndex
firstVer
=
walGetFirstVer
(
pWal
);
SyncIndex
lastVer
=
walGetLastVer
(
pWal
);
bool
isEmpty
=
walIsEmpty
(
pWal
);
printf
(
"before -------- firstVer:%ld lastVer:%ld isEmpty:%d
\n
"
,
firstVer
,
lastVer
,
isEmpty
);
}
while
(
0
);
logStoreDestory
(
pLogStore
);
logStoreDestory
(
pLogStore
);
cleanup
();
cleanup
();
// restart
// restart
init
();
init
();
pLogStore
=
logStoreCreate
(
pSyncNode
);
pLogStore
=
logStoreCreate
(
pSyncNode
);
assert
(
pLogStore
);
assert
(
pLogStore
);
pSyncNode
->
pLogStore
=
pLogStore
;
pSyncNode
->
pLogStore
=
pLogStore
;
do
{
SyncIndex
firstVer
=
walGetFirstVer
(
pWal
);
SyncIndex
lastVer
=
walGetLastVer
(
pWal
);
bool
isEmpty
=
walIsEmpty
(
pWal
);
printf
(
"after -------- firstVer:%ld lastVer:%ld isEmpty:%d
\n
"
,
firstVer
,
lastVer
,
isEmpty
);
}
while
(
0
);
logStoreLog2
((
char
*
)
"
\n\n\n
test6 restart ----- "
,
pLogStore
);
logStoreLog2
((
char
*
)
"
\n\n\n
test6 restart ----- "
,
pLogStore
);
if
(
gAssert
)
{
if
(
gAssert
)
{
...
@@ -432,17 +454,20 @@ void test6() {
...
@@ -432,17 +454,20 @@ void test6() {
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
tsAsyncLog
=
0
;
tsAsyncLog
=
0
;
sDebugFlag
=
DEBUG_TRACE
+
DEBUG_INFO
+
DEBUG_SCREEN
+
DEBUG_FILE
;
sDebugFlag
=
DEBUG_TRACE
+
DEBUG_INFO
+
DEBUG_SCREEN
+
DEBUG_FILE
;
gRaftDetailLog
=
true
;
if
(
argc
==
2
)
{
if
(
argc
==
2
)
{
gAssert
=
atoi
(
argv
[
1
]);
gAssert
=
atoi
(
argv
[
1
]);
}
}
sTrace
(
"gAssert : %d"
,
gAssert
);
sTrace
(
"gAssert : %d"
,
gAssert
);
/*
test1();
test1();
test2();
test2();
test3();
test3();
test4();
test4();
test5();
test5();
*/
test6
();
test6
();
return
0
;
return
0
;
...
...
source/libs/sync/test/syncRaftLogTest3.cpp
浏览文件 @
291aab04
...
@@ -312,7 +312,8 @@ void test5() {
...
@@ -312,7 +312,8 @@ void test5() {
pSyncNode
->
pLogStore
=
pLogStore
;
pSyncNode
->
pLogStore
=
pLogStore
;
logStoreLog2
((
char
*
)
"
\n\n\n
test5 ----- "
,
pLogStore
);
logStoreLog2
((
char
*
)
"
\n\n\n
test5 ----- "
,
pLogStore
);
pSyncNode
->
pLogStore
->
syncLogSetBeginIndex
(
pSyncNode
->
pLogStore
,
6
);
//pSyncNode->pLogStore->syncLogSetBeginIndex(pSyncNode->pLogStore, 6);
pLogStore
->
syncLogRestoreFromSnapshot
(
pSyncNode
->
pLogStore
,
5
);
for
(
int
i
=
6
;
i
<=
10
;
++
i
)
{
for
(
int
i
=
6
;
i
<=
10
;
++
i
)
{
int32_t
dataLen
=
10
;
int32_t
dataLen
=
10
;
SSyncRaftEntry
*
pEntry
=
syncEntryBuild
(
dataLen
);
SSyncRaftEntry
*
pEntry
=
syncEntryBuild
(
dataLen
);
...
@@ -372,6 +373,7 @@ void test5() {
...
@@ -372,6 +373,7 @@ void test5() {
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
tsAsyncLog
=
0
;
tsAsyncLog
=
0
;
sDebugFlag
=
DEBUG_TRACE
+
DEBUG_INFO
+
DEBUG_SCREEN
+
DEBUG_FILE
;
sDebugFlag
=
DEBUG_TRACE
+
DEBUG_INFO
+
DEBUG_SCREEN
+
DEBUG_FILE
;
gRaftDetailLog
=
true
;
if
(
argc
==
2
)
{
if
(
argc
==
2
)
{
gAssert
=
atoi
(
argv
[
1
]);
gAssert
=
atoi
(
argv
[
1
]);
...
...
source/libs/wal/src/walRead.c
浏览文件 @
291aab04
...
@@ -272,14 +272,23 @@ int32_t walReadWithHandle(SWalReadHandle *pRead, int64_t ver) {
...
@@ -272,14 +272,23 @@ int32_t walReadWithHandle(SWalReadHandle *pRead, int64_t ver) {
}
}
}
}
if
(
ver
>
pRead
->
pWal
->
vers
.
lastVer
||
ver
<
pRead
->
pWal
->
vers
.
firstVer
)
{
wError
(
"invalid version: % "
PRId64
", first ver %ld, last ver %ld"
,
ver
,
pRead
->
pWal
->
vers
.
firstVer
,
pRead
->
pWal
->
vers
.
lastVer
);
terrno
=
TSDB_CODE_WAL_LOG_NOT_EXIST
;
return
-
1
;
}
ASSERT
(
taosValidFile
(
pRead
->
pReadLogTFile
)
==
true
);
ASSERT
(
taosValidFile
(
pRead
->
pReadLogTFile
)
==
true
);
code
=
taosReadFile
(
pRead
->
pReadLogTFile
,
pRead
->
pHead
,
sizeof
(
SWalHead
));
code
=
taosReadFile
(
pRead
->
pReadLogTFile
,
pRead
->
pHead
,
sizeof
(
SWalHead
));
if
(
code
!=
sizeof
(
SWalHead
))
{
if
(
code
!=
sizeof
(
SWalHead
))
{
if
(
code
<
0
)
if
(
code
<
0
)
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
else
else
{
terrno
=
TSDB_CODE_WAL_FILE_CORRUPTED
;
terrno
=
TSDB_CODE_WAL_FILE_CORRUPTED
;
ASSERT
(
0
);
}
return
-
1
;
return
-
1
;
}
}
...
@@ -304,8 +313,10 @@ int32_t walReadWithHandle(SWalReadHandle *pRead, int64_t ver) {
...
@@ -304,8 +313,10 @@ int32_t walReadWithHandle(SWalReadHandle *pRead, int64_t ver) {
pRead
->
pHead
->
head
.
bodyLen
)
{
pRead
->
pHead
->
head
.
bodyLen
)
{
if
(
code
<
0
)
if
(
code
<
0
)
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
else
else
{
terrno
=
TSDB_CODE_WAL_FILE_CORRUPTED
;
terrno
=
TSDB_CODE_WAL_FILE_CORRUPTED
;
ASSERT
(
0
);
}
return
-
1
;
return
-
1
;
}
}
...
...
source/libs/wal/src/walWrite.c
浏览文件 @
291aab04
此差异已折叠。
点击以展开。
tests/pytest/util/cluster.py
浏览文件 @
291aab04
此差异已折叠。
点击以展开。
tests/script/tmp/monitor.sim
浏览文件 @
291aab04
此差异已折叠。
点击以展开。
tests/system-test/6-cluster/5dnode3mnodeStop.py
浏览文件 @
291aab04
此差异已折叠。
点击以展开。
tests/system-test/fulltest.sh
浏览文件 @
291aab04
此差异已折叠。
点击以展开。
tests/system-test/test.py
浏览文件 @
291aab04
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录