Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6e50691b
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
6e50691b
编写于
5月 07, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: sql command 'grant', 'revoke', 'kill transaction' and 'show transactions'
上级
f54cdb02
变更
24
展开全部
隐藏空白更改
内联
并排
Showing
24 changed file
with
3556 addition
and
3069 deletion
+3556
-3069
include/common/tmsg.h
include/common/tmsg.h
+2
-2
include/common/ttokendef.h
include/common/ttokendef.h
+202
-195
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/util/taoserror.h
include/util/taoserror.h
+1
-0
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+18
-14
source/dnode/mnode/impl/src/mndUser.c
source/dnode/mnode/impl/src/mndUser.c
+0
-5
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
+150
-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
+53
-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/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/util/src/terror.c
source/util/src/terror.c
+1
-0
未找到文件。
include/common/tmsg.h
浏览文件 @
6e50691b
...
...
@@ -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
...
...
@@ -672,7 +674,6 @@ typedef struct {
SArray
*
pArray
;
// Array of SUseDbRsp
}
SUseDbBatchRsp
;
int32_t
tSerializeSUseDbBatchRsp
(
void
*
buf
,
int32_t
bufLen
,
SUseDbBatchRsp
*
pRsp
);
int32_t
tDeserializeSUseDbBatchRsp
(
void
*
buf
,
int32_t
bufLen
,
SUseDbBatchRsp
*
pRsp
);
void
tFreeSUseDbBatchRsp
(
SUseDbBatchRsp
*
pRsp
);
...
...
@@ -685,7 +686,6 @@ int32_t tSerializeSUserAuthBatchRsp(void* buf, int32_t bufLen, SUserAuthBatchRsp
int32_t
tDeserializeSUserAuthBatchRsp
(
void
*
buf
,
int32_t
bufLen
,
SUserAuthBatchRsp
*
pRsp
);
void
tFreeSUserAuthBatchRsp
(
SUserAuthBatchRsp
*
pRsp
);
typedef
struct
{
char
db
[
TSDB_DB_FNAME_LEN
];
}
SCompactDbReq
;
...
...
include/common/ttokendef.h
浏览文件 @
6e50691b
...
...
@@ -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/nodes/cmdnodes.h
浏览文件 @
6e50691b
...
...
@@ -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
浏览文件 @
6e50691b
...
...
@@ -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
浏览文件 @
6e50691b
...
...
@@ -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/util/taoserror.h
浏览文件 @
6e50691b
...
...
@@ -629,6 +629,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
浏览文件 @
6e50691b
...
...
@@ -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,16 @@ 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
);
}
catalogFreeHandle
(
pCatalog
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
qCreateQueryPlan
(
&
cxt
,
pPlan
,
pNodeList
);
}
...
...
source/dnode/mnode/impl/src/mndUser.c
浏览文件 @
6e50691b
...
...
@@ -412,11 +412,6 @@ static int32_t mndProcessAlterUserReq(SNodeMsg *pReq) {
goto
_OVER
;
}
if
(
alterReq
.
pass
[
0
]
==
0
)
{
terrno
=
TSDB_CODE_MND_INVALID_PASS_FORMAT
;
goto
_OVER
;
}
pUser
=
mndAcquireUser
(
pMnode
,
alterReq
.
user
);
if
(
pUser
==
NULL
)
{
terrno
=
TSDB_CODE_MND_USER_NOT_EXIST
;
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
6e50691b
...
...
@@ -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
浏览文件 @
6e50691b
...
...
@@ -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
浏览文件 @
6e50691b
...
...
@@ -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
浏览文件 @
6e50691b
...
...
@@ -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
浏览文件 @
6e50691b
...
...
@@ -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
浏览文件 @
6e50691b
/*
* 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
authQuery
(
SAuthCxt
*
pCxt
,
SNode
*
pStmt
)
{
switch
(
nodeType
(
pStmt
))
{
case
QUERY_NODE_SET_OPERATOR
:
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
浏览文件 @
6e50691b
...
...
@@ -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
浏览文件 @
6e50691b
...
...
@@ -2628,6 +2628,7 @@ static int32_t setAlterTableField(SAlterTableStmt* pStmt, SMAltertbReq* pAlterRe
break
;
}
pAlterReq
->
numOfFields
=
taosArrayGetSize
(
pAlterReq
->
pFields
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -2636,9 +2637,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
;
...
...
@@ -3022,6 +3022,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
};
...
...
@@ -3120,6 +3126,38 @@ static int32_t translateCreateFunction(STranslateContext* pCxt, SCreateFunctionS
return
code
;
}
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
))
{
...
...
@@ -3215,6 +3253,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
;
...
...
@@ -3224,6 +3265,12 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
case
QUERY_NODE_CREATE_FUNCTION_STMT
:
code
=
translateCreateFunction
(
pCxt
,
(
SCreateFunctionStmt
*
)
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
;
}
...
...
@@ -3344,6 +3391,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
;
...
...
@@ -3391,6 +3439,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
浏览文件 @
6e50691b
...
...
@@ -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
浏览文件 @
6e50691b
此差异已折叠。
点击以展开。
source/libs/parser/test/parExplainToSyncdbTest.cpp
浏览文件 @
6e50691b
...
...
@@ -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
浏览文件 @
6e50691b
...
...
@@ -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
浏览文件 @
6e50691b
...
...
@@ -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
浏览文件 @
6e50691b
...
...
@@ -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
浏览文件 @
6e50691b
...
...
@@ -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/util/src/terror.c
浏览文件 @
6e50691b
...
...
@@ -445,6 +445,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"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录