cmdnodes.h 12.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
 *
 * This program is free software: you can use, redistribute, and/or modify
 * it under the terms of the GNU Affero General Public License, version 3
 * or later ("AGPL"), as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

16 17
#ifndef _TD_CMD_NODES_H_
#define _TD_CMD_NODES_H_
18 19 20 21 22

#ifdef __cplusplus
extern "C" {
#endif

23
#include "query.h"
X
Xiaoyu Wang 已提交
24
#include "querynodes.h"
25

X
Xiaoyu Wang 已提交
26
#define DESCRIBE_RESULT_COLS      4
27
#define DESCRIBE_RESULT_FIELD_LEN (TSDB_COL_NAME_LEN - 1 + VARSTR_HEADER_SIZE)
X
Xiaoyu Wang 已提交
28 29
#define DESCRIBE_RESULT_TYPE_LEN  (20 + VARSTR_HEADER_SIZE)
#define DESCRIBE_RESULT_NOTE_LEN  (8 + VARSTR_HEADER_SIZE)
30

31
#define SHOW_CREATE_DB_RESULT_COLS       2
D
dapan1121 已提交
32 33 34
#define SHOW_CREATE_DB_RESULT_FIELD1_LEN (TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE)
#define SHOW_CREATE_DB_RESULT_FIELD2_LEN (TSDB_MAX_BINARY_LEN + VARSTR_HEADER_SIZE)

35
#define SHOW_CREATE_TB_RESULT_COLS       2
D
dapan1121 已提交
36
#define SHOW_CREATE_TB_RESULT_FIELD1_LEN (TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE)
D
dapan1121 已提交
37
#define SHOW_CREATE_TB_RESULT_FIELD2_LEN (TSDB_MAX_ALLOWED_SQL_LEN * 3)
D
dapan1121 已提交
38

X
Xiaoyu Wang 已提交
39
#define SHOW_LOCAL_VARIABLES_RESULT_COLS       2
D
dapan1121 已提交
40 41 42
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD1_LEN (TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE)
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD2_LEN (TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE)

43
#define SHOW_ALIVE_RESULT_COLS 1
X
Xiaoyu Wang 已提交
44

X
Xiaoyu Wang 已提交
45 46 47
#define BIT_FLAG_MASK(n)              (1 << n)
#define BIT_FLAG_SET_MASK(val, mask)  ((val) |= (mask))
#define BIT_FLAG_TEST_MASK(val, mask) (((val) & (mask)) != 0)
X
Xiaoyu Wang 已提交
48

X
Xiaoyu Wang 已提交
49 50 51 52
#define PRIVILEGE_TYPE_ALL       BIT_FLAG_MASK(0)
#define PRIVILEGE_TYPE_READ      BIT_FLAG_MASK(1)
#define PRIVILEGE_TYPE_WRITE     BIT_FLAG_MASK(2)
#define PRIVILEGE_TYPE_SUBSCRIBE BIT_FLAG_MASK(3)
X
Xiaoyu Wang 已提交
53

54
typedef struct SDatabaseOptions {
X
Xiaoyu Wang 已提交
55 56
  ENodeType   type;
  int32_t     buffer;
57 58
  char        cacheModelStr[TSDB_CACHE_MODEL_STR_LEN];
  int8_t      cacheModel;
59
  int32_t     cacheLastSize;
X
Xiaoyu Wang 已提交
60 61
  int8_t      compressionLevel;
  int32_t     daysPerFile;
X
Xiaoyu Wang 已提交
62
  SValueNode* pDaysPerFile;
X
Xiaoyu Wang 已提交
63 64 65 66
  int32_t     fsyncPeriod;
  int32_t     maxRowsPerBlock;
  int32_t     minRowsPerBlock;
  SNodeList*  pKeep;
X
Xiaoyu Wang 已提交
67
  int64_t     keep[3];
X
Xiaoyu Wang 已提交
68 69
  int32_t     pages;
  int32_t     pagesize;
70
  int32_t     tsdbPageSize;
X
Xiaoyu Wang 已提交
71 72 73
  char        precisionStr[3];
  int8_t      precision;
  int8_t      replica;
74
  char        strictStr[TSDB_DB_STRICT_STR_LEN];
X
Xiaoyu Wang 已提交
75 76 77 78 79
  int8_t      strict;
  int8_t      walLevel;
  int32_t     numOfVgroups;
  int8_t      singleStable;
  SNodeList*  pRetentions;
X
Xiaoyu Wang 已提交
80
  int8_t      schemaless;
X
Xiaoyu Wang 已提交
81 82 83 84
  int32_t     walRetentionPeriod;
  int32_t     walRetentionSize;
  int32_t     walRollPeriod;
  int32_t     walSegmentSize;
85 86 87
  bool        walRetentionPeriodIsSet;
  bool        walRetentionSizeIsSet;
  bool        walRollPeriodIsSet;
88
  int32_t     sstTrigger;
89 90
  int32_t     tablePrefix;
  int32_t     tableSuffix;
91
} SDatabaseOptions;
92

93
typedef struct SCreateDatabaseStmt {
X
Xiaoyu Wang 已提交
94 95 96
  ENodeType         type;
  char              dbName[TSDB_DB_NAME_LEN];
  bool              ignoreExists;
X
Xiaoyu Wang 已提交
97
  SDatabaseOptions* pOptions;
98
} SCreateDatabaseStmt;
99

100 101
typedef struct SUseDatabaseStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
102
  char      dbName[TSDB_DB_NAME_LEN];
103 104
} SUseDatabaseStmt;

105 106
typedef struct SDropDatabaseStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
107 108
  char      dbName[TSDB_DB_NAME_LEN];
  bool      ignoreNotExists;
109 110
} SDropDatabaseStmt;

111
typedef struct SAlterDatabaseStmt {
X
Xiaoyu Wang 已提交
112 113
  ENodeType         type;
  char              dbName[TSDB_DB_NAME_LEN];
114 115 116
  SDatabaseOptions* pOptions;
} SAlterDatabaseStmt;

X
Xiaoyu Wang 已提交
117 118 119 120 121
typedef struct SFlushDatabaseStmt {
  ENodeType type;
  char      dbName[TSDB_DB_NAME_LEN];
} SFlushDatabaseStmt;

X
Xiaoyu Wang 已提交
122 123 124
typedef struct STrimDatabaseStmt {
  ENodeType type;
  char      dbName[TSDB_DB_NAME_LEN];
125
  int32_t   maxSpeed;
X
Xiaoyu Wang 已提交
126 127
} STrimDatabaseStmt;

X
Xiaoyu Wang 已提交
128 129 130 131 132
typedef struct SCompactDatabaseStmt {
  ENodeType type;
  char      dbName[TSDB_DB_NAME_LEN];
} SCompactDatabaseStmt;

X
Xiaoyu Wang 已提交
133
typedef struct STableOptions {
X
Xiaoyu Wang 已提交
134
  ENodeType  type;
wmmhello's avatar
wmmhello 已提交
135
  bool       commentNull;
136
  char       comment[TSDB_TB_COMMENT_LEN];
X
Xiaoyu Wang 已提交
137 138 139 140 141 142
  SNodeList* pMaxDelay;
  int64_t    maxDelay1;
  int64_t    maxDelay2;
  SNodeList* pWatermark;
  int64_t    watermark1;
  int64_t    watermark2;
143 144 145
  SNodeList* pDeleteMark;
  int64_t    deleteMark1;
  int64_t    deleteMark2;
X
Xiaoyu Wang 已提交
146 147
  SNodeList* pRollupFuncs;
  int32_t    ttl;
148
  SNodeList* pSma;
X
Xiaoyu Wang 已提交
149 150 151 152
} STableOptions;

typedef struct SColumnDefNode {
  ENodeType type;
X
Xiaoyu Wang 已提交
153
  char      colName[TSDB_COL_NAME_LEN];
X
Xiaoyu Wang 已提交
154
  SDataType dataType;
155
  char      comments[TSDB_TB_COMMENT_LEN];
X
Xiaoyu Wang 已提交
156
  bool      sma;
X
Xiaoyu Wang 已提交
157 158 159
} SColumnDefNode;

typedef struct SCreateTableStmt {
X
Xiaoyu Wang 已提交
160 161 162 163 164 165
  ENodeType      type;
  char           dbName[TSDB_DB_NAME_LEN];
  char           tableName[TSDB_TABLE_NAME_LEN];
  bool           ignoreExists;
  SNodeList*     pCols;
  SNodeList*     pTags;
X
Xiaoyu Wang 已提交
166
  STableOptions* pOptions;
X
Xiaoyu Wang 已提交
167 168
} SCreateTableStmt;

169
typedef struct SCreateSubTableClause {
170 171 172 173 174 175 176 177
  ENodeType      type;
  char           dbName[TSDB_DB_NAME_LEN];
  char           tableName[TSDB_TABLE_NAME_LEN];
  char           useDbName[TSDB_DB_NAME_LEN];
  char           useTableName[TSDB_TABLE_NAME_LEN];
  bool           ignoreExists;
  SNodeList*     pSpecificTags;
  SNodeList*     pValsOfTags;
wmmhello's avatar
wmmhello 已提交
178
  STableOptions* pOptions;
179
} SCreateSubTableClause;
180

X
Xiaoyu Wang 已提交
181
typedef struct SCreateMultiTablesStmt {
X
Xiaoyu Wang 已提交
182
  ENodeType  type;
183
  SNodeList* pSubTables;
X
Xiaoyu Wang 已提交
184
} SCreateMultiTablesStmt;
X
Xiaoyu Wang 已提交
185

186 187
typedef struct SDropTableClause {
  ENodeType type;
X
Xiaoyu Wang 已提交
188 189 190
  char      dbName[TSDB_DB_NAME_LEN];
  char      tableName[TSDB_TABLE_NAME_LEN];
  bool      ignoreNotExists;
191 192 193
} SDropTableClause;

typedef struct SDropTableStmt {
X
Xiaoyu Wang 已提交
194
  ENodeType  type;
195 196 197
  SNodeList* pTables;
} SDropTableStmt;

198 199
typedef struct SDropSuperTableStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
200 201 202
  char      dbName[TSDB_DB_NAME_LEN];
  char      tableName[TSDB_TABLE_NAME_LEN];
  bool      ignoreNotExists;
203 204
} SDropSuperTableStmt;

205
typedef struct SAlterTableStmt {
X
Xiaoyu Wang 已提交
206 207 208 209 210 211
  ENodeType      type;
  char           dbName[TSDB_DB_NAME_LEN];
  char           tableName[TSDB_TABLE_NAME_LEN];
  int8_t         alterType;
  char           colName[TSDB_COL_NAME_LEN];
  char           newColName[TSDB_COL_NAME_LEN];
212
  STableOptions* pOptions;
X
Xiaoyu Wang 已提交
213 214
  SDataType      dataType;
  SValueNode*    pVal;
215 216
} SAlterTableStmt;

217 218
typedef struct SCreateUserStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
219
  char      userName[TSDB_USER_LEN];
X
Xiaoyu Wang 已提交
220
  char      password[TSDB_USET_PASSWORD_LEN];
X
Xiaoyu Wang 已提交
221
  int8_t    sysinfo;
222 223 224 225
} SCreateUserStmt;

typedef struct SAlterUserStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
226
  char      userName[TSDB_USER_LEN];
X
Xiaoyu Wang 已提交
227
  int8_t    alterType;
X
Xiaoyu Wang 已提交
228 229 230
  char      password[TSDB_USET_PASSWORD_LEN];
  int8_t    enable;
  int8_t    sysinfo;
231 232 233 234
} SAlterUserStmt;

typedef struct SDropUserStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
235
  char      userName[TSDB_USER_LEN];
236 237 238 239
} SDropUserStmt;

typedef struct SCreateDnodeStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
240 241
  char      fqdn[TSDB_FQDN_LEN];
  int32_t   port;
242 243 244 245
} SCreateDnodeStmt;

typedef struct SDropDnodeStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
246 247 248
  int32_t   dnodeId;
  char      fqdn[TSDB_FQDN_LEN];
  int32_t   port;
249
  bool      force;
250 251
} SDropDnodeStmt;

252 253
typedef struct SAlterDnodeStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
254 255 256
  int32_t   dnodeId;
  char      config[TSDB_DNODE_CONFIG_LEN];
  char      value[TSDB_DNODE_VALUE_LEN];
257 258
} SAlterDnodeStmt;

259
typedef struct SShowStmt {
260 261 262 263
  ENodeType     type;
  SNode*        pDbName;  // SValueNode
  SNode*        pTbName;  // SValueNode
  EOperatorType tableCondType;
264 265
} SShowStmt;

266
typedef struct SShowCreateDatabaseStmt {
267
  ENodeType type;
X
Xiaoyu Wang 已提交
268
  char      dbName[TSDB_DB_NAME_LEN];
269
  char      dbFName[TSDB_DB_FNAME_LEN];
270 271 272
  void*     pCfg;  // SDbCfgInfo
} SShowCreateDatabaseStmt;

273 274 275 276 277
typedef struct SShowAliveStmt {
  ENodeType type;
  char      dbName[TSDB_DB_NAME_LEN];
} SShowAliveStmt;

278
typedef struct SShowCreateTableStmt {
279 280 281
  ENodeType type;
  char      dbName[TSDB_DB_NAME_LEN];
  char      tableName[TSDB_TABLE_NAME_LEN];
X
Xiaoyu Wang 已提交
282 283
  void*     pDbCfg;     // SDbCfgInfo
  void*     pTableCfg;  // STableCfg
284
} SShowCreateTableStmt;
285

286 287 288 289 290 291
typedef struct SShowTableDistributedStmt {
  ENodeType type;
  char      dbName[TSDB_DB_NAME_LEN];
  char      tableName[TSDB_TABLE_NAME_LEN];
} SShowTableDistributedStmt;

292 293 294
typedef struct SShowDnodeVariablesStmt {
  ENodeType type;
  SNode*    pDnodeId;
295
  SNode*    pLikePattern;
296 297
} SShowDnodeVariablesStmt;

298 299 300 301 302 303
typedef struct SShowVnodesStmt {
  ENodeType type;
  SNode*    pDnodeId;
  SNode*    pDnodeEndpoint;
} SShowVnodesStmt;

304 305 306 307 308 309 310
typedef struct SShowTableTagsStmt {
  ENodeType  type;
  SNode*     pDbName;  // SValueNode
  SNode*     pTbName;  // SValueNode
  SNodeList* pTags;
} SShowTableTagsStmt;

X
Xiaoyu Wang 已提交
311
typedef enum EIndexType { INDEX_TYPE_SMA = 1, INDEX_TYPE_FULLTEXT, INDEX_TYPE_NORMAL } EIndexType;
X
Xiaoyu Wang 已提交
312 313

typedef struct SIndexOptions {
X
Xiaoyu Wang 已提交
314
  ENodeType  type;
X
Xiaoyu Wang 已提交
315
  SNodeList* pFuncs;
X
Xiaoyu Wang 已提交
316 317 318
  SNode*     pInterval;
  SNode*     pOffset;
  SNode*     pSliding;
319
  SNode*     pStreamOptions;
X
Xiaoyu Wang 已提交
320 321 322
} SIndexOptions;

typedef struct SCreateIndexStmt {
X
Xiaoyu Wang 已提交
323 324 325
  ENodeType      type;
  EIndexType     indexType;
  bool           ignoreExists;
X
Xiaoyu Wang 已提交
326
  char           indexDbName[TSDB_DB_NAME_LEN];
X
Xiaoyu Wang 已提交
327
  char           indexName[TSDB_INDEX_NAME_LEN];
328
  char           dbName[TSDB_DB_NAME_LEN];
X
Xiaoyu Wang 已提交
329 330
  char           tableName[TSDB_TABLE_NAME_LEN];
  SNodeList*     pCols;
X
Xiaoyu Wang 已提交
331 332 333
  SIndexOptions* pOptions;
} SCreateIndexStmt;

334 335
typedef struct SDropIndexStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
336
  bool      ignoreNotExists;
X
Xiaoyu Wang 已提交
337
  char      indexDbName[TSDB_DB_NAME_LEN];
X
Xiaoyu Wang 已提交
338
  char      indexName[TSDB_INDEX_NAME_LEN];
339 340
} SDropIndexStmt;

341
typedef struct SCreateComponentNodeStmt {
X
Xiaoyu Wang 已提交
342
  ENodeType type;
X
Xiaoyu Wang 已提交
343
  int32_t   dnodeId;
344
} SCreateComponentNodeStmt;
X
Xiaoyu Wang 已提交
345

346
typedef struct SDropComponentNodeStmt {
347
  ENodeType type;
X
Xiaoyu Wang 已提交
348
  int32_t   dnodeId;
349
} SDropComponentNodeStmt;
350 351

typedef struct SCreateTopicStmt {
352 353 354 355 356
  ENodeType type;
  char      topicName[TSDB_TABLE_NAME_LEN];
  char      subDbName[TSDB_DB_NAME_LEN];
  char      subSTbName[TSDB_TABLE_NAME_LEN];
  bool      ignoreExists;
X
Xiaoyu Wang 已提交
357
  bool      withMeta;
358
  SNode*    pQuery;
359 360 361 362
} SCreateTopicStmt;

typedef struct SDropTopicStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
363 364
  char      topicName[TSDB_TABLE_NAME_LEN];
  bool      ignoreNotExists;
365 366
} SDropTopicStmt;

X
Xiaoyu Wang 已提交
367 368 369 370 371 372 373
typedef struct SDropCGroupStmt {
  ENodeType type;
  char      topicName[TSDB_TABLE_NAME_LEN];
  char      cgroup[TSDB_CGROUP_LEN];
  bool      ignoreNotExists;
} SDropCGroupStmt;

374 375
typedef struct SAlterLocalStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
376 377
  char      config[TSDB_DNODE_CONFIG_LEN];
  char      value[TSDB_DNODE_VALUE_LEN];
378 379
} SAlterLocalStmt;

380
typedef struct SDescribeStmt {
X
Xiaoyu Wang 已提交
381 382 383
  ENodeType   type;
  char        dbName[TSDB_DB_NAME_LEN];
  char        tableName[TSDB_TABLE_NAME_LEN];
384 385 386
  STableMeta* pMeta;
} SDescribeStmt;

387 388
typedef struct SKillStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
389
  int32_t   targetId;
390 391
} SKillStmt;

X
Xiaoyu Wang 已提交
392 393 394 395 396
typedef struct SKillQueryStmt {
  ENodeType type;
  char      queryId[TSDB_QUERY_ID_LEN];
} SKillQueryStmt;

X
Xiaoyu Wang 已提交
397 398 399 400 401 402 403 404 405
typedef enum EStreamOptionsSetFlag {
  SOPT_TRIGGER_TYPE_SET = BIT_FLAG_MASK(0),
  SOPT_WATERMARK_SET = BIT_FLAG_MASK(1),
  SOPT_DELETE_MARK_SET = BIT_FLAG_MASK(2),
  SOPT_FILL_HISTORY_SET = BIT_FLAG_MASK(3),
  SOPT_IGNORE_EXPIRED_SET = BIT_FLAG_MASK(4),
  SOPT_IGNORE_UPDATE_SET = BIT_FLAG_MASK(5),
} EStreamOptionsSetFlag;

406 407
typedef struct SStreamOptions {
  ENodeType type;
X
Xiaoyu Wang 已提交
408
  int8_t    triggerType;
409
  SNode*    pDelay;
X
Xiaoyu Wang 已提交
410
  SNode*    pWatermark;
411
  SNode*    pDeleteMark;
412
  int8_t    fillHistory;
X
Xiaoyu Wang 已提交
413
  int8_t    ignoreExpired;
414
  int8_t    ignoreUpdate;
X
Xiaoyu Wang 已提交
415
  int64_t   setFlag;
416 417 418
} SStreamOptions;

typedef struct SCreateStreamStmt {
X
Xiaoyu Wang 已提交
419 420 421 422 423
  ENodeType       type;
  char            streamName[TSDB_TABLE_NAME_LEN];
  char            targetDbName[TSDB_DB_NAME_LEN];
  char            targetTabName[TSDB_TABLE_NAME_LEN];
  bool            ignoreExists;
424
  SStreamOptions* pOptions;
X
Xiaoyu Wang 已提交
425
  SNode*          pQuery;
426 427
  SNodeList*      pTags;
  SNode*          pSubtable;
428
  SNodeList*      pCols;
429 430 431 432
} SCreateStreamStmt;

typedef struct SDropStreamStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
433 434
  char      streamName[TSDB_TABLE_NAME_LEN];
  bool      ignoreNotExists;
435 436
} SDropStreamStmt;

437 438
typedef struct SCreateFunctionStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
439 440 441 442
  bool      ignoreExists;
  char      funcName[TSDB_FUNC_NAME_LEN];
  bool      isAgg;
  char      libraryPath[PATH_MAX];
443
  SDataType outputDt;
X
Xiaoyu Wang 已提交
444
  int32_t   bufSize;
445 446
} SCreateFunctionStmt;

447 448 449 450 451 452 453 454 455
typedef struct SDropFunctionStmt {
  ENodeType type;
  char      funcName[TSDB_FUNC_NAME_LEN];
  bool      ignoreNotExists;
} SDropFunctionStmt;

typedef struct SGrantStmt {
  ENodeType type;
  char      userName[TSDB_USER_LEN];
456
  char      objName[TSDB_DB_NAME_LEN];  // db or topic
457 458 459 460 461
  int64_t   privileges;
} SGrantStmt;

typedef SGrantStmt SRevokeStmt;

X
Xiaoyu Wang 已提交
462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485
typedef struct SBalanceVgroupStmt {
  ENodeType type;
} SBalanceVgroupStmt;

typedef struct SMergeVgroupStmt {
  ENodeType type;
  int32_t   vgId1;
  int32_t   vgId2;
} SMergeVgroupStmt;

typedef struct SRedistributeVgroupStmt {
  ENodeType  type;
  int32_t    vgId;
  int32_t    dnodeId1;
  int32_t    dnodeId2;
  int32_t    dnodeId3;
  SNodeList* pDnodes;
} SRedistributeVgroupStmt;

typedef struct SSplitVgroupStmt {
  ENodeType type;
  int32_t   vgId;
} SSplitVgroupStmt;

486 487 488 489
#ifdef __cplusplus
}
#endif

490
#endif /*_TD_CMD_NODES_H_*/