提交 a8c65cd2 编写于 作者: D dapan1121

feat: support restore dnode clause

上级 843d6060
...@@ -1634,8 +1634,6 @@ enum { ...@@ -1634,8 +1634,6 @@ enum {
typedef struct { typedef struct {
int32_t dnodeId; int32_t dnodeId;
char fqdn[TSDB_FQDN_LEN];
int32_t port;
int8_t restoreType; int8_t restoreType;
} SRestoreDnodeReq; } SRestoreDnodeReq;
......
...@@ -16,335 +16,338 @@ ...@@ -16,335 +16,338 @@
#ifndef _TD_COMMON_TOKEN_H_ #ifndef _TD_COMMON_TOKEN_H_
#define _TD_COMMON_TOKEN_H_ #define _TD_COMMON_TOKEN_H_
#define TK_OR 1 #define TK_OR 1
#define TK_AND 2 #define TK_AND 2
#define TK_UNION 3 #define TK_UNION 3
#define TK_ALL 4 #define TK_ALL 4
#define TK_MINUS 5 #define TK_MINUS 5
#define TK_EXCEPT 6 #define TK_EXCEPT 6
#define TK_INTERSECT 7 #define TK_INTERSECT 7
#define TK_NK_BITAND 8 #define TK_NK_BITAND 8
#define TK_NK_BITOR 9 #define TK_NK_BITOR 9
#define TK_NK_LSHIFT 10 #define TK_NK_LSHIFT 10
#define TK_NK_RSHIFT 11 #define TK_NK_RSHIFT 11
#define TK_NK_PLUS 12 #define TK_NK_PLUS 12
#define TK_NK_MINUS 13 #define TK_NK_MINUS 13
#define TK_NK_STAR 14 #define TK_NK_STAR 14
#define TK_NK_SLASH 15 #define TK_NK_SLASH 15
#define TK_NK_REM 16 #define TK_NK_REM 16
#define TK_NK_CONCAT 17 #define TK_NK_CONCAT 17
#define TK_CREATE 18 #define TK_CREATE 18
#define TK_ACCOUNT 19 #define TK_ACCOUNT 19
#define TK_NK_ID 20 #define TK_NK_ID 20
#define TK_PASS 21 #define TK_PASS 21
#define TK_NK_STRING 22 #define TK_NK_STRING 22
#define TK_ALTER 23 #define TK_ALTER 23
#define TK_PPS 24 #define TK_PPS 24
#define TK_TSERIES 25 #define TK_TSERIES 25
#define TK_STORAGE 26 #define TK_STORAGE 26
#define TK_STREAMS 27 #define TK_STREAMS 27
#define TK_QTIME 28 #define TK_QTIME 28
#define TK_DBS 29 #define TK_DBS 29
#define TK_USERS 30 #define TK_USERS 30
#define TK_CONNS 31 #define TK_CONNS 31
#define TK_STATE 32 #define TK_STATE 32
#define TK_USER 33 #define TK_USER 33
#define TK_ENABLE 34 #define TK_ENABLE 34
#define TK_NK_INTEGER 35 #define TK_NK_INTEGER 35
#define TK_SYSINFO 36 #define TK_SYSINFO 36
#define TK_DROP 37 #define TK_DROP 37
#define TK_GRANT 38 #define TK_GRANT 38
#define TK_ON 39 #define TK_ON 39
#define TK_TO 40 #define TK_TO 40
#define TK_REVOKE 41 #define TK_REVOKE 41
#define TK_FROM 42 #define TK_FROM 42
#define TK_SUBSCRIBE 43 #define TK_SUBSCRIBE 43
#define TK_NK_COMMA 44 #define TK_NK_COMMA 44
#define TK_READ 45 #define TK_READ 45
#define TK_WRITE 46 #define TK_WRITE 46
#define TK_NK_DOT 47 #define TK_NK_DOT 47
#define TK_WITH 48 #define TK_WITH 48
#define TK_DNODE 49 #define TK_DNODE 49
#define TK_PORT 50 #define TK_PORT 50
#define TK_DNODES 51 #define TK_DNODES 51
#define TK_NK_IPTOKEN 52 #define TK_RESTORE 52
#define TK_FORCE 53 #define TK_NK_IPTOKEN 53
#define TK_LOCAL 54 #define TK_FORCE 54
#define TK_QNODE 55 #define TK_LOCAL 55
#define TK_BNODE 56 #define TK_QNODE 56
#define TK_SNODE 57 #define TK_BNODE 57
#define TK_MNODE 58 #define TK_SNODE 58
#define TK_DATABASE 59 #define TK_MNODE 59
#define TK_USE 60 #define TK_VNODE 60
#define TK_FLUSH 61 #define TK_DATABASE 61
#define TK_TRIM 62 #define TK_USE 62
#define TK_COMPACT 63 #define TK_FLUSH 63
#define TK_IF 64 #define TK_TRIM 64
#define TK_NOT 65 #define TK_COMPACT 65
#define TK_EXISTS 66 #define TK_IF 66
#define TK_BUFFER 67 #define TK_NOT 67
#define TK_CACHEMODEL 68 #define TK_EXISTS 68
#define TK_CACHESIZE 69 #define TK_BUFFER 69
#define TK_COMP 70 #define TK_CACHEMODEL 70
#define TK_DURATION 71 #define TK_CACHESIZE 71
#define TK_NK_VARIABLE 72 #define TK_COMP 72
#define TK_MAXROWS 73 #define TK_DURATION 73
#define TK_MINROWS 74 #define TK_NK_VARIABLE 74
#define TK_KEEP 75 #define TK_MAXROWS 75
#define TK_PAGES 76 #define TK_MINROWS 76
#define TK_PAGESIZE 77 #define TK_KEEP 77
#define TK_TSDB_PAGESIZE 78 #define TK_PAGES 78
#define TK_PRECISION 79 #define TK_PAGESIZE 79
#define TK_REPLICA 80 #define TK_TSDB_PAGESIZE 80
#define TK_VGROUPS 81 #define TK_PRECISION 81
#define TK_SINGLE_STABLE 82 #define TK_REPLICA 82
#define TK_RETENTIONS 83 #define TK_VGROUPS 83
#define TK_SCHEMALESS 84 #define TK_SINGLE_STABLE 84
#define TK_WAL_LEVEL 85 #define TK_RETENTIONS 85
#define TK_WAL_FSYNC_PERIOD 86 #define TK_SCHEMALESS 86
#define TK_WAL_RETENTION_PERIOD 87 #define TK_WAL_LEVEL 87
#define TK_WAL_RETENTION_SIZE 88 #define TK_WAL_FSYNC_PERIOD 88
#define TK_WAL_ROLL_PERIOD 89 #define TK_WAL_RETENTION_PERIOD 89
#define TK_WAL_SEGMENT_SIZE 90 #define TK_WAL_RETENTION_SIZE 90
#define TK_STT_TRIGGER 91 #define TK_WAL_ROLL_PERIOD 91
#define TK_TABLE_PREFIX 92 #define TK_WAL_SEGMENT_SIZE 92
#define TK_TABLE_SUFFIX 93 #define TK_STT_TRIGGER 93
#define TK_NK_COLON 94 #define TK_TABLE_PREFIX 94
#define TK_MAX_SPEED 95 #define TK_TABLE_SUFFIX 95
#define TK_START 96 #define TK_NK_COLON 96
#define TK_TIMESTAMP 97 #define TK_MAX_SPEED 97
#define TK_END 98 #define TK_START 98
#define TK_TABLE 99 #define TK_TIMESTAMP 99
#define TK_NK_LP 100 #define TK_END 100
#define TK_NK_RP 101 #define TK_TABLE 101
#define TK_STABLE 102 #define TK_NK_LP 102
#define TK_ADD 103 #define TK_NK_RP 103
#define TK_COLUMN 104 #define TK_STABLE 104
#define TK_MODIFY 105 #define TK_ADD 105
#define TK_RENAME 106 #define TK_COLUMN 106
#define TK_TAG 107 #define TK_MODIFY 107
#define TK_SET 108 #define TK_RENAME 108
#define TK_NK_EQ 109 #define TK_TAG 109
#define TK_USING 110 #define TK_SET 110
#define TK_TAGS 111 #define TK_NK_EQ 111
#define TK_BOOL 112 #define TK_USING 112
#define TK_TINYINT 113 #define TK_TAGS 113
#define TK_SMALLINT 114 #define TK_BOOL 114
#define TK_INT 115 #define TK_TINYINT 115
#define TK_INTEGER 116 #define TK_SMALLINT 116
#define TK_BIGINT 117 #define TK_INT 117
#define TK_FLOAT 118 #define TK_INTEGER 118
#define TK_DOUBLE 119 #define TK_BIGINT 119
#define TK_BINARY 120 #define TK_FLOAT 120
#define TK_NCHAR 121 #define TK_DOUBLE 121
#define TK_UNSIGNED 122 #define TK_BINARY 122
#define TK_JSON 123 #define TK_NCHAR 123
#define TK_VARCHAR 124 #define TK_UNSIGNED 124
#define TK_MEDIUMBLOB 125 #define TK_JSON 125
#define TK_BLOB 126 #define TK_VARCHAR 126
#define TK_VARBINARY 127 #define TK_MEDIUMBLOB 127
#define TK_DECIMAL 128 #define TK_BLOB 128
#define TK_COMMENT 129 #define TK_VARBINARY 129
#define TK_MAX_DELAY 130 #define TK_DECIMAL 130
#define TK_WATERMARK 131 #define TK_COMMENT 131
#define TK_ROLLUP 132 #define TK_MAX_DELAY 132
#define TK_TTL 133 #define TK_WATERMARK 133
#define TK_SMA 134 #define TK_ROLLUP 134
#define TK_DELETE_MARK 135 #define TK_TTL 135
#define TK_FIRST 136 #define TK_SMA 136
#define TK_LAST 137 #define TK_DELETE_MARK 137
#define TK_SHOW 138 #define TK_FIRST 138
#define TK_PRIVILEGES 139 #define TK_LAST 139
#define TK_DATABASES 140 #define TK_SHOW 140
#define TK_TABLES 141 #define TK_PRIVILEGES 141
#define TK_STABLES 142 #define TK_DATABASES 142
#define TK_MNODES 143 #define TK_TABLES 143
#define TK_QNODES 144 #define TK_STABLES 144
#define TK_FUNCTIONS 145 #define TK_MNODES 145
#define TK_INDEXES 146 #define TK_QNODES 146
#define TK_ACCOUNTS 147 #define TK_FUNCTIONS 147
#define TK_APPS 148 #define TK_INDEXES 148
#define TK_CONNECTIONS 149 #define TK_ACCOUNTS 149
#define TK_LICENCES 150 #define TK_APPS 150
#define TK_GRANTS 151 #define TK_CONNECTIONS 151
#define TK_QUERIES 152 #define TK_LICENCES 152
#define TK_SCORES 153 #define TK_GRANTS 153
#define TK_TOPICS 154 #define TK_QUERIES 154
#define TK_VARIABLES 155 #define TK_SCORES 155
#define TK_CLUSTER 156 #define TK_TOPICS 156
#define TK_BNODES 157 #define TK_VARIABLES 157
#define TK_SNODES 158 #define TK_CLUSTER 158
#define TK_TRANSACTIONS 159 #define TK_BNODES 159
#define TK_DISTRIBUTED 160 #define TK_SNODES 160
#define TK_CONSUMERS 161 #define TK_TRANSACTIONS 161
#define TK_SUBSCRIPTIONS 162 #define TK_DISTRIBUTED 162
#define TK_VNODES 163 #define TK_CONSUMERS 163
#define TK_ALIVE 164 #define TK_SUBSCRIPTIONS 164
#define TK_LIKE 165 #define TK_VNODES 165
#define TK_TBNAME 166 #define TK_ALIVE 166
#define TK_QTAGS 167 #define TK_LIKE 167
#define TK_AS 168 #define TK_TBNAME 168
#define TK_INDEX 169 #define TK_QTAGS 169
#define TK_FUNCTION 170 #define TK_AS 170
#define TK_INTERVAL 171 #define TK_INDEX 171
#define TK_COUNT 172 #define TK_FUNCTION 172
#define TK_LAST_ROW 173 #define TK_INTERVAL 173
#define TK_TOPIC 174 #define TK_COUNT 174
#define TK_META 175 #define TK_LAST_ROW 175
#define TK_CONSUMER 176 #define TK_TOPIC 176
#define TK_GROUP 177 #define TK_META 177
#define TK_DESC 178 #define TK_CONSUMER 178
#define TK_DESCRIBE 179 #define TK_GROUP 179
#define TK_RESET 180 #define TK_DESC 180
#define TK_QUERY 181 #define TK_DESCRIBE 181
#define TK_CACHE 182 #define TK_RESET 182
#define TK_EXPLAIN 183 #define TK_QUERY 183
#define TK_ANALYZE 184 #define TK_CACHE 184
#define TK_VERBOSE 185 #define TK_EXPLAIN 185
#define TK_NK_BOOL 186 #define TK_ANALYZE 186
#define TK_RATIO 187 #define TK_VERBOSE 187
#define TK_NK_FLOAT 188 #define TK_NK_BOOL 188
#define TK_OUTPUTTYPE 189 #define TK_RATIO 189
#define TK_AGGREGATE 190 #define TK_NK_FLOAT 190
#define TK_BUFSIZE 191 #define TK_OUTPUTTYPE 191
#define TK_LANGUAGE 192 #define TK_AGGREGATE 192
#define TK_REPLACE 193 #define TK_BUFSIZE 193
#define TK_STREAM 194 #define TK_LANGUAGE 194
#define TK_INTO 195 #define TK_REPLACE 195
#define TK_TRIGGER 196 #define TK_STREAM 196
#define TK_AT_ONCE 197 #define TK_INTO 197
#define TK_WINDOW_CLOSE 198 #define TK_TRIGGER 198
#define TK_IGNORE 199 #define TK_AT_ONCE 199
#define TK_EXPIRED 200 #define TK_WINDOW_CLOSE 200
#define TK_FILL_HISTORY 201 #define TK_IGNORE 201
#define TK_UPDATE 202 #define TK_EXPIRED 202
#define TK_SUBTABLE 203 #define TK_FILL_HISTORY 203
#define TK_KILL 204 #define TK_UPDATE 204
#define TK_CONNECTION 205 #define TK_SUBTABLE 205
#define TK_TRANSACTION 206 #define TK_KILL 206
#define TK_BALANCE 207 #define TK_CONNECTION 207
#define TK_VGROUP 208 #define TK_TRANSACTION 208
#define TK_LEADER 209 #define TK_BALANCE 209
#define TK_MERGE 210 #define TK_VGROUP 210
#define TK_REDISTRIBUTE 211 #define TK_LEADER 211
#define TK_SPLIT 212 #define TK_MERGE 212
#define TK_DELETE 213 #define TK_REDISTRIBUTE 213
#define TK_INSERT 214 #define TK_SPLIT 214
#define TK_NULL 215 #define TK_DELETE 215
#define TK_NK_QUESTION 216 #define TK_INSERT 216
#define TK_NK_ARROW 217 #define TK_NULL 217
#define TK_ROWTS 218 #define TK_NK_QUESTION 218
#define TK_QSTART 219 #define TK_NK_ARROW 219
#define TK_QEND 220 #define TK_ROWTS 220
#define TK_QDURATION 221 #define TK_QSTART 221
#define TK_WSTART 222 #define TK_QEND 222
#define TK_WEND 223 #define TK_QDURATION 223
#define TK_WDURATION 224 #define TK_WSTART 224
#define TK_IROWTS 225 #define TK_WEND 225
#define TK_ISFILLED 226 #define TK_WDURATION 226
#define TK_CAST 227 #define TK_IROWTS 227
#define TK_NOW 228 #define TK_ISFILLED 228
#define TK_TODAY 229 #define TK_CAST 229
#define TK_TIMEZONE 230 #define TK_NOW 230
#define TK_CLIENT_VERSION 231 #define TK_TODAY 231
#define TK_SERVER_VERSION 232 #define TK_TIMEZONE 232
#define TK_SERVER_STATUS 233 #define TK_CLIENT_VERSION 233
#define TK_CURRENT_USER 234 #define TK_SERVER_VERSION 234
#define TK_CASE 235 #define TK_SERVER_STATUS 235
#define TK_WHEN 236 #define TK_CURRENT_USER 236
#define TK_THEN 237 #define TK_CASE 237
#define TK_ELSE 238 #define TK_WHEN 238
#define TK_BETWEEN 239 #define TK_THEN 239
#define TK_IS 240 #define TK_ELSE 240
#define TK_NK_LT 241 #define TK_BETWEEN 241
#define TK_NK_GT 242 #define TK_IS 242
#define TK_NK_LE 243 #define TK_NK_LT 243
#define TK_NK_GE 244 #define TK_NK_GT 244
#define TK_NK_NE 245 #define TK_NK_LE 245
#define TK_MATCH 246 #define TK_NK_GE 246
#define TK_NMATCH 247 #define TK_NK_NE 247
#define TK_CONTAINS 248 #define TK_MATCH 248
#define TK_IN 249 #define TK_NMATCH 249
#define TK_JOIN 250 #define TK_CONTAINS 250
#define TK_INNER 251 #define TK_IN 251
#define TK_SELECT 252 #define TK_JOIN 252
#define TK_DISTINCT 253 #define TK_INNER 253
#define TK_WHERE 254 #define TK_SELECT 254
#define TK_PARTITION 255 #define TK_DISTINCT 255
#define TK_BY 256 #define TK_WHERE 256
#define TK_SESSION 257 #define TK_PARTITION 257
#define TK_STATE_WINDOW 258 #define TK_BY 258
#define TK_EVENT_WINDOW 259 #define TK_SESSION 259
#define TK_SLIDING 260 #define TK_STATE_WINDOW 260
#define TK_FILL 261 #define TK_EVENT_WINDOW 261
#define TK_VALUE 262 #define TK_SLIDING 262
#define TK_VALUE_F 263 #define TK_FILL 263
#define TK_NONE 264 #define TK_VALUE 264
#define TK_PREV 265 #define TK_VALUE_F 265
#define TK_NULL_F 266 #define TK_NONE 266
#define TK_LINEAR 267 #define TK_PREV 267
#define TK_NEXT 268 #define TK_NULL_F 268
#define TK_HAVING 269 #define TK_LINEAR 269
#define TK_RANGE 270 #define TK_NEXT 270
#define TK_EVERY 271 #define TK_HAVING 271
#define TK_ORDER 272 #define TK_RANGE 272
#define TK_SLIMIT 273 #define TK_EVERY 273
#define TK_SOFFSET 274 #define TK_ORDER 274
#define TK_LIMIT 275 #define TK_SLIMIT 275
#define TK_OFFSET 276 #define TK_SOFFSET 276
#define TK_ASC 277 #define TK_LIMIT 277
#define TK_NULLS 278 #define TK_OFFSET 278
#define TK_ABORT 279 #define TK_ASC 279
#define TK_AFTER 280 #define TK_NULLS 280
#define TK_ATTACH 281 #define TK_ABORT 281
#define TK_BEFORE 282 #define TK_AFTER 282
#define TK_BEGIN 283 #define TK_ATTACH 283
#define TK_BITAND 284 #define TK_BEFORE 284
#define TK_BITNOT 285 #define TK_BEGIN 285
#define TK_BITOR 286 #define TK_BITAND 286
#define TK_BLOCKS 287 #define TK_BITNOT 287
#define TK_CHANGE 288 #define TK_BITOR 288
#define TK_COMMA 289 #define TK_BLOCKS 289
#define TK_CONCAT 290 #define TK_CHANGE 290
#define TK_CONFLICT 291 #define TK_COMMA 291
#define TK_COPY 292 #define TK_CONCAT 292
#define TK_DEFERRED 293 #define TK_CONFLICT 293
#define TK_DELIMITERS 294 #define TK_COPY 294
#define TK_DETACH 295 #define TK_DEFERRED 295
#define TK_DIVIDE 296 #define TK_DELIMITERS 296
#define TK_DOT 297 #define TK_DETACH 297
#define TK_EACH 298 #define TK_DIVIDE 298
#define TK_FAIL 299 #define TK_DOT 299
#define TK_FILE 300 #define TK_EACH 300
#define TK_FOR 301 #define TK_FAIL 301
#define TK_GLOB 302 #define TK_FILE 302
#define TK_ID 303 #define TK_FOR 303
#define TK_IMMEDIATE 304 #define TK_GLOB 304
#define TK_IMPORT 305 #define TK_ID 305
#define TK_INITIALLY 306 #define TK_IMMEDIATE 306
#define TK_INSTEAD 307 #define TK_IMPORT 307
#define TK_ISNULL 308 #define TK_INITIALLY 308
#define TK_KEY 309 #define TK_INSTEAD 309
#define TK_MODULES 310 #define TK_ISNULL 310
#define TK_NK_BITNOT 311 #define TK_KEY 311
#define TK_NK_SEMI 312 #define TK_MODULES 312
#define TK_NOTNULL 313 #define TK_NK_BITNOT 313
#define TK_OF 314 #define TK_NK_SEMI 314
#define TK_PLUS 315 #define TK_NOTNULL 315
#define TK_PRIVILEGE 316 #define TK_OF 316
#define TK_RAISE 317 #define TK_PLUS 317
#define TK_RESTRICT 318 #define TK_PRIVILEGE 318
#define TK_ROW 319 #define TK_RAISE 319
#define TK_SEMI 320 #define TK_RESTRICT 320
#define TK_STAR 321 #define TK_ROW 321
#define TK_STATEMENT 322 #define TK_SEMI 322
#define TK_STRICT 323 #define TK_STAR 323
#define TK_STRING 324 #define TK_STATEMENT 324
#define TK_TIMES 325 #define TK_STRICT 325
#define TK_VALUES 326 #define TK_STRING 326
#define TK_VARIABLE 327 #define TK_TIMES 327
#define TK_VIEW 328 #define TK_VALUES 328
#define TK_WAL 329 #define TK_VARIABLE 329
#define TK_VIEW 330
#define TK_WAL 331
#define TK_NK_SPACE 600 #define TK_NK_SPACE 600
#define TK_NK_COMMENT 601 #define TK_NK_COMMENT 601
......
...@@ -350,6 +350,11 @@ typedef struct SDropComponentNodeStmt { ...@@ -350,6 +350,11 @@ typedef struct SDropComponentNodeStmt {
int32_t dnodeId; int32_t dnodeId;
} SDropComponentNodeStmt; } SDropComponentNodeStmt;
typedef struct SRestoreComponentNodeStmt {
ENodeType type;
int32_t dnodeId;
} SRestoreComponentNodeStmt;
typedef struct SCreateTopicStmt { typedef struct SCreateTopicStmt {
ENodeType type; ENodeType type;
char topicName[TSDB_TABLE_NAME_LEN]; char topicName[TSDB_TABLE_NAME_LEN];
......
...@@ -211,6 +211,10 @@ typedef enum ENodeType { ...@@ -211,6 +211,10 @@ typedef enum ENodeType {
QUERY_NODE_SHOW_DB_ALIVE_STMT, QUERY_NODE_SHOW_DB_ALIVE_STMT,
QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT, QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT,
QUERY_NODE_BALANCE_VGROUP_LEADER_STMT, QUERY_NODE_BALANCE_VGROUP_LEADER_STMT,
QUERY_NODE_RESTORE_DNODE_STMT,
QUERY_NODE_RESTORE_QNODE_STMT,
QUERY_NODE_RESTORE_MNODE_STMT,
QUERY_NODE_RESTORE_VNODE_STMT,
// logic plan node // logic plan node
QUERY_NODE_LOGIC_PLAN_SCAN = 1000, QUERY_NODE_LOGIC_PLAN_SCAN = 1000,
......
...@@ -1726,8 +1726,6 @@ int32_t tSerializeSRestoreDnodeReq(void *buf, int32_t bufLen, SRestoreDnodeReq * ...@@ -1726,8 +1726,6 @@ int32_t tSerializeSRestoreDnodeReq(void *buf, int32_t bufLen, SRestoreDnodeReq *
if (tStartEncode(&encoder) < 0) return -1; if (tStartEncode(&encoder) < 0) return -1;
if (tEncodeI32(&encoder, pReq->dnodeId) < 0) return -1; if (tEncodeI32(&encoder, pReq->dnodeId) < 0) return -1;
if (tEncodeCStr(&encoder, pReq->fqdn) < 0) return -1;
if (tEncodeI32(&encoder, pReq->port) < 0) return -1;
if (tEncodeI8(&encoder, pReq->restoreType) < 0) return -1; if (tEncodeI8(&encoder, pReq->restoreType) < 0) return -1;
tEndEncode(&encoder); tEndEncode(&encoder);
...@@ -1742,8 +1740,6 @@ int32_t tDeserializeSRestoreDnodeReq(void *buf, int32_t bufLen, SRestoreDnodeReq ...@@ -1742,8 +1740,6 @@ int32_t tDeserializeSRestoreDnodeReq(void *buf, int32_t bufLen, SRestoreDnodeReq
if (tStartDecode(&decoder) < 0) return -1; if (tStartDecode(&decoder) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->dnodeId) < 0) return -1; if (tDecodeI32(&decoder, &pReq->dnodeId) < 0) return -1;
if (tDecodeCStrTo(&decoder, pReq->fqdn) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->port) < 0) return -1;
if (tDecodeI8(&decoder, &pReq->restoreType) < 0) return -1; if (tDecodeI8(&decoder, &pReq->restoreType) < 0) return -1;
tEndDecode(&decoder); tEndDecode(&decoder);
......
...@@ -257,6 +257,14 @@ const char* nodesNodeName(ENodeType type) { ...@@ -257,6 +257,14 @@ const char* nodesNodeName(ENodeType type) {
return "DeleteStmt"; return "DeleteStmt";
case QUERY_NODE_INSERT_STMT: case QUERY_NODE_INSERT_STMT:
return "InsertStmt"; return "InsertStmt";
case QUERY_NODE_RESTORE_DNODE_STMT:
return "RestoreDnodeStmt";
case QUERY_NODE_RESTORE_QNODE_STMT:
return "RestoreQnodeStmt";
case QUERY_NODE_RESTORE_MNODE_STMT:
return "RestoreMnodeStmt";
case QUERY_NODE_RESTORE_VNODE_STMT:
return "RestoreVnodeStmt";
case QUERY_NODE_LOGIC_PLAN_SCAN: case QUERY_NODE_LOGIC_PLAN_SCAN:
return "LogicScan"; return "LogicScan";
case QUERY_NODE_LOGIC_PLAN_JOIN: case QUERY_NODE_LOGIC_PLAN_JOIN:
...@@ -5533,6 +5541,35 @@ static int32_t jsonToDropDnodeStmt(const SJson* pJson, void* pObj) { ...@@ -5533,6 +5541,35 @@ static int32_t jsonToDropDnodeStmt(const SJson* pJson, void* pObj) {
return code; return code;
} }
static const char* jkRestoreComponentNodeStmtDnodeId = "DnodeId";
static int32_t restoreComponentNodeStmtToJson(const void* pObj, SJson* pJson) {
const SRestoreComponentNodeStmt* pNode = (const SRestoreComponentNodeStmt*)pObj;
return tjsonAddIntegerToObject(pJson, jkRestoreComponentNodeStmtDnodeId, pNode->dnodeId);
}
static int32_t jsonToRestoreComponentNodeStmt(const SJson* pJson, void* pObj) {
SRestoreComponentNodeStmt* pNode = (SRestoreComponentNodeStmt*)pObj;
return tjsonGetIntValue(pJson, jkRestoreComponentNodeStmtDnodeId, &pNode->dnodeId);
}
static int32_t jsonToRestoreDnodeStmt(const SJson* pJson, void* pObj) {
return jsonToRestoreComponentNodeStmt(pJson, pObj);
}
static int32_t jsonToRestoreQnodeStmt(const SJson* pJson, void* pObj) {
return jsonToRestoreComponentNodeStmt(pJson, pObj);
}
static int32_t jsonToRestoreMnodeStmt(const SJson* pJson, void* pObj) {
return jsonToRestoreComponentNodeStmt(pJson, pObj);
}
static int32_t jsonToRestoreVnodeStmt(const SJson* pJson, void* pObj) {
return jsonToRestoreComponentNodeStmt(pJson, pObj);
}
static const char* jkCreateTopicStmtTopicName = "TopicName"; static const char* jkCreateTopicStmtTopicName = "TopicName";
static const char* jkCreateTopicStmtSubscribeDbName = "SubscribeDbName"; static const char* jkCreateTopicStmtSubscribeDbName = "SubscribeDbName";
static const char* jkCreateTopicStmtIgnoreExists = "IgnoreExists"; static const char* jkCreateTopicStmtIgnoreExists = "IgnoreExists";
...@@ -6820,6 +6857,14 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) { ...@@ -6820,6 +6857,14 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
return jsonToDeleteStmt(pJson, pObj); return jsonToDeleteStmt(pJson, pObj);
case QUERY_NODE_INSERT_STMT: case QUERY_NODE_INSERT_STMT:
return jsonToInsertStmt(pJson, pObj); return jsonToInsertStmt(pJson, pObj);
case QUERY_NODE_RESTORE_DNODE_STMT:
return jsonToRestoreDnodeStmt(pJson, pObj);
case QUERY_NODE_RESTORE_QNODE_STMT:
return jsonToRestoreQnodeStmt(pJson, pObj);
case QUERY_NODE_RESTORE_MNODE_STMT:
return jsonToRestoreMnodeStmt(pJson, pObj);
case QUERY_NODE_RESTORE_VNODE_STMT:
return jsonToRestoreVnodeStmt(pJson, pObj);
case QUERY_NODE_LOGIC_PLAN_SCAN: case QUERY_NODE_LOGIC_PLAN_SCAN:
return jsonToLogicScanNode(pJson, pObj); return jsonToLogicScanNode(pJson, pObj);
case QUERY_NODE_LOGIC_PLAN_JOIN: case QUERY_NODE_LOGIC_PLAN_JOIN:
......
...@@ -455,6 +455,11 @@ SNode* nodesMakeNode(ENodeType type) { ...@@ -455,6 +455,11 @@ SNode* nodesMakeNode(ENodeType type) {
return makeNode(type, sizeof(SInsertStmt)); return makeNode(type, sizeof(SInsertStmt));
case QUERY_NODE_QUERY: case QUERY_NODE_QUERY:
return makeNode(type, sizeof(SQuery)); return makeNode(type, sizeof(SQuery));
case QUERY_NODE_RESTORE_DNODE_STMT:
case QUERY_NODE_RESTORE_QNODE_STMT:
case QUERY_NODE_RESTORE_MNODE_STMT:
case QUERY_NODE_RESTORE_VNODE_STMT:
return makeNode(type, sizeof(SRestoreComponentNodeStmt));
case QUERY_NODE_LOGIC_PLAN_SCAN: case QUERY_NODE_LOGIC_PLAN_SCAN:
return makeNode(type, sizeof(SScanLogicNode)); return makeNode(type, sizeof(SScanLogicNode));
case QUERY_NODE_LOGIC_PLAN_JOIN: case QUERY_NODE_LOGIC_PLAN_JOIN:
...@@ -1046,6 +1051,11 @@ void nodesDestroyNode(SNode* pNode) { ...@@ -1046,6 +1051,11 @@ void nodesDestroyNode(SNode* pNode) {
nodesDestroyNode(pQuery->pPrepareRoot); nodesDestroyNode(pQuery->pPrepareRoot);
break; break;
} }
case QUERY_NODE_RESTORE_DNODE_STMT: // no pointer field
case QUERY_NODE_RESTORE_QNODE_STMT: // no pointer field
case QUERY_NODE_RESTORE_MNODE_STMT: // no pointer field
case QUERY_NODE_RESTORE_VNODE_STMT: // no pointer field
break;
case QUERY_NODE_LOGIC_PLAN_SCAN: { case QUERY_NODE_LOGIC_PLAN_SCAN: {
SScanLogicNode* pLogicNode = (SScanLogicNode*)pNode; SScanLogicNode* pLogicNode = (SScanLogicNode*)pNode;
destroyLogicNode((SLogicNode*)pLogicNode); destroyLogicNode((SLogicNode*)pLogicNode);
......
...@@ -123,7 +123,7 @@ priv_level(A) ::= topic_name(B). ...@@ -123,7 +123,7 @@ priv_level(A) ::= topic_name(B).
with_opt(A) ::= . { A = NULL; } with_opt(A) ::= . { A = NULL; }
with_opt(A) ::= WITH search_condition(B). { A = B; } with_opt(A) ::= WITH search_condition(B). { A = B; }
/************************************************ create/drop/alter dnode *********************************************/ /************************************************ create/drop/alter/restore dnode *********************************************/
cmd ::= CREATE DNODE dnode_endpoint(A). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, NULL); } 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); } cmd ::= CREATE DNODE dnode_endpoint(A) PORT NK_INTEGER(B). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, &B); }
cmd ::= DROP DNODE NK_INTEGER(A) force_opt(B). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A, B); } cmd ::= DROP DNODE NK_INTEGER(A) force_opt(B). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A, B); }
...@@ -132,6 +132,7 @@ cmd ::= ALTER DNODE NK_INTEGER(A) NK_STRING(B). ...@@ -132,6 +132,7 @@ cmd ::= ALTER DNODE NK_INTEGER(A) NK_STRING(B).
cmd ::= ALTER DNODE NK_INTEGER(A) NK_STRING(B) NK_STRING(C). { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &A, &B, &C); } cmd ::= ALTER DNODE NK_INTEGER(A) NK_STRING(B) NK_STRING(C). { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &A, &B, &C); }
cmd ::= ALTER ALL DNODES NK_STRING(A). { pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &A, NULL); } cmd ::= ALTER ALL DNODES NK_STRING(A). { pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &A, NULL); }
cmd ::= ALTER ALL DNODES NK_STRING(A) NK_STRING(B). { pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &A, &B); } cmd ::= ALTER ALL DNODES NK_STRING(A) NK_STRING(B). { pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &A, &B); }
cmd ::= RESTORE DNODE NK_INTEGER(A). { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_DNODE_STMT, &A); }
%type dnode_endpoint { SToken } %type dnode_endpoint { SToken }
%destructor dnode_endpoint { } %destructor dnode_endpoint { }
...@@ -148,9 +149,10 @@ force_opt(A) ::= FORCE. ...@@ -148,9 +149,10 @@ force_opt(A) ::= FORCE.
cmd ::= ALTER LOCAL NK_STRING(A). { pCxt->pRootNode = createAlterLocalStmt(pCxt, &A, NULL); } cmd ::= ALTER LOCAL NK_STRING(A). { pCxt->pRootNode = createAlterLocalStmt(pCxt, &A, NULL); }
cmd ::= ALTER LOCAL NK_STRING(A) NK_STRING(B). { pCxt->pRootNode = createAlterLocalStmt(pCxt, &A, &B); } cmd ::= ALTER LOCAL NK_STRING(A) NK_STRING(B). { pCxt->pRootNode = createAlterLocalStmt(pCxt, &A, &B); }
/************************************************ create/drop qnode ***************************************************/ /************************************************ create/drop/restore qnode ***************************************************/
cmd ::= CREATE QNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_QNODE_STMT, &A); } cmd ::= CREATE QNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_QNODE_STMT, &A); }
cmd ::= DROP QNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_QNODE_STMT, &A); } cmd ::= DROP QNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_QNODE_STMT, &A); }
cmd ::= RESTORE QNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_QNODE_STMT, &A); }
/************************************************ create/drop bnode ***************************************************/ /************************************************ create/drop bnode ***************************************************/
cmd ::= CREATE BNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_BNODE_STMT, &A); } cmd ::= CREATE BNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_BNODE_STMT, &A); }
...@@ -160,9 +162,13 @@ cmd ::= DROP BNODE ON DNODE NK_INTEGER(A). ...@@ -160,9 +162,13 @@ cmd ::= DROP BNODE ON DNODE NK_INTEGER(A).
cmd ::= CREATE SNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_SNODE_STMT, &A); } cmd ::= CREATE SNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_SNODE_STMT, &A); }
cmd ::= DROP SNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_SNODE_STMT, &A); } cmd ::= DROP SNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_SNODE_STMT, &A); }
/************************************************ create/drop mnode ***************************************************/ /************************************************ create/drop/restore mnode ***************************************************/
cmd ::= CREATE MNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_MNODE_STMT, &A); } cmd ::= CREATE MNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_MNODE_STMT, &A); }
cmd ::= DROP MNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &A); } cmd ::= DROP MNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &A); }
cmd ::= RESTORE MNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_MNODE_STMT, &A); }
/************************************************ restore vnode ***************************************************/
cmd ::= RESTORE VNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_VNODE_STMT, &A); }
/************************************************ create/drop/use database ********************************************/ /************************************************ create/drop/use database ********************************************/
cmd ::= CREATE DATABASE not_exists_opt(A) db_name(B) db_options(C). { pCxt->pRootNode = createCreateDatabaseStmt(pCxt, A, &B, C); } cmd ::= CREATE DATABASE not_exists_opt(A) db_name(B) db_options(C). { pCxt->pRootNode = createCreateDatabaseStmt(pCxt, A, &B, C); }
......
...@@ -1658,6 +1658,14 @@ SNode* createDropComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, cons ...@@ -1658,6 +1658,14 @@ SNode* createDropComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, cons
return (SNode*)pStmt; return (SNode*)pStmt;
} }
SNode* createRestoreComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId) {
CHECK_PARSER_STATUS(pCxt);
SRestoreComponentNodeStmt* pStmt = (SRestoreComponentNodeStmt*)nodesMakeNode(type);
CHECK_OUT_OF_MEM(pStmt);
pStmt->dnodeId = taosStr2Int32(pDnodeId->z, NULL, 10);
return (SNode*)pStmt;
}
SNode* createCreateTopicStmtUseQuery(SAstCreateContext* pCxt, bool ignoreExists, SToken* pTopicName, SNode* pQuery) { SNode* createCreateTopicStmtUseQuery(SAstCreateContext* pCxt, bool ignoreExists, SToken* pTopicName, SNode* pQuery) {
CHECK_PARSER_STATUS(pCxt); CHECK_PARSER_STATUS(pCxt);
if (!checkTopicName(pCxt, pTopicName)) { if (!checkTopicName(pCxt, pTopicName)) {
......
...@@ -5431,6 +5431,29 @@ static int32_t translateAlterDnode(STranslateContext* pCxt, SAlterDnodeStmt* pSt ...@@ -5431,6 +5431,29 @@ static int32_t translateAlterDnode(STranslateContext* pCxt, SAlterDnodeStmt* pSt
return buildCmdMsg(pCxt, TDMT_MND_CONFIG_DNODE, (FSerializeFunc)tSerializeSMCfgDnodeReq, &cfgReq); return buildCmdMsg(pCxt, TDMT_MND_CONFIG_DNODE, (FSerializeFunc)tSerializeSMCfgDnodeReq, &cfgReq);
} }
static int32_t translateRestoreDnode(STranslateContext* pCxt, SRestoreComponentNodeStmt* pStmt) {
SRestoreDnodeReq restoreReq = {0};
restoreReq.dnodeId = pStmt->dnodeId;
switch (nodeType((SNode*)pStmt)) {
case QUERY_NODE_RESTORE_DNODE_STMT:
restoreReq.restoreType = RESTORE_TYPE__ALL;
break;
case QUERY_NODE_RESTORE_QNODE_STMT:
restoreReq.restoreType = RESTORE_TYPE__QNODE;
break;
case QUERY_NODE_RESTORE_MNODE_STMT:
restoreReq.restoreType = RESTORE_TYPE__MNODE;
break;
case QUERY_NODE_RESTORE_VNODE_STMT:
restoreReq.restoreType = RESTORE_TYPE__VNODE;
break;
default:
return -1;
}
return buildCmdMsg(pCxt, TDMT_MND_RESTORE_DNODE, (FSerializeFunc)tSerializeSRestoreDnodeReq, &restoreReq);
}
static int32_t getSmaIndexDstVgId(STranslateContext* pCxt, const char* pDbName, const char* pTableName, static int32_t getSmaIndexDstVgId(STranslateContext* pCxt, const char* pDbName, const char* pTableName,
int32_t* pVgId) { int32_t* pVgId) {
SVgroupInfo vg = {0}; SVgroupInfo vg = {0};
...@@ -6916,6 +6939,12 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { ...@@ -6916,6 +6939,12 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
case QUERY_NODE_SHOW_CREATE_STABLE_STMT: case QUERY_NODE_SHOW_CREATE_STABLE_STMT:
code = translateShowCreateTable(pCxt, (SShowCreateTableStmt*)pNode); code = translateShowCreateTable(pCxt, (SShowCreateTableStmt*)pNode);
break; break;
case QUERY_NODE_RESTORE_DNODE_STMT:
case QUERY_NODE_RESTORE_QNODE_STMT:
case QUERY_NODE_RESTORE_MNODE_STMT:
case QUERY_NODE_RESTORE_VNODE_STMT:
code = translateRestoreDnode(pCxt, (SRestoreComponentNodeStmt*)pNode);
break;
default: default:
break; break;
} }
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
...@@ -92,6 +92,62 @@ TEST_F(ParserInitialATest, alterDnode) { ...@@ -92,6 +92,62 @@ TEST_F(ParserInitialATest, alterDnode) {
clearCfgDnodeReq(); clearCfgDnodeReq();
} }
TEST_F(ParserInitialATest, restoreDnode) {
useDb("root", "test");
SRestoreDnodeReq expect = {0};
auto clearRestoreDnodeReq = [&]() { memset(&expect, 0, sizeof(SRestoreDnodeReq)); };
auto setRestoreDnodeReq = [&](int32_t dnodeId, int8_t type) {
expect.dnodeId = dnodeId;
expect.restoreType = type;
};
setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) {
int32_t expectNodeType = 0;
switch (expect.restoreType) {
case RESTORE_TYPE__ALL:
expectNodeType = QUERY_NODE_RESTORE_DNODE_STMT;
break;
case RESTORE_TYPE__MNODE:
expectNodeType = QUERY_NODE_RESTORE_MNODE_STMT;
break;
case RESTORE_TYPE__VNODE:
expectNodeType = QUERY_NODE_RESTORE_VNODE_STMT;
break;
case RESTORE_TYPE__QNODE:
expectNodeType = QUERY_NODE_RESTORE_QNODE_STMT;
break;
default:
break;
}
ASSERT_EQ(nodeType(pQuery->pRoot), expectNodeType);
ASSERT_EQ(pQuery->pCmdMsg->msgType, TDMT_MND_RESTORE_DNODE);
SRestoreDnodeReq req = {0};
ASSERT_EQ(tDeserializeSRestoreDnodeReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req), TSDB_CODE_SUCCESS);
ASSERT_EQ(req.dnodeId, expect.dnodeId);
ASSERT_EQ(req.restoreType, expect.restoreType);
});
setRestoreDnodeReq(1, RESTORE_TYPE__ALL);
run("RESTORE DNODE 1");
clearRestoreDnodeReq();
setRestoreDnodeReq(2, RESTORE_TYPE__MNODE);
run("RESTORE MNODE ON DNODE 2");
clearRestoreDnodeReq();
setRestoreDnodeReq(1, RESTORE_TYPE__VNODE);
run("RESTORE VNODE ON DNODE 1");
clearRestoreDnodeReq();
setRestoreDnodeReq(2, RESTORE_TYPE__QNODE);
run("RESTORE QNODE ON DNODE 2");
clearRestoreDnodeReq();
}
/* /*
* ALTER DATABASE db_name [alter_database_options] * ALTER DATABASE db_name [alter_database_options]
* *
...@@ -875,4 +931,4 @@ TEST_F(ParserInitialATest, balanceVgroupLeader) { ...@@ -875,4 +931,4 @@ TEST_F(ParserInitialATest, balanceVgroupLeader) {
run("BALANCE VGROUP LEADER"); run("BALANCE VGROUP LEADER");
} }
} // namespace ParserTest } // namespace ParserTest
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册