feat: support uniq grant
This commit is contained in:
parent
bf0205b54d
commit
76558da849
|
@ -52,6 +52,8 @@ extern "C" {
|
|||
#define TSDB_INS_TABLE_VIEWS "ins_views"
|
||||
#define TSDB_INS_TABLE_COMPACTS "ins_compacts"
|
||||
#define TSDB_INS_TABLE_COMPACT_DETAILS "ins_compact_details"
|
||||
#define TSDB_INS_TABLE_GRANTS_FULL "ins_grants_full"
|
||||
#define TSDB_INS_TABLE_GRANTS_LOG "ins_grants_log"
|
||||
|
||||
#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema"
|
||||
#define TSDB_PERFS_TABLE_SMAS "perf_smas"
|
||||
|
|
|
@ -147,6 +147,8 @@ typedef enum _mgmt_table {
|
|||
TSDB_MGMT_TABLE_VIEWS,
|
||||
TSDB_MGMT_TABLE_COMPACT,
|
||||
TSDB_MGMT_TABLE_COMPACT_DETAIL,
|
||||
TSDB_MGMT_TABLE_GRANTS_FULL,
|
||||
TSDB_MGMT_TABLE_GRANTS_LOG,
|
||||
TSDB_MGMT_TABLE_MAX,
|
||||
} EShowType;
|
||||
|
||||
|
@ -360,6 +362,8 @@ typedef enum ENodeType {
|
|||
QUERY_NODE_SHOW_VIEWS_STMT,
|
||||
QUERY_NODE_SHOW_COMPACTS_STMT,
|
||||
QUERY_NODE_SHOW_COMPACT_DETAILS_STMT,
|
||||
QUERY_NODE_SHOW_GRANTS_FULL_STMT,
|
||||
QUERY_NODE_SHOW_GRANTS_LOG_STMT,
|
||||
|
||||
// logic plan node
|
||||
QUERY_NODE_LOGIC_PLAN_SCAN = 1000,
|
||||
|
|
|
@ -175,194 +175,196 @@
|
|||
#define TK_CONNECTIONS 156
|
||||
#define TK_LICENCES 157
|
||||
#define TK_GRANTS 158
|
||||
#define TK_QUERIES 159
|
||||
#define TK_SCORES 160
|
||||
#define TK_TOPICS 161
|
||||
#define TK_VARIABLES 162
|
||||
#define TK_BNODES 163
|
||||
#define TK_SNODES 164
|
||||
#define TK_TRANSACTIONS 165
|
||||
#define TK_DISTRIBUTED 166
|
||||
#define TK_CONSUMERS 167
|
||||
#define TK_SUBSCRIPTIONS 168
|
||||
#define TK_VNODES 169
|
||||
#define TK_ALIVE 170
|
||||
#define TK_VIEWS 171
|
||||
#define TK_VIEW 172
|
||||
#define TK_COMPACTS 173
|
||||
#define TK_NORMAL 174
|
||||
#define TK_CHILD 175
|
||||
#define TK_LIKE 176
|
||||
#define TK_TBNAME 177
|
||||
#define TK_QTAGS 178
|
||||
#define TK_AS 179
|
||||
#define TK_SYSTEM 180
|
||||
#define TK_INDEX 181
|
||||
#define TK_FUNCTION 182
|
||||
#define TK_INTERVAL 183
|
||||
#define TK_COUNT 184
|
||||
#define TK_LAST_ROW 185
|
||||
#define TK_META 186
|
||||
#define TK_ONLY 187
|
||||
#define TK_TOPIC 188
|
||||
#define TK_CONSUMER 189
|
||||
#define TK_GROUP 190
|
||||
#define TK_DESC 191
|
||||
#define TK_DESCRIBE 192
|
||||
#define TK_RESET 193
|
||||
#define TK_QUERY 194
|
||||
#define TK_CACHE 195
|
||||
#define TK_EXPLAIN 196
|
||||
#define TK_ANALYZE 197
|
||||
#define TK_VERBOSE 198
|
||||
#define TK_NK_BOOL 199
|
||||
#define TK_RATIO 200
|
||||
#define TK_NK_FLOAT 201
|
||||
#define TK_OUTPUTTYPE 202
|
||||
#define TK_AGGREGATE 203
|
||||
#define TK_BUFSIZE 204
|
||||
#define TK_LANGUAGE 205
|
||||
#define TK_REPLACE 206
|
||||
#define TK_STREAM 207
|
||||
#define TK_INTO 208
|
||||
#define TK_PAUSE 209
|
||||
#define TK_RESUME 210
|
||||
#define TK_TRIGGER 211
|
||||
#define TK_AT_ONCE 212
|
||||
#define TK_WINDOW_CLOSE 213
|
||||
#define TK_IGNORE 214
|
||||
#define TK_EXPIRED 215
|
||||
#define TK_FILL_HISTORY 216
|
||||
#define TK_UPDATE 217
|
||||
#define TK_SUBTABLE 218
|
||||
#define TK_UNTREATED 219
|
||||
#define TK_KILL 220
|
||||
#define TK_CONNECTION 221
|
||||
#define TK_TRANSACTION 222
|
||||
#define TK_BALANCE 223
|
||||
#define TK_VGROUP 224
|
||||
#define TK_LEADER 225
|
||||
#define TK_MERGE 226
|
||||
#define TK_REDISTRIBUTE 227
|
||||
#define TK_SPLIT 228
|
||||
#define TK_DELETE 229
|
||||
#define TK_INSERT 230
|
||||
#define TK_NULL 231
|
||||
#define TK_NK_QUESTION 232
|
||||
#define TK_NK_ALIAS 233
|
||||
#define TK_NK_ARROW 234
|
||||
#define TK_ROWTS 235
|
||||
#define TK_QSTART 236
|
||||
#define TK_QEND 237
|
||||
#define TK_QDURATION 238
|
||||
#define TK_WSTART 239
|
||||
#define TK_WEND 240
|
||||
#define TK_WDURATION 241
|
||||
#define TK_IROWTS 242
|
||||
#define TK_ISFILLED 243
|
||||
#define TK_CAST 244
|
||||
#define TK_NOW 245
|
||||
#define TK_TODAY 246
|
||||
#define TK_TIMEZONE 247
|
||||
#define TK_CLIENT_VERSION 248
|
||||
#define TK_SERVER_VERSION 249
|
||||
#define TK_SERVER_STATUS 250
|
||||
#define TK_CURRENT_USER 251
|
||||
#define TK_CASE 252
|
||||
#define TK_WHEN 253
|
||||
#define TK_THEN 254
|
||||
#define TK_ELSE 255
|
||||
#define TK_BETWEEN 256
|
||||
#define TK_IS 257
|
||||
#define TK_NK_LT 258
|
||||
#define TK_NK_GT 259
|
||||
#define TK_NK_LE 260
|
||||
#define TK_NK_GE 261
|
||||
#define TK_NK_NE 262
|
||||
#define TK_MATCH 263
|
||||
#define TK_NMATCH 264
|
||||
#define TK_CONTAINS 265
|
||||
#define TK_IN 266
|
||||
#define TK_JOIN 267
|
||||
#define TK_INNER 268
|
||||
#define TK_SELECT 269
|
||||
#define TK_NK_HINT 270
|
||||
#define TK_DISTINCT 271
|
||||
#define TK_WHERE 272
|
||||
#define TK_PARTITION 273
|
||||
#define TK_BY 274
|
||||
#define TK_SESSION 275
|
||||
#define TK_STATE_WINDOW 276
|
||||
#define TK_EVENT_WINDOW 277
|
||||
#define TK_SLIDING 278
|
||||
#define TK_FILL 279
|
||||
#define TK_VALUE 280
|
||||
#define TK_VALUE_F 281
|
||||
#define TK_NONE 282
|
||||
#define TK_PREV 283
|
||||
#define TK_NULL_F 284
|
||||
#define TK_LINEAR 285
|
||||
#define TK_NEXT 286
|
||||
#define TK_HAVING 287
|
||||
#define TK_RANGE 288
|
||||
#define TK_EVERY 289
|
||||
#define TK_ORDER 290
|
||||
#define TK_SLIMIT 291
|
||||
#define TK_SOFFSET 292
|
||||
#define TK_LIMIT 293
|
||||
#define TK_OFFSET 294
|
||||
#define TK_ASC 295
|
||||
#define TK_NULLS 296
|
||||
#define TK_ABORT 297
|
||||
#define TK_AFTER 298
|
||||
#define TK_ATTACH 299
|
||||
#define TK_BEFORE 300
|
||||
#define TK_BEGIN 301
|
||||
#define TK_BITAND 302
|
||||
#define TK_BITNOT 303
|
||||
#define TK_BITOR 304
|
||||
#define TK_BLOCKS 305
|
||||
#define TK_CHANGE 306
|
||||
#define TK_COMMA 307
|
||||
#define TK_CONCAT 308
|
||||
#define TK_CONFLICT 309
|
||||
#define TK_COPY 310
|
||||
#define TK_DEFERRED 311
|
||||
#define TK_DELIMITERS 312
|
||||
#define TK_DETACH 313
|
||||
#define TK_DIVIDE 314
|
||||
#define TK_DOT 315
|
||||
#define TK_EACH 316
|
||||
#define TK_FAIL 317
|
||||
#define TK_FILE 318
|
||||
#define TK_FOR 319
|
||||
#define TK_GLOB 320
|
||||
#define TK_ID 321
|
||||
#define TK_IMMEDIATE 322
|
||||
#define TK_IMPORT 323
|
||||
#define TK_INITIALLY 324
|
||||
#define TK_INSTEAD 325
|
||||
#define TK_ISNULL 326
|
||||
#define TK_KEY 327
|
||||
#define TK_MODULES 328
|
||||
#define TK_NK_BITNOT 329
|
||||
#define TK_NK_SEMI 330
|
||||
#define TK_NOTNULL 331
|
||||
#define TK_OF 332
|
||||
#define TK_PLUS 333
|
||||
#define TK_PRIVILEGE 334
|
||||
#define TK_RAISE 335
|
||||
#define TK_RESTRICT 336
|
||||
#define TK_ROW 337
|
||||
#define TK_SEMI 338
|
||||
#define TK_STAR 339
|
||||
#define TK_STATEMENT 340
|
||||
#define TK_STRICT 341
|
||||
#define TK_STRING 342
|
||||
#define TK_TIMES 343
|
||||
#define TK_VALUES 344
|
||||
#define TK_VARIABLE 345
|
||||
#define TK_WAL 346
|
||||
#define TK_FULL 159
|
||||
#define TK_LOG 160
|
||||
#define TK_QUERIES 161
|
||||
#define TK_SCORES 162
|
||||
#define TK_TOPICS 163
|
||||
#define TK_VARIABLES 164
|
||||
#define TK_BNODES 165
|
||||
#define TK_SNODES 166
|
||||
#define TK_TRANSACTIONS 167
|
||||
#define TK_DISTRIBUTED 168
|
||||
#define TK_CONSUMERS 169
|
||||
#define TK_SUBSCRIPTIONS 170
|
||||
#define TK_VNODES 171
|
||||
#define TK_ALIVE 172
|
||||
#define TK_VIEWS 173
|
||||
#define TK_VIEW 174
|
||||
#define TK_COMPACTS 175
|
||||
#define TK_NORMAL 176
|
||||
#define TK_CHILD 177
|
||||
#define TK_LIKE 178
|
||||
#define TK_TBNAME 179
|
||||
#define TK_QTAGS 180
|
||||
#define TK_AS 181
|
||||
#define TK_SYSTEM 182
|
||||
#define TK_INDEX 183
|
||||
#define TK_FUNCTION 184
|
||||
#define TK_INTERVAL 185
|
||||
#define TK_COUNT 186
|
||||
#define TK_LAST_ROW 187
|
||||
#define TK_META 188
|
||||
#define TK_ONLY 189
|
||||
#define TK_TOPIC 190
|
||||
#define TK_CONSUMER 191
|
||||
#define TK_GROUP 192
|
||||
#define TK_DESC 193
|
||||
#define TK_DESCRIBE 194
|
||||
#define TK_RESET 195
|
||||
#define TK_QUERY 196
|
||||
#define TK_CACHE 197
|
||||
#define TK_EXPLAIN 198
|
||||
#define TK_ANALYZE 199
|
||||
#define TK_VERBOSE 200
|
||||
#define TK_NK_BOOL 201
|
||||
#define TK_RATIO 202
|
||||
#define TK_NK_FLOAT 203
|
||||
#define TK_OUTPUTTYPE 204
|
||||
#define TK_AGGREGATE 205
|
||||
#define TK_BUFSIZE 206
|
||||
#define TK_LANGUAGE 207
|
||||
#define TK_REPLACE 208
|
||||
#define TK_STREAM 209
|
||||
#define TK_INTO 210
|
||||
#define TK_PAUSE 211
|
||||
#define TK_RESUME 212
|
||||
#define TK_TRIGGER 213
|
||||
#define TK_AT_ONCE 214
|
||||
#define TK_WINDOW_CLOSE 215
|
||||
#define TK_IGNORE 216
|
||||
#define TK_EXPIRED 217
|
||||
#define TK_FILL_HISTORY 218
|
||||
#define TK_UPDATE 219
|
||||
#define TK_SUBTABLE 220
|
||||
#define TK_UNTREATED 221
|
||||
#define TK_KILL 222
|
||||
#define TK_CONNECTION 223
|
||||
#define TK_TRANSACTION 224
|
||||
#define TK_BALANCE 225
|
||||
#define TK_VGROUP 226
|
||||
#define TK_LEADER 227
|
||||
#define TK_MERGE 228
|
||||
#define TK_REDISTRIBUTE 229
|
||||
#define TK_SPLIT 230
|
||||
#define TK_DELETE 231
|
||||
#define TK_INSERT 232
|
||||
#define TK_NULL 233
|
||||
#define TK_NK_QUESTION 234
|
||||
#define TK_NK_ALIAS 235
|
||||
#define TK_NK_ARROW 236
|
||||
#define TK_ROWTS 237
|
||||
#define TK_QSTART 238
|
||||
#define TK_QEND 239
|
||||
#define TK_QDURATION 240
|
||||
#define TK_WSTART 241
|
||||
#define TK_WEND 242
|
||||
#define TK_WDURATION 243
|
||||
#define TK_IROWTS 244
|
||||
#define TK_ISFILLED 245
|
||||
#define TK_CAST 246
|
||||
#define TK_NOW 247
|
||||
#define TK_TODAY 248
|
||||
#define TK_TIMEZONE 249
|
||||
#define TK_CLIENT_VERSION 250
|
||||
#define TK_SERVER_VERSION 251
|
||||
#define TK_SERVER_STATUS 252
|
||||
#define TK_CURRENT_USER 253
|
||||
#define TK_CASE 254
|
||||
#define TK_WHEN 255
|
||||
#define TK_THEN 256
|
||||
#define TK_ELSE 257
|
||||
#define TK_BETWEEN 258
|
||||
#define TK_IS 259
|
||||
#define TK_NK_LT 260
|
||||
#define TK_NK_GT 261
|
||||
#define TK_NK_LE 262
|
||||
#define TK_NK_GE 263
|
||||
#define TK_NK_NE 264
|
||||
#define TK_MATCH 265
|
||||
#define TK_NMATCH 266
|
||||
#define TK_CONTAINS 267
|
||||
#define TK_IN 268
|
||||
#define TK_JOIN 269
|
||||
#define TK_INNER 270
|
||||
#define TK_SELECT 271
|
||||
#define TK_NK_HINT 272
|
||||
#define TK_DISTINCT 273
|
||||
#define TK_WHERE 274
|
||||
#define TK_PARTITION 275
|
||||
#define TK_BY 276
|
||||
#define TK_SESSION 277
|
||||
#define TK_STATE_WINDOW 278
|
||||
#define TK_EVENT_WINDOW 279
|
||||
#define TK_SLIDING 280
|
||||
#define TK_FILL 281
|
||||
#define TK_VALUE 282
|
||||
#define TK_VALUE_F 283
|
||||
#define TK_NONE 284
|
||||
#define TK_PREV 285
|
||||
#define TK_NULL_F 286
|
||||
#define TK_LINEAR 287
|
||||
#define TK_NEXT 288
|
||||
#define TK_HAVING 289
|
||||
#define TK_RANGE 290
|
||||
#define TK_EVERY 291
|
||||
#define TK_ORDER 292
|
||||
#define TK_SLIMIT 293
|
||||
#define TK_SOFFSET 294
|
||||
#define TK_LIMIT 295
|
||||
#define TK_OFFSET 296
|
||||
#define TK_ASC 297
|
||||
#define TK_NULLS 298
|
||||
#define TK_ABORT 299
|
||||
#define TK_AFTER 300
|
||||
#define TK_ATTACH 301
|
||||
#define TK_BEFORE 302
|
||||
#define TK_BEGIN 303
|
||||
#define TK_BITAND 304
|
||||
#define TK_BITNOT 305
|
||||
#define TK_BITOR 306
|
||||
#define TK_BLOCKS 307
|
||||
#define TK_CHANGE 308
|
||||
#define TK_COMMA 309
|
||||
#define TK_CONCAT 310
|
||||
#define TK_CONFLICT 311
|
||||
#define TK_COPY 312
|
||||
#define TK_DEFERRED 313
|
||||
#define TK_DELIMITERS 314
|
||||
#define TK_DETACH 315
|
||||
#define TK_DIVIDE 316
|
||||
#define TK_DOT 317
|
||||
#define TK_EACH 318
|
||||
#define TK_FAIL 319
|
||||
#define TK_FILE 320
|
||||
#define TK_FOR 321
|
||||
#define TK_GLOB 322
|
||||
#define TK_ID 323
|
||||
#define TK_IMMEDIATE 324
|
||||
#define TK_IMPORT 325
|
||||
#define TK_INITIALLY 326
|
||||
#define TK_INSTEAD 327
|
||||
#define TK_ISNULL 328
|
||||
#define TK_KEY 329
|
||||
#define TK_MODULES 330
|
||||
#define TK_NK_BITNOT 331
|
||||
#define TK_NK_SEMI 332
|
||||
#define TK_NOTNULL 333
|
||||
#define TK_OF 334
|
||||
#define TK_PLUS 335
|
||||
#define TK_PRIVILEGE 336
|
||||
#define TK_RAISE 337
|
||||
#define TK_RESTRICT 338
|
||||
#define TK_ROW 339
|
||||
#define TK_SEMI 340
|
||||
#define TK_STAR 341
|
||||
#define TK_STATEMENT 342
|
||||
#define TK_STRICT 343
|
||||
#define TK_STRING 344
|
||||
#define TK_TIMES 345
|
||||
#define TK_VALUES 346
|
||||
#define TK_VARIABLE 347
|
||||
#define TK_WAL 348
|
||||
|
||||
#define TK_NK_SPACE 600
|
||||
#define TK_NK_COMMENT 601
|
||||
|
|
|
@ -353,6 +353,18 @@ static const SSysDbTableSchema userCompactsDetailSchema[] = {
|
|||
{.name = "start_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema useGrantsFullSchema[] = {
|
||||
{.name = "grant_name", .bytes = 32 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "display_name", .bytes = 256 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "limit", .bytes = 512 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema useGrantsLogSchema[] = {
|
||||
{.name = "state", .bytes = 1536 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "active", .bytes = 512 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "machine", .bytes = 6016 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
};
|
||||
|
||||
static const SSysTableMeta infosMeta[] = {
|
||||
{TSDB_INS_TABLE_DNODES, dnodesSchema, tListLen(dnodesSchema), true},
|
||||
{TSDB_INS_TABLE_MNODES, mnodesSchema, tListLen(mnodesSchema), true},
|
||||
|
@ -382,6 +394,8 @@ static const SSysTableMeta infosMeta[] = {
|
|||
{TSDB_INS_TABLE_VIEWS, userViewsSchema, tListLen(userViewsSchema), false},
|
||||
{TSDB_INS_TABLE_COMPACTS, userCompactsSchema, tListLen(userCompactsSchema), false},
|
||||
{TSDB_INS_TABLE_COMPACT_DETAILS, userCompactsDetailSchema, tListLen(userCompactsDetailSchema), false},
|
||||
{TSDB_INS_TABLE_GRANTS_FULL, useGrantsFullSchema, tListLen(useGrantsFullSchema), false},
|
||||
{TSDB_INS_TABLE_GRANTS_LOG, useGrantsLogSchema, tListLen(useGrantsLogSchema), false},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema connectionsSchema[] = {
|
||||
|
|
|
@ -768,6 +768,72 @@ typedef struct {
|
|||
SArray* compactDetail;
|
||||
} SCompactObj;
|
||||
|
||||
// SGrantObj
|
||||
typedef enum {
|
||||
GRANT_STATE_UNGRANTED = 0,
|
||||
GRANT_STATE_GRANTED = 1,
|
||||
GRANT_STATE_EXPIRED = 2,
|
||||
GRANT_STATE_REVOKED = 3,
|
||||
} EGrantState;
|
||||
|
||||
typedef enum {
|
||||
GRANT_STATE_REASON_ALTER = 0, // alter activeCode 'revoked' or 'xxx'
|
||||
GRANT_STATE_REASON_MISMATCH = 1, // dnode machine mismatch
|
||||
GRANT_STATE_REASON_EXPIRE = 2, // expire
|
||||
} EGrantStateReason;
|
||||
|
||||
#define GRANT_STATE_NUM 30
|
||||
#define GRANT_ACTIVE_NUM 10
|
||||
#define GRANT_ACTIVE_LEN 30
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
int64_t u0;
|
||||
struct {
|
||||
int64_t ts : 36;
|
||||
int64_t reserve : 4;
|
||||
int64_t lastState : 8;
|
||||
int64_t state : 8;
|
||||
int64_t reason : 8;
|
||||
};
|
||||
};
|
||||
} SGrantState;
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
int64_t u0;
|
||||
struct {
|
||||
int64_t ts : 36;
|
||||
int64_t reserve : 28;
|
||||
};
|
||||
};
|
||||
char active[GRANT_ACTIVE_LEN + 1];
|
||||
} SGrantActive;
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
int64_t u0;
|
||||
struct {
|
||||
int64_t ts : 36;
|
||||
int64_t reserve : 4;
|
||||
int64_t id : 24;
|
||||
};
|
||||
};
|
||||
uint16_t port;
|
||||
char fqdn[TSDB_FQDN_LEN];
|
||||
char machine[TSDB_MACHINE_ID_LEN + 1];
|
||||
} SGrantMachine;
|
||||
|
||||
typedef struct {
|
||||
int32_t id;
|
||||
int64_t createTime;
|
||||
int64_t updateTime;
|
||||
SGrantState state[GRANT_STATE_NUM];
|
||||
SGrantActive active[GRANT_ACTIVE_NUM];
|
||||
SArray *pMachines; // SGrantMachines
|
||||
SRWLatch lock;
|
||||
} SGrantObj;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TDENGINE_GTANT_H
|
||||
#define TDENGINE_GTANT_H
|
||||
#ifndef _TD_MND_GRANT_H_
|
||||
#define _TD_MND_GRANT_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
"C" {
|
||||
|
@ -23,12 +23,33 @@
|
|||
#include "mndInt.h"
|
||||
|
||||
int32_t mndInitGrant(SMnode * pMnode);
|
||||
void mndCleanupGrant();
|
||||
void mndCleanupGrant(SMnode * pMnode);
|
||||
void grantParseParameter();
|
||||
void grantReset(SMnode * pMnode, EGrantType grant, uint64_t value);
|
||||
void grantAdd(EGrantType grant, uint64_t value);
|
||||
void grantRestore(EGrantType grant, uint64_t value);
|
||||
|
||||
|
||||
#ifdef TD_ENTERPRISE
|
||||
|
||||
// void initDynGrantVersion(void);
|
||||
|
||||
SGrantObj *mndAcquireGrant(SMnode * pMnode, int32_t id);
|
||||
void mndReleaseGrant(SMnode * pMnode, SGrantObj *pGrant);
|
||||
|
||||
SSdbRaw *mndGrantActionEncode(SGrantObj * pGrant);
|
||||
SSdbRow *mndGrantActionDecode(SSdbRaw * pRaw);
|
||||
int32_t mndGrantActionInsert(SSdb * pSdb, SGrantObj * pGrant);
|
||||
int32_t mndGrantActionDelete(SSdb * pSdb, SGrantObj * pGrant);
|
||||
int32_t mndGrantActionUpdate(SSdb * pSdb, SGrantObj * pOldGrant, SGrantObj * pNewGrant);
|
||||
|
||||
int32_t mndProcessUpdMachineReqImpl(void *pMachine, SRpcMsg *pReq);
|
||||
int32_t mndProcessUpdStateReqImpl(void *pState, SRpcMsg *pReq);
|
||||
int32_t mndProcessUpdActiveReqImpl(void *pActive, SRpcMsg *pReq);
|
||||
int32_t mndRetrieveGrantImpl(SRpcMsg * pReq, SShowObj * pShow, SSDataBlock * pBlock, int32_t rows);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -19,6 +19,15 @@
|
|||
|
||||
#ifndef _GRANT
|
||||
|
||||
#define GRANT_ITEM_SHOW() \
|
||||
do { \
|
||||
cols++; \
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols); \
|
||||
src = "unlimited"; \
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32); \
|
||||
colDataSetVal(pColInfo, numOfRows, tmp, false); \
|
||||
} while (0)
|
||||
|
||||
static int32_t mndRetrieveGrant(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
||||
int32_t numOfRows = 0;
|
||||
int32_t cols = 0;
|
||||
|
@ -31,47 +40,13 @@ static int32_t mndRetrieveGrant(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
|
|||
STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
|
||||
colDataSetVal(pColInfo, numOfRows, tmp, false);
|
||||
|
||||
cols++;
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
||||
src = "unlimited";
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
|
||||
colDataSetVal(pColInfo, numOfRows, tmp, false);
|
||||
|
||||
cols++;
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
||||
src = "false";
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
|
||||
colDataSetVal(pColInfo, numOfRows, tmp, false);
|
||||
|
||||
cols++;
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
||||
src = "unlimited";
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
|
||||
colDataSetVal(pColInfo, numOfRows, tmp, false);
|
||||
|
||||
cols++;
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
||||
src = "unlimited";
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
|
||||
colDataSetVal(pColInfo, numOfRows, tmp, false);
|
||||
|
||||
cols++;
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
||||
src = "unlimited";
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
|
||||
colDataSetVal(pColInfo, numOfRows, tmp, false);
|
||||
|
||||
cols++;
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
||||
src = "unlimited";
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
|
||||
colDataSetVal(pColInfo, numOfRows, tmp, false);
|
||||
|
||||
cols++;
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
||||
src = "unlimited";
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
|
||||
colDataSetVal(pColInfo, numOfRows, tmp, false);
|
||||
GRANT_ITEM_SHOW();
|
||||
GRANT_ITEM_SHOW();
|
||||
GRANT_ITEM_SHOW();
|
||||
GRANT_ITEM_SHOW();
|
||||
GRANT_ITEM_SHOW();
|
||||
GRANT_ITEM_SHOW();
|
||||
GRANT_ITEM_SHOW();
|
||||
|
||||
numOfRows++;
|
||||
}
|
||||
|
@ -80,15 +55,20 @@ static int32_t mndRetrieveGrant(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
|
|||
return numOfRows;
|
||||
}
|
||||
|
||||
static int32_t mndRetrieveGrantFull(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { return 0; }
|
||||
static int32_t mndRetrieveGrantLog(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { return 0; }
|
||||
|
||||
static int32_t mndProcessGrantHB(SRpcMsg *pReq) { return TSDB_CODE_SUCCESS; }
|
||||
|
||||
int32_t mndInitGrant(SMnode *pMnode) {
|
||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_GRANTS, mndRetrieveGrant);
|
||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_GRANTS_FULL, mndRetrieveGrantFull);
|
||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_GRANTS_LOG, mndRetrieveGrantLog);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_GRANT_HB_TIMER, mndProcessGrantHB);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mndCleanupGrant() {}
|
||||
void mndCleanupGrant(SMnode *pMnode) {}
|
||||
void grantParseParameter() { mError("can't parsed parameter k"); }
|
||||
void grantReset(SMnode *pMnode, EGrantType grant, uint64_t value) {}
|
||||
void grantAdd(EGrantType grant, uint64_t value) {}
|
||||
|
|
|
@ -123,6 +123,10 @@ static int32_t convertToRetrieveType(char *name, int32_t len) {
|
|||
type = TSDB_MGMT_TABLE_COMPACT;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_COMPACT_DETAILS, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_COMPACT_DETAIL;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_GRANTS_FULL, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_GRANTS_FULL;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_GRANTS_LOG, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_GRANTS_LOG;
|
||||
} else {
|
||||
mError("invalid show name:%s len:%d", name, len);
|
||||
}
|
||||
|
|
|
@ -152,7 +152,8 @@ typedef enum {
|
|||
SDB_STREAM_SEQ = 23,
|
||||
SDB_COMPACT = 24,
|
||||
SDB_COMPACT_DETAIL = 25,
|
||||
SDB_MAX = 26
|
||||
SDB_GRANT = 26, // grant log
|
||||
SDB_MAX = 27
|
||||
} ESdbType;
|
||||
|
||||
typedef struct SSdbRaw {
|
||||
|
|
|
@ -264,7 +264,11 @@ const char* nodesNodeName(ENodeType type) {
|
|||
case QUERY_NODE_SHOW_COMPACTS_STMT:
|
||||
return "ShowCompactsStmt";
|
||||
case QUERY_NODE_SHOW_COMPACT_DETAILS_STMT:
|
||||
return "ShowCompactDetailsStmt";
|
||||
return "ShowCompactDetailsStmt";
|
||||
case QUERY_NODE_SHOW_GRANTS_FULL_STMT:
|
||||
return "ShowGrantsFullStmt";
|
||||
case QUERY_NODE_SHOW_GRANTS_LOG_STMT:
|
||||
return "ShowGrantsLogStmt";
|
||||
case QUERY_NODE_DELETE_STMT:
|
||||
return "DeleteStmt";
|
||||
case QUERY_NODE_INSERT_STMT:
|
||||
|
|
|
@ -441,6 +441,8 @@ SNode* nodesMakeNode(ENodeType type) {
|
|||
case QUERY_NODE_SHOW_TAGS_STMT:
|
||||
case QUERY_NODE_SHOW_USER_PRIVILEGES_STMT:
|
||||
case QUERY_NODE_SHOW_VIEWS_STMT:
|
||||
case QUERY_NODE_SHOW_GRANTS_FULL_STMT:
|
||||
case QUERY_NODE_SHOW_GRANTS_LOG_STMT:
|
||||
return makeNode(type, sizeof(SShowStmt));
|
||||
case QUERY_NODE_SHOW_TABLE_TAGS_STMT:
|
||||
return makeNode(type, sizeof(SShowTableTagsStmt));
|
||||
|
@ -1079,7 +1081,9 @@ void nodesDestroyNode(SNode* pNode) {
|
|||
case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT:
|
||||
case QUERY_NODE_SHOW_TAGS_STMT:
|
||||
case QUERY_NODE_SHOW_USER_PRIVILEGES_STMT:
|
||||
case QUERY_NODE_SHOW_VIEWS_STMT: {
|
||||
case QUERY_NODE_SHOW_VIEWS_STMT:
|
||||
case QUERY_NODE_SHOW_GRANTS_FULL_STMT:
|
||||
case QUERY_NODE_SHOW_GRANTS_LOG_STMT: {
|
||||
SShowStmt* pStmt = (SShowStmt*)pNode;
|
||||
nodesDestroyNode(pStmt->pDbName);
|
||||
nodesDestroyNode(pStmt->pTbName);
|
||||
|
|
|
@ -487,6 +487,8 @@ cmd ::= SHOW APPS.
|
|||
cmd ::= SHOW CONNECTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT); }
|
||||
cmd ::= SHOW LICENCES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCES_STMT); }
|
||||
cmd ::= SHOW GRANTS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCES_STMT); }
|
||||
cmd ::= SHOW GRANTS FULL. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_GRANTS_FULL_STMT); }
|
||||
cmd ::= SHOW GRANTS LOG. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_GRANTS_LOG_STMT); }
|
||||
cmd ::= SHOW CREATE DATABASE db_name(A). { pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &A); }
|
||||
cmd ::= SHOW CREATE TABLE full_table_name(A). { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, A); }
|
||||
cmd ::= SHOW CREATE STABLE full_table_name(A). { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, A); }
|
||||
|
|
|
@ -619,6 +619,16 @@ static int32_t collectMetaKeyFromShowCompactDetails(SCollectMetaKeyCxt* pCxt, SS
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t collectMetaKeyFromShowGrantsFull(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_GRANTS_FULL,
|
||||
pCxt->pMetaCache);
|
||||
}
|
||||
|
||||
static int32_t collectMetaKeyFromShowGrantsLog(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_GRANTS_LOG,
|
||||
pCxt->pMetaCache);
|
||||
}
|
||||
|
||||
static int32_t collectMetaKeyFromShowCreateDatabase(SCollectMetaKeyCxt* pCxt, SShowCreateDatabaseStmt* pStmt) {
|
||||
return reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
|
||||
}
|
||||
|
@ -839,6 +849,10 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
|
|||
return collectMetaKeyFromShowCompacts(pCxt, (SShowStmt*)pStmt);
|
||||
case QUERY_NODE_SHOW_COMPACT_DETAILS_STMT:
|
||||
return collectMetaKeyFromShowCompactDetails(pCxt, (SShowStmt*)pStmt);
|
||||
case QUERY_NODE_SHOW_GRANTS_FULL_STMT:
|
||||
return collectMetaKeyFromShowGrantsFull(pCxt, (SShowStmt*)pStmt);
|
||||
case QUERY_NODE_SHOW_GRANTS_LOG_STMT:
|
||||
return collectMetaKeyFromShowGrantsLog(pCxt, (SShowStmt*)pStmt);
|
||||
case QUERY_NODE_SHOW_CREATE_DATABASE_STMT:
|
||||
return collectMetaKeyFromShowCreateDatabase(pCxt, (SShowCreateDatabaseStmt*)pStmt);
|
||||
case QUERY_NODE_SHOW_CREATE_TABLE_STMT:
|
||||
|
|
|
@ -349,6 +349,8 @@ static int32_t authQuery(SAuthCxt* pCxt, SNode* pStmt) {
|
|||
case QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT:
|
||||
case QUERY_NODE_SHOW_VNODES_STMT:
|
||||
case QUERY_NODE_SHOW_SCORES_STMT:
|
||||
case QUERY_NODE_SHOW_GRANTS_FULL_STMT:
|
||||
case QUERY_NODE_SHOW_GRANTS_LOG_STMT:
|
||||
return !pCxt->pParseCxt->enableSysInfo ? TSDB_CODE_PAR_PERMISSION_DENIED : TSDB_CODE_SUCCESS;
|
||||
case QUERY_NODE_SHOW_TABLES_STMT:
|
||||
case QUERY_NODE_SHOW_STABLES_STMT:
|
||||
|
|
|
@ -268,7 +268,19 @@ static const SSysTableShowAdapter sysTableShowAdapter[] = {
|
|||
.pTableName = TSDB_INS_TABLE_COMPACT_DETAILS,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"*"}
|
||||
},
|
||||
},
|
||||
{ .showType = QUERY_NODE_SHOW_GRANTS_FULL_STMT,
|
||||
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
||||
.pTableName = TSDB_INS_TABLE_GRANTS_FULL,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"*"}
|
||||
},
|
||||
{ .showType = QUERY_NODE_SHOW_GRANTS_FULL_STMT,
|
||||
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
||||
.pTableName = TSDB_INS_TABLE_GRANTS_LOG,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"*"}
|
||||
},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
|
@ -10636,6 +10648,8 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) {
|
|||
case QUERY_NODE_SHOW_TAGS_STMT:
|
||||
case QUERY_NODE_SHOW_USER_PRIVILEGES_STMT:
|
||||
case QUERY_NODE_SHOW_VIEWS_STMT:
|
||||
case QUERY_NODE_SHOW_GRANTS_FULL_STMT:
|
||||
case QUERY_NODE_SHOW_GRANTS_LOG_STMT:
|
||||
code = rewriteShow(pCxt, pQuery);
|
||||
break;
|
||||
case QUERY_NODE_SHOW_VGROUPS_STMT:
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue