feat: encryptions/encrypt_key grammar

This commit is contained in:
kailixu 2024-03-26 19:56:15 +08:00
parent ab093d80bd
commit 374ef4593c
17 changed files with 5294 additions and 6458 deletions

View File

@ -56,6 +56,7 @@ extern "C" {
#define TSDB_INS_TABLE_GRANTS_FULL "ins_grants_full"
#define TSDB_INS_TABLE_GRANTS_LOGS "ins_grants_logs"
#define TSDB_INS_TABLE_MACHINES "ins_machines"
#define TSDB_INS_TABLE_ENCRYPTIONS "ins_encryptions"
#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema"
#define TSDB_PERFS_TABLE_SMAS "perf_smas"

View File

@ -151,6 +151,7 @@ typedef enum _mgmt_table {
TSDB_MGMT_TABLE_GRANTS_LOGS,
TSDB_MGMT_TABLE_MACHINES,
TSDB_MGMT_TABLE_ARBGROUP,
TSDB_MGMT_TABLE_ENCRYPTIONS,
TSDB_MGMT_TABLE_MAX,
} EShowType;
@ -328,6 +329,7 @@ typedef enum ENodeType {
QUERY_NODE_RESUME_STREAM_STMT,
QUERY_NODE_CREATE_VIEW_STMT,
QUERY_NODE_DROP_VIEW_STMT,
QUERY_NODE_CREATE_ENCRYPT_KEY_STMT,
// show statement nodes
// see 'sysTableShowAdapter', 'SYSTABLE_SHOW_TYPE_OFFSET'
@ -366,6 +368,7 @@ typedef enum ENodeType {
QUERY_NODE_SHOW_GRANTS_FULL_STMT,
QUERY_NODE_SHOW_GRANTS_LOGS_STMT,
QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT,
QUERY_NODE_SHOW_ENCRYPTIONS_STMT,
// logic plan node
QUERY_NODE_LOGIC_PLAN_SCAN = 1000,

View File

@ -67,309 +67,312 @@
#define TK_WRITE 48
#define TK_NK_DOT 49
#define TK_WITH 50
#define TK_DNODE 51
#define TK_PORT 52
#define TK_DNODES 53
#define TK_RESTORE 54
#define TK_NK_IPTOKEN 55
#define TK_FORCE 56
#define TK_UNSAFE 57
#define TK_CLUSTER 58
#define TK_LOCAL 59
#define TK_QNODE 60
#define TK_BNODE 61
#define TK_SNODE 62
#define TK_MNODE 63
#define TK_VNODE 64
#define TK_DATABASE 65
#define TK_USE 66
#define TK_FLUSH 67
#define TK_TRIM 68
#define TK_COMPACT 69
#define TK_IF 70
#define TK_NOT 71
#define TK_EXISTS 72
#define TK_BUFFER 73
#define TK_CACHEMODEL 74
#define TK_CACHESIZE 75
#define TK_COMP 76
#define TK_DURATION 77
#define TK_NK_VARIABLE 78
#define TK_MAXROWS 79
#define TK_MINROWS 80
#define TK_KEEP 81
#define TK_PAGES 82
#define TK_PAGESIZE 83
#define TK_TSDB_PAGESIZE 84
#define TK_PRECISION 85
#define TK_REPLICA 86
#define TK_VGROUPS 87
#define TK_SINGLE_STABLE 88
#define TK_RETENTIONS 89
#define TK_SCHEMALESS 90
#define TK_WAL_LEVEL 91
#define TK_WAL_FSYNC_PERIOD 92
#define TK_WAL_RETENTION_PERIOD 93
#define TK_WAL_RETENTION_SIZE 94
#define TK_WAL_ROLL_PERIOD 95
#define TK_WAL_SEGMENT_SIZE 96
#define TK_STT_TRIGGER 97
#define TK_TABLE_PREFIX 98
#define TK_TABLE_SUFFIX 99
#define TK_KEEP_TIME_OFFSET 100
#define TK_NK_COLON 101
#define TK_BWLIMIT 102
#define TK_START 103
#define TK_TIMESTAMP 104
#define TK_END 105
#define TK_TABLE 106
#define TK_NK_LP 107
#define TK_NK_RP 108
#define TK_STABLE 109
#define TK_COLUMN 110
#define TK_MODIFY 111
#define TK_RENAME 112
#define TK_TAG 113
#define TK_SET 114
#define TK_NK_EQ 115
#define TK_USING 116
#define TK_TAGS 117
#define TK_BOOL 118
#define TK_TINYINT 119
#define TK_SMALLINT 120
#define TK_INT 121
#define TK_INTEGER 122
#define TK_BIGINT 123
#define TK_FLOAT 124
#define TK_DOUBLE 125
#define TK_BINARY 126
#define TK_NCHAR 127
#define TK_UNSIGNED 128
#define TK_JSON 129
#define TK_VARCHAR 130
#define TK_MEDIUMBLOB 131
#define TK_BLOB 132
#define TK_VARBINARY 133
#define TK_GEOMETRY 134
#define TK_DECIMAL 135
#define TK_COMMENT 136
#define TK_MAX_DELAY 137
#define TK_WATERMARK 138
#define TK_ROLLUP 139
#define TK_TTL 140
#define TK_SMA 141
#define TK_DELETE_MARK 142
#define TK_FIRST 143
#define TK_LAST 144
#define TK_SHOW 145
#define TK_PRIVILEGES 146
#define TK_DATABASES 147
#define TK_TABLES 148
#define TK_STABLES 149
#define TK_MNODES 150
#define TK_QNODES 151
#define TK_ARBGROUPS 152
#define TK_FUNCTIONS 153
#define TK_INDEXES 154
#define TK_ACCOUNTS 155
#define TK_APPS 156
#define TK_CONNECTIONS 157
#define TK_LICENCES 158
#define TK_GRANTS 159
#define TK_FULL 160
#define TK_LOGS 161
#define TK_MACHINES 162
#define TK_QUERIES 163
#define TK_SCORES 164
#define TK_TOPICS 165
#define TK_VARIABLES 166
#define TK_BNODES 167
#define TK_SNODES 168
#define TK_TRANSACTIONS 169
#define TK_DISTRIBUTED 170
#define TK_CONSUMERS 171
#define TK_SUBSCRIPTIONS 172
#define TK_VNODES 173
#define TK_ALIVE 174
#define TK_VIEWS 175
#define TK_VIEW 176
#define TK_COMPACTS 177
#define TK_NORMAL 178
#define TK_CHILD 179
#define TK_LIKE 180
#define TK_TBNAME 181
#define TK_QTAGS 182
#define TK_AS 183
#define TK_SYSTEM 184
#define TK_INDEX 185
#define TK_FUNCTION 186
#define TK_INTERVAL 187
#define TK_COUNT 188
#define TK_LAST_ROW 189
#define TK_META 190
#define TK_ONLY 191
#define TK_TOPIC 192
#define TK_CONSUMER 193
#define TK_GROUP 194
#define TK_DESC 195
#define TK_DESCRIBE 196
#define TK_RESET 197
#define TK_QUERY 198
#define TK_CACHE 199
#define TK_EXPLAIN 200
#define TK_ANALYZE 201
#define TK_VERBOSE 202
#define TK_NK_BOOL 203
#define TK_RATIO 204
#define TK_NK_FLOAT 205
#define TK_OUTPUTTYPE 206
#define TK_AGGREGATE 207
#define TK_BUFSIZE 208
#define TK_LANGUAGE 209
#define TK_REPLACE 210
#define TK_STREAM 211
#define TK_INTO 212
#define TK_PAUSE 213
#define TK_RESUME 214
#define TK_TRIGGER 215
#define TK_AT_ONCE 216
#define TK_WINDOW_CLOSE 217
#define TK_IGNORE 218
#define TK_EXPIRED 219
#define TK_FILL_HISTORY 220
#define TK_UPDATE 221
#define TK_SUBTABLE 222
#define TK_UNTREATED 223
#define TK_KILL 224
#define TK_CONNECTION 225
#define TK_TRANSACTION 226
#define TK_BALANCE 227
#define TK_VGROUP 228
#define TK_LEADER 229
#define TK_MERGE 230
#define TK_REDISTRIBUTE 231
#define TK_SPLIT 232
#define TK_DELETE 233
#define TK_INSERT 234
#define TK_NK_BIN 235
#define TK_NK_HEX 236
#define TK_NULL 237
#define TK_NK_QUESTION 238
#define TK_NK_ALIAS 239
#define TK_NK_ARROW 240
#define TK_ROWTS 241
#define TK_QSTART 242
#define TK_QEND 243
#define TK_QDURATION 244
#define TK_WSTART 245
#define TK_WEND 246
#define TK_WDURATION 247
#define TK_IROWTS 248
#define TK_ISFILLED 249
#define TK_CAST 250
#define TK_NOW 251
#define TK_TODAY 252
#define TK_TIMEZONE 253
#define TK_CLIENT_VERSION 254
#define TK_SERVER_VERSION 255
#define TK_SERVER_STATUS 256
#define TK_CURRENT_USER 257
#define TK_CASE 258
#define TK_WHEN 259
#define TK_THEN 260
#define TK_ELSE 261
#define TK_BETWEEN 262
#define TK_IS 263
#define TK_NK_LT 264
#define TK_NK_GT 265
#define TK_NK_LE 266
#define TK_NK_GE 267
#define TK_NK_NE 268
#define TK_MATCH 269
#define TK_NMATCH 270
#define TK_CONTAINS 271
#define TK_IN 272
#define TK_JOIN 273
#define TK_INNER 274
#define TK_SELECT 275
#define TK_NK_HINT 276
#define TK_DISTINCT 277
#define TK_WHERE 278
#define TK_PARTITION 279
#define TK_BY 280
#define TK_SESSION 281
#define TK_STATE_WINDOW 282
#define TK_EVENT_WINDOW 283
#define TK_COUNT_WINDOW 284
#define TK_SLIDING 285
#define TK_FILL 286
#define TK_VALUE 287
#define TK_VALUE_F 288
#define TK_NONE 289
#define TK_PREV 290
#define TK_NULL_F 291
#define TK_LINEAR 292
#define TK_NEXT 293
#define TK_HAVING 294
#define TK_RANGE 295
#define TK_EVERY 296
#define TK_ORDER 297
#define TK_SLIMIT 298
#define TK_SOFFSET 299
#define TK_LIMIT 300
#define TK_OFFSET 301
#define TK_ASC 302
#define TK_NULLS 303
#define TK_ABORT 304
#define TK_AFTER 305
#define TK_ATTACH 306
#define TK_BEFORE 307
#define TK_BEGIN 308
#define TK_BITAND 309
#define TK_BITNOT 310
#define TK_BITOR 311
#define TK_BLOCKS 312
#define TK_CHANGE 313
#define TK_COMMA 314
#define TK_CONCAT 315
#define TK_CONFLICT 316
#define TK_COPY 317
#define TK_DEFERRED 318
#define TK_DELIMITERS 319
#define TK_DETACH 320
#define TK_DIVIDE 321
#define TK_DOT 322
#define TK_EACH 323
#define TK_FAIL 324
#define TK_FILE 325
#define TK_FOR 326
#define TK_GLOB 327
#define TK_ID 328
#define TK_IMMEDIATE 329
#define TK_IMPORT 330
#define TK_INITIALLY 331
#define TK_INSTEAD 332
#define TK_ISNULL 333
#define TK_KEY 334
#define TK_MODULES 335
#define TK_NK_BITNOT 336
#define TK_NK_SEMI 337
#define TK_NOTNULL 338
#define TK_OF 339
#define TK_PLUS 340
#define TK_PRIVILEGE 341
#define TK_RAISE 342
#define TK_RESTRICT 343
#define TK_ROW 344
#define TK_SEMI 345
#define TK_STAR 346
#define TK_STATEMENT 347
#define TK_STRICT 348
#define TK_STRING 349
#define TK_TIMES 350
#define TK_VALUES 351
#define TK_VARIABLE 352
#define TK_WAL 353
#define TK_ENCRYPT_KEY 51
#define TK_DNODE 52
#define TK_PORT 53
#define TK_DNODES 54
#define TK_RESTORE 55
#define TK_NK_IPTOKEN 56
#define TK_FORCE 57
#define TK_UNSAFE 58
#define TK_CLUSTER 59
#define TK_LOCAL 60
#define TK_QNODE 61
#define TK_BNODE 62
#define TK_SNODE 63
#define TK_MNODE 64
#define TK_VNODE 65
#define TK_DATABASE 66
#define TK_USE 67
#define TK_FLUSH 68
#define TK_TRIM 69
#define TK_COMPACT 70
#define TK_IF 71
#define TK_NOT 72
#define TK_EXISTS 73
#define TK_BUFFER 74
#define TK_CACHEMODEL 75
#define TK_CACHESIZE 76
#define TK_COMP 77
#define TK_DURATION 78
#define TK_NK_VARIABLE 79
#define TK_MAXROWS 80
#define TK_MINROWS 81
#define TK_KEEP 82
#define TK_PAGES 83
#define TK_PAGESIZE 84
#define TK_TSDB_PAGESIZE 85
#define TK_PRECISION 86
#define TK_REPLICA 87
#define TK_VGROUPS 88
#define TK_SINGLE_STABLE 89
#define TK_RETENTIONS 90
#define TK_SCHEMALESS 91
#define TK_WAL_LEVEL 92
#define TK_WAL_FSYNC_PERIOD 93
#define TK_WAL_RETENTION_PERIOD 94
#define TK_WAL_RETENTION_SIZE 95
#define TK_WAL_ROLL_PERIOD 96
#define TK_WAL_SEGMENT_SIZE 97
#define TK_STT_TRIGGER 98
#define TK_TABLE_PREFIX 99
#define TK_TABLE_SUFFIX 100
#define TK_KEEP_TIME_OFFSET 101
#define TK_ENCRYPT_ALGORITHM 102
#define TK_NK_COLON 103
#define TK_BWLIMIT 104
#define TK_START 105
#define TK_TIMESTAMP 106
#define TK_END 107
#define TK_TABLE 108
#define TK_NK_LP 109
#define TK_NK_RP 110
#define TK_STABLE 111
#define TK_COLUMN 112
#define TK_MODIFY 113
#define TK_RENAME 114
#define TK_TAG 115
#define TK_SET 116
#define TK_NK_EQ 117
#define TK_USING 118
#define TK_TAGS 119
#define TK_BOOL 120
#define TK_TINYINT 121
#define TK_SMALLINT 122
#define TK_INT 123
#define TK_INTEGER 124
#define TK_BIGINT 125
#define TK_FLOAT 126
#define TK_DOUBLE 127
#define TK_BINARY 128
#define TK_NCHAR 129
#define TK_UNSIGNED 130
#define TK_JSON 131
#define TK_VARCHAR 132
#define TK_MEDIUMBLOB 133
#define TK_BLOB 134
#define TK_VARBINARY 135
#define TK_GEOMETRY 136
#define TK_DECIMAL 137
#define TK_COMMENT 138
#define TK_MAX_DELAY 139
#define TK_WATERMARK 140
#define TK_ROLLUP 141
#define TK_TTL 142
#define TK_SMA 143
#define TK_DELETE_MARK 144
#define TK_FIRST 145
#define TK_LAST 146
#define TK_SHOW 147
#define TK_PRIVILEGES 148
#define TK_DATABASES 149
#define TK_TABLES 150
#define TK_STABLES 151
#define TK_MNODES 152
#define TK_QNODES 153
#define TK_ARBGROUPS 154
#define TK_FUNCTIONS 155
#define TK_INDEXES 156
#define TK_ACCOUNTS 157
#define TK_APPS 158
#define TK_CONNECTIONS 159
#define TK_LICENCES 160
#define TK_GRANTS 161
#define TK_FULL 162
#define TK_LOGS 163
#define TK_MACHINES 164
#define TK_ENCRYPTIONS 165
#define TK_QUERIES 166
#define TK_SCORES 167
#define TK_TOPICS 168
#define TK_VARIABLES 169
#define TK_BNODES 170
#define TK_SNODES 171
#define TK_TRANSACTIONS 172
#define TK_DISTRIBUTED 173
#define TK_CONSUMERS 174
#define TK_SUBSCRIPTIONS 175
#define TK_VNODES 176
#define TK_ALIVE 177
#define TK_VIEWS 178
#define TK_VIEW 179
#define TK_COMPACTS 180
#define TK_NORMAL 181
#define TK_CHILD 182
#define TK_LIKE 183
#define TK_TBNAME 184
#define TK_QTAGS 185
#define TK_AS 186
#define TK_SYSTEM 187
#define TK_INDEX 188
#define TK_FUNCTION 189
#define TK_INTERVAL 190
#define TK_COUNT 191
#define TK_LAST_ROW 192
#define TK_META 193
#define TK_ONLY 194
#define TK_TOPIC 195
#define TK_CONSUMER 196
#define TK_GROUP 197
#define TK_DESC 198
#define TK_DESCRIBE 199
#define TK_RESET 200
#define TK_QUERY 201
#define TK_CACHE 202
#define TK_EXPLAIN 203
#define TK_ANALYZE 204
#define TK_VERBOSE 205
#define TK_NK_BOOL 206
#define TK_RATIO 207
#define TK_NK_FLOAT 208
#define TK_OUTPUTTYPE 209
#define TK_AGGREGATE 210
#define TK_BUFSIZE 211
#define TK_LANGUAGE 212
#define TK_REPLACE 213
#define TK_STREAM 214
#define TK_INTO 215
#define TK_PAUSE 216
#define TK_RESUME 217
#define TK_TRIGGER 218
#define TK_AT_ONCE 219
#define TK_WINDOW_CLOSE 220
#define TK_IGNORE 221
#define TK_EXPIRED 222
#define TK_FILL_HISTORY 223
#define TK_UPDATE 224
#define TK_SUBTABLE 225
#define TK_UNTREATED 226
#define TK_KILL 227
#define TK_CONNECTION 228
#define TK_TRANSACTION 229
#define TK_BALANCE 230
#define TK_VGROUP 231
#define TK_LEADER 232
#define TK_MERGE 233
#define TK_REDISTRIBUTE 234
#define TK_SPLIT 235
#define TK_DELETE 236
#define TK_INSERT 237
#define TK_NK_BIN 238
#define TK_NK_HEX 239
#define TK_NULL 240
#define TK_NK_QUESTION 241
#define TK_NK_ALIAS 242
#define TK_NK_ARROW 243
#define TK_ROWTS 244
#define TK_QSTART 245
#define TK_QEND 246
#define TK_QDURATION 247
#define TK_WSTART 248
#define TK_WEND 249
#define TK_WDURATION 250
#define TK_IROWTS 251
#define TK_ISFILLED 252
#define TK_CAST 253
#define TK_NOW 254
#define TK_TODAY 255
#define TK_TIMEZONE 256
#define TK_CLIENT_VERSION 257
#define TK_SERVER_VERSION 258
#define TK_SERVER_STATUS 259
#define TK_CURRENT_USER 260
#define TK_CASE 261
#define TK_WHEN 262
#define TK_THEN 263
#define TK_ELSE 264
#define TK_BETWEEN 265
#define TK_IS 266
#define TK_NK_LT 267
#define TK_NK_GT 268
#define TK_NK_LE 269
#define TK_NK_GE 270
#define TK_NK_NE 271
#define TK_MATCH 272
#define TK_NMATCH 273
#define TK_CONTAINS 274
#define TK_IN 275
#define TK_JOIN 276
#define TK_INNER 277
#define TK_SELECT 278
#define TK_NK_HINT 279
#define TK_DISTINCT 280
#define TK_WHERE 281
#define TK_PARTITION 282
#define TK_BY 283
#define TK_SESSION 284
#define TK_STATE_WINDOW 285
#define TK_EVENT_WINDOW 286
#define TK_COUNT_WINDOW 287
#define TK_SLIDING 288
#define TK_FILL 289
#define TK_VALUE 290
#define TK_VALUE_F 291
#define TK_NONE 292
#define TK_PREV 293
#define TK_NULL_F 294
#define TK_LINEAR 295
#define TK_NEXT 296
#define TK_HAVING 297
#define TK_RANGE 298
#define TK_EVERY 299
#define TK_ORDER 300
#define TK_SLIMIT 301
#define TK_SOFFSET 302
#define TK_LIMIT 303
#define TK_OFFSET 304
#define TK_ASC 305
#define TK_NULLS 306
#define TK_ABORT 307
#define TK_AFTER 308
#define TK_ATTACH 309
#define TK_BEFORE 310
#define TK_BEGIN 311
#define TK_BITAND 312
#define TK_BITNOT 313
#define TK_BITOR 314
#define TK_BLOCKS 315
#define TK_CHANGE 316
#define TK_COMMA 317
#define TK_CONCAT 318
#define TK_CONFLICT 319
#define TK_COPY 320
#define TK_DEFERRED 321
#define TK_DELIMITERS 322
#define TK_DETACH 323
#define TK_DIVIDE 324
#define TK_DOT 325
#define TK_EACH 326
#define TK_FAIL 327
#define TK_FILE 328
#define TK_FOR 329
#define TK_GLOB 330
#define TK_ID 331
#define TK_IMMEDIATE 332
#define TK_IMPORT 333
#define TK_INITIALLY 334
#define TK_INSTEAD 335
#define TK_ISNULL 336
#define TK_KEY 337
#define TK_MODULES 338
#define TK_NK_BITNOT 339
#define TK_NK_SEMI 340
#define TK_NOTNULL 341
#define TK_OF 342
#define TK_PLUS 343
#define TK_PRIVILEGE 344
#define TK_RAISE 345
#define TK_RESTRICT 346
#define TK_ROW 347
#define TK_SEMI 348
#define TK_STAR 349
#define TK_STATEMENT 350
#define TK_STRICT 351
#define TK_STRING 352
#define TK_TIMES 353
#define TK_VALUES 354
#define TK_VARIABLE 355
#define TK_WAL 356
#define TK_NK_SPACE 600
#define TK_NK_COMMENT 601

View File

@ -69,7 +69,9 @@ typedef struct SDatabaseOptions {
int8_t cacheModel;
int32_t cacheLastSize;
int8_t compressionLevel;
int8_t encryptAlgorithm;
int32_t daysPerFile;
char encryptAlgorithmStr[TSDB_ENCRYPT_ALGO_STR_LEN];
SValueNode* pDaysPerFile;
int32_t fsyncPeriod;
int32_t maxRowsPerBlock;
@ -258,6 +260,11 @@ typedef struct SDropUserStmt {
char userName[TSDB_USER_LEN];
} SDropUserStmt;
typedef struct SCreateEncryptKeyStmt {
ENodeType type;
char value[TSDB_ENCRYPT_KEY_LEN + 1];
} SCreateEncryptKeyStmt;
typedef struct SCreateDnodeStmt {
ENodeType type;
char fqdn[TSDB_FQDN_LEN];

View File

@ -293,6 +293,8 @@ typedef enum ELogicConditionType {
#define TSDB_DNODE_CONFIG_LEN 128
#define TSDB_DNODE_VALUE_LEN 256
#define TSDB_ENCRYPT_KEY_LEN 16
#define TSDB_CLUSTER_VALUE_LEN 1000
#define TSDB_GRANT_LOG_COL_LEN 15600
@ -387,6 +389,14 @@ typedef enum ELogicConditionType {
#define TSDB_CACHE_MODEL_LAST_ROW 1
#define TSDB_CACHE_MODEL_LAST_VALUE 2
#define TSDB_CACHE_MODEL_BOTH 3
#define TSDB_ENCRYPT_ALGO_STR_LEN 16
#define TSDB_ENCRYPT_ALGO_NONE_STR "none"
#define TSDB_ENCRYPT_ALGO_SM4_STR "sm4"
#define TSDB_ENCRYPT_ALGO_NONE 0
#define TSDB_ENCRYPT_ALGO_SM1 1
#define TSDB_ENCRYPT_ALGO_SM2 2
#define TSDB_ENCRYPT_ALGO_SM3 3
#define TSDB_ENCRYPT_ALGO_SM4 4
#define TSDB_DEFAULT_CACHE_MODEL TSDB_CACHE_MODEL_NONE
#define TSDB_MIN_DB_CACHE_SIZE 1 // MB
#define TSDB_MAX_DB_CACHE_SIZE 65536

View File

@ -118,6 +118,7 @@ static const SSysDbTableSchema userDBSchema[] = {
{.name = "tsdb_pagesize", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
{.name = "keep_time_offset", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
{.name = "with_arbitrator", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT, .sysInfo = true},
{.name = "encrypt_algorithm", .bytes = TSDB_ENCRYPT_ALGO_STR_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
};
static const SSysDbTableSchema userFuncSchema[] = {
@ -374,12 +375,15 @@ static const SSysDbTableSchema userGrantsLogsSchema[] = {
static const SSysDbTableSchema userMachinesSchema[] = {
{.name = "id", .bytes = TSDB_CLUSTER_ID_LEN + 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
#ifndef TD_UNIQ_GRANT
{.name = "dnode_num", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
#endif
{.name = "machine", .bytes = 7552 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
};
static const SSysDbTableSchema encryptionsSchema[] = {
{.name = "dnode_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
{.name = "key_status", .bytes = 12 + 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},
@ -413,6 +417,7 @@ static const SSysTableMeta infosMeta[] = {
{TSDB_INS_TABLE_GRANTS_LOGS, userGrantsLogsSchema, tListLen(userGrantsLogsSchema), true},
{TSDB_INS_TABLE_MACHINES, userMachinesSchema, tListLen(userMachinesSchema), true},
{TSDB_INS_TABLE_ARBGROUPS, arbGroupsSchema, tListLen(arbGroupsSchema), true},
{TSDB_INS_TABLE_ENCRYPTIONS, encryptionsSchema, tListLen(encryptionsSchema), true},
};
static const SSysDbTableSchema connectionsSchema[] = {

View File

@ -131,6 +131,8 @@ static int32_t convertToRetrieveType(char *name, int32_t len) {
type = TSDB_MGMT_TABLE_GRANTS_LOGS;
} else if (strncasecmp(name, TSDB_INS_TABLE_MACHINES, len) == 0) {
type = TSDB_MGMT_TABLE_MACHINES;
} else if (strncasecmp(name, TSDB_INS_TABLE_ENCRYPTIONS, len) == 0) {
type = TSDB_MGMT_TABLE_ENCRYPTIONS;
} else {
mError("invalid show name:%s len:%d", name, len);
}

View File

@ -275,6 +275,8 @@ const char* nodesNodeName(ENodeType type) {
return "ShowGrantsLogsStmt";
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
return "ShowClusterMachinesStmt";
case QUERY_NODE_SHOW_ENCRYPTIONS_STMT:
return "ShowEncryptionsStmt";
case QUERY_NODE_DELETE_STMT:
return "DeleteStmt";
case QUERY_NODE_INSERT_STMT:
@ -6716,10 +6718,14 @@ static int32_t showGrantsLogsStmtToJson(const void* pObj, SJson* pJson) { return
static int32_t showClusterMachinesStmtToJson(const void* pObj, SJson* pJson) { return showStmtToJson(pObj, pJson); }
static int32_t showEncryptionsStmtToJson(const void* pObj, SJson* pJson) { return showStmtToJson(pObj, pJson); }
static int32_t jsonToShowGrantsLogsStmt(const SJson* pJson, void* pObj) { return jsonToShowStmt(pJson, pObj); }
static int32_t jsonToShowClusterMachinesStmt(const SJson* pJson, void* pObj) { return jsonToShowStmt(pJson, pObj); }
static int32_t jsonToShowEncryptionsStmt(const SJson* pJson, void* pObj) { return jsonToShowStmt(pJson, pObj); }
static const char* jkShowDnodeVariablesStmtDnodeId = "DnodeId";
static const char* jkShowDnodeVariablesStmtLikePattern = "LikePattern";
@ -7217,6 +7223,8 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
return showGrantsLogsStmtToJson(pObj, pJson);
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
return showClusterMachinesStmtToJson(pObj, pJson);
case QUERY_NODE_SHOW_ENCRYPTIONS_STMT:
return showEncryptionsStmtToJson(pObj, pJson);
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
return showDnodeVariablesStmtToJson(pObj, pJson);
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
@ -7556,6 +7564,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
return jsonToShowGrantsLogsStmt(pJson, pObj);
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
return jsonToShowClusterMachinesStmt(pJson, pObj);
case QUERY_NODE_SHOW_ENCRYPTIONS_STMT:
return jsonToShowEncryptionsStmt(pJson, pObj);
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
return jsonToShowDnodeVariablesStmt(pJson, pObj);
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:

View File

@ -447,6 +447,7 @@ SNode* nodesMakeNode(ENodeType type) {
case QUERY_NODE_SHOW_GRANTS_FULL_STMT:
case QUERY_NODE_SHOW_GRANTS_LOGS_STMT:
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
case QUERY_NODE_SHOW_ENCRYPTIONS_STMT:
return makeNode(type, sizeof(SShowStmt));
case QUERY_NODE_SHOW_TABLE_TAGS_STMT:
return makeNode(type, sizeof(SShowTableTagsStmt));
@ -485,6 +486,8 @@ SNode* nodesMakeNode(ENodeType type) {
case QUERY_NODE_RESTORE_MNODE_STMT:
case QUERY_NODE_RESTORE_VNODE_STMT:
return makeNode(type, sizeof(SRestoreComponentNodeStmt));
case QUERY_NODE_CREATE_ENCRYPT_KEY_STMT:
return makeNode(type, sizeof(SCreateEncryptKeyStmt));
case QUERY_NODE_CREATE_VIEW_STMT:
return makeNode(type, sizeof(SCreateViewStmt));
case QUERY_NODE_DROP_VIEW_STMT:

View File

@ -64,7 +64,8 @@ typedef enum EDatabaseOptionType {
DB_OPTION_STT_TRIGGER,
DB_OPTION_TABLE_PREFIX,
DB_OPTION_TABLE_SUFFIX,
DB_OPTION_KEEP_TIME_OFFSET
DB_OPTION_KEEP_TIME_OFFSET,
DB_OPTION_ENCRYPT_ALGORITHM,
} EDatabaseOptionType;
typedef enum ETableOptionType {
@ -209,6 +210,7 @@ SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const ST
SNode* addCreateUserStmtWhiteList(SAstCreateContext* pCxt, SNode* pStmt, SNodeList* pIpRangesNodeList);
SNode* createAlterUserStmt(SAstCreateContext* pCxt, SToken* pUserName, int8_t alterType, void* pAlterInfo);
SNode* createDropUserStmt(SAstCreateContext* pCxt, SToken* pUserName);
SNode* createEncryptKeyStmt(SAstCreateContext* pCxt, const SToken* pValue);
SNode* createCreateDnodeStmt(SAstCreateContext* pCxt, const SToken* pFqdn, const SToken* pPort);
SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, bool force, bool unsafe);
SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const SToken* pConfig, const SToken* pValue);

View File

@ -144,6 +144,9 @@ priv_level(A) ::= topic_name(B).
with_opt(A) ::= . { A = NULL; }
with_opt(A) ::= WITH search_condition(B). { A = B; }
/************************************************ create encrypt_key *********************************************/
cmd ::= CREATE ENCRYPT_KEY NK_STRING(A). { pCxt->pRootNode = createEncryptKeyStmt(pCxt, &A); }
/************************************************ create/drop/alter/restore dnode *********************************************/
cmd ::= CREATE DNODE dnode_endpoint(A). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, NULL); }
cmd ::= CREATE DNODE dnode_endpoint(A) PORT NK_INTEGER(B). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, &B); }
@ -261,6 +264,7 @@ db_options(A) ::= db_options(B) STT_TRIGGER NK_INTEGER(C).
db_options(A) ::= db_options(B) TABLE_PREFIX signed(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_TABLE_PREFIX, C); }
db_options(A) ::= db_options(B) TABLE_SUFFIX signed(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_TABLE_SUFFIX, C); }
db_options(A) ::= db_options(B) KEEP_TIME_OFFSET NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_KEEP_TIME_OFFSET, &C); }
db_options(A) ::= db_options(B) ENCRYPT_ALGORITHM NK_STRING(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_ENCRYPT_ALGORITHM, &C); }
alter_db_options(A) ::= alter_db_option(B). { A = createAlterDatabaseOptions(pCxt); A = setAlterDatabaseOption(pCxt, A, &B); }
alter_db_options(A) ::= alter_db_options(B) alter_db_option(C). { A = setAlterDatabaseOption(pCxt, B, &C); }
@ -493,7 +497,9 @@ cmd ::= SHOW GRANTS LOGS.
cmd ::= SHOW CLUSTER MACHINES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_MACHINES_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); }
cmd ::= SHOW CREATE STABLE full_table_name(A). { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT,
A); }
cmd ::= SHOW ENCRYPTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_ENCRYPTIONS_STMT); }
cmd ::= SHOW QUERIES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); }
cmd ::= SHOW SCORES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT); }
cmd ::= SHOW TOPICS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TOPICS_STMT); }

View File

@ -1418,6 +1418,9 @@ static SNode* setDatabaseOptionImpl(SAstCreateContext* pCxt, SNode* pOptions, ED
case DB_OPTION_KEEP_TIME_OFFSET: {
pDbOptions->keepTimeOffset = taosStr2Int32(((SToken*)pVal)->z, NULL, 10);
break;
case DB_OPTION_ENCRYPT_ALGORITHM:
COPY_STRING_FORM_STR_TOKEN(pDbOptions->encryptAlgorithmStr, (SToken*)pVal);
break;
}
default:
break;
@ -2092,6 +2095,16 @@ SNode* createDropUserStmt(SAstCreateContext* pCxt, SToken* pUserName) {
return (SNode*)pStmt;
}
SNode* createEncryptKeyStmt(SAstCreateContext* pCxt, const SToken* pValue) {
CHECK_PARSER_STATUS(pCxt);
SCreateEncryptKeyStmt* pStmt = (SCreateEncryptKeyStmt*)nodesMakeNode(QUERY_NODE_CREATE_ENCRYPT_KEY_STMT);
CHECK_OUT_OF_MEM(pStmt);
if (NULL != pValue) {
trimString(pValue->z, pValue->n, pStmt->value, sizeof(pStmt->value));
}
return (SNode*)pStmt;
}
SNode* createCreateDnodeStmt(SAstCreateContext* pCxt, const SToken* pFqdn, const SToken* pPort) {
CHECK_PARSER_STATUS(pCxt);
SCreateDnodeStmt* pStmt = (SCreateDnodeStmt*)nodesMakeNode(QUERY_NODE_CREATE_DNODE_STMT);

View File

@ -640,6 +640,11 @@ static int32_t collectMetaKeyFromShowClusterMachines(SCollectMetaKeyCxt* pCxt, S
pCxt->pMetaCache);
}
static int32_t collectMetaKeyFromShowEncryptions(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_ENCRYPTIONS,
pCxt->pMetaCache);
}
static int32_t collectMetaKeyFromShowCreateDatabase(SCollectMetaKeyCxt* pCxt, SShowCreateDatabaseStmt* pStmt) {
return reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
}
@ -868,6 +873,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
return collectMetaKeyFromShowGrantsLogs(pCxt, (SShowStmt*)pStmt);
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
return collectMetaKeyFromShowClusterMachines(pCxt, (SShowStmt*)pStmt);
case QUERY_NODE_SHOW_ENCRYPTIONS_STMT:
return collectMetaKeyFromShowEncryptions(pCxt, (SShowStmt*)pStmt);
case QUERY_NODE_SHOW_CREATE_DATABASE_STMT:
return collectMetaKeyFromShowCreateDatabase(pCxt, (SShowCreateDatabaseStmt*)pStmt);
case QUERY_NODE_SHOW_CREATE_TABLE_STMT:

View File

@ -356,6 +356,7 @@ static int32_t authQuery(SAuthCxt* pCxt, SNode* pStmt) {
case QUERY_NODE_SHOW_GRANTS_LOGS_STMT:
case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
case QUERY_NODE_SHOW_ARBGROUPS_STMT:
case QUERY_NODE_SHOW_ENCRYPTIONS_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:

View File

@ -91,6 +91,9 @@ static SKeyword keywordTable[] = {
{"DURATION", TK_DURATION},
{"ELSE", TK_ELSE},
{"ENABLE", TK_ENABLE},
{"ENCRYPTIONS", TK_ENCRYPTIONS},
{"ENCRYPT_ALGORITHM", TK_ENCRYPT_ALGORITHM},
{"ENCRYPT_KEY", TK_ENCRYPT_KEY},
{"END", TK_END},
{"EXISTS", TK_EXISTS},
{"EXPIRED", TK_EXPIRED},

View File

@ -295,6 +295,12 @@ static const SSysTableShowAdapter sysTableShowAdapter[] = {
.numOfShowCols = 1,
.pShowCols = {"*"}
},
{ .showType = QUERY_NODE_SHOW_ENCRYPTIONS_STMT,
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
.pTableName = TSDB_INS_TABLE_ENCRYPTIONS,
.numOfShowCols = 1,
.pShowCols = {"*"}
},
};
// clang-format on
@ -5274,6 +5280,20 @@ static int32_t checkDbCacheModelOption(STranslateContext* pCxt, SDatabaseOptions
return TSDB_CODE_SUCCESS;
}
static int32_t checkDbEncryptAlgorithmOption(STranslateContext* pCxt, SDatabaseOptions* pOptions) {
if ('\0' != pOptions->encryptAlgorithmStr[0]) {
if (0 == strcasecmp(pOptions->encryptAlgorithmStr, TSDB_ENCRYPT_ALGO_NONE_STR)) {
pOptions->encryptAlgorithm = TSDB_ENCRYPT_ALGO_NONE;
} else if (0 == strcasecmp(pOptions->encryptAlgorithmStr, TSDB_ENCRYPT_ALGO_SM4_STR)) {
pOptions->cacheModel = TSDB_CACHE_MODEL_LAST_ROW;
} else {
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION,
"Invalid option encryptAlgorithm: %s", pOptions->encryptAlgorithmStr);
}
}
return TSDB_CODE_SUCCESS;
}
static int32_t checkDbPrecisionOption(STranslateContext* pCxt, SDatabaseOptions* pOptions) {
if ('\0' != pOptions->precisionStr[0]) {
if (0 == strcasecmp(pOptions->precisionStr, TSDB_TIME_PRECISION_MILLI_STR)) {
@ -5462,6 +5482,9 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, const char* pDbName
if (TSDB_CODE_SUCCESS == code) {
code = checkDbCacheModelOption(pCxt, pOptions);
}
if (TSDB_CODE_SUCCESS == code) {
code = checkDbEncryptAlgorithmOption(pCxt, pOptions);
}
if (TSDB_CODE_SUCCESS == code) {
code =
checkDbRangeOption(pCxt, "cacheSize", pOptions->cacheLastSize, TSDB_MIN_DB_CACHE_SIZE, TSDB_MAX_DB_CACHE_SIZE);

File diff suppressed because it is too large Load Diff