cmdnodes.h 11.3 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 37 38
#define SHOW_CREATE_TB_RESULT_FIELD1_LEN (TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE)
#define SHOW_CREATE_TB_RESULT_FIELD2_LEN (TSDB_MAX_BINARY_LEN + VARSTR_HEADER_SIZE)

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)

X
Xiaoyu Wang 已提交
43 44 45 46 47 48 49 50
#define PRIVILEGE_TYPE_MASK(n) (1 << n)

#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_TEST_MASK(val, mask) (((val) & (mask)) != 0)

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

86
typedef struct SCreateDatabaseStmt {
X
Xiaoyu Wang 已提交
87 88 89
  ENodeType         type;
  char              dbName[TSDB_DB_NAME_LEN];
  bool              ignoreExists;
X
Xiaoyu Wang 已提交
90
  SDatabaseOptions* pOptions;
91
} SCreateDatabaseStmt;
92

93 94
typedef struct SUseDatabaseStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
95
  char      dbName[TSDB_DB_NAME_LEN];
96 97
} SUseDatabaseStmt;

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

104
typedef struct SAlterDatabaseStmt {
X
Xiaoyu Wang 已提交
105 106
  ENodeType         type;
  char              dbName[TSDB_DB_NAME_LEN];
107 108 109
  SDatabaseOptions* pOptions;
} SAlterDatabaseStmt;

X
Xiaoyu Wang 已提交
110 111 112 113 114
typedef struct SFlushDatabaseStmt {
  ENodeType type;
  char      dbName[TSDB_DB_NAME_LEN];
} SFlushDatabaseStmt;

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

X
Xiaoyu Wang 已提交
120
typedef struct STableOptions {
X
Xiaoyu Wang 已提交
121
  ENodeType  type;
wmmhello's avatar
wmmhello 已提交
122
  bool       commentNull;
123
  char       comment[TSDB_TB_COMMENT_LEN];
X
Xiaoyu Wang 已提交
124 125 126 127 128 129
  SNodeList* pMaxDelay;
  int64_t    maxDelay1;
  int64_t    maxDelay2;
  SNodeList* pWatermark;
  int64_t    watermark1;
  int64_t    watermark2;
X
Xiaoyu Wang 已提交
130 131
  SNodeList* pRollupFuncs;
  int32_t    ttl;
132
  SNodeList* pSma;
X
Xiaoyu Wang 已提交
133 134 135 136
} STableOptions;

typedef struct SColumnDefNode {
  ENodeType type;
X
Xiaoyu Wang 已提交
137
  char      colName[TSDB_COL_NAME_LEN];
X
Xiaoyu Wang 已提交
138
  SDataType dataType;
139
  char      comments[TSDB_TB_COMMENT_LEN];
X
Xiaoyu Wang 已提交
140
  bool      sma;
X
Xiaoyu Wang 已提交
141 142 143
} SColumnDefNode;

typedef struct SCreateTableStmt {
X
Xiaoyu Wang 已提交
144 145 146 147 148 149
  ENodeType      type;
  char           dbName[TSDB_DB_NAME_LEN];
  char           tableName[TSDB_TABLE_NAME_LEN];
  bool           ignoreExists;
  SNodeList*     pCols;
  SNodeList*     pTags;
X
Xiaoyu Wang 已提交
150
  STableOptions* pOptions;
X
Xiaoyu Wang 已提交
151 152
} SCreateTableStmt;

153
typedef struct SCreateSubTableClause {
154 155 156 157 158 159 160 161
  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 已提交
162
  STableOptions* pOptions;
163
} SCreateSubTableClause;
164 165

typedef struct SCreateMultiTableStmt {
X
Xiaoyu Wang 已提交
166
  ENodeType  type;
167 168
  SNodeList* pSubTables;
} SCreateMultiTableStmt;
X
Xiaoyu Wang 已提交
169

170 171
typedef struct SDropTableClause {
  ENodeType type;
X
Xiaoyu Wang 已提交
172 173 174
  char      dbName[TSDB_DB_NAME_LEN];
  char      tableName[TSDB_TABLE_NAME_LEN];
  bool      ignoreNotExists;
175 176 177
} SDropTableClause;

typedef struct SDropTableStmt {
X
Xiaoyu Wang 已提交
178
  ENodeType  type;
179 180 181
  SNodeList* pTables;
} SDropTableStmt;

182 183
typedef struct SDropSuperTableStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
184 185 186
  char      dbName[TSDB_DB_NAME_LEN];
  char      tableName[TSDB_TABLE_NAME_LEN];
  bool      ignoreNotExists;
187 188
} SDropSuperTableStmt;

189
typedef struct SAlterTableStmt {
X
Xiaoyu Wang 已提交
190 191 192 193 194 195
  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];
196
  STableOptions* pOptions;
X
Xiaoyu Wang 已提交
197 198
  SDataType      dataType;
  SValueNode*    pVal;
199 200
} SAlterTableStmt;

201 202
typedef struct SCreateUserStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
203 204
  char      useName[TSDB_USER_LEN];
  char      password[TSDB_USET_PASSWORD_LEN];
X
Xiaoyu Wang 已提交
205
  int8_t    sysinfo;
206 207 208 209
} SCreateUserStmt;

typedef struct SAlterUserStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
210 211
  char      useName[TSDB_USER_LEN];
  int8_t    alterType;
X
Xiaoyu Wang 已提交
212 213 214
  char      password[TSDB_USET_PASSWORD_LEN];
  int8_t    enable;
  int8_t    sysinfo;
215 216 217 218
} SAlterUserStmt;

typedef struct SDropUserStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
219
  char      useName[TSDB_USER_LEN];
220 221 222 223
} SDropUserStmt;

typedef struct SCreateDnodeStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
224 225
  char      fqdn[TSDB_FQDN_LEN];
  int32_t   port;
226 227 228 229
} SCreateDnodeStmt;

typedef struct SDropDnodeStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
230 231 232
  int32_t   dnodeId;
  char      fqdn[TSDB_FQDN_LEN];
  int32_t   port;
233 234
} SDropDnodeStmt;

235 236
typedef struct SAlterDnodeStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
237 238 239
  int32_t   dnodeId;
  char      config[TSDB_DNODE_CONFIG_LEN];
  char      value[TSDB_DNODE_VALUE_LEN];
240 241
} SAlterDnodeStmt;

242
typedef struct SShowStmt {
243 244 245 246
  ENodeType     type;
  SNode*        pDbName;  // SValueNode
  SNode*        pTbName;  // SValueNode
  EOperatorType tableCondType;
247 248
} SShowStmt;

249
typedef struct SShowCreateDatabaseStmt {
250
  ENodeType type;
X
Xiaoyu Wang 已提交
251
  char      dbName[TSDB_DB_NAME_LEN];
252 253 254 255
  void*     pCfg;  // SDbCfgInfo
} SShowCreateDatabaseStmt;

typedef struct SShowCreateTableStmt {
256 257 258
  ENodeType type;
  char      dbName[TSDB_DB_NAME_LEN];
  char      tableName[TSDB_TABLE_NAME_LEN];
X
Xiaoyu Wang 已提交
259 260
  void*     pDbCfg;     // SDbCfgInfo
  void*     pTableCfg;  // STableCfg
261
} SShowCreateTableStmt;
262

263 264 265 266 267 268
typedef struct SShowTableDistributedStmt {
  ENodeType type;
  char      dbName[TSDB_DB_NAME_LEN];
  char      tableName[TSDB_TABLE_NAME_LEN];
} SShowTableDistributedStmt;

269 270 271 272 273
typedef struct SShowDnodeVariablesStmt {
  ENodeType type;
  SNode*    pDnodeId;
} SShowDnodeVariablesStmt;

X
Xiaoyu Wang 已提交
274
typedef enum EIndexType { INDEX_TYPE_SMA = 1, INDEX_TYPE_FULLTEXT } EIndexType;
X
Xiaoyu Wang 已提交
275 276

typedef struct SIndexOptions {
X
Xiaoyu Wang 已提交
277
  ENodeType  type;
X
Xiaoyu Wang 已提交
278
  SNodeList* pFuncs;
X
Xiaoyu Wang 已提交
279 280 281
  SNode*     pInterval;
  SNode*     pOffset;
  SNode*     pSliding;
282
  SNode*     pStreamOptions;
X
Xiaoyu Wang 已提交
283 284 285
} SIndexOptions;

typedef struct SCreateIndexStmt {
X
Xiaoyu Wang 已提交
286 287 288
  ENodeType      type;
  EIndexType     indexType;
  bool           ignoreExists;
X
Xiaoyu Wang 已提交
289
  char           indexDbName[TSDB_DB_NAME_LEN];
X
Xiaoyu Wang 已提交
290
  char           indexName[TSDB_INDEX_NAME_LEN];
291
  char           dbName[TSDB_DB_NAME_LEN];
X
Xiaoyu Wang 已提交
292 293
  char           tableName[TSDB_TABLE_NAME_LEN];
  SNodeList*     pCols;
X
Xiaoyu Wang 已提交
294 295 296
  SIndexOptions* pOptions;
} SCreateIndexStmt;

297 298
typedef struct SDropIndexStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
299
  bool      ignoreNotExists;
X
Xiaoyu Wang 已提交
300
  char      indexDbName[TSDB_DB_NAME_LEN];
X
Xiaoyu Wang 已提交
301
  char      indexName[TSDB_INDEX_NAME_LEN];
302 303
} SDropIndexStmt;

304
typedef struct SCreateComponentNodeStmt {
X
Xiaoyu Wang 已提交
305
  ENodeType type;
X
Xiaoyu Wang 已提交
306
  int32_t   dnodeId;
307
} SCreateComponentNodeStmt;
X
Xiaoyu Wang 已提交
308

309
typedef struct SDropComponentNodeStmt {
310
  ENodeType type;
X
Xiaoyu Wang 已提交
311
  int32_t   dnodeId;
312
} SDropComponentNodeStmt;
313 314

typedef struct SCreateTopicStmt {
315 316 317 318 319
  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 已提交
320
  bool      withMeta;
321
  SNode*    pQuery;
322 323 324 325
} SCreateTopicStmt;

typedef struct SDropTopicStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
326 327
  char      topicName[TSDB_TABLE_NAME_LEN];
  bool      ignoreNotExists;
328 329
} SDropTopicStmt;

X
Xiaoyu Wang 已提交
330 331 332 333 334 335 336
typedef struct SDropCGroupStmt {
  ENodeType type;
  char      topicName[TSDB_TABLE_NAME_LEN];
  char      cgroup[TSDB_CGROUP_LEN];
  bool      ignoreNotExists;
} SDropCGroupStmt;

337 338
typedef struct SAlterLocalStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
339 340
  char      config[TSDB_DNODE_CONFIG_LEN];
  char      value[TSDB_DNODE_VALUE_LEN];
341 342
} SAlterLocalStmt;

343
typedef struct SDescribeStmt {
X
Xiaoyu Wang 已提交
344 345 346
  ENodeType   type;
  char        dbName[TSDB_DB_NAME_LEN];
  char        tableName[TSDB_TABLE_NAME_LEN];
347 348 349
  STableMeta* pMeta;
} SDescribeStmt;

350 351
typedef struct SKillStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
352
  int32_t   targetId;
353 354
} SKillStmt;

X
Xiaoyu Wang 已提交
355 356 357 358 359
typedef struct SKillQueryStmt {
  ENodeType type;
  char      queryId[TSDB_QUERY_ID_LEN];
} SKillQueryStmt;

360 361
typedef struct SStreamOptions {
  ENodeType type;
X
Xiaoyu Wang 已提交
362
  int8_t    triggerType;
363
  SNode*    pDelay;
X
Xiaoyu Wang 已提交
364
  SNode*    pWatermark;
X
Xiaoyu Wang 已提交
365
  int8_t    ignoreExpired;
366 367 368
} SStreamOptions;

typedef struct SCreateStreamStmt {
X
Xiaoyu Wang 已提交
369 370 371 372 373
  ENodeType       type;
  char            streamName[TSDB_TABLE_NAME_LEN];
  char            targetDbName[TSDB_DB_NAME_LEN];
  char            targetTabName[TSDB_TABLE_NAME_LEN];
  bool            ignoreExists;
374
  SStreamOptions* pOptions;
X
Xiaoyu Wang 已提交
375
  SNode*          pQuery;
376 377 378 379
} SCreateStreamStmt;

typedef struct SDropStreamStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
380 381
  char      streamName[TSDB_TABLE_NAME_LEN];
  bool      ignoreNotExists;
382 383
} SDropStreamStmt;

384 385
typedef struct SCreateFunctionStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
386 387 388 389
  bool      ignoreExists;
  char      funcName[TSDB_FUNC_NAME_LEN];
  bool      isAgg;
  char      libraryPath[PATH_MAX];
390
  SDataType outputDt;
X
Xiaoyu Wang 已提交
391
  int32_t   bufSize;
392 393
} SCreateFunctionStmt;

394 395 396 397 398 399 400 401 402 403 404 405 406 407 408
typedef struct SDropFunctionStmt {
  ENodeType type;
  char      funcName[TSDB_FUNC_NAME_LEN];
  bool      ignoreNotExists;
} SDropFunctionStmt;

typedef struct SGrantStmt {
  ENodeType type;
  char      userName[TSDB_USER_LEN];
  char      dbName[TSDB_DB_NAME_LEN];
  int64_t   privileges;
} SGrantStmt;

typedef SGrantStmt SRevokeStmt;

X
Xiaoyu Wang 已提交
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432
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;

433 434 435 436
#ifdef __cplusplus
}
#endif

437
#endif /*_TD_CMD_NODES_H_*/