cmdnodes.h 12.4 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 45
#define PRIVILEGE_TYPE_MASK(n) (1 << n)

46 47 48 49
#define PRIVILEGE_TYPE_ALL       PRIVILEGE_TYPE_MASK(0)
#define PRIVILEGE_TYPE_READ      PRIVILEGE_TYPE_MASK(1)
#define PRIVILEGE_TYPE_WRITE     PRIVILEGE_TYPE_MASK(2)
#define PRIVILEGE_TYPE_SUBSCRIBE PRIVILEGE_TYPE_MASK(3)
X
Xiaoyu Wang 已提交
50 51 52

#define PRIVILEGE_TYPE_TEST_MASK(val, mask) (((val) & (mask)) != 0)

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

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

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

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

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

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

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

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

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

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

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

168
typedef struct SCreateSubTableClause {
169 170 171 172 173 174 175 176
  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 已提交
177
  STableOptions* pOptions;
178
} SCreateSubTableClause;
179

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

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

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

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

204
typedef struct SAlterTableStmt {
X
Xiaoyu Wang 已提交
205 206 207 208 209 210
  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];
211
  STableOptions* pOptions;
X
Xiaoyu Wang 已提交
212 213
  SDataType      dataType;
  SValueNode*    pVal;
214 215
} SAlterTableStmt;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

typedef struct SCreateTopicStmt {
351 352 353 354 355
  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 已提交
356
  bool      withMeta;
357
  SNode*    pQuery;
358 359 360 361
} SCreateTopicStmt;

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

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

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

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

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

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

396 397
typedef struct SStreamOptions {
  ENodeType type;
X
Xiaoyu Wang 已提交
398
  int8_t    triggerType;
399
  SNode*    pDelay;
X
Xiaoyu Wang 已提交
400
  SNode*    pWatermark;
401
  SNode*    pDeleteMark;
402
  int8_t    fillHistory;
X
Xiaoyu Wang 已提交
403
  int8_t    ignoreExpired;
404
  int8_t    ignoreUpdate;
405 406 407
} SStreamOptions;

typedef struct SCreateStreamStmt {
X
Xiaoyu Wang 已提交
408 409 410 411 412
  ENodeType       type;
  char            streamName[TSDB_TABLE_NAME_LEN];
  char            targetDbName[TSDB_DB_NAME_LEN];
  char            targetTabName[TSDB_TABLE_NAME_LEN];
  bool            ignoreExists;
413
  SStreamOptions* pOptions;
X
Xiaoyu Wang 已提交
414
  SNode*          pQuery;
415 416
  SNodeList*      pTags;
  SNode*          pSubtable;
417
  SNodeList*      pCols;
418 419 420 421
} SCreateStreamStmt;

typedef struct SDropStreamStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
422 423
  char      streamName[TSDB_TABLE_NAME_LEN];
  bool      ignoreNotExists;
424 425
} SDropStreamStmt;

426 427
typedef struct SCreateFunctionStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
428 429 430 431
  bool      ignoreExists;
  char      funcName[TSDB_FUNC_NAME_LEN];
  bool      isAgg;
  char      libraryPath[PATH_MAX];
432
  SDataType outputDt;
X
Xiaoyu Wang 已提交
433
  int32_t   bufSize;
434 435
} SCreateFunctionStmt;

436 437 438 439 440 441 442 443 444
typedef struct SDropFunctionStmt {
  ENodeType type;
  char      funcName[TSDB_FUNC_NAME_LEN];
  bool      ignoreNotExists;
} SDropFunctionStmt;

typedef struct SGrantStmt {
  ENodeType type;
  char      userName[TSDB_USER_LEN];
445
  char      objName[TSDB_DB_NAME_LEN];  // db or topic
446 447 448 449 450
  int64_t   privileges;
} SGrantStmt;

typedef SGrantStmt SRevokeStmt;

X
Xiaoyu Wang 已提交
451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474
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;

475 476 477 478
#ifdef __cplusplus
}
#endif

479
#endif /*_TD_CMD_NODES_H_*/