cmdnodes.h 9.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

X
Xiaoyu Wang 已提交
31 32 33 34 35 36 37 38
#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)

39
typedef struct SDatabaseOptions {
X
Xiaoyu Wang 已提交
40 41 42 43 44
  ENodeType   type;
  int32_t     buffer;
  int8_t      cachelast;
  int8_t      compressionLevel;
  int32_t     daysPerFile;
X
Xiaoyu Wang 已提交
45
  SValueNode* pDaysPerFile;
X
Xiaoyu Wang 已提交
46 47 48 49
  int32_t     fsyncPeriod;
  int32_t     maxRowsPerBlock;
  int32_t     minRowsPerBlock;
  SNodeList*  pKeep;
X
Xiaoyu Wang 已提交
50
  int64_t     keep[3];
X
Xiaoyu Wang 已提交
51 52 53 54 55 56 57 58 59 60
  int32_t     pages;
  int32_t     pagesize;
  char        precisionStr[3];
  int8_t      precision;
  int8_t      replica;
  int8_t      strict;
  int8_t      walLevel;
  int32_t     numOfVgroups;
  int8_t      singleStable;
  SNodeList*  pRetentions;
X
Xiaoyu Wang 已提交
61
  int8_t      schemaless;
62
} SDatabaseOptions;
63

64
typedef struct SCreateDatabaseStmt {
X
Xiaoyu Wang 已提交
65 66 67
  ENodeType         type;
  char              dbName[TSDB_DB_NAME_LEN];
  bool              ignoreExists;
X
Xiaoyu Wang 已提交
68
  SDatabaseOptions* pOptions;
69
} SCreateDatabaseStmt;
70

71 72
typedef struct SUseDatabaseStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
73
  char      dbName[TSDB_DB_NAME_LEN];
74 75
} SUseDatabaseStmt;

76 77
typedef struct SDropDatabaseStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
78 79
  char      dbName[TSDB_DB_NAME_LEN];
  bool      ignoreNotExists;
80 81
} SDropDatabaseStmt;

82
typedef struct SAlterDatabaseStmt {
X
Xiaoyu Wang 已提交
83 84
  ENodeType         type;
  char              dbName[TSDB_DB_NAME_LEN];
85 86 87
  SDatabaseOptions* pOptions;
} SAlterDatabaseStmt;

X
Xiaoyu Wang 已提交
88
typedef struct STableOptions {
X
Xiaoyu Wang 已提交
89
  ENodeType  type;
90
  char       comment[TSDB_TB_COMMENT_LEN];
X
Xiaoyu Wang 已提交
91 92 93 94 95 96
  SNodeList* pMaxDelay;
  int64_t    maxDelay1;
  int64_t    maxDelay2;
  SNodeList* pWatermark;
  int64_t    watermark1;
  int64_t    watermark2;
X
Xiaoyu Wang 已提交
97 98
  SNodeList* pRollupFuncs;
  int32_t    ttl;
99
  SNodeList* pSma;
X
Xiaoyu Wang 已提交
100 101 102 103
} STableOptions;

typedef struct SColumnDefNode {
  ENodeType type;
X
Xiaoyu Wang 已提交
104
  char      colName[TSDB_COL_NAME_LEN];
X
Xiaoyu Wang 已提交
105
  SDataType dataType;
106
  char      comments[TSDB_TB_COMMENT_LEN];
X
Xiaoyu Wang 已提交
107
  bool      sma;
X
Xiaoyu Wang 已提交
108 109 110
} SColumnDefNode;

typedef struct SCreateTableStmt {
X
Xiaoyu Wang 已提交
111 112 113 114 115 116
  ENodeType      type;
  char           dbName[TSDB_DB_NAME_LEN];
  char           tableName[TSDB_TABLE_NAME_LEN];
  bool           ignoreExists;
  SNodeList*     pCols;
  SNodeList*     pTags;
X
Xiaoyu Wang 已提交
117
  STableOptions* pOptions;
X
Xiaoyu Wang 已提交
118 119
} SCreateTableStmt;

120
typedef struct SCreateSubTableClause {
X
Xiaoyu Wang 已提交
121 122 123 124 125 126
  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;
127 128
  SNodeList* pSpecificTags;
  SNodeList* pValsOfTags;
129
} SCreateSubTableClause;
130 131

typedef struct SCreateMultiTableStmt {
X
Xiaoyu Wang 已提交
132
  ENodeType  type;
133 134
  SNodeList* pSubTables;
} SCreateMultiTableStmt;
X
Xiaoyu Wang 已提交
135

136 137
typedef struct SDropTableClause {
  ENodeType type;
X
Xiaoyu Wang 已提交
138 139 140
  char      dbName[TSDB_DB_NAME_LEN];
  char      tableName[TSDB_TABLE_NAME_LEN];
  bool      ignoreNotExists;
141 142 143
} SDropTableClause;

typedef struct SDropTableStmt {
X
Xiaoyu Wang 已提交
144
  ENodeType  type;
145 146 147
  SNodeList* pTables;
} SDropTableStmt;

148 149
typedef struct SDropSuperTableStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
150 151 152
  char      dbName[TSDB_DB_NAME_LEN];
  char      tableName[TSDB_TABLE_NAME_LEN];
  bool      ignoreNotExists;
153 154
} SDropSuperTableStmt;

155
typedef struct SAlterTableStmt {
X
Xiaoyu Wang 已提交
156 157 158 159 160 161
  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];
162
  STableOptions* pOptions;
X
Xiaoyu Wang 已提交
163 164
  SDataType      dataType;
  SValueNode*    pVal;
165 166
} SAlterTableStmt;

167 168
typedef struct SCreateUserStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
169 170
  char      useName[TSDB_USER_LEN];
  char      password[TSDB_USET_PASSWORD_LEN];
171 172 173 174
} SCreateUserStmt;

typedef struct SAlterUserStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
175 176 177
  char      useName[TSDB_USER_LEN];
  char      password[TSDB_USET_PASSWORD_LEN];
  int8_t    alterType;
178 179 180 181
} SAlterUserStmt;

typedef struct SDropUserStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
182
  char      useName[TSDB_USER_LEN];
183 184 185 186
} SDropUserStmt;

typedef struct SCreateDnodeStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
187 188
  char      fqdn[TSDB_FQDN_LEN];
  int32_t   port;
189 190 191 192
} SCreateDnodeStmt;

typedef struct SDropDnodeStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
193 194 195
  int32_t   dnodeId;
  char      fqdn[TSDB_FQDN_LEN];
  int32_t   port;
196 197
} SDropDnodeStmt;

198 199
typedef struct SAlterDnodeStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
200 201 202
  int32_t   dnodeId;
  char      config[TSDB_DNODE_CONFIG_LEN];
  char      value[TSDB_DNODE_VALUE_LEN];
203 204
} SAlterDnodeStmt;

205 206
typedef struct SShowStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
207 208
  SNode*    pDbName;         // SValueNode
  SNode*    pTbNamePattern;  // SValueNode
209 210
} SShowStmt;

211
typedef struct SShowCreateDatabaseStmt {
212
  ENodeType type;
X
Xiaoyu Wang 已提交
213
  char      dbName[TSDB_DB_NAME_LEN];
214 215 216 217 218 219 220 221 222
  void*     pCfg;  // SDbCfgInfo
} SShowCreateDatabaseStmt;

typedef struct SShowCreateTableStmt {
  ENodeType   type;
  char        dbName[TSDB_DB_NAME_LEN];
  char        tableName[TSDB_TABLE_NAME_LEN];
  STableMeta* pMeta;
} SShowCreateTableStmt;
223

X
Xiaoyu Wang 已提交
224
typedef enum EIndexType { INDEX_TYPE_SMA = 1, INDEX_TYPE_FULLTEXT } EIndexType;
X
Xiaoyu Wang 已提交
225 226

typedef struct SIndexOptions {
X
Xiaoyu Wang 已提交
227
  ENodeType  type;
X
Xiaoyu Wang 已提交
228
  SNodeList* pFuncs;
X
Xiaoyu Wang 已提交
229 230 231
  SNode*     pInterval;
  SNode*     pOffset;
  SNode*     pSliding;
X
Xiaoyu Wang 已提交
232 233 234
} SIndexOptions;

typedef struct SCreateIndexStmt {
X
Xiaoyu Wang 已提交
235 236 237 238 239 240
  ENodeType      type;
  EIndexType     indexType;
  bool           ignoreExists;
  char           indexName[TSDB_INDEX_NAME_LEN];
  char           tableName[TSDB_TABLE_NAME_LEN];
  SNodeList*     pCols;
X
Xiaoyu Wang 已提交
241 242 243
  SIndexOptions* pOptions;
} SCreateIndexStmt;

244 245
typedef struct SDropIndexStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
246 247 248
  bool      ignoreNotExists;
  char      indexName[TSDB_INDEX_NAME_LEN];
  char      tableName[TSDB_TABLE_NAME_LEN];
249 250
} SDropIndexStmt;

251
typedef struct SCreateComponentNodeStmt {
X
Xiaoyu Wang 已提交
252
  ENodeType type;
X
Xiaoyu Wang 已提交
253
  int32_t   dnodeId;
254
} SCreateComponentNodeStmt;
X
Xiaoyu Wang 已提交
255

256
typedef struct SDropComponentNodeStmt {
257
  ENodeType type;
X
Xiaoyu Wang 已提交
258
  int32_t   dnodeId;
259
} SDropComponentNodeStmt;
260 261

typedef struct SCreateTopicStmt {
262 263 264 265 266 267
  ENodeType type;
  char      topicName[TSDB_TABLE_NAME_LEN];
  char      subDbName[TSDB_DB_NAME_LEN];
  char      subSTbName[TSDB_TABLE_NAME_LEN];
  bool      ignoreExists;
  SNode*    pQuery;
268 269 270 271
} SCreateTopicStmt;

typedef struct SDropTopicStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
272 273
  char      topicName[TSDB_TABLE_NAME_LEN];
  bool      ignoreNotExists;
274 275
} SDropTopicStmt;

X
Xiaoyu Wang 已提交
276 277 278 279 280 281 282
typedef struct SDropCGroupStmt {
  ENodeType type;
  char      topicName[TSDB_TABLE_NAME_LEN];
  char      cgroup[TSDB_CGROUP_LEN];
  bool      ignoreNotExists;
} SDropCGroupStmt;

283 284
typedef struct SAlterLocalStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
285 286
  char      config[TSDB_DNODE_CONFIG_LEN];
  char      value[TSDB_DNODE_VALUE_LEN];
287 288
} SAlterLocalStmt;

289
typedef struct SDescribeStmt {
X
Xiaoyu Wang 已提交
290 291 292
  ENodeType   type;
  char        dbName[TSDB_DB_NAME_LEN];
  char        tableName[TSDB_TABLE_NAME_LEN];
293 294 295
  STableMeta* pMeta;
} SDescribeStmt;

296 297
typedef struct SKillStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
298
  int32_t   targetId;
299 300
} SKillStmt;

X
Xiaoyu Wang 已提交
301 302 303 304 305
typedef struct SKillQueryStmt {
  ENodeType type;
  char      queryId[TSDB_QUERY_ID_LEN];
} SKillQueryStmt;

306 307
typedef struct SStreamOptions {
  ENodeType type;
X
Xiaoyu Wang 已提交
308
  int8_t    triggerType;
309
  SNode*    pDelay;
X
Xiaoyu Wang 已提交
310
  SNode*    pWatermark;
311 312 313
} SStreamOptions;

typedef struct SCreateStreamStmt {
X
Xiaoyu Wang 已提交
314 315 316 317 318
  ENodeType       type;
  char            streamName[TSDB_TABLE_NAME_LEN];
  char            targetDbName[TSDB_DB_NAME_LEN];
  char            targetTabName[TSDB_TABLE_NAME_LEN];
  bool            ignoreExists;
319
  SStreamOptions* pOptions;
X
Xiaoyu Wang 已提交
320
  SNode*          pQuery;
321 322 323 324
} SCreateStreamStmt;

typedef struct SDropStreamStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
325 326
  char      streamName[TSDB_TABLE_NAME_LEN];
  bool      ignoreNotExists;
327 328
} SDropStreamStmt;

329 330
typedef struct SCreateFunctionStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
331 332 333 334
  bool      ignoreExists;
  char      funcName[TSDB_FUNC_NAME_LEN];
  bool      isAgg;
  char      libraryPath[PATH_MAX];
335
  SDataType outputDt;
X
Xiaoyu Wang 已提交
336
  int32_t   bufSize;
337 338
} SCreateFunctionStmt;

339 340 341 342 343 344 345 346 347 348 349 350 351 352 353
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 已提交
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377
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;

378 379 380 381
#ifdef __cplusplus
}
#endif

382
#endif /*_TD_CMD_NODES_H_*/