cmdnodes.h 8.5 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;
53
} SDatabaseOptions;
54

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

X
Xiaoyu Wang 已提交
241 242
typedef struct STopicOptions {
  ENodeType type;
X
Xiaoyu Wang 已提交
243 244 245
  bool      withTable;
  bool      withSchema;
  bool      withTag;
X
Xiaoyu Wang 已提交
246 247
} STopicOptions;

248
typedef struct SCreateTopicStmt {
X
Xiaoyu Wang 已提交
249 250 251 252 253
  ENodeType      type;
  char           topicName[TSDB_TABLE_NAME_LEN];
  char           subscribeDbName[TSDB_DB_NAME_LEN];
  bool           ignoreExists;
  SNode*         pQuery;
X
Xiaoyu Wang 已提交
254
  STopicOptions* pOptions;
255 256 257 258
} SCreateTopicStmt;

typedef struct SDropTopicStmt {
  ENodeType type;
X
Xiaoyu Wang 已提交
259 260
  char      topicName[TSDB_TABLE_NAME_LEN];
  bool      ignoreNotExists;
261 262
} SDropTopicStmt;

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

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

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

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

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

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

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

313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335
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;

336 337 338 339
#ifdef __cplusplus
}
#endif

340
#endif /*_TD_CMD_NODES_H_*/