cmdnodes.h 8.6 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
typedef struct SDatabaseOptions {
X
Xiaoyu Wang 已提交
32 33 34 35 36
  ENodeType   type;
  int32_t     buffer;
  int8_t      cachelast;
  int8_t      compressionLevel;
  int32_t     daysPerFile;
X
Xiaoyu Wang 已提交
37
  SValueNode* pDaysPerFile;
X
Xiaoyu Wang 已提交
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
  int32_t     fsyncPeriod;
  int32_t     maxRowsPerBlock;
  int32_t     minRowsPerBlock;
  SNodeList*  pKeep;
  int32_t     keep[3];
  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 已提交
53
  int8_t      schemaless;
54
} SDatabaseOptions;
55

56
typedef struct SCreateDatabaseStmt {
X
Xiaoyu Wang 已提交
57 58 59
  ENodeType         type;
  char              dbName[TSDB_DB_NAME_LEN];
  bool              ignoreExists;
X
Xiaoyu Wang 已提交
60
  SDatabaseOptions* pOptions;
61
} SCreateDatabaseStmt;
62

63 64
typedef struct SUseDatabaseStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
65
  char      dbName[TSDB_DB_NAME_LEN];
66 67
} SUseDatabaseStmt;

68 69
typedef struct SDropDatabaseStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
70 71
  char      dbName[TSDB_DB_NAME_LEN];
  bool      ignoreNotExists;
72 73
} SDropDatabaseStmt;

74
typedef struct SAlterDatabaseStmt {
X
Xiaoyu Wang 已提交
75 76
  ENodeType         type;
  char              dbName[TSDB_DB_NAME_LEN];
77 78 79
  SDatabaseOptions* pOptions;
} SAlterDatabaseStmt;

X
Xiaoyu Wang 已提交
80
typedef struct STableOptions {
X
Xiaoyu Wang 已提交
81
  ENodeType  type;
82
  char       comment[TSDB_TB_COMMENT_LEN];
X
Xiaoyu Wang 已提交
83 84 85 86
  int32_t    delay;
  float      filesFactor;
  SNodeList* pRollupFuncs;
  int32_t    ttl;
87
  SNodeList* pSma;
X
Xiaoyu Wang 已提交
88 89 90 91
} STableOptions;

typedef struct SColumnDefNode {
  ENodeType type;
X
Xiaoyu Wang 已提交
92
  char      colName[TSDB_COL_NAME_LEN];
X
Xiaoyu Wang 已提交
93
  SDataType dataType;
94
  char      comments[TSDB_TB_COMMENT_LEN];
X
Xiaoyu Wang 已提交
95
  bool      sma;
X
Xiaoyu Wang 已提交
96 97 98
} SColumnDefNode;

typedef struct SCreateTableStmt {
X
Xiaoyu Wang 已提交
99 100 101 102 103 104
  ENodeType      type;
  char           dbName[TSDB_DB_NAME_LEN];
  char           tableName[TSDB_TABLE_NAME_LEN];
  bool           ignoreExists;
  SNodeList*     pCols;
  SNodeList*     pTags;
X
Xiaoyu Wang 已提交
105
  STableOptions* pOptions;
X
Xiaoyu Wang 已提交
106 107
} SCreateTableStmt;

108
typedef struct SCreateSubTableClause {
X
Xiaoyu Wang 已提交
109 110 111 112 113 114
  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;
115 116
  SNodeList* pSpecificTags;
  SNodeList* pValsOfTags;
117
} SCreateSubTableClause;
118 119

typedef struct SCreateMultiTableStmt {
X
Xiaoyu Wang 已提交
120
  ENodeType  type;
121 122
  SNodeList* pSubTables;
} SCreateMultiTableStmt;
X
Xiaoyu Wang 已提交
123

124 125
typedef struct SDropTableClause {
  ENodeType type;
X
Xiaoyu Wang 已提交
126 127 128
  char      dbName[TSDB_DB_NAME_LEN];
  char      tableName[TSDB_TABLE_NAME_LEN];
  bool      ignoreNotExists;
129 130 131
} SDropTableClause;

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

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

143
typedef struct SAlterTableStmt {
X
Xiaoyu Wang 已提交
144 145 146 147 148 149
  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];
150
  STableOptions* pOptions;
X
Xiaoyu Wang 已提交
151 152
  SDataType      dataType;
  SValueNode*    pVal;
153 154
} SAlterTableStmt;

155 156
typedef struct SCreateUserStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
157 158
  char      useName[TSDB_USER_LEN];
  char      password[TSDB_USET_PASSWORD_LEN];
159 160 161 162
} SCreateUserStmt;

typedef struct SAlterUserStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
163 164 165
  char      useName[TSDB_USER_LEN];
  char      password[TSDB_USET_PASSWORD_LEN];
  int8_t    alterType;
166 167 168 169
} SAlterUserStmt;

typedef struct SDropUserStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
170
  char      useName[TSDB_USER_LEN];
171 172 173 174
} SDropUserStmt;

typedef struct SCreateDnodeStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
175 176
  char      fqdn[TSDB_FQDN_LEN];
  int32_t   port;
177 178 179 180
} SCreateDnodeStmt;

typedef struct SDropDnodeStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
181 182 183
  int32_t   dnodeId;
  char      fqdn[TSDB_FQDN_LEN];
  int32_t   port;
184 185
} SDropDnodeStmt;

186 187
typedef struct SAlterDnodeStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
188 189 190
  int32_t   dnodeId;
  char      config[TSDB_DNODE_CONFIG_LEN];
  char      value[TSDB_DNODE_VALUE_LEN];
191 192
} SAlterDnodeStmt;

193 194
typedef struct SShowStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
195 196
  SNode*    pDbName;         // SValueNode
  SNode*    pTbNamePattern;  // SValueNode
197 198
} SShowStmt;

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

X
Xiaoyu Wang 已提交
205
typedef enum EIndexType { INDEX_TYPE_SMA = 1, INDEX_TYPE_FULLTEXT } EIndexType;
X
Xiaoyu Wang 已提交
206 207

typedef struct SIndexOptions {
X
Xiaoyu Wang 已提交
208
  ENodeType  type;
X
Xiaoyu Wang 已提交
209
  SNodeList* pFuncs;
X
Xiaoyu Wang 已提交
210 211 212
  SNode*     pInterval;
  SNode*     pOffset;
  SNode*     pSliding;
X
Xiaoyu Wang 已提交
213 214 215
} SIndexOptions;

typedef struct SCreateIndexStmt {
X
Xiaoyu Wang 已提交
216 217 218 219 220 221
  ENodeType      type;
  EIndexType     indexType;
  bool           ignoreExists;
  char           indexName[TSDB_INDEX_NAME_LEN];
  char           tableName[TSDB_TABLE_NAME_LEN];
  SNodeList*     pCols;
X
Xiaoyu Wang 已提交
222 223 224
  SIndexOptions* pOptions;
} SCreateIndexStmt;

225 226
typedef struct SDropIndexStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
227 228 229
  bool      ignoreNotExists;
  char      indexName[TSDB_INDEX_NAME_LEN];
  char      tableName[TSDB_TABLE_NAME_LEN];
230 231
} SDropIndexStmt;

232
typedef struct SCreateComponentNodeStmt {
X
Xiaoyu Wang 已提交
233
  ENodeType type;
X
Xiaoyu Wang 已提交
234
  int32_t   dnodeId;
235
} SCreateComponentNodeStmt;
X
Xiaoyu Wang 已提交
236

237
typedef struct SDropComponentNodeStmt {
238
  ENodeType type;
X
Xiaoyu Wang 已提交
239
  int32_t   dnodeId;
240
} SDropComponentNodeStmt;
241 242

typedef struct SCreateTopicStmt {
243 244 245 246 247 248
  ENodeType type;
  char      topicName[TSDB_TABLE_NAME_LEN];
  char      subDbName[TSDB_DB_NAME_LEN];
  char      subSTbName[TSDB_TABLE_NAME_LEN];
  bool      ignoreExists;
  SNode*    pQuery;
249 250 251 252
} SCreateTopicStmt;

typedef struct SDropTopicStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
253 254
  char      topicName[TSDB_TABLE_NAME_LEN];
  bool      ignoreNotExists;
255 256
} SDropTopicStmt;

X
Xiaoyu Wang 已提交
257 258 259 260 261 262 263
typedef struct SDropCGroupStmt {
  ENodeType type;
  char      topicName[TSDB_TABLE_NAME_LEN];
  char      cgroup[TSDB_CGROUP_LEN];
  bool      ignoreNotExists;
} SDropCGroupStmt;

264 265
typedef struct SAlterLocalStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
266 267
  char      config[TSDB_DNODE_CONFIG_LEN];
  char      value[TSDB_DNODE_VALUE_LEN];
268 269
} SAlterLocalStmt;

270
typedef struct SDescribeStmt {
X
Xiaoyu Wang 已提交
271 272 273
  ENodeType   type;
  char        dbName[TSDB_DB_NAME_LEN];
  char        tableName[TSDB_TABLE_NAME_LEN];
274 275 276
  STableMeta* pMeta;
} SDescribeStmt;

277 278
typedef struct SKillStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
279
  int32_t   targetId;
280 281
} SKillStmt;

282 283
typedef struct SStreamOptions {
  ENodeType type;
X
Xiaoyu Wang 已提交
284 285
  int8_t    triggerType;
  SNode*    pWatermark;
286 287 288
} SStreamOptions;

typedef struct SCreateStreamStmt {
X
Xiaoyu Wang 已提交
289 290 291 292 293
  ENodeType       type;
  char            streamName[TSDB_TABLE_NAME_LEN];
  char            targetDbName[TSDB_DB_NAME_LEN];
  char            targetTabName[TSDB_TABLE_NAME_LEN];
  bool            ignoreExists;
294
  SStreamOptions* pOptions;
X
Xiaoyu Wang 已提交
295
  SNode*          pQuery;
296 297 298 299
} SCreateStreamStmt;

typedef struct SDropStreamStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
300 301
  char      streamName[TSDB_TABLE_NAME_LEN];
  bool      ignoreNotExists;
302 303
} SDropStreamStmt;

304 305
typedef struct SCreateFunctionStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
306 307 308 309
  bool      ignoreExists;
  char      funcName[TSDB_FUNC_NAME_LEN];
  bool      isAgg;
  char      libraryPath[PATH_MAX];
310
  SDataType outputDt;
X
Xiaoyu Wang 已提交
311
  int32_t   bufSize;
312 313
} SCreateFunctionStmt;

314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336
typedef struct SDropFunctionStmt {
  ENodeType type;
  char      funcName[TSDB_FUNC_NAME_LEN];
  bool      ignoreNotExists;
} SDropFunctionStmt;

#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)

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

typedef SGrantStmt SRevokeStmt;

337 338 339 340
#ifdef __cplusplus
}
#endif

341
#endif /*_TD_CMD_NODES_H_*/