Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
306de052
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
306de052
编写于
5月 08, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' of
https://github.com/taosdata/TDengine
into feature/vnode_refact1
上级
16897f17
ff5d97c8
变更
57
展开全部
隐藏空白更改
内联
并排
Showing
57 changed file
with
6346 addition
and
3355 deletion
+6346
-3355
cmake/cmake.define
cmake/cmake.define
+19
-0
example/src/tmq.c
example/src/tmq.c
+2
-2
include/common/tdatablock.h
include/common/tdatablock.h
+7
-7
include/common/tmsg.h
include/common/tmsg.h
+2
-0
include/common/ttokendef.h
include/common/ttokendef.h
+202
-195
include/libs/function/tudf.h
include/libs/function/tudf.h
+51
-7
include/libs/nodes/cmdnodes.h
include/libs/nodes/cmdnodes.h
+23
-0
include/libs/nodes/nodes.h
include/libs/nodes/nodes.h
+4
-0
include/libs/planner/planner.h
include/libs/planner/planner.h
+14
-16
include/libs/stream/tstream.h
include/libs/stream/tstream.h
+11
-6
include/util/taoserror.h
include/util/taoserror.h
+1
-0
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+17
-14
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+72
-15
source/common/src/tmsg.c
source/common/src/tmsg.c
+1
-2
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
+1
-0
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
+2
-0
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
+2
-1
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
+8
-0
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+1
-0
source/dnode/mnode/impl/src/mndDef.c
source/dnode/mnode/impl/src/mndDef.c
+7
-1
source/dnode/mnode/impl/src/mndScheduler.c
source/dnode/mnode/impl/src/mndScheduler.c
+4
-1
source/dnode/mnode/impl/src/mndStream.c
source/dnode/mnode/impl/src/mndStream.c
+3
-0
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+2
-2
source/dnode/mnode/impl/src/mndUser.c
source/dnode/mnode/impl/src/mndUser.c
+1
-1
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+40
-16
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+100
-93
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+52
-52
source/libs/function/src/tudf.c
source/libs/function/src/tudf.c
+64
-50
source/libs/function/test/udf1.c
source/libs/function/test/udf1.c
+11
-4
source/libs/function/test/udf2.c
source/libs/function/test/udf2.c
+18
-8
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+9
-1
source/libs/parser/inc/parAst.h
source/libs/parser/inc/parAst.h
+3
-1
source/libs/parser/inc/parInt.h
source/libs/parser/inc/parInt.h
+1
-0
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+27
-1
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+33
-5
source/libs/parser/src/parAuthenticator.c
source/libs/parser/src/parAuthenticator.c
+159
-0
source/libs/parser/src/parTokenizer.c
source/libs/parser/src/parTokenizer.c
+9
-1
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+63
-3
source/libs/parser/src/parser.c
source/libs/parser/src/parser.c
+3
-0
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+2875
-2771
source/libs/parser/test/mockCatalog.cpp
source/libs/parser/test/mockCatalog.cpp
+7
-0
source/libs/parser/test/parExplainToSyncdbTest.cpp
source/libs/parser/test/parExplainToSyncdbTest.cpp
+22
-3
source/libs/parser/test/parInitialATest.cpp
source/libs/parser/test/parInitialATest.cpp
+55
-10
source/libs/parser/test/parShowToUse.cpp
source/libs/parser/test/parShowToUse.cpp
+38
-32
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+4
-6
source/libs/planner/test/planSTableTest.cpp
source/libs/planner/test/planSTableTest.cpp
+9
-3
source/libs/scalar/src/sclfunc.c
source/libs/scalar/src/sclfunc.c
+2
-2
source/libs/stream/src/tstream.c
source/libs/stream/src/tstream.c
+6
-6
source/libs/transport/src/transSrv.c
source/libs/transport/src/transSrv.c
+2
-1
source/os/src/osSocket.c
source/os/src/osSocket.c
+6
-1
source/util/src/terror.c
source/util/src/terror.c
+1
-0
source/util/test/encodeTest.cpp
source/util/test/encodeTest.cpp
+4
-0
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+4
-0
tests/script/tsim/query/udf.sim
tests/script/tsim/query/udf.sim
+44
-3
tests/script/tsim/tstream/basic0.sim
tests/script/tsim/tstream/basic0.sim
+71
-0
tests/script/tsim/user/pass_alter.sim
tests/script/tsim/user/pass_alter.sim
+12
-12
tests/system-test/2-query/query_cols_tags_and_or.py
tests/system-test/2-query/query_cols_tags_and_or.py
+2135
-0
未找到文件。
cmake/cmake.define
浏览文件 @
306de052
...
...
@@ -14,6 +14,25 @@ MESSAGE(STATUS "Project binary files output path: " ${PROJECT_BINARY_DIR})
MESSAGE(STATUS "Project executable files output path: " ${EXECUTABLE_OUTPUT_PATH})
MESSAGE(STATUS "Project library files output path: " ${LIBRARY_OUTPUT_PATH})
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
# Update submodules as needed
option(GIT_SUBMODULE "Check submodules during build" ON)
if(GIT_SUBMODULE)
message(STATUS "Submodule update")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(WARNING "git submodule update --init --recursive failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
endif()
endif()
endif()
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/tools/taos-tools/CMakeLists.txt")
message(WARNING "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules manually if you need build them.")
endif()
if (NOT DEFINED TD_GRANT)
SET(TD_GRANT FALSE)
endif()
...
...
example/src/tmq.c
浏览文件 @
306de052
...
...
@@ -101,8 +101,8 @@ int32_t create_topic() {
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"create topic topic_ctb_column as abc1"
);
/*pRes = taos_query(pConn, "create topic topic_ctb_column as select ts, c1, c2, c3 from ct1");*/
/*pRes = taos_query(pConn, "create topic topic_ctb_column as abc1");*/
pRes
=
taos_query
(
pConn
,
"create topic topic_ctb_column as select ts, c1, c2, c3 from ct1"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create topic topic_ctb_column, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
...
...
include/common/tdatablock.h
浏览文件 @
306de052
...
...
@@ -56,11 +56,11 @@ SEpSet getEpSet_s(SCorEpSet* pEpSet);
#define colDataSetNotNull_f(bm_, r_) \
do { \
BMCharPos(bm_, r_) &= ~(1u << (7u - BitPos(r_)));
\
BMCharPos(bm_, r_) &= ~(1u << (7u - BitPos(r_))); \
} while (0)
#define colDataIsNull_var(pColumnInfoData, row) (pColumnInfoData->varmeta.offset[row] == -1)
#define colDataSetNull_var(pColumnInfoData, row)
(pColumnInfoData->varmeta.offset[row] = -1)
#define colDataIsNull_var(pColumnInfoData, row)
(pColumnInfoData->varmeta.offset[row] == -1)
#define colDataSetNull_var(pColumnInfoData, row) (pColumnInfoData->varmeta.offset[row] = -1)
#define BitmapLen(_n) (((_n) + ((1 << NBIT) - 1)) >> NBIT)
...
...
@@ -187,8 +187,8 @@ static FORCE_INLINE void colDataAppendDouble(SColumnInfoData* pColumnInfoData, u
}
int32_t
colDataAppend
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
currentRow
,
const
char
*
pData
,
bool
isNull
);
int32_t
colDataMergeCol
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
numOfRow1
,
int32_t
*
capacity
,
const
SColumnInfoData
*
pSource
,
uint32_t
numOfRow2
);
int32_t
colDataMergeCol
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
numOfRow1
,
int32_t
*
capacity
,
const
SColumnInfoData
*
pSource
,
uint32_t
numOfRow2
);
int32_t
colDataAssign
(
SColumnInfoData
*
pColumnInfoData
,
const
SColumnInfoData
*
pSource
,
int32_t
numOfRows
);
int32_t
blockDataUpdateTsWindow
(
SSDataBlock
*
pDataBlock
);
...
...
@@ -230,9 +230,9 @@ SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock, bool copyData);
void
blockDebugShowData
(
const
SArray
*
dataBlocks
);
int32_t
buildSubmitReqFromDataBlock
(
SSubmitReq
**
pReq
,
const
SArray
*
pDataBlocks
,
STSchema
*
pTSchema
,
int32_t
vgId
,
tb_uid_t
uid
,
tb_uid_t
suid
);
tb_uid_t
uid
,
tb_uid_t
suid
);
SSubmitReq
*
tdBlockToSubmit
(
const
SArray
*
pBlocks
,
const
STSchema
*
pSchema
);
SSubmitReq
*
tdBlockToSubmit
(
const
SArray
*
pBlocks
,
const
STSchema
*
pSchema
,
bool
createTb
,
int64_t
suid
,
int32_t
vgId
);
static
FORCE_INLINE
int32_t
blockGetEncodeSize
(
const
SSDataBlock
*
pBlock
)
{
return
blockDataGetSerialMetaSize
(
pBlock
)
+
blockDataGetSize
(
pBlock
);
...
...
include/common/tmsg.h
浏览文件 @
306de052
...
...
@@ -135,6 +135,8 @@ typedef enum _mgmt_table {
#define TSDB_ALTER_USER_ADD_WRITE_DB 0x6
#define TSDB_ALTER_USER_REMOVE_WRITE_DB 0x7
#define TSDB_ALTER_USER_CLEAR_WRITE_DB 0x8
#define TSDB_ALTER_USER_ADD_ALL_DB 0x9
#define TSDB_ALTER_USER_REMOVE_ALL_DB 0xA
#define TSDB_ALTER_USER_PRIVILEGES 0x2
...
...
include/common/ttokendef.h
浏览文件 @
306de052
...
...
@@ -51,201 +51,208 @@
#define TK_USER 33
#define TK_PRIVILEGE 34
#define TK_DROP 35
#define TK_DNODE 36
#define TK_PORT 37
#define TK_NK_INTEGER 38
#define TK_DNODES 39
#define TK_NK_IPTOKEN 40
#define TK_LOCAL 41
#define TK_QNODE 42
#define TK_ON 43
#define TK_BNODE 44
#define TK_SNODE 45
#define TK_MNODE 46
#define TK_DATABASE 47
#define TK_USE 48
#define TK_IF 49
#define TK_NOT 50
#define TK_EXISTS 51
#define TK_BUFFER 52
#define TK_CACHELAST 53
#define TK_COMP 54
#define TK_DAYS 55
#define TK_NK_VARIABLE 56
#define TK_FSYNC 57
#define TK_MAXROWS 58
#define TK_MINROWS 59
#define TK_KEEP 60
#define TK_PAGES 61
#define TK_PAGESIZE 62
#define TK_PRECISION 63
#define TK_REPLICA 64
#define TK_STRICT 65
#define TK_WAL 66
#define TK_VGROUPS 67
#define TK_SINGLE_STABLE 68
#define TK_RETENTIONS 69
#define TK_NK_COMMA 70
#define TK_NK_COLON 71
#define TK_TABLE 72
#define TK_NK_LP 73
#define TK_NK_RP 74
#define TK_STABLE 75
#define TK_ADD 76
#define TK_COLUMN 77
#define TK_MODIFY 78
#define TK_RENAME 79
#define TK_TAG 80
#define TK_SET 81
#define TK_NK_EQ 82
#define TK_USING 83
#define TK_TAGS 84
#define TK_NK_DOT 85
#define TK_COMMENT 86
#define TK_BOOL 87
#define TK_TINYINT 88
#define TK_SMALLINT 89
#define TK_INT 90
#define TK_INTEGER 91
#define TK_BIGINT 92
#define TK_FLOAT 93
#define TK_DOUBLE 94
#define TK_BINARY 95
#define TK_TIMESTAMP 96
#define TK_NCHAR 97
#define TK_UNSIGNED 98
#define TK_JSON 99
#define TK_VARCHAR 100
#define TK_MEDIUMBLOB 101
#define TK_BLOB 102
#define TK_VARBINARY 103
#define TK_DECIMAL 104
#define TK_DELAY 105
#define TK_FILE_FACTOR 106
#define TK_NK_FLOAT 107
#define TK_ROLLUP 108
#define TK_TTL 109
#define TK_SMA 110
#define TK_SHOW 111
#define TK_DATABASES 112
#define TK_TABLES 113
#define TK_STABLES 114
#define TK_MNODES 115
#define TK_MODULES 116
#define TK_QNODES 117
#define TK_FUNCTIONS 118
#define TK_INDEXES 119
#define TK_FROM 120
#define TK_ACCOUNTS 121
#define TK_APPS 122
#define TK_CONNECTIONS 123
#define TK_LICENCE 124
#define TK_GRANTS 125
#define TK_QUERIES 126
#define TK_SCORES 127
#define TK_TOPICS 128
#define TK_VARIABLES 129
#define TK_BNODES 130
#define TK_SNODES 131
#define TK_CLUSTER 132
#define TK_LIKE 133
#define TK_INDEX 134
#define TK_FULLTEXT 135
#define TK_FUNCTION 136
#define TK_INTERVAL 137
#define TK_TOPIC 138
#define TK_AS 139
#define TK_WITH 140
#define TK_SCHEMA 141
#define TK_DESC 142
#define TK_DESCRIBE 143
#define TK_RESET 144
#define TK_QUERY 145
#define TK_CACHE 146
#define TK_EXPLAIN 147
#define TK_ANALYZE 148
#define TK_VERBOSE 149
#define TK_NK_BOOL 150
#define TK_RATIO 151
#define TK_COMPACT 152
#define TK_VNODES 153
#define TK_IN 154
#define TK_OUTPUTTYPE 155
#define TK_AGGREGATE 156
#define TK_BUFSIZE 157
#define TK_STREAM 158
#define TK_INTO 159
#define TK_TRIGGER 160
#define TK_AT_ONCE 161
#define TK_WINDOW_CLOSE 162
#define TK_WATERMARK 163
#define TK_KILL 164
#define TK_CONNECTION 165
#define TK_MERGE 166
#define TK_VGROUP 167
#define TK_REDISTRIBUTE 168
#define TK_SPLIT 169
#define TK_SYNCDB 170
#define TK_NULL 171
#define TK_NK_QUESTION 172
#define TK_NK_ARROW 173
#define TK_ROWTS 174
#define TK_TBNAME 175
#define TK_QSTARTTS 176
#define TK_QENDTS 177
#define TK_WSTARTTS 178
#define TK_WENDTS 179
#define TK_WDURATION 180
#define TK_CAST 181
#define TK_NOW 182
#define TK_TODAY 183
#define TK_TIMEZONE 184
#define TK_COUNT 185
#define TK_FIRST 186
#define TK_LAST 187
#define TK_LAST_ROW 188
#define TK_BETWEEN 189
#define TK_IS 190
#define TK_NK_LT 191
#define TK_NK_GT 192
#define TK_NK_LE 193
#define TK_NK_GE 194
#define TK_NK_NE 195
#define TK_MATCH 196
#define TK_NMATCH 197
#define TK_CONTAINS 198
#define TK_JOIN 199
#define TK_INNER 200
#define TK_SELECT 201
#define TK_DISTINCT 202
#define TK_WHERE 203
#define TK_PARTITION 204
#define TK_BY 205
#define TK_SESSION 206
#define TK_STATE_WINDOW 207
#define TK_SLIDING 208
#define TK_FILL 209
#define TK_VALUE 210
#define TK_NONE 211
#define TK_PREV 212
#define TK_LINEAR 213
#define TK_NEXT 214
#define TK_GROUP 215
#define TK_HAVING 216
#define TK_ORDER 217
#define TK_SLIMIT 218
#define TK_SOFFSET 219
#define TK_LIMIT 220
#define TK_OFFSET 221
#define TK_ASC 222
#define TK_NULLS 223
#define TK_ID 224
#define TK_NK_BITNOT 225
#define TK_INSERT 226
#define TK_VALUES 227
#define TK_IMPORT 228
#define TK_NK_SEMI 229
#define TK_FILE 230
#define TK_GRANT 36
#define TK_ON 37
#define TK_TO 38
#define TK_REVOKE 39
#define TK_FROM 40
#define TK_NK_COMMA 41
#define TK_READ 42
#define TK_WRITE 43
#define TK_NK_DOT 44
#define TK_DNODE 45
#define TK_PORT 46
#define TK_NK_INTEGER 47
#define TK_DNODES 48
#define TK_NK_IPTOKEN 49
#define TK_LOCAL 50
#define TK_QNODE 51
#define TK_BNODE 52
#define TK_SNODE 53
#define TK_MNODE 54
#define TK_DATABASE 55
#define TK_USE 56
#define TK_IF 57
#define TK_NOT 58
#define TK_EXISTS 59
#define TK_BUFFER 60
#define TK_CACHELAST 61
#define TK_COMP 62
#define TK_DAYS 63
#define TK_NK_VARIABLE 64
#define TK_FSYNC 65
#define TK_MAXROWS 66
#define TK_MINROWS 67
#define TK_KEEP 68
#define TK_PAGES 69
#define TK_PAGESIZE 70
#define TK_PRECISION 71
#define TK_REPLICA 72
#define TK_STRICT 73
#define TK_WAL 74
#define TK_VGROUPS 75
#define TK_SINGLE_STABLE 76
#define TK_RETENTIONS 77
#define TK_NK_COLON 78
#define TK_TABLE 79
#define TK_NK_LP 80
#define TK_NK_RP 81
#define TK_STABLE 82
#define TK_ADD 83
#define TK_COLUMN 84
#define TK_MODIFY 85
#define TK_RENAME 86
#define TK_TAG 87
#define TK_SET 88
#define TK_NK_EQ 89
#define TK_USING 90
#define TK_TAGS 91
#define TK_COMMENT 92
#define TK_BOOL 93
#define TK_TINYINT 94
#define TK_SMALLINT 95
#define TK_INT 96
#define TK_INTEGER 97
#define TK_BIGINT 98
#define TK_FLOAT 99
#define TK_DOUBLE 100
#define TK_BINARY 101
#define TK_TIMESTAMP 102
#define TK_NCHAR 103
#define TK_UNSIGNED 104
#define TK_JSON 105
#define TK_VARCHAR 106
#define TK_MEDIUMBLOB 107
#define TK_BLOB 108
#define TK_VARBINARY 109
#define TK_DECIMAL 110
#define TK_DELAY 111
#define TK_FILE_FACTOR 112
#define TK_NK_FLOAT 113
#define TK_ROLLUP 114
#define TK_TTL 115
#define TK_SMA 116
#define TK_SHOW 117
#define TK_DATABASES 118
#define TK_TABLES 119
#define TK_STABLES 120
#define TK_MNODES 121
#define TK_MODULES 122
#define TK_QNODES 123
#define TK_FUNCTIONS 124
#define TK_INDEXES 125
#define TK_ACCOUNTS 126
#define TK_APPS 127
#define TK_CONNECTIONS 128
#define TK_LICENCE 129
#define TK_GRANTS 130
#define TK_QUERIES 131
#define TK_SCORES 132
#define TK_TOPICS 133
#define TK_VARIABLES 134
#define TK_BNODES 135
#define TK_SNODES 136
#define TK_CLUSTER 137
#define TK_TRANSACTIONS 138
#define TK_LIKE 139
#define TK_INDEX 140
#define TK_FULLTEXT 141
#define TK_FUNCTION 142
#define TK_INTERVAL 143
#define TK_TOPIC 144
#define TK_AS 145
#define TK_WITH 146
#define TK_SCHEMA 147
#define TK_DESC 148
#define TK_DESCRIBE 149
#define TK_RESET 150
#define TK_QUERY 151
#define TK_CACHE 152
#define TK_EXPLAIN 153
#define TK_ANALYZE 154
#define TK_VERBOSE 155
#define TK_NK_BOOL 156
#define TK_RATIO 157
#define TK_COMPACT 158
#define TK_VNODES 159
#define TK_IN 160
#define TK_OUTPUTTYPE 161
#define TK_AGGREGATE 162
#define TK_BUFSIZE 163
#define TK_STREAM 164
#define TK_INTO 165
#define TK_TRIGGER 166
#define TK_AT_ONCE 167
#define TK_WINDOW_CLOSE 168
#define TK_WATERMARK 169
#define TK_KILL 170
#define TK_CONNECTION 171
#define TK_TRANSACTION 172
#define TK_MERGE 173
#define TK_VGROUP 174
#define TK_REDISTRIBUTE 175
#define TK_SPLIT 176
#define TK_SYNCDB 177
#define TK_NULL 178
#define TK_NK_QUESTION 179
#define TK_NK_ARROW 180
#define TK_ROWTS 181
#define TK_TBNAME 182
#define TK_QSTARTTS 183
#define TK_QENDTS 184
#define TK_WSTARTTS 185
#define TK_WENDTS 186
#define TK_WDURATION 187
#define TK_CAST 188
#define TK_NOW 189
#define TK_TODAY 190
#define TK_TIMEZONE 191
#define TK_COUNT 192
#define TK_FIRST 193
#define TK_LAST 194
#define TK_LAST_ROW 195
#define TK_BETWEEN 196
#define TK_IS 197
#define TK_NK_LT 198
#define TK_NK_GT 199
#define TK_NK_LE 200
#define TK_NK_GE 201
#define TK_NK_NE 202
#define TK_MATCH 203
#define TK_NMATCH 204
#define TK_CONTAINS 205
#define TK_JOIN 206
#define TK_INNER 207
#define TK_SELECT 208
#define TK_DISTINCT 209
#define TK_WHERE 210
#define TK_PARTITION 211
#define TK_BY 212
#define TK_SESSION 213
#define TK_STATE_WINDOW 214
#define TK_SLIDING 215
#define TK_FILL 216
#define TK_VALUE 217
#define TK_NONE 218
#define TK_PREV 219
#define TK_LINEAR 220
#define TK_NEXT 221
#define TK_GROUP 222
#define TK_HAVING 223
#define TK_ORDER 224
#define TK_SLIMIT 225
#define TK_SOFFSET 226
#define TK_LIMIT 227
#define TK_OFFSET 228
#define TK_ASC 229
#define TK_NULLS 230
#define TK_ID 231
#define TK_NK_BITNOT 232
#define TK_INSERT 233
#define TK_VALUES 234
#define TK_IMPORT 235
#define TK_NK_SEMI 236
#define TK_FILE 237
#define TK_NK_SPACE 300
#define TK_NK_COMMENT 301
...
...
include/libs/function/tudf.h
浏览文件 @
306de052
...
...
@@ -44,7 +44,8 @@ enum {
UDFC_CODE_PIPE_READ_ERR
=
-
2
,
UDFC_CODE_CONNECT_PIPE_ERR
=
-
3
,
UDFC_CODE_LOAD_UDF_FAILURE
=
-
4
,
UDFC_CODE_INVALID_STATE
=
-
5
UDFC_CODE_INVALID_STATE
=
-
5
,
UDFC_CODE_NO_PIPE
=
-
6
,
};
typedef
void
*
UdfcFuncHandle
;
...
...
@@ -140,6 +141,44 @@ typedef int32_t (*TUdfDestroyFunc)();
#define UDF_MEMORY_EXP_GROWTH 1.5
#define udfColDataIsNull_var(pColumn, row) ((pColumn->colData.varLenCol.varOffsets)[row] == -1)
#define udfColDataIsNull_f(pColumn, row) ((BMCharPos(pColumn->colData.fixLenCol.nullBitmap, row) & (1u << (7u - BitPos(row)))) == (1u << (7u - BitPos(row))))
#define udfColDataSetNull_f(pColumn, row) \
do { \
BMCharPos(pColumn->colData.fixLenCol.nullBitmap, row) |= (1u << (7u - BitPos(row))); \
} while (0)
#define udfColDataSetNotNull_f(pColumn, r_) \
do { \
BMCharPos(pColumn->colData.fixLenCol.nullBitmap, r_) &= ~(1u << (7u - BitPos(r_))); \
} while (0)
#define udfColDataSetNull_var(pColumn, row) ((pColumn->colData.varLenCol.varOffsets)[row] = -1)
static
FORCE_INLINE
char
*
udfColDataGetData
(
const
SUdfColumn
*
pColumn
,
int32_t
row
)
{
if
(
IS_VAR_DATA_TYPE
(
pColumn
->
colMeta
.
type
))
{
return
pColumn
->
colData
.
varLenCol
.
payload
+
pColumn
->
colData
.
varLenCol
.
varOffsets
[
row
];
}
else
{
return
pColumn
->
colData
.
fixLenCol
.
data
+
pColumn
->
colMeta
.
bytes
*
row
;
}
}
static
FORCE_INLINE
bool
udfColDataIsNull
(
const
SUdfColumn
*
pColumn
,
int32_t
row
)
{
if
(
IS_VAR_DATA_TYPE
(
pColumn
->
colMeta
.
type
))
{
if
(
pColumn
->
colMeta
.
type
==
TSDB_DATA_TYPE_JSON
)
{
if
(
udfColDataIsNull_var
(
pColumn
,
row
))
{
return
true
;
}
char
*
data
=
udfColDataGetData
(
pColumn
,
row
);
return
(
*
data
==
TSDB_DATA_TYPE_NULL
);
}
else
{
return
udfColDataIsNull_var
(
pColumn
,
row
);
}
}
else
{
return
udfColDataIsNull_f
(
pColumn
,
row
);
}
}
static
FORCE_INLINE
int32_t
udfColEnsureCapacity
(
SUdfColumn
*
pColumn
,
int32_t
newCapacity
)
{
SUdfColumnMeta
*
meta
=
&
pColumn
->
colMeta
;
SUdfColumnData
*
data
=
&
pColumn
->
colData
;
...
...
@@ -186,17 +225,22 @@ static FORCE_INLINE int32_t udfColEnsureCapacity(SUdfColumn* pColumn, int32_t ne
return
TSDB_CODE_SUCCESS
;
}
static
FORCE_INLINE
int32_t
udfColSetRow
(
SUdfColumn
*
pColumn
,
uint32_t
currentRow
,
const
char
*
pData
,
bool
isNull
)
{
static
FORCE_INLINE
void
udfColDataSetNull
(
SUdfColumn
*
pColumn
,
int32_t
row
)
{
udfColEnsureCapacity
(
pColumn
,
row
+
1
);
if
(
IS_VAR_DATA_TYPE
(
pColumn
->
colMeta
.
type
))
{
udfColDataSetNull_var
(
pColumn
,
row
);
}
else
{
udfColDataSetNull_f
(
pColumn
,
row
);
}
}
static
FORCE_INLINE
int32_t
udfColDataSet
(
SUdfColumn
*
pColumn
,
uint32_t
currentRow
,
const
char
*
pData
,
bool
isNull
)
{
SUdfColumnMeta
*
meta
=
&
pColumn
->
colMeta
;
SUdfColumnData
*
data
=
&
pColumn
->
colData
;
udfColEnsureCapacity
(
pColumn
,
currentRow
+
1
);
bool
isVarCol
=
IS_VAR_DATA_TYPE
(
meta
->
type
);
if
(
isNull
)
{
if
(
isVarCol
)
{
data
->
varLenCol
.
varOffsets
[
currentRow
]
=
-
1
;
}
else
{
colDataSetNull_f
(
data
->
fixLenCol
.
nullBitmap
,
currentRow
);
}
udfColDataSetNull
(
pColumn
,
currentRow
);
}
else
{
if
(
!
isVarCol
)
{
colDataSetNotNull_f
(
data
->
fixLenCol
.
nullBitmap
,
currentRow
);
...
...
include/libs/nodes/cmdnodes.h
浏览文件 @
306de052
...
...
@@ -310,6 +310,29 @@ typedef struct SCreateFunctionStmt {
int32_t
bufSize
;
}
SCreateFunctionStmt
;
typedef
struct
SDropFunctionStmt
{
ENodeType
type
;
char
funcName
[
TSDB_FUNC_NAME_LEN
];
bool
ignoreNotExists
;
}
SDropFunctionStmt
;
#define PRIVILEGE_TYPE_MASK(n) (1 << n)
#define PRIVILEGE_TYPE_ALL PRIVILEGE_TYPE_MASK(0)
#define PRIVILEGE_TYPE_READ PRIVILEGE_TYPE_MASK(1)
#define PRIVILEGE_TYPE_WRITE PRIVILEGE_TYPE_MASK(2)
#define PRIVILEGE_TYPE_TEST_MASK(val, mask) (((val) & (mask)) != 0)
typedef
struct
SGrantStmt
{
ENodeType
type
;
char
userName
[
TSDB_USER_LEN
];
char
dbName
[
TSDB_DB_NAME_LEN
];
int64_t
privileges
;
}
SGrantStmt
;
typedef
SGrantStmt
SRevokeStmt
;
#ifdef __cplusplus
}
#endif
...
...
include/libs/nodes/nodes.h
浏览文件 @
306de052
...
...
@@ -143,6 +143,8 @@ typedef enum ENodeType {
QUERY_NODE_REDISTRIBUTE_VGROUP_STMT
,
QUERY_NODE_SPLIT_VGROUP_STMT
,
QUERY_NODE_SYNCDB_STMT
,
QUERY_NODE_GRANT_STMT
,
QUERY_NODE_REVOKE_STMT
,
QUERY_NODE_SHOW_DNODES_STMT
,
QUERY_NODE_SHOW_MNODES_STMT
,
QUERY_NODE_SHOW_MODULES_STMT
,
...
...
@@ -174,8 +176,10 @@ typedef enum ENodeType {
QUERY_NODE_SHOW_CREATE_DATABASE_STMT
,
QUERY_NODE_SHOW_CREATE_TABLE_STMT
,
QUERY_NODE_SHOW_CREATE_STABLE_STMT
,
QUERY_NODE_SHOW_TRANSACTIONS_STMT
,
QUERY_NODE_KILL_CONNECTION_STMT
,
QUERY_NODE_KILL_QUERY_STMT
,
QUERY_NODE_KILL_TRANSACTION_STMT
,
// logic plan node
QUERY_NODE_LOGIC_PLAN_SCAN
,
...
...
include/libs/planner/planner.h
浏览文件 @
306de052
...
...
@@ -25,20 +25,18 @@ extern "C" {
typedef
struct
SPlanContext
{
uint64_t
queryId
;
int32_t
acctId
;
SEpSet
mgmtEpSet
;
SNode
*
pAstRoot
;
bool
topicQuery
;
bool
streamQuery
;
bool
rSmaQuery
;
bool
showRewrite
;
int8_t
triggerType
;
int64_t
watermark
;
int32_t
placeholderNum
;
void
*
pTransporter
;
struct
SCatalog
*
pCatalog
;
char
*
pMsg
;
int32_t
msgLen
;
int32_t
acctId
;
SEpSet
mgmtEpSet
;
SNode
*
pAstRoot
;
bool
topicQuery
;
bool
streamQuery
;
bool
rSmaQuery
;
bool
showRewrite
;
int8_t
triggerType
;
int64_t
watermark
;
int32_t
placeholderNum
;
char
*
pMsg
;
int32_t
msgLen
;
}
SPlanContext
;
// Create the physical plan for the query, according to the AST.
...
...
@@ -47,7 +45,7 @@ int32_t qCreateQueryPlan(SPlanContext* pCxt, SQueryPlan** pPlan, SArray* pExecNo
// Set datasource of this subplan, multiple calls may be made to a subplan.
// @pSubplan subplan to be schedule
// @groupId id of a group of datasource subplans of this @pSubplan
// @pSource one execution location of this group of datasource subplans
// @pSource one execution location of this group of datasource subplans
int32_t
qSetSubplanExecutionNode
(
SSubplan
*
pSubplan
,
int32_t
groupId
,
SDownstreamSourceNode
*
pSource
);
int32_t
qStmtBindParam
(
SQueryPlan
*
pPlan
,
TAOS_MULTI_BIND
*
pParams
,
int32_t
colIdx
,
uint64_t
queryId
);
...
...
@@ -56,7 +54,7 @@ int32_t qStmtBindParam(SQueryPlan* pPlan, TAOS_MULTI_BIND* pParams, int32_t colI
int32_t
qSubPlanToString
(
const
SSubplan
*
pSubplan
,
char
**
pStr
,
int32_t
*
pLen
);
int32_t
qStringToSubplan
(
const
char
*
pStr
,
SSubplan
**
pSubplan
);
char
*
qQueryPlanToString
(
const
SQueryPlan
*
pPlan
);
char
*
qQueryPlanToString
(
const
SQueryPlan
*
pPlan
);
SQueryPlan
*
qStringToQueryPlan
(
const
char
*
pStr
);
void
qDestroyQueryPlan
(
SQueryPlan
*
pPlan
);
...
...
include/libs/stream/tstream.h
浏览文件 @
306de052
...
...
@@ -25,6 +25,8 @@ extern "C" {
#ifndef _TSTREAM_H_
#define _TSTREAM_H_
typedef
struct
SStreamTask
SStreamTask
;
enum
{
STREAM_TASK_STATUS__RUNNING
=
1
,
STREAM_TASK_STATUS__STOP
,
...
...
@@ -69,20 +71,24 @@ typedef struct {
SUseDbRsp
dbInfo
;
}
STaskDispatcherShuffle
;
typedef
void
FTbSink
(
SStreamTask
*
pTask
,
void
*
vnode
,
int64_t
ver
,
void
*
data
);
typedef
struct
{
int
8_t
reserve
d
;
int
64_t
stbUi
d
;
SSchemaWrapper
*
pSchemaWrapper
;
// not applicable to encoder and decoder
void
*
vnode
;
FTbSink
*
tbSinkFunc
;
STSchema
*
pTSchema
;
SHashObj
*
pHash
;
// groupId to tbuid
}
STaskSinkTb
;
typedef
void
FSma
Handle
(
void
*
vnode
,
int64_t
smaId
,
const
SArray
*
data
);
typedef
void
FSma
Sink
(
void
*
vnode
,
int64_t
smaId
,
const
SArray
*
data
);
typedef
struct
{
int64_t
smaId
;
// following are not applicable to encoder and decoder
FSma
Handle
*
smaHandle
;
FSma
Sink
*
smaSink
;
}
STaskSinkSma
;
typedef
struct
{
...
...
@@ -115,7 +121,7 @@ enum {
TASK_SINK__FETCH
,
};
typedef
struct
{
struct
SStreamTask
{
int64_t
streamId
;
int32_t
taskId
;
int8_t
status
;
...
...
@@ -150,8 +156,7 @@ typedef struct {
// application storage
void
*
ahandle
;
}
SStreamTask
;
};
SStreamTask
*
tNewSStreamTask
(
int64_t
streamId
);
int32_t
tEncodeSStreamTask
(
SEncoder
*
pEncoder
,
const
SStreamTask
*
pTask
);
...
...
include/util/taoserror.h
浏览文件 @
306de052
...
...
@@ -632,6 +632,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_PAR_INVALID_FIRST_COLUMN TAOS_DEF_ERROR_CODE(0, 0x2641)
#define TSDB_CODE_PAR_INVALID_VAR_COLUMN_LEN TAOS_DEF_ERROR_CODE(0, 0x2642)
#define TSDB_CODE_PAR_INVALID_TAGS_NUM TAOS_DEF_ERROR_CODE(0, 0x2643)
#define TSDB_CODE_PAR_PERMISSION_DENIED TAOS_DEF_ERROR_CODE(0, 0x2644)
//planner
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
...
...
source/client/src/clientImpl.c
浏览文件 @
306de052
...
...
@@ -162,18 +162,17 @@ int32_t buildRequest(STscObj* pTscObj, const char* sql, int sqlLen, SRequestObj*
int32_t
parseSql
(
SRequestObj
*
pRequest
,
bool
topicQuery
,
SQuery
**
pQuery
,
SStmtCallback
*
pStmtCb
)
{
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
SParseContext
cxt
=
{
.
requestId
=
pRequest
->
requestId
,
.
acctId
=
pTscObj
->
acctId
,
.
db
=
pRequest
->
pDb
,
.
topicQuery
=
topicQuery
,
.
pSql
=
pRequest
->
sqlstr
,
.
sqlLen
=
pRequest
->
sqlLen
,
.
pMsg
=
pRequest
->
msgBuf
,
.
msgLen
=
ERROR_MSG_BUF_DEFAULT_SIZE
,
.
pTransporter
=
pTscObj
->
pAppInfo
->
pTransporter
,
.
pStmtCb
=
pStmtCb
,
};
SParseContext
cxt
=
{.
requestId
=
pRequest
->
requestId
,
.
acctId
=
pTscObj
->
acctId
,
.
db
=
pRequest
->
pDb
,
.
topicQuery
=
topicQuery
,
.
pSql
=
pRequest
->
sqlstr
,
.
sqlLen
=
pRequest
->
sqlLen
,
.
pMsg
=
pRequest
->
msgBuf
,
.
msgLen
=
ERROR_MSG_BUF_DEFAULT_SIZE
,
.
pTransporter
=
pTscObj
->
pAppInfo
->
pTransporter
,
.
pStmtCb
=
pStmtCb
,
.
pUser
=
pTscObj
->
user
};
cxt
.
mgmtEpSet
=
getEpSet_s
(
&
pTscObj
->
pAppInfo
->
mgmtEp
);
int32_t
code
=
catalogGetHandle
(
pTscObj
->
pAppInfo
->
clusterId
,
&
cxt
.
pCatalog
);
...
...
@@ -232,11 +231,15 @@ int32_t getPlan(SRequestObj* pRequest, SQuery* pQuery, SQueryPlan** pPlan, SArra
.
mgmtEpSet
=
getEpSet_s
(
&
pRequest
->
pTscObj
->
pAppInfo
->
mgmtEp
),
.
pAstRoot
=
pQuery
->
pRoot
,
.
showRewrite
=
pQuery
->
showRewrite
,
.
pTransporter
=
pRequest
->
pTscObj
->
pAppInfo
->
pTransporter
,
.
pMsg
=
pRequest
->
msgBuf
,
.
msgLen
=
ERROR_MSG_BUF_DEFAULT_SIZE
,
.
placeholderNum
=
pQuery
->
placeholderNum
};
int32_t
code
=
catalogGetHandle
(
pRequest
->
pTscObj
->
pAppInfo
->
clusterId
,
&
cxt
.
pCatalog
);
SEpSet
mgmtEpSet
=
getEpSet_s
(
&
pRequest
->
pTscObj
->
pAppInfo
->
mgmtEp
);
SCatalog
*
pCatalog
=
NULL
;
int32_t
code
=
catalogGetHandle
(
pRequest
->
pTscObj
->
pAppInfo
->
clusterId
,
&
pCatalog
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
catalogGetQnodeList
(
pCatalog
,
pRequest
->
pTscObj
->
pAppInfo
->
pTransporter
,
&
mgmtEpSet
,
pNodeList
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
qCreateQueryPlan
(
&
cxt
,
pPlan
,
pNodeList
);
}
...
...
source/common/src/tdatablock.c
浏览文件 @
306de052
...
...
@@ -363,9 +363,9 @@ int32_t blockDataMerge(SSDataBlock* pDest, const SSDataBlock* pSrc, SArray* pInd
for
(
int32_t
i
=
0
;
i
<
pDest
->
info
.
numOfCols
;
++
i
)
{
int32_t
mapIndex
=
i
;
// if (pIndexMap) {
// mapIndex = *(int32_t*)taosArrayGet(pIndexMap, i);
// }
// if (pIndexMap) {
// mapIndex = *(int32_t*)taosArrayGet(pIndexMap, i);
// }
SColumnInfoData
*
pCol2
=
taosArrayGet
(
pDest
->
pDataBlock
,
i
);
SColumnInfoData
*
pCol1
=
taosArrayGet
(
pSrc
->
pDataBlock
,
mapIndex
);
...
...
@@ -1596,7 +1596,8 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SArray* pDataBlocks
return
TSDB_CODE_SUCCESS
;
}
SSubmitReq
*
tdBlockToSubmit
(
const
SArray
*
pBlocks
,
const
STSchema
*
pTSchema
)
{
SSubmitReq
*
tdBlockToSubmit
(
const
SArray
*
pBlocks
,
const
STSchema
*
pTSchema
,
bool
createTb
,
int64_t
suid
,
int32_t
vgId
)
{
SSubmitReq
*
ret
=
NULL
;
// cal size
...
...
@@ -1608,13 +1609,37 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema) {
// TODO min
int32_t
rowSize
=
pDataBlock
->
info
.
rowSize
;
int32_t
maxLen
=
TD_ROW_MAX_BYTES_FROM_SCHEMA
(
pTSchema
);
cap
+=
sizeof
(
SSubmitBlk
)
+
rows
*
maxLen
;
int32_t
schemaLen
=
0
;
if
(
createTb
)
{
SVCreateTbReq
createTbReq
=
{
0
};
createTbReq
.
name
=
"a"
;
createTbReq
.
flags
=
0
;
createTbReq
.
type
=
TSDB_CHILD_TABLE
;
createTbReq
.
ctb
.
suid
=
htobe64
(
suid
);
SKVRowBuilder
kvRowBuilder
=
{
0
};
if
(
tdInitKVRowBuilder
(
&
kvRowBuilder
)
<
0
)
{
ASSERT
(
0
);
}
tdAddColToKVRow
(
&
kvRowBuilder
,
1
,
&
pDataBlock
->
info
.
groupId
,
sizeof
(
uint64_t
));
createTbReq
.
ctb
.
pTag
=
tdGetKVRowFromBuilder
(
&
kvRowBuilder
);
tdDestroyKVRowBuilder
(
&
kvRowBuilder
);
int32_t
code
;
tEncodeSize
(
tEncodeSVCreateTbReq
,
&
createTbReq
,
schemaLen
,
code
);
if
(
code
<
0
)
return
NULL
;
}
cap
+=
sizeof
(
SSubmitBlk
)
+
schemaLen
+
rows
*
maxLen
;
}
// assign data
ret
=
taosMemoryCalloc
(
1
,
cap
);
ret
=
taosMemoryCalloc
(
1
,
cap
+
46
);
ret
=
POINTER_SHIFT
(
ret
,
46
);
ret
->
header
.
vgId
=
vgId
;
ret
->
version
=
htonl
(
1
);
ret
->
length
=
htonl
(
cap
-
sizeof
(
SSubmitReq
)
);
ret
->
length
=
sizeof
(
SSubmitReq
);
ret
->
numOfBlocks
=
htonl
(
sz
);
void
*
submitBlk
=
POINTER_SHIFT
(
ret
,
sizeof
(
SSubmitReq
));
...
...
@@ -1623,19 +1648,47 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema) {
SSubmitBlk
*
blkHead
=
submitBlk
;
blkHead
->
numOfRows
=
htons
(
pDataBlock
->
info
.
rows
);
blkHead
->
schemaLen
=
0
;
blkHead
->
sversion
=
htonl
(
pTSchema
->
version
);
// TODO
blkHead
->
suid
=
0
;
blkHead
->
uid
=
htobe64
(
pDataBlock
->
info
.
uid
);
blkHead
->
suid
=
htobe64
(
suid
);
// uid is assigned by vnode
blkHead
->
uid
=
0
;
int32_t
rows
=
pDataBlock
->
info
.
rows
;
/*int32_t maxLen = TD_ROW_MAX_BYTES_FROM_SCHEMA(pTSchema);*/
/*blkHead->dataLen = htonl(rows * maxLen);*/
blkHead
->
dataLen
=
0
;
void
*
blockData
=
POINTER_SHIFT
(
submitBlk
,
sizeof
(
SSubmitBlk
));
STSRow
*
rowData
=
blockData
;
void
*
blockData
=
POINTER_SHIFT
(
submitBlk
,
sizeof
(
SSubmitBlk
));
int32_t
schemaLen
=
0
;
if
(
createTb
)
{
SVCreateTbReq
createTbReq
=
{
0
};
createTbReq
.
name
=
"a"
;
createTbReq
.
flags
=
0
;
createTbReq
.
type
=
TSDB_CHILD_TABLE
;
createTbReq
.
ctb
.
suid
=
suid
;
SKVRowBuilder
kvRowBuilder
=
{
0
};
if
(
tdInitKVRowBuilder
(
&
kvRowBuilder
)
<
0
)
{
ASSERT
(
0
);
}
tdAddColToKVRow
(
&
kvRowBuilder
,
1
,
&
pDataBlock
->
info
.
groupId
,
sizeof
(
uint64_t
));
createTbReq
.
ctb
.
pTag
=
tdGetKVRowFromBuilder
(
&
kvRowBuilder
);
tdDestroyKVRowBuilder
(
&
kvRowBuilder
);
int32_t
code
;
tEncodeSize
(
tEncodeSVCreateTbReq
,
&
createTbReq
,
schemaLen
,
code
);
if
(
code
<
0
)
return
NULL
;
SEncoder
encoder
=
{
0
};
tEncoderInit
(
&
encoder
,
blockData
,
schemaLen
);
if
(
tEncodeSVCreateTbReq
(
&
encoder
,
&
createTbReq
)
<
0
)
return
NULL
;
tEncoderClear
(
&
encoder
);
}
blkHead
->
schemaLen
=
htonl
(
schemaLen
);
STSRow
*
rowData
=
POINTER_SHIFT
(
blockData
,
schemaLen
);
for
(
int32_t
j
=
0
;
j
<
rows
;
j
++
)
{
SRowBuilder
rb
=
{
0
};
...
...
@@ -1653,10 +1706,14 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema) {
rowData
=
POINTER_SHIFT
(
rowData
,
rowLen
);
blkHead
->
dataLen
+=
rowLen
;
}
int32_t
len
=
blkHead
->
dataLen
;
blkHead
->
dataLen
=
htonl
(
len
);
blkHead
=
POINTER_SHIFT
(
blkHead
,
len
);
int32_t
dataLen
=
blkHead
->
dataLen
;
blkHead
->
dataLen
=
htonl
(
dataLen
);
ret
->
length
+=
sizeof
(
SSubmitBlk
)
+
schemaLen
+
dataLen
;
blkHead
=
POINTER_SHIFT
(
blkHead
,
schemaLen
+
dataLen
);
/*submitBlk = blkHead;*/
}
ret
->
length
=
htonl
(
ret
->
length
);
return
ret
;
}
source/common/src/tmsg.c
浏览文件 @
306de052
...
...
@@ -56,7 +56,6 @@ int32_t tGetSubmitMsgNext(SSubmitMsgIter *pIter, SSubmitBlk **pPBlock) {
ASSERT
(
0
);
}
SSubmitBlk
*
pSubmitBlk
=
(
SSubmitBlk
*
)
POINTER_SHIFT
(
pIter
->
pMsg
,
pIter
->
len
);
pIter
->
len
+=
(
sizeof
(
SSubmitBlk
)
+
pIter
->
dataLen
+
pIter
->
schemaLen
);
ASSERT
(
pIter
->
len
>
0
);
}
...
...
@@ -4013,4 +4012,4 @@ int32_t tDecodeSVSubmitReq(SDecoder *pCoder, SVSubmitReq *pReq) {
tEndDecode
(
pCoder
);
return
0
;
}
\ No newline at end of file
}
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
浏览文件 @
306de052
...
...
@@ -106,6 +106,7 @@ int32_t vmAllocQueue(SVnodesMgmt *pMgmt, SVnodeObj *pVnode);
void
vmFreeQueue
(
SVnodesMgmt
*
pMgmt
,
SVnodeObj
*
pVnode
);
int32_t
vmPutMsgToSyncQueue
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pRpc
);
// sync integration
int32_t
vmPutMsgToWriteQueue
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pRpc
);
int32_t
vmPutMsgToQueryQueue
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pMsg
);
int32_t
vmPutMsgToFetchQueue
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pMsg
);
int32_t
vmPutMsgToApplyQueue
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pMsg
);
...
...
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
浏览文件 @
306de052
...
...
@@ -51,6 +51,7 @@ void vmGetMonitorInfo(SMgmtWrapper *pWrapper, SMonVmInfo *pInfo) {
pInfo
->
vstat
.
numOfBatchInsertSuccessReqs
=
numOfBatchInsertSuccessReqs
-
pMgmt
->
state
.
numOfBatchInsertSuccessReqs
;
pMgmt
->
state
=
pInfo
->
vstat
;
tfsGetMonitorInfo
(
pMgmt
->
pTfs
,
&
pInfo
->
tfs
);
taosArrayDestroy
(
vloads
.
pVloads
);
}
...
...
@@ -177,6 +178,7 @@ int32_t vmProcessCreateVnodeReq(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) {
SMsgCb
msgCb
=
pMgmt
->
pDnode
->
data
.
msgCb
;
msgCb
.
pWrapper
=
pMgmt
->
pWrapper
;
msgCb
.
queueFps
[
WRITE_QUEUE
]
=
vmPutMsgToWriteQueue
;
msgCb
.
queueFps
[
QUERY_QUEUE
]
=
vmPutMsgToQueryQueue
;
msgCb
.
queueFps
[
FETCH_QUEUE
]
=
vmPutMsgToFetchQueue
;
msgCb
.
queueFps
[
APPLY_QUEUE
]
=
vmPutMsgToApplyQueue
;
...
...
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
浏览文件 @
306de052
...
...
@@ -135,6 +135,7 @@ static void *vmOpenVnodeFunc(void *param) {
SMsgCb
msgCb
=
pMgmt
->
pDnode
->
data
.
msgCb
;
msgCb
.
pWrapper
=
pMgmt
->
pWrapper
;
msgCb
.
queueFps
[
WRITE_QUEUE
]
=
vmPutMsgToWriteQueue
;
msgCb
.
queueFps
[
QUERY_QUEUE
]
=
vmPutMsgToQueryQueue
;
msgCb
.
queueFps
[
FETCH_QUEUE
]
=
vmPutMsgToFetchQueue
;
msgCb
.
queueFps
[
APPLY_QUEUE
]
=
vmPutMsgToApplyQueue
;
...
...
@@ -147,7 +148,7 @@ static void *vmOpenVnodeFunc(void *param) {
pThread
->
failed
++
;
}
else
{
vmOpenVnode
(
pMgmt
,
pCfg
,
pImpl
);
//vnodeStart(pImpl);
//
vnodeStart(pImpl);
dDebug
(
"vgId:%d, is opened by thread:%d"
,
pCfg
->
vgId
,
pThread
->
threadIndex
);
pThread
->
opened
++
;
}
...
...
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
浏览文件 @
306de052
...
...
@@ -357,6 +357,10 @@ static int32_t vmPutRpcMsgToQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc, EQueueT
pMsg
->
rpcMsg
=
*
pRpc
;
// if (pMsg->rpcMsg.handle != NULL) assert(pMsg->rpcMsg.refId != 0);
switch
(
qtype
)
{
case
WRITE_QUEUE
:
dTrace
(
"msg:%p, will be put into vnode-write queue"
,
pMsg
);
taosWriteQitem
(
pVnode
->
pWriteQ
,
pMsg
);
break
;
case
QUERY_QUEUE
:
dTrace
(
"msg:%p, will be put into vnode-query queue"
,
pMsg
);
taosWriteQitem
(
pVnode
->
pQueryQ
,
pMsg
);
...
...
@@ -387,6 +391,10 @@ static int32_t vmPutRpcMsgToQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc, EQueueT
return
code
;
}
int32_t
vmPutMsgToWriteQueue
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pRpc
)
{
return
vmPutRpcMsgToQueue
(
pWrapper
,
pRpc
,
WRITE_QUEUE
);
}
int32_t
vmPutMsgToQueryQueue
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pRpc
)
{
return
vmPutRpcMsgToQueue
(
pWrapper
,
pRpc
,
QUERY_QUEUE
);
}
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
306de052
...
...
@@ -574,6 +574,7 @@ typedef struct {
char
sourceDb
[
TSDB_DB_FNAME_LEN
];
char
targetDb
[
TSDB_DB_FNAME_LEN
];
char
targetSTbName
[
TSDB_TABLE_FNAME_LEN
];
int64_t
targetStbUid
;
int64_t
createTime
;
int64_t
updateTime
;
int64_t
uid
;
...
...
source/dnode/mnode/impl/src/mndDef.c
浏览文件 @
306de052
...
...
@@ -416,6 +416,9 @@ int32_t tEncodeSStreamObj(SEncoder *pEncoder, const SStreamObj *pObj) {
/*int32_t outputNameSz = 0;*/
if
(
tEncodeCStr
(
pEncoder
,
pObj
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
pObj
->
sourceDb
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
pObj
->
targetDb
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
pObj
->
targetSTbName
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pEncoder
,
pObj
->
targetStbUid
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pEncoder
,
pObj
->
createTime
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pEncoder
,
pObj
->
updateTime
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pEncoder
,
pObj
->
uid
)
<
0
)
return
-
1
;
...
...
@@ -465,6 +468,9 @@ int32_t tEncodeSStreamObj(SEncoder *pEncoder, const SStreamObj *pObj) {
int32_t
tDecodeSStreamObj
(
SDecoder
*
pDecoder
,
SStreamObj
*
pObj
)
{
if
(
tDecodeCStrTo
(
pDecoder
,
pObj
->
name
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
pDecoder
,
pObj
->
sourceDb
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
pDecoder
,
pObj
->
targetDb
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
pDecoder
,
pObj
->
targetSTbName
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pDecoder
,
&
pObj
->
targetStbUid
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pDecoder
,
&
pObj
->
createTime
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pDecoder
,
&
pObj
->
updateTime
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pDecoder
,
&
pObj
->
uid
)
<
0
)
return
-
1
;
...
...
@@ -529,4 +535,4 @@ void *tDecodeSMqOffsetObj(void *buf, SMqOffsetObj *pOffset) {
buf
=
taosDecodeStringTo
(
buf
,
pOffset
->
key
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pOffset
->
offset
);
return
buf
;
}
\ No newline at end of file
}
source/dnode/mnode/impl/src/mndScheduler.c
浏览文件 @
306de052
...
...
@@ -204,6 +204,7 @@ int32_t mndAddShuffledSinkToStream(SMnode* pMnode, STrans* pTrans, SStreamObj* p
pTask
->
smaSink
.
smaId
=
pStream
->
smaId
;
}
else
{
pTask
->
sinkType
=
TASK_SINK__TABLE
;
pTask
->
tbSink
.
stbUid
=
pStream
->
targetStbUid
;
pTask
->
tbSink
.
pSchemaWrapper
=
tCloneSSchemaWrapper
(
&
pStream
->
outputSchema
);
ASSERT
(
pTask
->
tbSink
.
pSchemaWrapper
);
}
...
...
@@ -244,9 +245,10 @@ int32_t mndAddFixedSinkToStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStr
pTask
->
smaSink
.
smaId
=
pStream
->
smaId
;
}
else
{
pTask
->
sinkType
=
TASK_SINK__TABLE
;
pTask
->
tbSink
.
stbUid
=
pStream
->
targetStbUid
;
pTask
->
tbSink
.
pSchemaWrapper
=
tCloneSSchemaWrapper
(
&
pStream
->
outputSchema
);
}
//
// dispatch
pTask
->
dispatchType
=
TASK_DISPATCH__NONE
;
...
...
@@ -319,6 +321,7 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
pTask
->
smaSink
.
smaId
=
pStream
->
smaId
;
}
else
{
pTask
->
sinkType
=
TASK_SINK__TABLE
;
pTask
->
tbSink
.
stbUid
=
pStream
->
targetStbUid
;
pTask
->
tbSink
.
pSchemaWrapper
=
tCloneSSchemaWrapper
(
&
pStream
->
outputSchema
);
}
#endif
...
...
source/dnode/mnode/impl/src/mndStream.c
浏览文件 @
306de052
...
...
@@ -360,6 +360,8 @@ static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStre
goto
_OVER
;
}
stbObj
.
uid
=
pStream
->
targetStbUid
;
if
(
mndAddStbToTrans
(
pMnode
,
pTrans
,
pDb
,
&
stbObj
)
<
0
)
goto
_OVER
;
return
0
;
...
...
@@ -379,6 +381,7 @@ static int32_t mndCreateStream(SMnode *pMnode, SNodeMsg *pReq, SCMCreateStreamRe
streamObj
.
createTime
=
taosGetTimestampMs
();
streamObj
.
updateTime
=
streamObj
.
createTime
;
streamObj
.
uid
=
mndGenerateUid
(
pCreate
->
name
,
strlen
(
pCreate
->
name
));
streamObj
.
targetStbUid
=
mndGenerateUid
(
pCreate
->
targetStbFullName
,
TSDB_TABLE_FNAME_LEN
);
streamObj
.
dbUid
=
pDb
->
uid
;
streamObj
.
version
=
1
;
streamObj
.
sql
=
pCreate
->
sql
;
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
306de052
...
...
@@ -967,7 +967,7 @@ static void mndTransResetActions(SMnode *pMnode, STrans *pTrans, SArray *pArray)
pAction
->
msgSent
=
0
;
pAction
->
msgReceived
=
0
;
pAction
->
errCode
=
0
;
mDebug
(
"trans:%d, action:%d
is reset and will be re-executed
"
,
pTrans
->
id
,
action
);
mDebug
(
"trans:%d, action:%d
execute status is reset
"
,
pTrans
->
id
,
action
);
}
}
...
...
@@ -1043,7 +1043,7 @@ static int32_t mndTransExecuteActions(SMnode *pMnode, STrans *pTrans, SArray *pA
return
errCode
;
}
}
else
{
mDebug
(
"trans:%d, %d of %d actions execut
ing
"
,
pTrans
->
id
,
numOfReceived
,
numOfActions
);
mDebug
(
"trans:%d, %d of %d actions execut
ed
"
,
pTrans
->
id
,
numOfReceived
,
numOfActions
);
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
}
...
...
source/dnode/mnode/impl/src/mndUser.c
浏览文件 @
306de052
...
...
@@ -412,7 +412,7 @@ static int32_t mndProcessAlterUserReq(SNodeMsg *pReq) {
goto
_OVER
;
}
if
(
alterReq
.
pass
[
0
]
==
0
)
{
if
(
TSDB_ALTER_USER_PASSWD
==
alterReq
.
alterType
&&
alterReq
.
pass
[
0
]
==
0
)
{
terrno
=
TSDB_CODE_MND_INVALID_PASS_FORMAT
;
goto
_OVER
;
}
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
306de052
...
...
@@ -884,24 +884,48 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
}
}
int32_t
tqExpandTask
(
STQ
*
pTq
,
SStreamTask
*
pTask
,
int32_t
parallel
)
{
if
(
pTask
->
execType
==
TASK_EXEC__NONE
)
return
0
;
void
tqTableSink
(
SStreamTask
*
pTask
,
void
*
vnode
,
int64_t
ver
,
void
*
data
)
{
const
SArray
*
pRes
=
(
const
SArray
*
)
data
;
SVnode
*
pVnode
=
(
SVnode
*
)
vnode
;
ASSERT
(
pTask
->
tbSink
.
pTSchema
);
SSubmitReq
*
pReq
=
tdBlockToSubmit
(
pRes
,
pTask
->
tbSink
.
pTSchema
,
true
,
pTask
->
tbSink
.
stbUid
,
pVnode
->
config
.
vgId
);
tPrintFixedSchemaSubmitReq
(
pReq
,
pTask
->
tbSink
.
pTSchema
);
// build write msg
SRpcMsg
msg
=
{
.
msgType
=
TDMT_VND_SUBMIT
,
.
pCont
=
pReq
,
.
contLen
=
ntohl
(
pReq
->
length
),
};
pTask
->
exec
.
numOfRunners
=
parallel
;
pTask
->
exec
.
runners
=
taosMemoryCalloc
(
parallel
,
sizeof
(
SStreamRunner
));
if
(
pTask
->
exec
.
runners
==
NULL
)
{
return
-
1
;
ASSERT
(
tmsgPutToQueue
(
&
pVnode
->
msgCb
,
WRITE_QUEUE
,
&
msg
)
==
0
);
}
int32_t
tqExpandTask
(
STQ
*
pTq
,
SStreamTask
*
pTask
,
int32_t
parallel
)
{
if
(
pTask
->
execType
!=
TASK_EXEC__NONE
)
{
// expand runners
pTask
->
exec
.
numOfRunners
=
parallel
;
pTask
->
exec
.
runners
=
taosMemoryCalloc
(
parallel
,
sizeof
(
SStreamRunner
));
if
(
pTask
->
exec
.
runners
==
NULL
)
{
return
-
1
;
}
for
(
int32_t
i
=
0
;
i
<
parallel
;
i
++
)
{
STqReadHandle
*
pStreamReader
=
tqInitSubmitMsgScanner
(
pTq
->
pVnode
->
pMeta
);
SReadHandle
handle
=
{
.
reader
=
pStreamReader
,
.
meta
=
pTq
->
pVnode
->
pMeta
,
};
pTask
->
exec
.
runners
[
i
].
inputHandle
=
pStreamReader
;
pTask
->
exec
.
runners
[
i
].
executor
=
qCreateStreamExecTaskInfo
(
pTask
->
exec
.
qmsg
,
&
handle
);
ASSERT
(
pTask
->
exec
.
runners
[
i
].
executor
);
}
}
for
(
int32_t
i
=
0
;
i
<
parallel
;
i
++
)
{
STqReadHandle
*
pStreamReader
=
tqInitSubmitMsgScanner
(
pTq
->
pVnode
->
pMeta
);
SReadHandle
handle
=
{
.
reader
=
pStreamReader
,
.
meta
=
pTq
->
pVnode
->
pMeta
,
};
pTask
->
exec
.
runners
[
i
].
inputHandle
=
pStreamReader
;
pTask
->
exec
.
runners
[
i
].
executor
=
qCreateStreamExecTaskInfo
(
pTask
->
exec
.
qmsg
,
&
handle
);
ASSERT
(
pTask
->
exec
.
runners
[
i
].
executor
);
if
(
pTask
->
sinkType
==
TASK_SINK__TABLE
)
{
pTask
->
tbSink
.
vnode
=
pTq
->
pVnode
;
pTask
->
tbSink
.
tbSinkFunc
=
tqTableSink
;
}
return
0
;
}
...
...
@@ -925,7 +949,7 @@ int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen) {
// sink
pTask
->
ahandle
=
pTq
->
pVnode
;
if
(
pTask
->
sinkType
==
TASK_SINK__SMA
)
{
pTask
->
smaSink
.
sma
Handle
=
smaHandleRes
;
pTask
->
smaSink
.
sma
Sink
=
smaHandleRes
;
}
else
if
(
pTask
->
sinkType
==
TASK_SINK__TABLE
)
{
ASSERT
(
pTask
->
tbSink
.
pSchemaWrapper
);
ASSERT
(
pTask
->
tbSink
.
pSchemaWrapper
->
pSchema
);
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
306de052
...
...
@@ -38,7 +38,8 @@
#define SWITCH_ORDER(n) (((n) = ((n) == TSDB_ORDER_ASC) ? TSDB_ORDER_DESC : TSDB_ORDER_ASC))
static
int32_t
buildSysDbTableInfo
(
const
SSysTableScanInfo
*
pInfo
,
int32_t
capacity
);
static
int32_t
buildDbTableInfoBlock
(
const
SSDataBlock
*
p
,
const
SSysTableMeta
*
pSysDbTableMeta
,
size_t
size
,
const
char
*
dbName
);
static
int32_t
buildDbTableInfoBlock
(
const
SSDataBlock
*
p
,
const
SSysTableMeta
*
pSysDbTableMeta
,
size_t
size
,
const
char
*
dbName
);
static
void
switchCtxOrder
(
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
)
{
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
...
...
@@ -159,7 +160,8 @@ static bool overlapWithTimeWindow(SInterval* pInterval, SDataBlockInfo* pBlockIn
return
false
;
}
static
int32_t
loadDataBlock
(
SOperatorInfo
*
pOperator
,
STableScanInfo
*
pTableScanInfo
,
SSDataBlock
*
pBlock
,
uint32_t
*
status
)
{
static
int32_t
loadDataBlock
(
SOperatorInfo
*
pOperator
,
STableScanInfo
*
pTableScanInfo
,
SSDataBlock
*
pBlock
,
uint32_t
*
status
)
{
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
STableScanInfo
*
pInfo
=
pOperator
->
info
;
...
...
@@ -189,7 +191,7 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableSca
}
else
if
(
*
status
==
FUNC_DATA_REQUIRED_STATIS_LOAD
)
{
pCost
->
loadBlockStatis
+=
1
;
bool
allColumnsHaveAgg
=
true
;
bool
allColumnsHaveAgg
=
true
;
SColumnDataAgg
**
pColAgg
=
NULL
;
tsdbRetrieveDataBlockStatisInfo
(
pTableScanInfo
->
dataReader
,
&
pColAgg
,
&
allColumnsHaveAgg
);
...
...
@@ -261,7 +263,7 @@ static void prepareForDescendingScan(STableScanInfo* pTableScanInfo, SqlFunction
static
SSDataBlock
*
doTableScanImpl
(
SOperatorInfo
*
pOperator
)
{
STableScanInfo
*
pTableScanInfo
=
pOperator
->
info
;
SSDataBlock
*
pBlock
=
pTableScanInfo
->
pResBlock
;
SSDataBlock
*
pBlock
=
pTableScanInfo
->
pResBlock
;
while
(
tsdbNextDataBlock
(
pTableScanInfo
->
dataReader
))
{
if
(
isTaskKilled
(
pOperator
->
pTaskInfo
))
{
...
...
@@ -344,7 +346,8 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
pTableScanInfo
->
scanFlag
=
REPEAT_SCAN
;
qDebug
(
"%s start to repeat descending order scan data blocks due to query func required, qrange:%"
PRId64
"-%"
PRId64
,
GET_TASKID
(
pTaskInfo
),
pTaskInfo
->
window
.
skey
,
pTaskInfo
->
window
.
ekey
);
"-%"
PRId64
,
GET_TASKID
(
pTaskInfo
),
pTaskInfo
->
window
.
skey
,
pTaskInfo
->
window
.
ekey
);
// do prepare for the next round table scan operation
tsdbResetReadHandle
(
pTableScanInfo
->
dataReader
,
&
pTableScanInfo
->
cond
);
...
...
@@ -373,22 +376,22 @@ SOperatorInfo* createTableScanOperatorInfo(void* pDataReader, SQueryTableDataCon
pInfo
->
cond
=
*
pCond
;
pInfo
->
scanInfo
=
(
SScanInfo
){.
numOfAsc
=
scanInfo
[
0
],
.
numOfDesc
=
scanInfo
[
1
]};
pInfo
->
interval
=
*
pInterval
;
pInfo
->
sampleRatio
=
sampleRatio
;
pInfo
->
interval
=
*
pInterval
;
pInfo
->
sampleRatio
=
sampleRatio
;
pInfo
->
dataBlockLoadFlag
=
dataLoadFlag
;
pInfo
->
pResBlock
=
pResBlock
;
pInfo
->
pFilterNode
=
pCondition
;
pInfo
->
dataReader
=
pDataReader
;
pInfo
->
scanFlag
=
MAIN_SCAN
;
pInfo
->
pColMatchInfo
=
pColMatchInfo
;
pOperator
->
name
=
"TableScanOperator"
;
// for dubug purpose
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
;
pOperator
->
blocking
=
false
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
info
=
pInfo
;
pOperator
->
numOfExprs
=
numOfOutput
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pInfo
->
pResBlock
=
pResBlock
;
pInfo
->
pFilterNode
=
pCondition
;
pInfo
->
dataReader
=
pDataReader
;
pInfo
->
scanFlag
=
MAIN_SCAN
;
pInfo
->
pColMatchInfo
=
pColMatchInfo
;
pOperator
->
name
=
"TableScanOperator"
;
// for dubug purpose
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
;
pOperator
->
blocking
=
false
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
info
=
pInfo
;
pOperator
->
numOfExprs
=
numOfOutput
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pOperator
->
fpSet
=
createOperatorFpSet
(
operatorDummyOpenFn
,
doTableScan
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
...
...
@@ -404,17 +407,17 @@ SOperatorInfo* createTableScanOperatorInfo(void* pDataReader, SQueryTableDataCon
SOperatorInfo
*
createTableSeqScanOperatorInfo
(
void
*
pReadHandle
,
SExecTaskInfo
*
pTaskInfo
)
{
STableScanInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
STableScanInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
pInfo
->
dataReader
=
pReadHandle
;
// pInfo->prevGroupId = -1;
pInfo
->
dataReader
=
pReadHandle
;
// pInfo->prevGroupId = -1;
pOperator
->
name
=
"TableSeqScanOperator"
;
pOperator
->
name
=
"TableSeqScanOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN
;
pOperator
->
blocking
=
false
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
info
=
pInfo
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pOperator
->
blocking
=
false
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
info
=
pInfo
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pOperator
->
fpSet
=
createOperatorFpSet
(
operatorDummyOpenFn
,
doTableScanImpl
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
return
pOperator
;
...
...
@@ -514,18 +517,18 @@ static void doClearBufferedBlocks(SStreamBlockScanInfo* pInfo) {
static
SSDataBlock
*
getUpdateDataBlock
(
SStreamBlockScanInfo
*
pInfo
)
{
SColumnInfoData
*
pColDataInfo
=
taosArrayGet
(
pInfo
->
pRes
->
pDataBlock
,
pInfo
->
primaryTsIndex
);
TSKEY
*
ts
=
(
TSKEY
*
)
pColDataInfo
->
pData
;
TSKEY
*
ts
=
(
TSKEY
*
)
pColDataInfo
->
pData
;
for
(
int32_t
i
=
0
;
i
<
pInfo
->
pRes
->
info
.
rows
;
i
++
)
{
if
(
updateInfoIsUpdated
(
pInfo
->
pUpdateInfo
,
pInfo
->
pRes
->
info
.
uid
,
ts
[
i
]))
{
taosArrayPush
(
pInfo
->
tsArray
,
ts
+
i
);
taosArrayPush
(
pInfo
->
tsArray
,
ts
+
i
);
}
}
if
(
taosArrayGetSize
(
pInfo
->
tsArray
)
>
0
)
{
//TODO(liuyao) get from tsdb
// SSDataBlock* p = createOneDataBlock(pInfo->pRes, true);
// p->info.type = STREAM_INVERT;
// taosArrayClear(pInfo->tsArray);
// return p;
//
TODO(liuyao) get from tsdb
//
SSDataBlock* p = createOneDataBlock(pInfo->pRes, true);
//
p->info.type = STREAM_INVERT;
//
taosArrayClear(pInfo->tsArray);
//
return p;
return
NULL
;
}
return
NULL
;
...
...
@@ -535,7 +538,7 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
// NOTE: this operator does never check if current status is done or not
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
SStreamBlockScanInfo
*
pInfo
=
pOperator
->
info
;
int32_t
rows
=
0
;
int32_t
rows
=
0
;
pTaskInfo
->
code
=
pOperator
->
fpSet
.
_openFn
(
pOperator
);
if
(
pTaskInfo
->
code
!=
TSDB_CODE_SUCCESS
||
pOperator
->
status
==
OP_EXEC_DONE
)
{
...
...
@@ -571,7 +574,7 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
int32_t
numOfRows
=
0
;
int16_t
outputCol
=
0
;
int32_t
code
=
tqRetrieveDataBlock
(
&
pCols
,
pInfo
->
readerHandle
,
&
groupId
,
&
uid
,
&
numOfRows
,
&
outputCol
);
int32_t
code
=
tqRetrieveDataBlock
(
&
pCols
,
pInfo
->
readerHandle
,
&
groupId
,
&
uid
,
&
numOfRows
,
&
outputCol
);
if
(
code
!=
TSDB_CODE_SUCCESS
||
numOfRows
==
0
)
{
pTaskInfo
->
code
=
code
;
...
...
@@ -652,8 +655,9 @@ SOperatorInfo* createStreamScanOperatorInfo(void* streamReadHandle, SSDataBlock*
SArray
*
pColIds
=
taosArrayInit
(
4
,
sizeof
(
int16_t
));
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
int16_t
*
id
=
taosArrayGet
(
pColList
,
i
);
taosArrayPush
(
pColIds
,
id
);
SColMatchInfo
*
id
=
taosArrayGet
(
pColList
,
i
);
int16_t
colId
=
id
->
colId
;
taosArrayPush
(
pColIds
,
&
colId
);
}
pInfo
->
pColMatchInfo
=
pColList
;
...
...
@@ -678,8 +682,8 @@ SOperatorInfo* createStreamScanOperatorInfo(void* streamReadHandle, SSDataBlock*
return
NULL
;
}
pInfo
->
primaryTsIndex
=
0
;
//
TODO(liuyao) get it from physical plan
pInfo
->
pUpdateInfo
=
updateInfoInit
(
60000
,
0
,
100
);
//
TODO(liuyao) get it from physical plan
pInfo
->
primaryTsIndex
=
0
;
//
TODO(liuyao) get it from physical plan
pInfo
->
pUpdateInfo
=
updateInfoInit
(
60000
,
0
,
100
);
//
TODO(liuyao) get it from physical plan
if
(
pInfo
->
pUpdateInfo
==
NULL
)
{
taosMemoryFreeClear
(
pInfo
);
taosMemoryFreeClear
(
pOperator
);
...
...
@@ -687,25 +691,26 @@ SOperatorInfo* createStreamScanOperatorInfo(void* streamReadHandle, SSDataBlock*
}
pInfo
->
readerHandle
=
streamReadHandle
;
pInfo
->
pRes
=
pResBlock
;
pInfo
->
pCondition
=
pCondition
;
pOperator
->
name
=
"StreamBlockScanOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN
;
pOperator
->
blocking
=
false
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
info
=
pInfo
;
pOperator
->
numOfExprs
=
pResBlock
->
info
.
numOfCols
;
pOperator
->
fpSet
.
_openFn
=
operatorDummyOpenFn
;
pInfo
->
pRes
=
pResBlock
;
pInfo
->
pCondition
=
pCondition
;
pOperator
->
name
=
"StreamBlockScanOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN
;
pOperator
->
blocking
=
false
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
info
=
pInfo
;
pOperator
->
numOfExprs
=
pResBlock
->
info
.
numOfCols
;
pOperator
->
fpSet
.
_openFn
=
operatorDummyOpenFn
;
pOperator
->
fpSet
.
getNextFn
=
doStreamBlockScan
;
pOperator
->
fpSet
.
closeFn
=
operatorDummyCloseFn
;
pOperator
->
fpSet
.
closeFn
=
operatorDummyCloseFn
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pOperator
->
fpSet
=
createOperatorFpSet
(
operatorDummyOpenFn
,
doStreamBlockScan
,
NULL
,
NULL
,
operatorDummyCloseFn
,
NULL
,
NULL
,
NULL
);
pOperator
->
fpSet
=
createOperatorFpSet
(
operatorDummyOpenFn
,
doStreamBlockScan
,
NULL
,
NULL
,
operatorDummyCloseFn
,
NULL
,
NULL
,
NULL
);
return
pOperator
;
_error:
_error:
taosMemoryFreeClear
(
pInfo
);
taosMemoryFreeClear
(
pOperator
);
return
NULL
;
...
...
@@ -774,7 +779,7 @@ static void getDBNameFromCondition(SNode* pCondition, const char* dbName) {
if
(
NULL
==
pCondition
)
{
return
;
}
nodesWalkExpr
(
pCondition
,
getDBNameFromConditionWalker
,
(
char
*
)
dbName
);
nodesWalkExpr
(
pCondition
,
getDBNameFromConditionWalker
,
(
char
*
)
dbName
);
}
static
int32_t
loadSysTableCallback
(
void
*
param
,
const
SDataBuf
*
pMsg
,
int32_t
code
)
{
...
...
@@ -809,7 +814,7 @@ static SSDataBlock* doFilterResult(SSysTableScanInfo* pInfo) {
code
=
filterSetDataFromSlotId
(
filter
,
&
param1
);
int8_t
*
rowRes
=
NULL
;
bool
keep
=
filterExecute
(
filter
,
pInfo
->
pRes
,
&
rowRes
,
NULL
,
param1
.
numOfCols
);
bool
keep
=
filterExecute
(
filter
,
pInfo
->
pRes
,
&
rowRes
,
NULL
,
param1
.
numOfCols
);
filterFreeInfo
(
filter
);
SSDataBlock
*
px
=
createOneDataBlock
(
pInfo
->
pRes
,
false
);
...
...
@@ -853,13 +858,13 @@ static SSDataBlock* doFilterResult(SSysTableScanInfo* pInfo) {
static
SSDataBlock
*
buildSysTableMetaBlock
()
{
SSDataBlock
*
pBlock
=
taosMemoryCalloc
(
1
,
sizeof
(
SSDataBlock
));
size_t
size
=
0
;
const
SSysTableMeta
*
pMeta
=
NULL
;
size_t
size
=
0
;
const
SSysTableMeta
*
pMeta
=
NULL
;
getInfosDbMeta
(
&
pMeta
,
&
size
);
int32_t
index
=
0
;
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
if
(
strcmp
(
pMeta
[
i
].
name
,
TSDB_INS_TABLE_USER_TABLES
)
==
0
)
{
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
if
(
strcmp
(
pMeta
[
i
].
name
,
TSDB_INS_TABLE_USER_TABLES
)
==
0
)
{
index
=
i
;
break
;
}
...
...
@@ -867,7 +872,7 @@ static SSDataBlock* buildSysTableMetaBlock() {
pBlock
->
pDataBlock
=
taosArrayInit
(
pBlock
->
info
.
numOfCols
,
sizeof
(
SColumnInfoData
));
for
(
int32_t
i
=
0
;
i
<
pMeta
[
index
].
colNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pMeta
[
index
].
colNum
;
++
i
)
{
SColumnInfoData
colInfoData
=
{
0
};
colInfoData
.
info
.
colId
=
i
+
1
;
colInfoData
.
info
.
type
=
pMeta
[
index
].
schema
[
i
].
type
;
...
...
@@ -1091,7 +1096,7 @@ int32_t buildSysDbTableInfo(const SSysTableScanInfo* pInfo, int32_t capacity) {
SSDataBlock
*
p
=
buildSysTableMetaBlock
();
blockDataEnsureCapacity
(
p
,
capacity
);
size_t
size
=
0
;
size_t
size
=
0
;
const
SSysTableMeta
*
pSysDbTableMeta
=
NULL
;
getInfosDbMeta
(
&
pSysDbTableMeta
,
&
size
);
...
...
@@ -1100,18 +1105,19 @@ int32_t buildSysDbTableInfo(const SSysTableScanInfo* pInfo, int32_t capacity) {
getPerfDbMeta
(
&
pSysDbTableMeta
,
&
size
);
p
->
info
.
rows
=
buildDbTableInfoBlock
(
p
,
pSysDbTableMeta
,
size
,
TSDB_PERFORMANCE_SCHEMA_DB
);
relocateColumnData
(
pInfo
->
pRes
,
pInfo
->
scanCols
,
p
->
pDataBlock
);
// blockDataDestroy(p); todo handle memory leak
relocateColumnData
(
pInfo
->
pRes
,
pInfo
->
scanCols
,
p
->
pDataBlock
);
// blockDataDestroy(p); todo handle memory leak
pInfo
->
pRes
->
info
.
rows
=
p
->
info
.
rows
;
return
p
->
info
.
rows
;
}
int32_t
buildDbTableInfoBlock
(
const
SSDataBlock
*
p
,
const
SSysTableMeta
*
pSysDbTableMeta
,
size_t
size
,
const
char
*
dbName
)
{
char
n
[
TSDB_TABLE_FNAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
int32_t
buildDbTableInfoBlock
(
const
SSDataBlock
*
p
,
const
SSysTableMeta
*
pSysDbTableMeta
,
size_t
size
,
const
char
*
dbName
)
{
char
n
[
TSDB_TABLE_FNAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
int32_t
numOfRows
=
p
->
info
.
rows
;
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
const
SSysTableMeta
*
pm
=
&
pSysDbTableMeta
[
i
];
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
p
->
pDataBlock
,
0
);
...
...
@@ -1132,7 +1138,7 @@ int32_t buildDbTableInfoBlock(const SSDataBlock* p, const SSysTableMeta* pSysDbT
pColInfoData
=
taosArrayGet
(
p
->
pDataBlock
,
3
);
colDataAppend
(
pColInfoData
,
numOfRows
,
(
char
*
)
&
pm
->
colNum
,
false
);
for
(
int32_t
j
=
4
;
j
<=
8
;
++
j
)
{
for
(
int32_t
j
=
4
;
j
<=
8
;
++
j
)
{
pColInfoData
=
taosArrayGet
(
p
->
pDataBlock
,
j
);
colDataAppendNULL
(
pColInfoData
,
numOfRows
);
}
...
...
@@ -1160,18 +1166,18 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSDataBlock* pRe
return
NULL
;
}
pInfo
->
accountId
=
accountId
;
pInfo
->
accountId
=
accountId
;
pInfo
->
showRewrite
=
showRewrite
;
pInfo
->
pRes
=
pResBlock
;
pInfo
->
pCondition
=
pCondition
;
pInfo
->
scanCols
=
colList
;
pInfo
->
pRes
=
pResBlock
;
pInfo
->
pCondition
=
pCondition
;
pInfo
->
scanCols
=
colList
;
initResultSizeInfo
(
pOperator
,
4096
);
tNameAssign
(
&
pInfo
->
name
,
pName
);
const
char
*
name
=
tNameGetTableName
(
&
pInfo
->
name
);
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_USER_TABLES
,
TSDB_TABLE_FNAME_LEN
)
==
0
)
{
pInfo
->
readHandle
=
*
(
SReadHandle
*
)
readHandle
;
pInfo
->
readHandle
=
*
(
SReadHandle
*
)
readHandle
;
blockDataEnsureCapacity
(
pInfo
->
pRes
,
pOperator
->
resultInfo
.
capacity
);
}
else
{
tsem_init
(
&
pInfo
->
ready
,
0
,
0
);
...
...
@@ -1201,14 +1207,14 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSDataBlock* pRe
#endif
}
pOperator
->
name
=
"SysTableScanOperator"
;
pOperator
->
name
=
"SysTableScanOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN
;
pOperator
->
blocking
=
false
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
info
=
pInfo
;
pOperator
->
numOfExprs
=
pResBlock
->
info
.
numOfCols
;
pOperator
->
fpSet
=
createOperatorFpSet
(
operatorDummyOpenFn
,
doSysTableScan
,
NULL
,
NULL
,
destroySysScanOperator
,
NULL
,
NULL
,
NULL
);
pOperator
->
blocking
=
false
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
info
=
pInfo
;
pOperator
->
numOfExprs
=
pResBlock
->
info
.
numOfCols
;
pOperator
->
fpSet
=
createOperatorFpSet
(
operatorDummyOpenFn
,
doSysTableScan
,
NULL
,
NULL
,
destroySysScanOperator
,
NULL
,
NULL
,
NULL
);
pOperator
->
pTaskInfo
=
pTaskInfo
;
return
pOperator
;
...
...
@@ -1355,26 +1361,27 @@ static void destroyTagScanOperatorInfo(void* param, int32_t numOfOutput) {
}
SOperatorInfo
*
createTagScanOperatorInfo
(
SReadHandle
*
pReadHandle
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
SSDataBlock
*
pResBlock
,
SArray
*
pColMatchInfo
,
STableGroupInfo
*
pTableGroupInfo
,
SExecTaskInfo
*
pTaskInfo
)
{
SSDataBlock
*
pResBlock
,
SArray
*
pColMatchInfo
,
STableGroupInfo
*
pTableGroupInfo
,
SExecTaskInfo
*
pTaskInfo
)
{
STagScanInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
STagScanInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
if
(
pInfo
==
NULL
||
pOperator
==
NULL
)
{
goto
_error
;
}
pInfo
->
pTableGroups
=
pTableGroupInfo
;
pInfo
->
pColMatchInfo
=
pColMatchInfo
;
pInfo
->
pRes
=
pResBlock
;
pInfo
->
readHandle
=
*
pReadHandle
;
pInfo
->
curPos
=
0
;
pOperator
->
name
=
"TagScanOperator"
;
pInfo
->
pTableGroups
=
pTableGroupInfo
;
pInfo
->
pColMatchInfo
=
pColMatchInfo
;
pInfo
->
pRes
=
pResBlock
;
pInfo
->
readHandle
=
*
pReadHandle
;
pInfo
->
curPos
=
0
;
pOperator
->
name
=
"TagScanOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN
;
pOperator
->
blocking
=
false
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
info
=
pInfo
;
pOperator
->
pExpr
=
pExpr
;
pOperator
->
numOfExprs
=
numOfOutput
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pOperator
->
blocking
=
false
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
info
=
pInfo
;
pOperator
->
pExpr
=
pExpr
;
pOperator
->
numOfExprs
=
numOfOutput
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
initResultSizeInfo
(
pOperator
,
4096
);
blockDataEnsureCapacity
(
pInfo
->
pRes
,
pOperator
->
resultInfo
.
capacity
);
...
...
source/libs/executor/src/timewindowoperator.c
浏览文件 @
306de052
#include "ttime.h"
#include "tdatablock.h"
#include "executorimpl.h"
#include "functionMgt.h"
#include "tdatablock.h"
#include "ttime.h"
typedef
enum
SResultTsInterpType
{
RESULT_ROW_START_INTERP
=
1
,
...
...
@@ -545,7 +545,6 @@ static void setResultRowInterpo(SResultRow* pResult, SResultTsInterpType type) {
}
}
static
void
doWindowBorderInterpolation
(
SOperatorInfo
*
pOperatorInfo
,
SSDataBlock
*
pBlock
,
SqlFunctionCtx
*
pCtx
,
SResultRow
*
pResult
,
STimeWindow
*
win
,
int32_t
startPos
,
int32_t
forwardStep
,
int32_t
order
,
bool
timeWindowInterpo
)
{
...
...
@@ -759,10 +758,10 @@ static int32_t doOpenIntervalAgg(SOperatorInfo* pOperator) {
return
TSDB_CODE_SUCCESS
;
}
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
SIntervalAggOperatorInfo
*
pInfo
=
pOperator
->
info
;
int32_t
order
=
TSDB_ORDER_ASC
;
int32_t
order
=
TSDB_ORDER_ASC
;
SOperatorInfo
*
downstream
=
pOperator
->
pDownstream
[
0
];
while
(
1
)
{
...
...
@@ -808,7 +807,7 @@ static int32_t doOpenIntervalAgg(SOperatorInfo* pOperator) {
}
static
void
doStateWindowAggImpl
(
SOperatorInfo
*
pOperator
,
SStateWindowOperatorInfo
*
pInfo
,
SSDataBlock
*
pBlock
)
{
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
SColumnInfoData
*
pStateColInfoData
=
taosArrayGet
(
pBlock
->
pDataBlock
,
pInfo
->
colIndex
);
int64_t
gid
=
pBlock
->
info
.
groupId
;
...
...
@@ -932,7 +931,7 @@ static SSDataBlock* doStateWindowAgg(SOperatorInfo* pOperator) {
static
SSDataBlock
*
doBuildIntervalResult
(
SOperatorInfo
*
pOperator
)
{
SIntervalAggOperatorInfo
*
pInfo
=
pOperator
->
info
;
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
if
(
pOperator
->
status
==
OP_EXEC_DONE
)
{
return
NULL
;
...
...
@@ -981,10 +980,10 @@ static void finalizeUpdatedResult(int32_t numOfOutput, SDiskbasedBuf* pBuf, SArr
}
}
static
void
setInverFunction
(
SqlFunctionCtx
*
pCtx
,
int32_t
num
,
EStreamType
type
)
{
for
(
int
i
=
0
;
i
<
num
;
i
++
)
{
for
(
int
i
=
0
;
i
<
num
;
i
++
)
{
if
(
type
==
STREAM_INVERT
)
{
fmSetInvertFunc
(
pCtx
[
i
].
functionId
,
&
(
pCtx
[
i
].
fpSet
));
}
else
if
(
type
==
STREAM_NORMAL
){
}
else
if
(
type
==
STREAM_NORMAL
)
{
fmSetNormalFunc
(
pCtx
[
i
].
functionId
,
&
(
pCtx
[
i
].
fpSet
));
}
}
...
...
@@ -992,7 +991,7 @@ static void setInverFunction(SqlFunctionCtx* pCtx, int32_t num, EStreamType type
static
SSDataBlock
*
doStreamIntervalAgg
(
SOperatorInfo
*
pOperator
)
{
SIntervalAggOperatorInfo
*
pInfo
=
pOperator
->
info
;
int32_t
order
=
TSDB_ORDER_ASC
;
int32_t
order
=
TSDB_ORDER_ASC
;
if
(
pOperator
->
status
==
OP_EXEC_DONE
)
{
return
NULL
;
...
...
@@ -1038,7 +1037,8 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
blockDataEnsureCapacity
(
pInfo
->
binfo
.
pRes
,
pOperator
->
resultInfo
.
capacity
);
doBuildResultDatablock
(
&
pInfo
->
binfo
,
&
pInfo
->
groupResInfo
,
pOperator
->
pExpr
,
pInfo
->
aggSup
.
pResultBuf
);
ASSERT
(
pInfo
->
binfo
.
pRes
->
info
.
rows
>
0
);
// TODO: remove for stream
/*ASSERT(pInfo->binfo.pRes->info.rows > 0);*/
pOperator
->
status
=
OP_RES_TO_RETURN
;
return
pInfo
->
binfo
.
pRes
->
info
.
rows
==
0
?
NULL
:
pInfo
->
binfo
.
pRes
;
...
...
@@ -1070,17 +1070,17 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo*
STimeWindowAggSupp
*
pTwAggSupp
,
const
STableGroupInfo
*
pTableGroupInfo
,
SExecTaskInfo
*
pTaskInfo
)
{
SIntervalAggOperatorInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SIntervalAggOperatorInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
if
(
pInfo
==
NULL
||
pOperator
==
NULL
)
{
goto
_error
;
}
pInfo
->
order
=
TSDB_ORDER_ASC
;
pInfo
->
interval
=
*
pInterval
;
pInfo
->
order
=
TSDB_ORDER_ASC
;
pInfo
->
interval
=
*
pInterval
;
// pInfo->execModel = OPTR_EXEC_MODEL_STREAM;
pInfo
->
execModel
=
pTaskInfo
->
execModel
;
pInfo
->
win
=
pTaskInfo
->
window
;
pInfo
->
twAggSup
=
*
pTwAggSupp
;
pInfo
->
execModel
=
pTaskInfo
->
execModel
;
pInfo
->
win
=
pTaskInfo
->
window
;
pInfo
->
twAggSup
=
*
pTwAggSupp
;
pInfo
->
primaryTsIndex
=
primaryTsSlotId
;
size_t
keyBufSize
=
sizeof
(
int64_t
)
+
sizeof
(
int64_t
)
+
POINTER_BYTES
;
...
...
@@ -1099,14 +1099,14 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo*
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
(
int32_t
)
1
);
pOperator
->
name
=
"TimeIntervalAggOperator"
;
pOperator
->
name
=
"TimeIntervalAggOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
;
pOperator
->
blocking
=
true
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
pExpr
=
pExprInfo
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pOperator
->
numOfExprs
=
numOfCols
;
pOperator
->
info
=
pInfo
;
pOperator
->
blocking
=
true
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
pExpr
=
pExprInfo
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pOperator
->
numOfExprs
=
numOfCols
;
pOperator
->
info
=
pInfo
;
pOperator
->
fpSet
=
createOperatorFpSet
(
doOpenIntervalAgg
,
doBuildIntervalResult
,
doStreamIntervalAgg
,
NULL
,
destroyIntervalOperatorInfo
,
aggEncodeResultRow
,
aggDecodeResultRow
,
NULL
);
...
...
@@ -1118,7 +1118,7 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo*
return
pOperator
;
_error:
_error:
destroyIntervalOperatorInfo
(
pInfo
,
numOfCols
);
taosMemoryFreeClear
(
pInfo
);
taosMemoryFreeClear
(
pOperator
);
...
...
@@ -1131,7 +1131,7 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SExpr
STimeWindowAggSupp
*
pTwAggSupp
,
const
STableGroupInfo
*
pTableGroupInfo
,
SExecTaskInfo
*
pTaskInfo
)
{
SIntervalAggOperatorInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SIntervalAggOperatorInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
if
(
pInfo
==
NULL
||
pOperator
==
NULL
)
{
goto
_error
;
}
...
...
@@ -1177,7 +1177,7 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SExpr
return
pOperator
;
_error:
_error:
destroyIntervalOperatorInfo
(
pInfo
,
numOfCols
);
taosMemoryFreeClear
(
pInfo
);
taosMemoryFreeClear
(
pOperator
);
...
...
@@ -1321,7 +1321,7 @@ static SSDataBlock* doAllIntervalAgg(SOperatorInfo* pOperator) {
return
pSliceInfo
->
binfo
.
pRes
;
}
int32_t
order
=
TSDB_ORDER_ASC
;
int32_t
order
=
TSDB_ORDER_ASC
;
SOperatorInfo
*
downstream
=
pOperator
->
pDownstream
[
0
];
while
(
1
)
{
...
...
@@ -1379,7 +1379,7 @@ SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SExprInfo*
int32_t
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
return
pOperator
;
_error:
_error:
taosMemoryFree
(
pInfo
);
taosMemoryFree
(
pOperator
);
pTaskInfo
->
code
=
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -1402,18 +1402,18 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SExprInf
initAggInfo
(
&
pInfo
->
binfo
,
&
pInfo
->
aggSup
,
pExpr
,
numOfCols
,
pResBlock
,
keyBufSize
,
pTaskInfo
->
id
.
str
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
);
pInfo
->
twAggSup
=
*
pTwAggSup
;
pInfo
->
twAggSup
=
*
pTwAggSup
;
initExecTimeWindowInfo
(
&
pInfo
->
twAggSup
.
timeWindowData
,
&
pTaskInfo
->
window
);
pInfo
->
tsSlotId
=
tsSlotId
;
pOperator
->
name
=
"StateWindowOperator"
;
pInfo
->
tsSlotId
=
tsSlotId
;
pOperator
->
name
=
"StateWindowOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW
;
pOperator
->
blocking
=
true
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
pExpr
=
pExpr
;
pOperator
->
numOfExprs
=
numOfCols
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pOperator
->
info
=
pInfo
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
pExpr
=
pExpr
;
pOperator
->
numOfExprs
=
numOfCols
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pOperator
->
info
=
pInfo
;
pOperator
->
fpSet
=
createOperatorFpSet
(
operatorDummyOpenFn
,
doStateWindowAgg
,
NULL
,
NULL
,
destroyStateWindowOperatorInfo
,
aggEncodeResultRow
,
aggDecodeResultRow
,
NULL
);
...
...
@@ -1421,7 +1421,7 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SExprInf
int32_t
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
return
pOperator
;
_error:
_error:
pTaskInfo
->
code
=
TSDB_CODE_SUCCESS
;
return
NULL
;
}
...
...
@@ -1432,8 +1432,8 @@ void destroySWindowOperatorInfo(void* param, int32_t numOfOutput) {
}
SOperatorInfo
*
createSessionAggOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResBlock
,
int64_t
gap
,
int32_t
tsSlotId
,
STimeWindowAggSupp
*
pTwAggSupp
,
SExecTaskInfo
*
pTaskInfo
)
{
SSDataBlock
*
pResBlock
,
int64_t
gap
,
int32_t
tsSlotId
,
S
TimeWindowAggSupp
*
pTwAggSupp
,
S
ExecTaskInfo
*
pTaskInfo
)
{
SSessionAggOperatorInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SSessionAggOperatorInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
if
(
pInfo
==
NULL
||
pOperator
==
NULL
)
{
...
...
@@ -1453,18 +1453,18 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
);
initExecTimeWindowInfo
(
&
pInfo
->
twAggSup
.
timeWindowData
,
&
pTaskInfo
->
window
);
pInfo
->
tsSlotId
=
tsSlotId
;
pInfo
->
gap
=
gap
;
pInfo
->
binfo
.
pRes
=
pResBlock
;
pInfo
->
winSup
.
prevTs
=
INT64_MIN
;
pInfo
->
reptScan
=
false
;
pOperator
->
name
=
"SessionWindowAggOperator"
;
pInfo
->
tsSlotId
=
tsSlotId
;
pInfo
->
gap
=
gap
;
pInfo
->
binfo
.
pRes
=
pResBlock
;
pInfo
->
winSup
.
prevTs
=
INT64_MIN
;
pInfo
->
reptScan
=
false
;
pOperator
->
name
=
"SessionWindowAggOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW
;
pOperator
->
blocking
=
true
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
pExpr
=
pExprInfo
;
pOperator
->
numOfExprs
=
numOfCols
;
pOperator
->
info
=
pInfo
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
pExpr
=
pExprInfo
;
pOperator
->
numOfExprs
=
numOfCols
;
pOperator
->
info
=
pInfo
;
pOperator
->
fpSet
=
createOperatorFpSet
(
operatorDummyOpenFn
,
doSessionWindowAgg
,
NULL
,
NULL
,
destroySWindowOperatorInfo
,
aggEncodeResultRow
,
aggDecodeResultRow
,
NULL
);
...
...
@@ -1473,7 +1473,7 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
return
pOperator
;
_error:
_error:
if
(
pInfo
!=
NULL
)
{
destroySWindowOperatorInfo
(
pInfo
,
numOfCols
);
}
...
...
@@ -1482,4 +1482,4 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo
taosMemoryFreeClear
(
pOperator
);
pTaskInfo
->
code
=
code
;
return
NULL
;
}
\ No newline at end of file
}
source/libs/function/src/tudf.c
浏览文件 @
306de052
...
...
@@ -146,15 +146,15 @@ typedef struct SUdfdProxy {
SUdfdProxy
gUdfdProxy
=
{
0
};
typedef
struct
SUdfUvSession
{
typedef
struct
S
Client
UdfUvSession
{
SUdfdProxy
*
udfc
;
int64_t
severHandle
;
uv_pipe_t
*
udf
Svc
Pipe
;
uv_pipe_t
*
udf
Uv
Pipe
;
int8_t
outputType
;
int32_t
outputLen
;
int32_t
bufSize
;
}
SUdfUvSession
;
}
S
Client
UdfUvSession
;
typedef
struct
SClientUvTaskNode
{
SUdfdProxy
*
udfc
;
...
...
@@ -177,7 +177,7 @@ typedef struct SClientUvTaskNode {
typedef
struct
SClientUdfTask
{
int8_t
type
;
SUdfUvSession
*
session
;
S
Client
UdfUvSession
*
session
;
int32_t
errCode
;
...
...
@@ -209,6 +209,7 @@ typedef struct SClientUvConn {
uv_pipe_t
*
pipe
;
QUEUE
taskQueue
;
SClientConnBuf
readBuf
;
SClientUdfUvSession
*
session
;
}
SClientUvConn
;
enum
{
...
...
@@ -617,18 +618,17 @@ void onUdfcPipeClose(uv_handle_t *handle) {
QUEUE
*
h
=
QUEUE_HEAD
(
&
conn
->
taskQueue
);
SClientUvTaskNode
*
task
=
QUEUE_DATA
(
h
,
SClientUvTaskNode
,
connTaskQueue
);
task
->
errCode
=
0
;
uv_sem_post
(
&
task
->
taskSem
);
QUEUE_REMOVE
(
&
task
->
procTaskQueue
);
uv_sem_post
(
&
task
->
taskSem
);
}
conn
->
session
->
udfUvPipe
=
NULL
;
taosMemoryFree
(
conn
->
readBuf
.
buf
);
taosMemoryFree
(
conn
);
taosMemoryFree
((
uv_pipe_t
*
)
handle
);
}
int32_t
udfcGetU
vTaskResponseResult
(
SClientUdfTask
*
task
,
SClientUvTaskNode
*
uvTask
)
{
fnDebug
(
"udfc get uv task result. task: %p
"
,
t
ask
);
int32_t
udfcGetU
dfTaskResultFromUvTask
(
SClientUdfTask
*
task
,
SClientUvTaskNode
*
uvTask
)
{
fnDebug
(
"udfc get uv task result. task: %p
, uvTask: %p"
,
task
,
uvT
ask
);
if
(
uvTask
->
type
==
UV_TASK_REQ_RSP
)
{
if
(
uvTask
->
rspBuf
.
base
!=
NULL
)
{
SUdfResponse
rsp
;
...
...
@@ -748,8 +748,8 @@ void udfcUvHandleRsp(SClientUvConn *conn) {
if
(
taskFound
)
{
taskFound
->
rspBuf
=
uv_buf_init
(
connBuf
->
buf
,
connBuf
->
len
);
QUEUE_REMOVE
(
&
taskFound
->
connTaskQueue
);
uv_sem_post
(
&
taskFound
->
taskSem
);
QUEUE_REMOVE
(
&
taskFound
->
procTaskQueue
);
uv_sem_post
(
&
taskFound
->
taskSem
);
}
else
{
fnError
(
"no task is waiting for the response."
);
}
...
...
@@ -764,14 +764,12 @@ void udfcUvHandleError(SClientUvConn *conn) {
QUEUE
*
h
=
QUEUE_HEAD
(
&
conn
->
taskQueue
);
SClientUvTaskNode
*
task
=
QUEUE_DATA
(
h
,
SClientUvTaskNode
,
connTaskQueue
);
task
->
errCode
=
UDFC_CODE_PIPE_READ_ERR
;
uv_sem_post
(
&
task
->
taskSem
);
QUEUE_REMOVE
(
&
task
->
connTaskQueue
);
QUEUE_REMOVE
(
&
task
->
procTaskQueue
);
uv_sem_post
(
&
task
->
taskSem
);
}
uv_close
((
uv_handle_t
*
)
conn
->
pipe
,
NULL
);
taosMemoryFree
(
conn
->
pipe
);
taosMemoryFree
(
conn
->
readBuf
.
buf
);
taosMemoryFree
(
conn
);
uv_close
((
uv_handle_t
*
)
conn
->
pipe
,
onUdfcPipeClose
);
}
void
onUdfcRead
(
uv_stream_t
*
client
,
ssize_t
nread
,
const
uv_buf_t
*
buf
)
{
...
...
@@ -788,9 +786,9 @@ void onUdfcRead(uv_stream_t *client, ssize_t nread, const uv_buf_t *buf) {
}
if
(
nread
<
0
)
{
fnError
(
"udfc client pipe %p read error: %
s"
,
client
,
uv_strerror
(
nread
));
fnError
(
"udfc client pipe %p read error: %
zd, %s."
,
client
,
nread
,
uv_strerror
(
nread
));
if
(
nread
==
UV_EOF
)
{
fnError
(
"udfc client pipe %p closed"
,
client
);
fnError
(
"
\t
udfc client pipe %p closed"
,
client
);
}
udfcUvHandleError
(
conn
);
}
...
...
@@ -823,14 +821,14 @@ void onUdfClientConnect(uv_connect_t *connect, int status) {
QUEUE_REMOVE
(
&
uvTask
->
procTaskQueue
);
}
int32_t
createUdfc
UvTask
(
SClientUdfTask
*
task
,
int8_t
uvTaskType
,
SClientUvTaskNode
**
pUvTask
)
{
int32_t
udfcCreate
UvTask
(
SClientUdfTask
*
task
,
int8_t
uvTaskType
,
SClientUvTaskNode
**
pUvTask
)
{
SClientUvTaskNode
*
uvTask
=
taosMemoryCalloc
(
1
,
sizeof
(
SClientUvTaskNode
));
uvTask
->
type
=
uvTaskType
;
uvTask
->
udfc
=
task
->
session
->
udfc
;
if
(
uvTaskType
==
UV_TASK_CONNECT
)
{
}
else
if
(
uvTaskType
==
UV_TASK_REQ_RSP
)
{
uvTask
->
pipe
=
task
->
session
->
udf
Svc
Pipe
;
uvTask
->
pipe
=
task
->
session
->
udf
Uv
Pipe
;
SUdfRequest
request
;
request
.
type
=
task
->
type
;
request
.
seqNum
=
atomic_fetch_add_64
(
&
gUdfTaskSeqNum
,
1
);
...
...
@@ -855,7 +853,7 @@ int32_t createUdfcUvTask(SClientUdfTask *task, int8_t uvTaskType, SClientUvTaskN
uvTask
->
reqBuf
=
uv_buf_init
(
bufBegin
,
bufLen
);
uvTask
->
seqNum
=
request
.
seqNum
;
}
else
if
(
uvTaskType
==
UV_TASK_DISCONNECT
)
{
uvTask
->
pipe
=
task
->
session
->
udf
Svc
Pipe
;
uvTask
->
pipe
=
task
->
session
->
udf
Uv
Pipe
;
}
uv_sem_init
(
&
uvTask
->
taskSem
,
0
);
...
...
@@ -863,7 +861,7 @@ int32_t createUdfcUvTask(SClientUdfTask *task, int8_t uvTaskType, SClientUvTaskN
return
0
;
}
int32_t
queueUvUdf
Task
(
SClientUvTaskNode
*
uvTask
)
{
int32_t
udfcQueueUv
Task
(
SClientUvTaskNode
*
uvTask
)
{
fnTrace
(
"queue uv task to event loop, task: %d, %p"
,
uvTask
->
type
,
uvTask
);
SUdfdProxy
*
udfc
=
uvTask
->
udfc
;
uv_mutex_lock
(
&
udfc
->
gUdfTaskQueueMutex
);
...
...
@@ -872,12 +870,13 @@ int32_t queueUvUdfTask(SClientUvTaskNode *uvTask) {
uv_async_send
(
&
udfc
->
gUdfLoopTaskAync
);
uv_sem_wait
(
&
uvTask
->
taskSem
);
fnInfo
(
"udfc uv task finished. task: %d, %p"
,
uvTask
->
type
,
uvTask
);
uv_sem_destroy
(
&
uvTask
->
taskSem
);
return
0
;
}
int32_t
startUvUdf
Task
(
SClientUvTaskNode
*
uvTask
)
{
int32_t
udfcStartUv
Task
(
SClientUvTaskNode
*
uvTask
)
{
fnTrace
(
"event loop start uv task. task: %d, %p"
,
uvTask
->
type
,
uvTask
);
switch
(
uvTask
->
type
)
{
case
UV_TASK_CONNECT
:
{
...
...
@@ -885,7 +884,7 @@ int32_t startUvUdfTask(SClientUvTaskNode *uvTask) {
uv_pipe_init
(
&
uvTask
->
udfc
->
gUdfdLoop
,
pipe
,
0
);
uvTask
->
pipe
=
pipe
;
SClientUvConn
*
conn
=
taosMemory
Malloc
(
sizeof
(
SClientUvConn
));
SClientUvConn
*
conn
=
taosMemory
Calloc
(
1
,
sizeof
(
SClientUvConn
));
conn
->
pipe
=
pipe
;
conn
->
readBuf
.
len
=
0
;
conn
->
readBuf
.
cap
=
0
;
...
...
@@ -933,13 +932,14 @@ void udfClientAsyncCb(uv_async_t *async) {
QUEUE
*
h
=
QUEUE_HEAD
(
&
wq
);
QUEUE_REMOVE
(
h
);
SClientUvTaskNode
*
task
=
QUEUE_DATA
(
h
,
SClientUvTaskNode
,
recvTaskQueue
);
startUvUdf
Task
(
task
);
udfcStartUv
Task
(
task
);
QUEUE_INSERT_TAIL
(
&
udfc
->
gUvProcTaskQueue
,
&
task
->
procTaskQueue
);
}
}
void
cleanUpUvTasks
(
SUdfdProxy
*
udfc
)
{
fnDebug
(
"clean up uv tasks"
)
QUEUE
wq
;
uv_mutex_lock
(
&
udfc
->
gUdfTaskQueueMutex
);
...
...
@@ -956,7 +956,6 @@ void cleanUpUvTasks(SUdfdProxy *udfc) {
uv_sem_post
(
&
task
->
taskSem
);
}
// TODO: deal with tasks that are waiting result.
while
(
!
QUEUE_EMPTY
(
&
udfc
->
gUvProcTaskQueue
))
{
QUEUE
*
h
=
QUEUE_HEAD
(
&
udfc
->
gUvProcTaskQueue
);
QUEUE_REMOVE
(
h
);
...
...
@@ -1027,14 +1026,16 @@ int32_t udfcClose() {
return
0
;
}
int32_t
udfcRunUvTask
(
SClientUdfTask
*
task
,
int8_t
uvTaskType
)
{
int32_t
udfcRunU
dfU
vTask
(
SClientUdfTask
*
task
,
int8_t
uvTaskType
)
{
SClientUvTaskNode
*
uvTask
=
NULL
;
createUdfc
UvTask
(
task
,
uvTaskType
,
&
uvTask
);
queueUvUdf
Task
(
uvTask
);
udfcGetU
vTaskResponseResult
(
task
,
uvTask
);
udfcCreate
UvTask
(
task
,
uvTaskType
,
&
uvTask
);
udfcQueueUv
Task
(
uvTask
);
udfcGetU
dfTaskResultFromUvTask
(
task
,
uvTask
);
if
(
uvTaskType
==
UV_TASK_CONNECT
)
{
task
->
session
->
udfSvcPipe
=
uvTask
->
pipe
;
task
->
session
->
udfUvPipe
=
uvTask
->
pipe
;
SClientUvConn
*
conn
=
uvTask
->
pipe
->
data
;
conn
->
session
=
task
->
session
;
}
taosMemoryFree
(
uvTask
);
uvTask
=
NULL
;
...
...
@@ -1046,22 +1047,22 @@ int32_t setupUdf(char udfName[], UdfcFuncHandle *funcHandle) {
if
(
gUdfdProxy
.
gUdfcState
!=
UDFC_STATE_READY
)
{
return
UDFC_CODE_INVALID_STATE
;
}
SClientUdfTask
*
task
=
taosMemory
Malloc
(
sizeof
(
SClientUdfTask
));
SClientUdfTask
*
task
=
taosMemory
Calloc
(
1
,
sizeof
(
SClientUdfTask
));
task
->
errCode
=
0
;
task
->
session
=
taosMemory
Malloc
(
sizeof
(
S
UdfUvSession
));
task
->
session
=
taosMemory
Calloc
(
1
,
sizeof
(
SClient
UdfUvSession
));
task
->
session
->
udfc
=
&
gUdfdProxy
;
task
->
type
=
UDF_TASK_SETUP
;
SUdfSetupRequest
*
req
=
&
task
->
_setup
.
req
;
memcpy
(
req
->
udfName
,
udfName
,
TSDB_FUNC_NAME_LEN
);
int32_t
errCode
=
udfcRunUvTask
(
task
,
UV_TASK_CONNECT
);
int32_t
errCode
=
udfcRunU
dfU
vTask
(
task
,
UV_TASK_CONNECT
);
if
(
errCode
!=
0
)
{
fnError
(
"failed to connect to pipe. udfName: %s, pipe: %s"
,
udfName
,
(
&
gUdfdProxy
)
->
udfdPipeName
);
return
UDFC_CODE_CONNECT_PIPE_ERR
;
}
udfcRunUvTask
(
task
,
UV_TASK_REQ_RSP
);
udfcRunU
dfU
vTask
(
task
,
UV_TASK_REQ_RSP
);
SUdfSetupResponse
*
rsp
=
&
task
->
_setup
.
rsp
;
task
->
session
->
severHandle
=
rsp
->
udfHandle
;
...
...
@@ -1082,10 +1083,14 @@ int32_t setupUdf(char udfName[], UdfcFuncHandle *funcHandle) {
int32_t
callUdf
(
UdfcFuncHandle
handle
,
int8_t
callType
,
SSDataBlock
*
input
,
SUdfInterBuf
*
state
,
SUdfInterBuf
*
state2
,
SSDataBlock
*
output
,
SUdfInterBuf
*
newState
)
{
fnTrace
(
"udfc call udf. callType: %d, funcHandle: %p"
,
callType
,
handle
);
SClientUdfTask
*
task
=
taosMemoryMalloc
(
sizeof
(
SClientUdfTask
));
SClientUdfUvSession
*
session
=
(
SClientUdfUvSession
*
)
handle
;
if
(
session
->
udfUvPipe
==
NULL
)
{
fnError
(
"No pipe to udfd"
);
return
UDFC_CODE_NO_PIPE
;
}
SClientUdfTask
*
task
=
taosMemoryCalloc
(
1
,
sizeof
(
SClientUdfTask
));
task
->
errCode
=
0
;
task
->
session
=
(
SUdfUvSession
*
)
handle
;
task
->
session
=
(
S
Client
UdfUvSession
*
)
handle
;
task
->
type
=
UDF_TASK_CALL
;
SUdfCallRequest
*
req
=
&
task
->
_call
.
req
;
...
...
@@ -1117,7 +1122,7 @@ int32_t callUdf(UdfcFuncHandle handle, int8_t callType, SSDataBlock *input, SUdf
}
}
udfcRunUvTask
(
task
,
UV_TASK_REQ_RSP
);
udfcRunU
dfU
vTask
(
task
,
UV_TASK_REQ_RSP
);
if
(
task
->
errCode
!=
0
)
{
fnError
(
"call udf failure. err: %d"
,
task
->
errCode
);
...
...
@@ -1145,9 +1150,10 @@ int32_t callUdf(UdfcFuncHandle handle, int8_t callType, SSDataBlock *input, SUdf
break
;
}
}
}
};
int
err
=
task
->
errCode
;
taosMemoryFree
(
task
);
return
task
->
errCode
;
return
err
;
}
int32_t
callUdfAggInit
(
UdfcFuncHandle
handle
,
SUdfInterBuf
*
interBuf
)
{
...
...
@@ -1188,28 +1194,36 @@ int32_t callUdfScalarFunc(UdfcFuncHandle handle, SScalarParam *input, int32_t nu
convertScalarParamToDataBlock
(
input
,
numOfCols
,
&
inputBlock
);
SSDataBlock
resultBlock
=
{
0
};
int32_t
err
=
callUdf
(
handle
,
callType
,
&
inputBlock
,
NULL
,
NULL
,
&
resultBlock
,
NULL
);
convertDataBlockToScalarParm
(
&
resultBlock
,
output
);
if
(
err
==
0
)
{
convertDataBlockToScalarParm
(
&
resultBlock
,
output
);
}
return
err
;
}
int32_t
teardownUdf
(
UdfcFuncHandle
handle
)
{
fnInfo
(
"tear down udf. udf func handle: %p"
,
handle
);
SClientUdfTask
*
task
=
taosMemoryMalloc
(
sizeof
(
SClientUdfTask
));
SClientUdfUvSession
*
session
=
(
SClientUdfUvSession
*
)
handle
;
if
(
session
->
udfUvPipe
==
NULL
)
{
fnError
(
"pipe to udfd does not exist"
);
return
UDFC_CODE_NO_PIPE
;
}
SClientUdfTask
*
task
=
taosMemoryCalloc
(
1
,
sizeof
(
SClientUdfTask
));
task
->
errCode
=
0
;
task
->
session
=
(
SUdfUvSession
*
)
handle
;
task
->
session
=
session
;
task
->
type
=
UDF_TASK_TEARDOWN
;
SUdfTeardownRequest
*
req
=
&
task
->
_teardown
.
req
;
req
->
udfHandle
=
task
->
session
->
severHandle
;
udfcRunUvTask
(
task
,
UV_TASK_REQ_RSP
);
udfcRunU
dfU
vTask
(
task
,
UV_TASK_REQ_RSP
);
SUdfTeardownResponse
*
rsp
=
&
task
->
_teardown
.
rsp
;
int32_t
err
=
task
->
errCode
;
udfcRunUvTask
(
task
,
UV_TASK_DISCONNECT
);
udfcRunU
dfU
vTask
(
task
,
UV_TASK_DISCONNECT
);
taosMemoryFree
(
task
->
session
);
taosMemoryFree
(
task
);
...
...
@@ -1219,7 +1233,7 @@ int32_t teardownUdf(UdfcFuncHandle handle) {
//memory layout |---SUdfAggRes----|-----final result-----|---inter result----|
typedef
struct
SUdfAggRes
{
SUdfUvSession
*
session
;
S
Client
UdfUvSession
*
session
;
int8_t
finalResNum
;
int8_t
interResNum
;
char
*
finalResBuf
;
...
...
@@ -1242,7 +1256,7 @@ bool udfAggInit(struct SqlFunctionCtx *pCtx, struct SResultRowEntryInfo* pResult
if
(
setupUdf
((
char
*
)
pCtx
->
udfName
,
&
handle
)
!=
0
)
{
return
false
;
}
S
UdfUvSession
*
session
=
(
S
UdfUvSession
*
)
handle
;
S
ClientUdfUvSession
*
session
=
(
SClient
UdfUvSession
*
)
handle
;
SUdfAggRes
*
udfRes
=
(
SUdfAggRes
*
)
GET_ROWCELL_INTERBUF
(
pResultCellInfo
);
int32_t
envSize
=
sizeof
(
SUdfAggRes
)
+
session
->
outputLen
+
session
->
bufSize
;
memset
(
udfRes
,
0
,
envSize
);
...
...
@@ -1250,7 +1264,7 @@ bool udfAggInit(struct SqlFunctionCtx *pCtx, struct SResultRowEntryInfo* pResult
udfRes
->
finalResBuf
=
(
char
*
)
udfRes
+
sizeof
(
SUdfAggRes
);
udfRes
->
interResBuf
=
(
char
*
)
udfRes
+
sizeof
(
SUdfAggRes
)
+
session
->
outputLen
;
udfRes
->
session
=
(
SUdfUvSession
*
)
handle
;
udfRes
->
session
=
(
S
Client
UdfUvSession
*
)
handle
;
SUdfInterBuf
buf
=
{
0
};
if
(
callUdfAggInit
(
handle
,
&
buf
)
!=
0
)
{
return
false
;
...
...
@@ -1265,7 +1279,7 @@ int32_t udfAggProcess(struct SqlFunctionCtx *pCtx) {
int32_t
numOfCols
=
pInput
->
numOfInputCols
;
SUdfAggRes
*
udfRes
=
(
SUdfAggRes
*
)
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
SUdfUvSession
*
session
=
udfRes
->
session
;
S
Client
UdfUvSession
*
session
=
udfRes
->
session
;
udfRes
->
finalResBuf
=
(
char
*
)
udfRes
+
sizeof
(
SUdfAggRes
);
udfRes
->
interResBuf
=
(
char
*
)
udfRes
+
sizeof
(
SUdfAggRes
)
+
session
->
outputLen
;
...
...
@@ -1315,7 +1329,7 @@ int32_t udfAggProcess(struct SqlFunctionCtx *pCtx) {
int32_t
udfAggFinalize
(
struct
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
)
{
SUdfAggRes
*
udfRes
=
(
SUdfAggRes
*
)
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
SUdfUvSession
*
session
=
udfRes
->
session
;
S
Client
UdfUvSession
*
session
=
udfRes
->
session
;
udfRes
->
finalResBuf
=
(
char
*
)
udfRes
+
sizeof
(
SUdfAggRes
);
udfRes
->
interResBuf
=
(
char
*
)
udfRes
+
sizeof
(
SUdfAggRes
)
+
session
->
outputLen
;
...
...
source/libs/function/test/udf1.c
浏览文件 @
306de052
...
...
@@ -26,11 +26,18 @@ int32_t udf1(SUdfDataBlock* block, SUdfColumn *resultCol) {
SUdfColumnData
*
resultData
=
&
resultCol
->
colData
;
resultData
->
numOfRows
=
block
->
numOfRows
;
SUdfColumnData
*
srcData
=
&
block
->
udfCols
[
0
]
->
colData
;
for
(
int32_t
i
=
0
;
i
<
resultData
->
numOfRows
;
++
i
)
{
int32_t
luckyNum
=
88
;
udfColSetRow
(
resultCol
,
i
,
(
char
*
)
&
luckyNum
,
false
);
int
j
=
0
;
for
(;
j
<
block
->
numOfCols
;
++
j
)
{
if
(
udfColDataIsNull
(
block
->
udfCols
[
j
],
i
))
{
udfColDataSetNull
(
resultCol
,
i
);
break
;
}
}
if
(
j
==
block
->
numOfCols
)
{
int32_t
luckyNum
=
88
;
udfColDataSet
(
resultCol
,
i
,
(
char
*
)
&
luckyNum
,
false
);
}
}
return
0
;
...
...
source/libs/function/test/udf2.c
浏览文件 @
306de052
...
...
@@ -26,24 +26,34 @@ int32_t udf2_start(SUdfInterBuf *buf) {
int32_t
udf2
(
SUdfDataBlock
*
block
,
SUdfInterBuf
*
interBuf
,
SUdfInterBuf
*
newInterBuf
)
{
int64_t
sumSquares
=
*
(
int64_t
*
)
interBuf
->
buf
;
int8_t
numOutput
=
0
;
for
(
int32_t
i
=
0
;
i
<
block
->
numOfCols
;
++
i
)
{
for
(
int32_t
j
=
0
;
j
<
block
->
numOfRows
;
++
j
)
{
SUdfColumn
*
col
=
block
->
udfCols
[
i
];
//TODO: check the bitmap for null value
int32_t
*
rows
=
(
int32_t
*
)
col
->
colData
.
fixLenCol
.
data
;
sumSquares
+=
rows
[
j
]
*
rows
[
j
];
if
(
udfColDataIsNull
(
col
,
j
))
{
continue
;
}
char
*
cell
=
udfColDataGetData
(
col
,
j
);
int32_t
num
=
*
(
int32_t
*
)
cell
;
sumSquares
+=
num
*
num
;
numOutput
=
1
;
}
}
*
(
int64_t
*
)(
newInterBuf
->
buf
)
=
sumSquares
;
newInterBuf
->
bufLen
=
sizeof
(
int64_t
);
//TODO: if all null value, numOfResult = 0;
newInterBuf
->
numOfResult
=
1
;
if
(
numOutput
==
1
)
{
*
(
int64_t
*
)(
newInterBuf
->
buf
)
=
sumSquares
;
newInterBuf
->
bufLen
=
sizeof
(
int64_t
);
}
newInterBuf
->
numOfResult
=
numOutput
;
return
0
;
}
int32_t
udf2_finish
(
SUdfInterBuf
*
buf
,
SUdfInterBuf
*
resultData
)
{
//TODO: check numOfResults;
if
(
buf
->
numOfResult
==
0
)
{
resultData
->
numOfResult
=
0
;
return
0
;
}
int64_t
sumSquares
=
*
(
int64_t
*
)(
buf
->
buf
);
*
(
double
*
)(
resultData
->
buf
)
=
sqrt
(
sumSquares
);
resultData
->
bufLen
=
sizeof
(
double
);
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
306de052
...
...
@@ -112,6 +112,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
return
makeNode
(
type
,
sizeof
(
SDropTableStmt
));
case
QUERY_NODE_DROP_SUPER_TABLE_STMT
:
return
makeNode
(
type
,
sizeof
(
SDropSuperTableStmt
));
case
QUERY_NODE_ALTER_TABLE_STMT
:
return
makeNode
(
type
,
sizeof
(
SAlterTableStmt
));
case
QUERY_NODE_CREATE_USER_STMT
:
return
makeNode
(
type
,
sizeof
(
SCreateUserStmt
));
case
QUERY_NODE_ALTER_USER_STMT
:
...
...
@@ -155,7 +157,7 @@ SNodeptr nodesMakeNode(ENodeType type) {
case
QUERY_NODE_CREATE_FUNCTION_STMT
:
return
makeNode
(
type
,
sizeof
(
SCreateFunctionStmt
));
case
QUERY_NODE_DROP_FUNCTION_STMT
:
break
;
return
makeNode
(
type
,
sizeof
(
SDropFunctionStmt
))
;
case
QUERY_NODE_CREATE_STREAM_STMT
:
return
makeNode
(
type
,
sizeof
(
SCreateStreamStmt
));
case
QUERY_NODE_DROP_STREAM_STMT
:
...
...
@@ -165,6 +167,10 @@ SNodeptr nodesMakeNode(ENodeType type) {
case
QUERY_NODE_SPLIT_VGROUP_STMT
:
case
QUERY_NODE_SYNCDB_STMT
:
break
;
case
QUERY_NODE_GRANT_STMT
:
return
makeNode
(
type
,
sizeof
(
SGrantStmt
));
case
QUERY_NODE_REVOKE_STMT
:
return
makeNode
(
type
,
sizeof
(
SRevokeStmt
));
case
QUERY_NODE_SHOW_DNODES_STMT
:
case
QUERY_NODE_SHOW_MNODES_STMT
:
case
QUERY_NODE_SHOW_MODULES_STMT
:
...
...
@@ -195,9 +201,11 @@ SNodeptr nodesMakeNode(ENodeType type) {
case
QUERY_NODE_SHOW_CREATE_DATABASE_STMT
:
case
QUERY_NODE_SHOW_CREATE_TABLE_STMT
:
case
QUERY_NODE_SHOW_CREATE_STABLE_STMT
:
case
QUERY_NODE_SHOW_TRANSACTIONS_STMT
:
return
makeNode
(
type
,
sizeof
(
SShowStmt
));
case
QUERY_NODE_KILL_CONNECTION_STMT
:
case
QUERY_NODE_KILL_QUERY_STMT
:
case
QUERY_NODE_KILL_TRANSACTION_STMT
:
return
makeNode
(
type
,
sizeof
(
SKillStmt
));
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
return
makeNode
(
type
,
sizeof
(
SScanLogicNode
));
...
...
source/libs/parser/inc/parAst.h
浏览文件 @
306de052
...
...
@@ -178,7 +178,7 @@ SNode* createResetQueryCacheStmt(SAstCreateContext* pCxt);
SNode
*
createCompactStmt
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pVgroups
);
SNode
*
createCreateFunctionStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
bool
aggFunc
,
const
SToken
*
pFuncName
,
const
SToken
*
pLibPath
,
SDataType
dataType
,
int32_t
bufSize
);
SNode
*
createDropFunctionStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pFuncName
);
SNode
*
createDropFunctionStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
const
SToken
*
pFuncName
);
SNode
*
createStreamOptions
(
SAstCreateContext
*
pCxt
);
SNode
*
createCreateStreamStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pStreamName
,
SNode
*
pRealTable
,
SNode
*
pOptions
,
SNode
*
pQuery
);
...
...
@@ -188,6 +188,8 @@ SNode* createMergeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId1, cons
SNode
*
createRedistributeVgroupStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pVgId
,
SNodeList
*
pDnodes
);
SNode
*
createSplitVgroupStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pVgId
);
SNode
*
createSyncdbStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDbName
);
SNode
*
createGrantStmt
(
SAstCreateContext
*
pCxt
,
int64_t
privileges
,
SToken
*
pDbName
,
SToken
*
pUserName
);
SNode
*
createRevokeStmt
(
SAstCreateContext
*
pCxt
,
int64_t
privileges
,
SToken
*
pDbName
,
SToken
*
pUserName
);
#ifdef __cplusplus
}
...
...
source/libs/parser/inc/parInt.h
浏览文件 @
306de052
...
...
@@ -26,6 +26,7 @@ extern "C" {
int32_t
parseInsertSql
(
SParseContext
*
pContext
,
SQuery
**
pQuery
);
int32_t
parse
(
SParseContext
*
pParseCxt
,
SQuery
**
pQuery
);
int32_t
authenticate
(
SParseContext
*
pParseCxt
,
SQuery
*
pQuery
);
int32_t
translate
(
SParseContext
*
pParseCxt
,
SQuery
*
pQuery
);
int32_t
extractResultSchema
(
const
SNode
*
pRoot
,
int32_t
*
numOfCols
,
SSchema
**
pSchema
);
int32_t
calculateConstant
(
SParseContext
*
pParseCxt
,
SQuery
*
pQuery
);
...
...
source/libs/parser/inc/sql.y
浏览文件 @
306de052
...
...
@@ -81,6 +81,30 @@ cmd ::= ALTER USER user_name(A) PASS NK_STRING(B).
cmd ::= ALTER USER user_name(A) PRIVILEGE NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PRIVILEGES, &B); }
cmd ::= DROP USER user_name(A). { pCxt->pRootNode = createDropUserStmt(pCxt, &A); }
/************************************************ grant/revoke ********************************************************/
cmd ::= GRANT privileges(A) ON priv_level(B) TO user_name(C). { pCxt->pRootNode = createGrantStmt(pCxt, A, &B, &C); }
cmd ::= REVOKE privileges(A) ON priv_level(B) FROM user_name(C). { pCxt->pRootNode = createRevokeStmt(pCxt, A, &B, &C); }
%type privileges { int64_t }
%destructor privileges { }
privileges(A) ::= ALL. { A = PRIVILEGE_TYPE_ALL; }
privileges(A) ::= priv_type_list(B). { A = B; }
%type priv_type_list { int64_t }
%destructor priv_type_list { }
priv_type_list(A) ::= priv_type(B). { A = B; }
priv_type_list(A) ::= priv_type_list(B) NK_COMMA priv_type(C). { A = B | C; }
%type priv_type { int64_t }
%destructor priv_type { }
priv_type(A) ::= READ. { A = PRIVILEGE_TYPE_READ; }
priv_type(A) ::= WRITE. { A = PRIVILEGE_TYPE_WRITE; }
%type priv_level { SToken }
%destructor priv_level { }
priv_level(A) ::= NK_STAR(B) NK_DOT NK_STAR. { A = B; }
priv_level(A) ::= db_name(B) NK_DOT NK_STAR. { A = B; }
/************************************************ create/drop/alter dnode *********************************************/
cmd ::= CREATE DNODE dnode_endpoint(A). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, NULL); }
cmd ::= CREATE DNODE dnode_host_name(A) PORT NK_INTEGER(B). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, &B); }
...
...
@@ -337,6 +361,7 @@ cmd ::= SHOW VARIABLES.
cmd ::= SHOW BNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT, NULL, NULL); }
cmd ::= SHOW SNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SNODES_STMT, NULL, NULL); }
cmd ::= SHOW CLUSTER. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT, NULL, NULL); }
cmd ::= SHOW TRANSACTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT, NULL, NULL); }
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); }
...
...
@@ -413,7 +438,7 @@ cmd ::= COMPACT VNODES IN NK_LP integer_list(A) NK_RP.
/************************************************ create/drop function ************************************************/
cmd ::= CREATE agg_func_opt(A) FUNCTION not_exists_opt(F) function_name(B)
AS NK_STRING(C) OUTPUTTYPE type_name(D) bufsize_opt(E). { pCxt->pRootNode = createCreateFunctionStmt(pCxt, F, A, &B, &C, D, E); }
cmd ::= DROP FUNCTION
function_name(A). { pCxt->pRootNode = createDropFunctionStmt(pCxt
, &A); }
cmd ::= DROP FUNCTION
exists_opt(B) function_name(A). { pCxt->pRootNode = createDropFunctionStmt(pCxt, B
, &A); }
%type agg_func_opt { bool }
%destructor agg_func_opt { }
...
...
@@ -441,6 +466,7 @@ stream_options(A) ::= stream_options(B) WATERMARK duration_literal(C).
/************************************************ kill connection/query ***********************************************/
cmd ::= KILL CONNECTION NK_INTEGER(A). { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &A); }
cmd ::= KILL QUERY NK_INTEGER(A). { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_QUERY_STMT, &A); }
cmd ::= KILL TRANSACTION NK_INTEGER(A). { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &A); }
/************************************************ merge/redistribute/ vgroup ******************************************/
cmd ::= MERGE VGROUP NK_INTEGER(A) NK_INTEGER(B). { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &A, &B); }
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
306de052
...
...
@@ -363,8 +363,10 @@ SNode* createCastFunctionNode(SAstCreateContext* pCxt, SNode* pExpr, SDataType d
CHECK_OUT_OF_MEM
(
func
);
strcpy
(
func
->
functionName
,
"cast"
);
func
->
node
.
resType
=
dt
;
if
(
TSDB_DATA_TYPE_NCHAR
==
dt
.
type
)
{
func
->
node
.
resType
.
bytes
=
func
->
node
.
resType
.
bytes
*
TSDB_NCHAR_SIZE
;
if
(
TSDB_DATA_TYPE_VARCHAR
==
dt
.
type
)
{
func
->
node
.
resType
.
bytes
=
func
->
node
.
resType
.
bytes
+
VARSTR_HEADER_SIZE
;
}
else
if
(
TSDB_DATA_TYPE_NCHAR
==
dt
.
type
)
{
func
->
node
.
resType
.
bytes
=
func
->
node
.
resType
.
bytes
*
TSDB_NCHAR_SIZE
+
VARSTR_HEADER_SIZE
;
}
nodesListMakeAppend
(
&
func
->
pParameterList
,
pExpr
);
return
(
SNode
*
)
func
;
...
...
@@ -1258,10 +1260,12 @@ SNode* createCreateFunctionStmt(SAstCreateContext* pCxt, bool ignoreExists, bool
return
(
SNode
*
)
pStmt
;
}
SNode
*
createDropFunctionStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pFuncName
)
{
S
Node
*
pStmt
=
nodesMakeNode
(
QUERY_NODE_DROP_FUNCTION_STMT
);
SNode
*
createDropFunctionStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
const
SToken
*
pFuncName
)
{
S
DropFunctionStmt
*
pStmt
=
nodesMakeNode
(
QUERY_NODE_DROP_FUNCTION_STMT
);
CHECK_OUT_OF_MEM
(
pStmt
);
return
pStmt
;
pStmt
->
ignoreNotExists
=
ignoreNotExists
;
strncpy
(
pStmt
->
funcName
,
pFuncName
->
z
,
pFuncName
->
n
);
return
(
SNode
*
)
pStmt
;
}
SNode
*
createStreamOptions
(
SAstCreateContext
*
pCxt
)
{
...
...
@@ -1324,3 +1328,27 @@ SNode* createSyncdbStmt(SAstCreateContext* pCxt, const SToken* pDbName) {
CHECK_OUT_OF_MEM
(
pStmt
);
return
pStmt
;
}
SNode
*
createGrantStmt
(
SAstCreateContext
*
pCxt
,
int64_t
privileges
,
SToken
*
pDbName
,
SToken
*
pUserName
)
{
if
(
!
checkDbName
(
pCxt
,
pDbName
,
false
)
||
!
checkUserName
(
pCxt
,
pUserName
))
{
return
NULL
;
}
SGrantStmt
*
pStmt
=
nodesMakeNode
(
QUERY_NODE_GRANT_STMT
);
CHECK_OUT_OF_MEM
(
pStmt
);
pStmt
->
privileges
=
privileges
;
strncpy
(
pStmt
->
dbName
,
pDbName
->
z
,
pDbName
->
n
);
strncpy
(
pStmt
->
userName
,
pUserName
->
z
,
pUserName
->
n
);
return
(
SNode
*
)
pStmt
;
}
SNode
*
createRevokeStmt
(
SAstCreateContext
*
pCxt
,
int64_t
privileges
,
SToken
*
pDbName
,
SToken
*
pUserName
)
{
if
(
!
checkDbName
(
pCxt
,
pDbName
,
false
)
||
!
checkUserName
(
pCxt
,
pUserName
))
{
return
NULL
;
}
SRevokeStmt
*
pStmt
=
nodesMakeNode
(
QUERY_NODE_REVOKE_STMT
);
CHECK_OUT_OF_MEM
(
pStmt
);
pStmt
->
privileges
=
privileges
;
strncpy
(
pStmt
->
dbName
,
pDbName
->
z
,
pDbName
->
n
);
strncpy
(
pStmt
->
userName
,
pUserName
->
z
,
pUserName
->
n
);
return
(
SNode
*
)
pStmt
;
}
source/libs/parser/src/parAuthenticator.c
0 → 100644
浏览文件 @
306de052
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "catalog.h"
#include "parInt.h"
typedef
struct
SAuthCxt
{
SParseContext
*
pParseCxt
;
int32_t
errCode
;
}
SAuthCxt
;
static
int32_t
authQuery
(
SAuthCxt
*
pCxt
,
SNode
*
pStmt
);
static
int32_t
checkAuth
(
SParseContext
*
pCxt
,
const
char
*
dbName
,
AUTH_TYPE
type
)
{
if
(
pCxt
->
isSuperUser
)
{
return
TSDB_CODE_SUCCESS
;
}
bool
pass
=
false
;
int32_t
code
=
catalogChkAuth
(
pCxt
->
pCatalog
,
pCxt
->
pTransporter
,
&
pCxt
->
mgmtEpSet
,
pCxt
->
pUser
,
dbName
,
type
,
&
pass
);
return
TSDB_CODE_SUCCESS
==
code
?
(
pass
?
TSDB_CODE_SUCCESS
:
TSDB_CODE_PAR_PERMISSION_DENIED
)
:
code
;
}
static
EDealRes
authSubquery
(
SAuthCxt
*
pCxt
,
SNode
*
pStmt
)
{
return
TSDB_CODE_SUCCESS
==
authQuery
(
pCxt
,
pStmt
)
?
DEAL_RES_CONTINUE
:
DEAL_RES_ERROR
;
}
static
EDealRes
authSelectImpl
(
SNode
*
pNode
,
void
*
pContext
)
{
SAuthCxt
*
pCxt
=
pContext
;
if
(
QUERY_NODE_REAL_TABLE
==
nodeType
(
pNode
))
{
pCxt
->
errCode
=
checkAuth
(
pCxt
->
pParseCxt
,
((
SRealTableNode
*
)
pNode
)
->
table
.
dbName
,
AUTH_TYPE_READ
);
return
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
?
DEAL_RES_CONTINUE
:
DEAL_RES_ERROR
;
}
else
if
(
QUERY_NODE_TEMP_TABLE
==
nodeType
(
pNode
))
{
return
authSubquery
(
pCxt
,
((
STempTableNode
*
)
pNode
)
->
pSubquery
);
}
return
DEAL_RES_CONTINUE
;
}
static
int32_t
authSelect
(
SAuthCxt
*
pCxt
,
SSelectStmt
*
pSelect
)
{
nodesWalkSelectStmt
(
pSelect
,
SQL_CLAUSE_FROM
,
authSelectImpl
,
pCxt
);
return
pCxt
->
errCode
;
}
static
int32_t
authSetOperator
(
SAuthCxt
*
pCxt
,
SSetOperator
*
pSetOper
)
{
int32_t
code
=
authQuery
(
pCxt
,
pSetOper
->
pLeft
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
authQuery
(
pCxt
,
pSetOper
->
pRight
);
}
return
code
;
}
static
int32_t
authQuery
(
SAuthCxt
*
pCxt
,
SNode
*
pStmt
)
{
switch
(
nodeType
(
pStmt
))
{
case
QUERY_NODE_SET_OPERATOR
:
return
authSetOperator
(
pCxt
,
(
SSetOperator
*
)
pStmt
);
case
QUERY_NODE_SELECT_STMT
:
return
authSelect
(
pCxt
,
(
SSelectStmt
*
)
pStmt
);
case
QUERY_NODE_VNODE_MODIF_STMT
:
case
QUERY_NODE_CREATE_DATABASE_STMT
:
case
QUERY_NODE_DROP_DATABASE_STMT
:
case
QUERY_NODE_ALTER_DATABASE_STMT
:
case
QUERY_NODE_CREATE_TABLE_STMT
:
case
QUERY_NODE_CREATE_SUBTABLE_CLAUSE
:
case
QUERY_NODE_CREATE_MULTI_TABLE_STMT
:
case
QUERY_NODE_DROP_TABLE_CLAUSE
:
case
QUERY_NODE_DROP_TABLE_STMT
:
case
QUERY_NODE_DROP_SUPER_TABLE_STMT
:
case
QUERY_NODE_ALTER_TABLE_STMT
:
case
QUERY_NODE_CREATE_USER_STMT
:
case
QUERY_NODE_ALTER_USER_STMT
:
case
QUERY_NODE_DROP_USER_STMT
:
case
QUERY_NODE_USE_DATABASE_STMT
:
case
QUERY_NODE_CREATE_DNODE_STMT
:
case
QUERY_NODE_DROP_DNODE_STMT
:
case
QUERY_NODE_ALTER_DNODE_STMT
:
case
QUERY_NODE_CREATE_INDEX_STMT
:
case
QUERY_NODE_DROP_INDEX_STMT
:
case
QUERY_NODE_CREATE_QNODE_STMT
:
case
QUERY_NODE_DROP_QNODE_STMT
:
case
QUERY_NODE_CREATE_BNODE_STMT
:
case
QUERY_NODE_DROP_BNODE_STMT
:
case
QUERY_NODE_CREATE_SNODE_STMT
:
case
QUERY_NODE_DROP_SNODE_STMT
:
case
QUERY_NODE_CREATE_MNODE_STMT
:
case
QUERY_NODE_DROP_MNODE_STMT
:
case
QUERY_NODE_CREATE_TOPIC_STMT
:
case
QUERY_NODE_DROP_TOPIC_STMT
:
case
QUERY_NODE_ALTER_LOCAL_STMT
:
case
QUERY_NODE_EXPLAIN_STMT
:
case
QUERY_NODE_DESCRIBE_STMT
:
case
QUERY_NODE_RESET_QUERY_CACHE_STMT
:
case
QUERY_NODE_COMPACT_STMT
:
case
QUERY_NODE_CREATE_FUNCTION_STMT
:
case
QUERY_NODE_DROP_FUNCTION_STMT
:
case
QUERY_NODE_CREATE_STREAM_STMT
:
case
QUERY_NODE_DROP_STREAM_STMT
:
case
QUERY_NODE_MERGE_VGROUP_STMT
:
case
QUERY_NODE_REDISTRIBUTE_VGROUP_STMT
:
case
QUERY_NODE_SPLIT_VGROUP_STMT
:
case
QUERY_NODE_SYNCDB_STMT
:
case
QUERY_NODE_GRANT_STMT
:
case
QUERY_NODE_REVOKE_STMT
:
case
QUERY_NODE_SHOW_DNODES_STMT
:
case
QUERY_NODE_SHOW_MNODES_STMT
:
case
QUERY_NODE_SHOW_MODULES_STMT
:
case
QUERY_NODE_SHOW_QNODES_STMT
:
case
QUERY_NODE_SHOW_SNODES_STMT
:
case
QUERY_NODE_SHOW_BNODES_STMT
:
case
QUERY_NODE_SHOW_CLUSTER_STMT
:
case
QUERY_NODE_SHOW_DATABASES_STMT
:
case
QUERY_NODE_SHOW_FUNCTIONS_STMT
:
case
QUERY_NODE_SHOW_INDEXES_STMT
:
case
QUERY_NODE_SHOW_STABLES_STMT
:
case
QUERY_NODE_SHOW_STREAMS_STMT
:
case
QUERY_NODE_SHOW_TABLES_STMT
:
case
QUERY_NODE_SHOW_USERS_STMT
:
case
QUERY_NODE_SHOW_LICENCE_STMT
:
case
QUERY_NODE_SHOW_VGROUPS_STMT
:
case
QUERY_NODE_SHOW_TOPICS_STMT
:
case
QUERY_NODE_SHOW_CONSUMERS_STMT
:
case
QUERY_NODE_SHOW_SUBSCRIBES_STMT
:
case
QUERY_NODE_SHOW_TRANS_STMT
:
case
QUERY_NODE_SHOW_SMAS_STMT
:
case
QUERY_NODE_SHOW_CONFIGS_STMT
:
case
QUERY_NODE_SHOW_CONNECTIONS_STMT
:
case
QUERY_NODE_SHOW_QUERIES_STMT
:
case
QUERY_NODE_SHOW_VNODES_STMT
:
case
QUERY_NODE_SHOW_APPS_STMT
:
case
QUERY_NODE_SHOW_SCORES_STMT
:
case
QUERY_NODE_SHOW_VARIABLE_STMT
:
case
QUERY_NODE_SHOW_CREATE_DATABASE_STMT
:
case
QUERY_NODE_SHOW_CREATE_TABLE_STMT
:
case
QUERY_NODE_SHOW_CREATE_STABLE_STMT
:
case
QUERY_NODE_SHOW_TRANSACTIONS_STMT
:
case
QUERY_NODE_KILL_CONNECTION_STMT
:
case
QUERY_NODE_KILL_QUERY_STMT
:
case
QUERY_NODE_KILL_TRANSACTION_STMT
:
default:
break
;
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
authenticate
(
SParseContext
*
pParseCxt
,
SQuery
*
pQuery
)
{
SAuthCxt
cxt
=
{.
pParseCxt
=
pParseCxt
,
.
errCode
=
TSDB_CODE_SUCCESS
};
return
authQuery
(
&
cxt
,
pQuery
->
pRoot
);
}
source/libs/parser/src/parTokenizer.c
浏览文件 @
306de052
...
...
@@ -85,6 +85,7 @@ static SKeyword keywordTable[] = {
{
"FSYNC"
,
TK_FSYNC
},
{
"FUNCTION"
,
TK_FUNCTION
},
{
"FUNCTIONS"
,
TK_FUNCTIONS
},
{
"GRANT"
,
TK_GRANT
},
{
"GRANTS"
,
TK_GRANTS
},
{
"GROUP"
,
TK_GROUP
},
{
"HAVING"
,
TK_HAVING
},
...
...
@@ -147,9 +148,12 @@ static SKeyword keywordTable[] = {
{
"QUERIES"
,
TK_QUERIES
},
{
"QUERY"
,
TK_QUERY
},
{
"RATIO"
,
TK_RATIO
},
{
"READ"
,
TK_READ
},
{
"RENAME"
,
TK_RENAME
},
{
"REPLICA"
,
TK_REPLICA
},
{
"RESET"
,
TK_RESET
},
{
"RETENTIONS"
,
TK_RETENTIONS
},
{
"REVOKE"
,
TK_REVOKE
},
{
"ROLLUP"
,
TK_ROLLUP
},
{
"SCHEMA"
,
TK_SCHEMA
},
{
"SCORES"
,
TK_SCORES
},
...
...
@@ -182,9 +186,12 @@ static SKeyword keywordTable[] = {
{
"TIMESTAMP"
,
TK_TIMESTAMP
},
{
"TIMEZONE"
,
TK_TIMEZONE
},
{
"TINYINT"
,
TK_TINYINT
},
{
"TO"
,
TK_TO
},
{
"TODAY"
,
TK_TODAY
},
{
"TOPIC"
,
TK_TOPIC
},
{
"TOPICS"
,
TK_TOPICS
},
{
"TRANSACTION"
,
TK_TRANSACTION
},
{
"TRANSACTIONS"
,
TK_TRANSACTIONS
},
{
"TRIGGER"
,
TK_TRIGGER
},
{
"TSERIES"
,
TK_TSERIES
},
{
"TTL"
,
TK_TTL
},
...
...
@@ -206,6 +213,7 @@ static SKeyword keywordTable[] = {
{
"WHERE"
,
TK_WHERE
},
{
"WINDOW_CLOSE"
,
TK_WINDOW_CLOSE
},
{
"WITH"
,
TK_WITH
},
{
"WRITE"
,
TK_WRITE
},
{
"_QENDTS"
,
TK_QENDTS
},
{
"_QSTARTTS"
,
TK_QSTARTTS
},
{
"_ROWTS"
,
TK_ROWTS
},
...
...
@@ -471,7 +479,7 @@ uint32_t tGetToken(const char* z, uint32_t* tokenId) {
int
delim
=
z
[
0
];
bool
strEnd
=
false
;
for
(
i
=
1
;
z
[
i
];
i
++
)
{
if
(
z
[
i
]
==
'\\'
)
{
// ignore the escaped character that follows this backslash
if
(
delim
!=
'`'
&&
z
[
i
]
==
'\\'
)
{
// ignore the escaped character that follows this backslash
i
++
;
continue
;
}
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
306de052
...
...
@@ -2629,6 +2629,7 @@ static int32_t setAlterTableField(SAlterTableStmt* pStmt, SMAlterStbReq* pAlterR
break
;
}
pAlterReq
->
numOfFields
=
taosArrayGetSize
(
pAlterReq
->
pFields
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -2637,9 +2638,8 @@ static int32_t translateAlterTable(STranslateContext* pCxt, SAlterTableStmt* pSt
SName
tableName
;
tNameExtractFullName
(
toName
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
tableName
),
alterReq
.
name
);
alterReq
.
alterType
=
pStmt
->
alterType
;
alterReq
.
numOfFields
=
1
;
if
(
TSDB_ALTER_TABLE_UPDATE_OPTIONS
==
pStmt
->
alterType
)
{
// todo
if
(
TSDB_ALTER_TABLE_UPDATE_OPTIONS
==
pStmt
->
alterType
||
TSDB_ALTER_TABLE_UPDATE_TAG_VAL
==
pStmt
->
alterType
)
{
return
TSDB_CODE_FAILED
;
}
else
{
if
(
TSDB_CODE_SUCCESS
!=
setAlterTableField
(
pStmt
,
&
alterReq
))
{
return
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -3023,6 +3023,12 @@ static int32_t translateKillQuery(STranslateContext* pCxt, SKillStmt* pStmt) {
return
buildCmdMsg
(
pCxt
,
TDMT_MND_KILL_QUERY
,
(
FSerializeFunc
)
tSerializeSKillQueryReq
,
&
killReq
);
}
static
int32_t
translateKillTransaction
(
STranslateContext
*
pCxt
,
SKillStmt
*
pStmt
)
{
SKillTransReq
killReq
=
{
0
};
killReq
.
transId
=
pStmt
->
targetId
;
return
buildCmdMsg
(
pCxt
,
TDMT_MND_KILL_TRANS
,
(
FSerializeFunc
)
tSerializeSKillTransReq
,
&
killReq
);
}
static
int32_t
translateCreateStream
(
STranslateContext
*
pCxt
,
SCreateStreamStmt
*
pStmt
)
{
SCMCreateStreamReq
createReq
=
{
0
};
...
...
@@ -3121,6 +3127,45 @@ static int32_t translateCreateFunction(STranslateContext* pCxt, SCreateFunctionS
return
code
;
}
static
int32_t
translateDropFunction
(
STranslateContext
*
pCxt
,
SDropFunctionStmt
*
pStmt
)
{
SDropFuncReq
req
=
{
0
};
strcpy
(
req
.
name
,
pStmt
->
funcName
);
req
.
igNotExists
=
pStmt
->
ignoreNotExists
;
return
buildCmdMsg
(
pCxt
,
TDMT_MND_DROP_FUNC
,
(
FSerializeFunc
)
tSerializeSDropFuncReq
,
&
req
);
}
static
int32_t
translateGrant
(
STranslateContext
*
pCxt
,
SGrantStmt
*
pStmt
)
{
SAlterUserReq
req
=
{
0
};
if
(
PRIVILEGE_TYPE_TEST_MASK
(
pStmt
->
privileges
,
PRIVILEGE_TYPE_ALL
)
||
(
PRIVILEGE_TYPE_TEST_MASK
(
pStmt
->
privileges
,
PRIVILEGE_TYPE_READ
)
&&
PRIVILEGE_TYPE_TEST_MASK
(
pStmt
->
privileges
,
PRIVILEGE_TYPE_WRITE
)))
{
req
.
alterType
=
TSDB_ALTER_USER_ADD_ALL_DB
;
}
else
if
(
PRIVILEGE_TYPE_TEST_MASK
(
pStmt
->
privileges
,
PRIVILEGE_TYPE_READ
))
{
req
.
alterType
=
TSDB_ALTER_USER_ADD_READ_DB
;
}
else
if
(
PRIVILEGE_TYPE_TEST_MASK
(
pStmt
->
privileges
,
PRIVILEGE_TYPE_WRITE
))
{
req
.
alterType
=
TSDB_ALTER_USER_ADD_WRITE_DB
;
}
strcpy
(
req
.
user
,
pStmt
->
userName
);
strcpy
(
req
.
dbname
,
pStmt
->
dbName
);
return
buildCmdMsg
(
pCxt
,
TDMT_MND_ALTER_USER
,
(
FSerializeFunc
)
tSerializeSAlterUserReq
,
&
req
);
}
static
int32_t
translateRevoke
(
STranslateContext
*
pCxt
,
SRevokeStmt
*
pStmt
)
{
SAlterUserReq
req
=
{
0
};
if
(
PRIVILEGE_TYPE_TEST_MASK
(
pStmt
->
privileges
,
PRIVILEGE_TYPE_ALL
)
||
(
PRIVILEGE_TYPE_TEST_MASK
(
pStmt
->
privileges
,
PRIVILEGE_TYPE_READ
)
&&
PRIVILEGE_TYPE_TEST_MASK
(
pStmt
->
privileges
,
PRIVILEGE_TYPE_WRITE
)))
{
req
.
alterType
=
TSDB_ALTER_USER_REMOVE_ALL_DB
;
}
else
if
(
PRIVILEGE_TYPE_TEST_MASK
(
pStmt
->
privileges
,
PRIVILEGE_TYPE_READ
))
{
req
.
alterType
=
TSDB_ALTER_USER_REMOVE_READ_DB
;
}
else
if
(
PRIVILEGE_TYPE_TEST_MASK
(
pStmt
->
privileges
,
PRIVILEGE_TYPE_WRITE
))
{
req
.
alterType
=
TSDB_ALTER_USER_REMOVE_WRITE_DB
;
}
strcpy
(
req
.
user
,
pStmt
->
userName
);
strcpy
(
req
.
dbname
,
pStmt
->
dbName
);
return
buildCmdMsg
(
pCxt
,
TDMT_MND_ALTER_USER
,
(
FSerializeFunc
)
tSerializeSAlterUserReq
,
&
req
);
}
static
int32_t
translateQuery
(
STranslateContext
*
pCxt
,
SNode
*
pNode
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
switch
(
nodeType
(
pNode
))
{
...
...
@@ -3216,6 +3261,9 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
case
QUERY_NODE_KILL_QUERY_STMT
:
code
=
translateKillQuery
(
pCxt
,
(
SKillStmt
*
)
pNode
);
break
;
case
QUERY_NODE_KILL_TRANSACTION_STMT
:
code
=
translateKillTransaction
(
pCxt
,
(
SKillStmt
*
)
pNode
);
break
;
case
QUERY_NODE_CREATE_STREAM_STMT
:
code
=
translateCreateStream
(
pCxt
,
(
SCreateStreamStmt
*
)
pNode
);
break
;
...
...
@@ -3225,6 +3273,15 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
case
QUERY_NODE_CREATE_FUNCTION_STMT
:
code
=
translateCreateFunction
(
pCxt
,
(
SCreateFunctionStmt
*
)
pNode
);
break
;
case
QUERY_NODE_DROP_FUNCTION_STMT
:
code
=
translateDropFunction
(
pCxt
,
(
SDropFunctionStmt
*
)
pNode
);
break
;
case
QUERY_NODE_GRANT_STMT
:
code
=
translateGrant
(
pCxt
,
(
SGrantStmt
*
)
pNode
);
break
;
case
QUERY_NODE_REVOKE_STMT
:
code
=
translateRevoke
(
pCxt
,
(
SRevokeStmt
*
)
pNode
);
break
;
default:
break
;
}
...
...
@@ -3345,6 +3402,7 @@ static const char* getSysDbName(ENodeType type) {
case
QUERY_NODE_SHOW_CONNECTIONS_STMT
:
case
QUERY_NODE_SHOW_QUERIES_STMT
:
case
QUERY_NODE_SHOW_TOPICS_STMT
:
case
QUERY_NODE_SHOW_TRANSACTIONS_STMT
:
return
TSDB_PERFORMANCE_SCHEMA_DB
;
default:
break
;
...
...
@@ -3392,6 +3450,8 @@ static const char* getSysTableName(ENodeType type) {
return
TSDB_PERFS_TABLE_QUERIES
;
case
QUERY_NODE_SHOW_TOPICS_STMT
:
return
TSDB_PERFS_TABLE_TOPICS
;
case
QUERY_NODE_SHOW_TRANSACTIONS_STMT
:
return
TSDB_PERFS_TABLE_TRANS
;
default:
break
;
}
...
...
source/libs/parser/src/parser.c
浏览文件 @
306de052
...
...
@@ -36,6 +36,9 @@ bool isInsertSql(const char* pStr, size_t length) {
static
int32_t
parseSqlIntoAst
(
SParseContext
*
pCxt
,
SQuery
**
pQuery
)
{
int32_t
code
=
parse
(
pCxt
,
pQuery
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
authenticate
(
pCxt
,
*
pQuery
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
translate
(
pCxt
,
*
pQuery
);
}
...
...
source/libs/parser/src/sql.c
浏览文件 @
306de052
此差异已折叠。
点击以展开。
source/libs/parser/test/mockCatalog.cpp
浏览文件 @
306de052
...
...
@@ -181,6 +181,12 @@ int32_t __catalogGetDBCfg(SCatalog* pCtg, void* pRpc, const SEpSet* pMgmtEps, co
return
0
;
}
int32_t
__catalogChkAuth
(
SCatalog
*
pCtg
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
char
*
user
,
const
char
*
dbFName
,
AUTH_TYPE
type
,
bool
*
pass
)
{
*
pass
=
true
;
return
0
;
}
void
initMetaDataEnv
()
{
mockCatalogService
.
reset
(
new
MockCatalogService
());
...
...
@@ -193,6 +199,7 @@ void initMetaDataEnv() {
stub
.
set
(
catalogGetDBVgVersion
,
__catalogGetDBVgVersion
);
stub
.
set
(
catalogGetDBVgInfo
,
__catalogGetDBVgInfo
);
stub
.
set
(
catalogGetDBCfg
,
__catalogGetDBCfg
);
stub
.
set
(
catalogChkAuth
,
__catalogChkAuth
);
// {
// AddrAny any("libcatalog.so");
// std::map<std::string,void*> result;
...
...
source/libs/parser/test/parExplainToSyncdbTest.cpp
浏览文件 @
306de052
...
...
@@ -24,11 +24,20 @@ class ParserExplainToSyncdbTest : public ParserTestBase {};
TEST_F
(
ParserExplainToSyncdbTest
,
explain
)
{
useDb
(
"root"
,
"test"
);
run
(
"
explain
SELECT * FROM t1"
);
run
(
"
EXPLAIN
SELECT * FROM t1"
);
run
(
"
explain analyze
SELECT * FROM t1"
);
run
(
"
EXPLAIN ANALYZE
SELECT * FROM t1"
);
run
(
"explain analyze verbose true ratio 0.01 SELECT * FROM t1"
);
run
(
"EXPLAIN ANALYZE VERBOSE true RATIO 0.01 SELECT * FROM t1"
);
}
TEST_F
(
ParserExplainToSyncdbTest
,
grant
)
{
useDb
(
"root"
,
"test"
);
run
(
"GRANT ALL ON test.* TO wxy"
);
run
(
"GRANT READ ON test.* TO wxy"
);
run
(
"GRANT WRITE ON test.* TO wxy"
);
run
(
"GRANT READ, WRITE ON test.* TO wxy"
);
}
// todo kill connection
...
...
@@ -37,6 +46,16 @@ TEST_F(ParserExplainToSyncdbTest, explain) {
// todo merge vgroup
// todo redistribute vgroup
// todo reset query cache
TEST_F
(
ParserExplainToSyncdbTest
,
revoke
)
{
useDb
(
"root"
,
"test"
);
run
(
"REVOKE ALL ON test.* FROM wxy"
);
run
(
"REVOKE READ ON test.* FROM wxy"
);
run
(
"REVOKE WRITE ON test.* FROM wxy"
);
run
(
"REVOKE READ, WRITE ON test.* FROM wxy"
);
}
// todo syncdb
}
// namespace ParserTest
source/libs/parser/test/parInitialATest.cpp
浏览文件 @
306de052
...
...
@@ -24,39 +24,84 @@ class ParserInitialATest : public ParserTestBase {};
TEST_F
(
ParserInitialATest
,
alterAccount
)
{
useDb
(
"root"
,
"test"
);
run
(
"
alter account ac_wxy pass
'123456'"
,
TSDB_CODE_PAR_EXPRIE_STATEMENT
);
run
(
"
ALTER ACCOUNT ac_wxy PASS
'123456'"
,
TSDB_CODE_PAR_EXPRIE_STATEMENT
);
}
TEST_F
(
ParserInitialATest
,
alterDnode
)
{
useDb
(
"root"
,
"test"
);
run
(
"
alter dnode
1 'resetLog'"
);
run
(
"
ALTER DNODE
1 'resetLog'"
);
run
(
"
alter dnode
1 'debugFlag' '134'"
);
run
(
"
ALTER DNODE
1 'debugFlag' '134'"
);
}
TEST_F
(
ParserInitialATest
,
alterDatabase
)
{
useDb
(
"root"
,
"test"
);
run
(
"
alter database wxy_db cachelast 1 fsync 200 wal
1"
);
run
(
"
ALTER DATABASE wxy_db CACHELAST 1 FSYNC 200 WAL
1"
);
}
// todo alter local
// todo alter stable
// todo alter table
// todo ALTER local
// todo ALTER stable
/*
* ALTER TABLE [db_name.]tb_name alter_table_clause
*
* alter_table_clause: {
* alter_table_options
* | ADD COLUMN col_name column_type
* | DROP COLUMN col_name
* | MODIFY COLUMN col_name column_type
* | RENAME COLUMN old_col_name new_col_name
* | ADD TAG tag_name tag_type
* | DROP TAG tag_name
* | MODIFY TAG tag_name tag_type
* | RENAME TAG old_tag_name new_tag_name
* | SET TAG tag_name = new_tag_value
* | ADD {FULLTEXT | SMA} INDEX index_name (col_name [, col_name] ...) [index_option]
* }
*
* alter_table_options:
* alter_table_option ...
*
* alter_table_option: {
* TTL value
* | COMMENT 'string_value'
* }
*/
TEST_F
(
ParserInitialATest
,
alterTable
)
{
useDb
(
"root"
,
"test"
);
// run("ALTER TABLE t1 TTL 10");
// run("ALTER TABLE t1 COMMENT 'test'");
run
(
"ALTER TABLE t1 ADD COLUMN cc1 BIGINT"
);
run
(
"ALTER TABLE t1 DROP COLUMN c1"
);
run
(
"ALTER TABLE t1 MODIFY COLUMN c1 VARCHAR(20)"
);
run
(
"ALTER TABLE t1 RENAME COLUMN c1 cc1"
);
run
(
"ALTER TABLE st1 ADD TAG tag11 BIGINT"
);
run
(
"ALTER TABLE st1 DROP TAG tag1"
);
run
(
"ALTER TABLE st1 MODIFY TAG tag1 VARCHAR(20)"
);
run
(
"ALTER TABLE st1 RENAME TAG tag1 tag11"
);
// run("ALTER TABLE st1s1 SET TAG tag1=10");
// todo
// ADD {FULLTEXT | SMA} INDEX index_name (col_name [, col_name] ...) [index_option]
}
TEST_F
(
ParserInitialATest
,
alterUser
)
{
useDb
(
"root"
,
"test"
);
run
(
"
alter user wxy pass
'123456'"
);
run
(
"
ALTER user wxy PASS
'123456'"
);
run
(
"
alter
user wxy privilege 'write'"
);
run
(
"
ALTER
user wxy privilege 'write'"
);
}
TEST_F
(
ParserInitialATest
,
bug001
)
{
useDb
(
"root"
,
"test"
);
run
(
"
alter database db wal
0 # td-14436"
,
TSDB_CODE_PAR_SYNTAX_ERROR
);
run
(
"
ALTER DATABASE db WAL
0 # td-14436"
,
TSDB_CODE_PAR_SYNTAX_ERROR
);
}
}
// namespace ParserTest
\ No newline at end of file
source/libs/parser/test/parShowToUse.cpp
浏览文件 @
306de052
...
...
@@ -21,111 +21,117 @@ namespace ParserTest {
class
ParserShowToUseTest
:
public
ParserTestBase
{};
// todo
show
accounts
// todo
show
apps
// todo
show
connections
// todo
show
create database
// todo
show
create stable
// todo
show
create table
// todo
SHOW
accounts
// todo
SHOW
apps
// todo
SHOW
connections
// todo
SHOW
create database
// todo
SHOW
create stable
// todo
SHOW
create table
TEST_F
(
ParserShowToUseTest
,
showDatabases
)
{
useDb
(
"root"
,
"test"
);
run
(
"
show
databases"
);
run
(
"
SHOW
databases"
);
}
TEST_F
(
ParserShowToUseTest
,
showDnodes
)
{
useDb
(
"root"
,
"test"
);
run
(
"
show
dnodes"
);
run
(
"
SHOW
dnodes"
);
}
TEST_F
(
ParserShowToUseTest
,
showFunctions
)
{
useDb
(
"root"
,
"test"
);
run
(
"
show
functions"
);
run
(
"
SHOW
functions"
);
}
// todo
show
licence
// todo
SHOW
licence
TEST_F
(
ParserShowToUseTest
,
showIndexes
)
{
useDb
(
"root"
,
"test"
);
run
(
"
show
indexes from t1"
);
run
(
"
SHOW
indexes from t1"
);
run
(
"
show
indexes from t1 from test"
);
run
(
"
SHOW
indexes from t1 from test"
);
}
TEST_F
(
ParserShowToUseTest
,
showMnodes
)
{
useDb
(
"root"
,
"test"
);
run
(
"
show
mnodes"
);
run
(
"
SHOW
mnodes"
);
}
TEST_F
(
ParserShowToUseTest
,
showModules
)
{
useDb
(
"root"
,
"test"
);
run
(
"
show
modules"
);
run
(
"
SHOW
modules"
);
}
TEST_F
(
ParserShowToUseTest
,
showQnodes
)
{
useDb
(
"root"
,
"test"
);
run
(
"
show
qnodes"
);
run
(
"
SHOW
qnodes"
);
}
// todo
show
queries
// todo
show
scores
// todo
SHOW
queries
// todo
SHOW
scores
TEST_F
(
ParserShowToUseTest
,
showStables
)
{
useDb
(
"root"
,
"test"
);
run
(
"
show
stables"
);
run
(
"
SHOW
stables"
);
run
(
"
show
test.stables"
);
run
(
"
SHOW
test.stables"
);
run
(
"
show
stables like 'c%'"
);
run
(
"
SHOW
stables like 'c%'"
);
run
(
"
show
test.stables like 'c%'"
);
run
(
"
SHOW
test.stables like 'c%'"
);
}
TEST_F
(
ParserShowToUseTest
,
showStreams
)
{
useDb
(
"root"
,
"test"
);
run
(
"show streams"
);
run
(
"SHOW streams"
);
}
TEST_F
(
ParserShowToUseTest
,
showTransactions
)
{
useDb
(
"root"
,
"test"
);
run
(
"SHOW TRANSACTIONS"
);
}
TEST_F
(
ParserShowToUseTest
,
showTables
)
{
useDb
(
"root"
,
"test"
);
run
(
"
show
tables"
);
run
(
"
SHOW
tables"
);
run
(
"
show
test.tables"
);
run
(
"
SHOW
test.tables"
);
run
(
"
show
tables like 'c%'"
);
run
(
"
SHOW
tables like 'c%'"
);
run
(
"
show
test.tables like 'c%'"
);
run
(
"
SHOW
test.tables like 'c%'"
);
}
// todo
show
topics
// todo
SHOW
topics
TEST_F
(
ParserShowToUseTest
,
showUsers
)
{
useDb
(
"root"
,
"test"
);
run
(
"
show
users"
);
run
(
"
SHOW
users"
);
}
// todo
show
variables
// todo
SHOW
variables
TEST_F
(
ParserShowToUseTest
,
showVgroups
)
{
useDb
(
"root"
,
"test"
);
run
(
"
show
vgroups"
);
run
(
"
SHOW
vgroups"
);
run
(
"
show
test.vgroups"
);
run
(
"
SHOW
test.vgroups"
);
}
// todo
show
vnodes
// todo
SHOW
vnodes
// todo split vgroup
...
...
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
306de052
...
...
@@ -1333,13 +1333,11 @@ int32_t createPhysiPlan(SPlanContext* pCxt, SQueryLogicPlan* pLogicPlan, SQueryP
return
TSDB_CODE_OUT_OF_MEMORY
;
}
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
(
tsQueryPolicy
>
QUERY_POLICY_VNODE
)
{
code
=
catalogGetQnodeList
(
pCxt
->
pCatalog
,
pCxt
->
pTransporter
,
&
pCxt
->
mgmtEpSet
,
pExecNodeList
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
doCreatePhysiPlan
(
&
cxt
,
pLogicPlan
,
pPlan
);
if
(
QUERY_POLICY_VNODE
==
tsQueryPolicy
)
{
taosArrayClear
(
pExecNodeList
);
}
int32_t
code
=
doCreatePhysiPlan
(
&
cxt
,
pLogicPlan
,
pPlan
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
setExplainInfo
(
pCxt
,
*
pPlan
);
}
...
...
source/libs/planner/test/planSTableTest.cpp
浏览文件 @
306de052
...
...
@@ -19,10 +19,16 @@ using namespace std;
class
PlanSuperTableTest
:
public
PlannerTestBase
{};
TEST_F
(
PlanSuperTableTest
,
tbname
)
{
TEST_F
(
PlanSuperTableTest
,
pseudoCol
)
{
useDb
(
"root"
,
"test"
);
run
(
"
select tbname from
st1"
);
run
(
"
SELECT TBNAME FROM
st1"
);
run
(
"select tbname, tag1, tag2 from st1"
);
run
(
"SELECT TBNAME, tag1, tag2 FROM st1"
);
}
TEST_F
(
PlanSuperTableTest
,
orderBy
)
{
useDb
(
"root"
,
"test"
);
run
(
"SELECT -1*c1, c1 FROM st1 ORDER BY -1*c1"
);
}
source/libs/scalar/src/sclfunc.c
浏览文件 @
306de052
...
...
@@ -432,7 +432,7 @@ int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
if
(
pInput
[
i
].
numOfRows
==
1
)
{
inputLen
+=
(
pInputData
[
i
]
->
varmeta
.
length
-
VARSTR_HEADER_SIZE
)
*
factor
*
(
numOfRows
-
numOfNulls
);
}
else
{
inputLen
+=
pInputData
[
i
]
->
varmeta
.
length
-
(
numOfRows
-
numOfNulls
)
*
VARSTR_HEADER_SIZE
;
inputLen
+=
(
pInputData
[
i
]
->
varmeta
.
length
-
(
numOfRows
-
numOfNulls
)
*
VARSTR_HEADER_SIZE
)
*
factor
;
}
}
...
...
@@ -510,7 +510,7 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
}
else
if
(
pInput
[
i
].
numOfRows
==
1
)
{
inputLen
+=
(
pInputData
[
i
]
->
varmeta
.
length
-
VARSTR_HEADER_SIZE
)
*
(
numOfRows
-
numOfNulls
)
*
factor
;
}
else
{
inputLen
+=
pInputData
[
i
]
->
varmeta
.
length
-
(
numOfRows
-
numOfNulls
)
*
VARSTR_HEADER_SIZE
;
inputLen
+=
(
pInputData
[
i
]
->
varmeta
.
length
-
(
numOfRows
-
numOfNulls
)
*
VARSTR_HEADER_SIZE
)
*
factor
;
}
}
...
...
source/libs/stream/src/tstream.c
浏览文件 @
306de052
...
...
@@ -150,14 +150,14 @@ int32_t streamExecTask(SStreamTask* pTask, SMsgCb* pMsgCb, const void* input, in
pRes
=
(
SArray
*
)
input
;
}
if
(
pRes
==
NULL
||
taosArrayGetSize
(
pRes
)
==
0
)
return
0
;
// sink
if
(
pTask
->
sinkType
==
TASK_SINK__TABLE
)
{
/*blockDebugShowData(pRes);*/
ASSERT
(
pTask
->
tbSink
.
pTSchema
);
SSubmitReq
*
pReq
=
tdBlockToSubmit
(
pRes
,
pTask
->
tbSink
.
pTSchema
);
tPrintFixedSchemaSubmitReq
(
pReq
,
pTask
->
tbSink
.
pTSchema
);
pTask
->
tbSink
.
tbSinkFunc
(
pTask
,
pTask
->
tbSink
.
vnode
,
0
,
pRes
);
}
else
if
(
pTask
->
sinkType
==
TASK_SINK__SMA
)
{
pTask
->
smaSink
.
sma
Handle
(
pTask
->
ahandle
,
pTask
->
smaSink
.
smaId
,
pRes
);
pTask
->
smaSink
.
sma
Sink
(
pTask
->
ahandle
,
pTask
->
smaSink
.
smaId
,
pRes
);
//
}
else
if
(
pTask
->
sinkType
==
TASK_SINK__FETCH
)
{
//
...
...
@@ -276,7 +276,7 @@ int32_t tEncodeSStreamTask(SEncoder* pEncoder, const SStreamTask* pTask) {
}
if
(
pTask
->
sinkType
==
TASK_SINK__TABLE
)
{
/*if (tEncodeI8(pEncoder, pTask->tbSink.reserved) < 0) return -1;*/
if
(
tEncodeI64
(
pEncoder
,
pTask
->
tbSink
.
stbUid
)
<
0
)
return
-
1
;
if
(
tEncodeSSchemaWrapper
(
pEncoder
,
pTask
->
tbSink
.
pSchemaWrapper
)
<
0
)
return
-
1
;
}
else
if
(
pTask
->
sinkType
==
TASK_SINK__SMA
)
{
if
(
tEncodeI64
(
pEncoder
,
pTask
->
smaSink
.
smaId
)
<
0
)
return
-
1
;
...
...
@@ -321,7 +321,7 @@ int32_t tDecodeSStreamTask(SDecoder* pDecoder, SStreamTask* pTask) {
}
if
(
pTask
->
sinkType
==
TASK_SINK__TABLE
)
{
/*if (tDecodeI8(pDecoder, &pTask->tbSink.reserved) < 0) return -1;*/
if
(
tDecodeI64
(
pDecoder
,
&
pTask
->
tbSink
.
stbUid
)
<
0
)
return
-
1
;
pTask
->
tbSink
.
pSchemaWrapper
=
taosMemoryCalloc
(
1
,
sizeof
(
SSchemaWrapper
));
if
(
pTask
->
tbSink
.
pSchemaWrapper
==
NULL
)
return
-
1
;
if
(
tDecodeSSchemaWrapper
(
pDecoder
,
pTask
->
tbSink
.
pSchemaWrapper
)
<
0
)
return
-
1
;
...
...
source/libs/transport/src/transSrv.c
浏览文件 @
306de052
...
...
@@ -850,7 +850,8 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
}
}
if
(
false
==
taosValidIpAndPort
(
srv
->
ip
,
srv
->
port
))
{
tError
(
"failed to bind, reason: %s"
,
terrstr
());
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
tError
(
"invalid ip/port, reason: %s"
,
terrstr
());
goto
End
;
}
if
(
false
==
addHandleToAcceptloop
(
srv
))
{
...
...
source/os/src/osSocket.c
浏览文件 @
306de052
...
...
@@ -669,7 +669,7 @@ bool taosValidIpAndPort(uint32_t ip, uint16_t port) {
if
(
taosSetSockOpt
(
pSocket
,
SOL_SOCKET
,
SO_REUSEADDR
,
(
void
*
)
&
reuse
,
sizeof
(
reuse
))
<
0
)
{
// printf("setsockopt SO_REUSEADDR failed: %d (%s)", errno, strerror(errno));
taosCloseSocket
(
&
pSocket
);
return
NULL
;
return
false
;
}
/* bind socket to server address */
if
(
bind
(
pSocket
->
fd
,
(
struct
sockaddr
*
)
&
serverAdd
,
sizeof
(
serverAdd
))
<
0
)
{
...
...
@@ -677,6 +677,11 @@ bool taosValidIpAndPort(uint32_t ip, uint16_t port) {
taosCloseSocket
(
&
pSocket
);
return
false
;
}
if
(
listen
(
pSocket
->
fd
,
1024
)
<
0
)
{
// printf("listen tcp server socket failed, 0x%x:%hu(%s)", ip, port, strerror(errno));
taosCloseSocket
(
&
pSocket
);
return
false
;
}
taosCloseSocket
(
&
pSocket
);
return
true
;
}
...
...
source/util/src/terror.c
浏览文件 @
306de052
...
...
@@ -448,6 +448,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_QW_MSG_ERROR, "Invalid msg order")
// parser
TAOS_DEFINE_ERROR
(
TSDB_CODE_PAR_TABLE_NOT_EXIST
,
"Table does not exist"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_PAR_PERMISSION_DENIED
,
"Permission denied"
)
//planner
TAOS_DEFINE_ERROR
(
TSDB_CODE_PLAN_INTERNAL_ERROR
,
"planner internal error"
)
...
...
source/util/test/encodeTest.cpp
浏览文件 @
306de052
#if 0
#include <iostream>
#include <gtest/gtest.h>
...
...
@@ -439,3 +441,5 @@ TEST(td_encode_test, compound_struct_encode_test) {
}
#endif
#pragma GCC diagnostic pop
#endif
tests/script/jenkins/basic.txt
浏览文件 @
306de052
...
...
@@ -59,6 +59,10 @@
# ---- table
./test.sh -f tsim/table/basic1.sim
# ---- tstream
./test.sh -f tsim/tstream/basic0.sim
# ---- tmq
./test.sh -f tsim/tmq/basic1.sim
./test.sh -f tsim/tmq/basic2.sim
...
...
tests/script/tsim/query/udf.sim
浏览文件 @
306de052
...
...
@@ -64,6 +64,47 @@ if $data00 != 1.414213562 then
return -1
endi
#sql drop function udf1;
#sql drop function udf2;
system sh/exec.sh -n dnode1 -s stop -x SIGKILL
sql insert into t2 values(now+2s, 1, null)(now+3s, null, 2);
sql select udf1(f1, f2) from t2;
print $rows , $data00 , $data10 , $data20 , $data30
if $rows != 4 then
return -1
endi
if $data00 != 88 then
return -1
endi
if $data10 != 88 then
return -1
endi
if $data20 != NULL then
return -1
endi
if $data30 != NULL then
return -1
endi
sql select udf2(f1, f2) from t2;
print $rows, $data00
if $rows != 1 then
return -1
endi
if $data00 != 2.645751311 then
return -1
endi
sql drop function udf1;
sql show functions;
if $rows != 1 then
return -1
endi
if $data00 != @udf2@ then
return -1
endi
sql drop function udf2;
sql show functions;
if $rows != 0 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGTERM
tests/script/tsim/tstream/basic0.sim
0 → 100644
浏览文件 @
306de052
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sleep 50
sql connect
print =============== create database
sql create database d0 vgroups 1
sql show databases
if $rows != 3 then
return -1
endi
print $data00 $data01 $data02
sql use d0
print =============== create super table, include column type for count/sum/min/max/first
sql create table if not exists stb (ts timestamp, k int) tags (a int)
sql show stables
if $rows != 1 then
return -1
endi
print =============== create child table
sql create table ct1 using stb tags(1000)
sql create table ct2 using stb tags(2000)
sql create table ct3 using stb tags(3000)
sql show tables
if $rows != 3 then
return -1
endi
sql create stream s1 into outstb as select _wstartts, min(k), max(k), sum(k) from ct1 interval(10m)
sql show stables
if $rows != 2 then
return -1
endi
print =============== insert data
sql insert into ct1 values(now+0s, 234)
sleep 100
#===================================================================
#===================================================================
print =============== query data from child table
sql select `_wstartts`,`min(k)`,`max(k)`,`sum(k)` from outstb
print rows: $rows
print $data00 $data01 $data02 $data03
if $rows != 1 then
return -1
endi
if $data01 != 234 then
return -1
endi
if $data02 != 234 then
return -1
endi
if $data03 != 234 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/tsim/user/pass_alter.sim
浏览文件 @
306de052
...
...
@@ -4,11 +4,11 @@ system sh/exec.sh -n dnode1 -s start
sql connect
print ============= step1
sql create user read pass 'taosdata1'
sql create user write pass 'taosdata1'
sql create user
u_
read pass 'taosdata1'
sql create user
u_
write pass 'taosdata1'
sql alter user read pass 'taosdata'
sql alter user write pass 'taosdata'
sql alter user
u_
read pass 'taosdata'
sql alter user
u_
write pass 'taosdata'
sql show users
if $rows != 3 then
...
...
@@ -18,10 +18,10 @@ endi
print ============= step2
sql close
sleep 2500
print user read login
sql connect read
sql alter user read pass 'taosdata'
sql alter user write pass 'taosdata1' -x step2
print user
u_
read login
sql connect
u_
read
sql alter user
u_
read pass 'taosdata'
sql alter user
u_
write pass 'taosdata1' -x step2
return -1
step2:
...
...
@@ -36,13 +36,13 @@ endi
print ============= step3
sql close
sleep 2500
print user write login
sql connect write
print user
u_
write login
sql connect
u_
write
sql_error create user read2 pass 'taosdata1'
sql_error create user write2 pass 'taosdata1'
sql alter user write pass 'taosdata'
sql alter user read pass 'taosdata' -x step3
sql alter user
u_
write pass 'taosdata'
sql alter user
u_
read pass 'taosdata' -x step3
return -1
step3:
...
...
tests/system-test/2-query/query_cols_tags_and_or.py
0 → 100644
浏览文件 @
306de052
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录