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

26 27 28 29 30
#define DESCRIBE_RESULT_COLS 4
#define DESCRIBE_RESULT_FIELD_LEN (TSDB_COL_NAME_LEN - 1 + VARSTR_HEADER_SIZE)
#define DESCRIBE_RESULT_TYPE_LEN (20 + VARSTR_HEADER_SIZE)
#define DESCRIBE_RESULT_NOTE_LEN (8 + VARSTR_HEADER_SIZE)

31
typedef struct SDatabaseOptions {
X
Xiaoyu Wang 已提交
32
  ENodeType type;
X
Xiaoyu Wang 已提交
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
  SValueNode* pNumOfBlocks;
  SValueNode* pCacheBlockSize;
  SValueNode* pCachelast;
  SValueNode* pCompressionLevel;
  SValueNode* pDaysPerFile;
  SValueNode* pFsyncPeriod;
  SValueNode* pMaxRowsPerBlock;
  SValueNode* pMinRowsPerBlock;
  SNodeList* pKeep;
  SValueNode* pPrecision;
  SValueNode* pQuorum;
  SValueNode* pReplica;
  SValueNode* pTtl;
  SValueNode* pWalLevel;
  SValueNode* pNumOfVgroups;
  SValueNode* pSingleStable;
  SValueNode* pStreamMode;
50
  SValueNode* pStrict;
X
Xiaoyu Wang 已提交
51
  SNodeList* pRetentions;
52
} SDatabaseOptions;
53

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

61 62 63 64 65
typedef struct SUseDatabaseStmt {
  ENodeType type;
  char dbName[TSDB_DB_NAME_LEN];
} SUseDatabaseStmt;

66 67 68 69 70 71
typedef struct SDropDatabaseStmt {
  ENodeType type;
  char dbName[TSDB_DB_NAME_LEN];
  bool ignoreNotExists;
} SDropDatabaseStmt;

72 73 74 75 76 77
typedef struct SAlterDatabaseStmt {
  ENodeType type;
  char dbName[TSDB_DB_NAME_LEN];
  SDatabaseOptions* pOptions;
} SAlterDatabaseStmt;

X
Xiaoyu Wang 已提交
78
typedef struct STableOptions {
X
Xiaoyu Wang 已提交
79
  ENodeType type;
X
Xiaoyu Wang 已提交
80 81 82
  SNodeList* pKeep;
  SValueNode* pTtl;
  SValueNode* pComments;
83
  SNodeList* pSma;
X
Xiaoyu Wang 已提交
84
  SNodeList* pFuncs;
X
Xiaoyu Wang 已提交
85 86
  SValueNode* pFilesFactor;
  SValueNode* pDelay;
X
Xiaoyu Wang 已提交
87 88 89 90 91 92 93
} STableOptions;

typedef struct SColumnDefNode {
  ENodeType type;
  char colName[TSDB_COL_NAME_LEN];
  SDataType dataType;
  char comments[TSDB_STB_COMMENT_LEN];
94
  bool sma;
X
Xiaoyu Wang 已提交
95 96 97 98 99 100 101 102
} SColumnDefNode;

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

107
typedef struct SCreateSubTableClause {
108 109 110 111 112 113 114 115
  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;
116
} SCreateSubTableClause;
117 118 119 120 121

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

123 124 125 126 127 128 129 130 131 132 133 134
typedef struct SDropTableClause {
  ENodeType type;
  char dbName[TSDB_DB_NAME_LEN];
  char tableName[TSDB_TABLE_NAME_LEN];
  bool ignoreNotExists;
} SDropTableClause;

typedef struct SDropTableStmt {
  ENodeType type;
  SNodeList* pTables;
} SDropTableStmt;

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

142 143 144 145
typedef struct SAlterTableStmt {
  ENodeType type;
  char dbName[TSDB_DB_NAME_LEN];
  char tableName[TSDB_TABLE_NAME_LEN];
146 147 148 149 150 151
  int8_t alterType;
  char colName[TSDB_COL_NAME_LEN];
  char newColName[TSDB_COL_NAME_LEN];
  STableOptions* pOptions;
  SDataType dataType;
  SValueNode* pVal;
152 153
} SAlterTableStmt;

154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
typedef struct SCreateUserStmt {
  ENodeType type;
  char useName[TSDB_USER_LEN];
  char password[TSDB_USET_PASSWORD_LEN];
} SCreateUserStmt;

typedef struct SAlterUserStmt {
  ENodeType type;
  char useName[TSDB_USER_LEN];
  char password[TSDB_USET_PASSWORD_LEN];
  int8_t alterType;
} SAlterUserStmt;

typedef struct SDropUserStmt {
  ENodeType type;
  char useName[TSDB_USER_LEN];
} SDropUserStmt;

typedef struct SCreateDnodeStmt {
  ENodeType type;
  char fqdn[TSDB_FQDN_LEN];
  int32_t port;
} SCreateDnodeStmt;

typedef struct SDropDnodeStmt {
  ENodeType type;
  int32_t dnodeId;
  char fqdn[TSDB_FQDN_LEN];
  int32_t port;
} SDropDnodeStmt;

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

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

198 199 200 201 202 203
typedef struct SShowCreatStmt {
  ENodeType type;
  char dbName[TSDB_DB_NAME_LEN];
  char tableName[TSDB_TABLE_NAME_LEN];
} SShowCreatStmt;

X
Xiaoyu Wang 已提交
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
typedef enum EIndexType {
  INDEX_TYPE_SMA = 1,
  INDEX_TYPE_FULLTEXT
} EIndexType;

typedef struct SIndexOptions {
  ENodeType type;
  SNodeList* pFuncs;
  SNode* pInterval;
  SNode* pOffset;
  SNode* pSliding;
} SIndexOptions;

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

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

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

239
typedef struct SDropComponentNodeStmt {
240 241
  ENodeType type;
  int32_t dnodeId;
242
} SDropComponentNodeStmt;
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257

typedef struct SCreateTopicStmt {
  ENodeType type;
  char topicName[TSDB_TABLE_NAME_LEN];
  char subscribeDbName[TSDB_DB_NAME_LEN];
  bool ignoreExists;
  SNode* pQuery;
} SCreateTopicStmt;

typedef struct SDropTopicStmt {
  ENodeType type;
  char topicName[TSDB_TABLE_NAME_LEN];
  bool ignoreNotExists;
} SDropTopicStmt;

258 259 260 261 262 263
typedef struct SAlterLocalStmt {
  ENodeType type;
  char config[TSDB_DNODE_CONFIG_LEN];
  char value[TSDB_DNODE_VALUE_LEN];
} SAlterLocalStmt;

264 265 266 267 268 269 270
typedef struct SDescribeStmt {
  ENodeType type;
  char dbName[TSDB_DB_NAME_LEN];
  char tableName[TSDB_TABLE_NAME_LEN];
  STableMeta* pMeta;
} SDescribeStmt;

271 272 273 274 275
typedef struct SKillStmt {
  ENodeType type;
  int32_t targetId;
} SKillStmt;

276 277
typedef struct SStreamOptions {
  ENodeType type;
X
Xiaoyu Wang 已提交
278
  int8_t triggerType;
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297
  SNode* pWatermark;
} SStreamOptions;

typedef struct SCreateStreamStmt {
  ENodeType type;
  char streamName[TSDB_TABLE_NAME_LEN];
  char targetDbName[TSDB_DB_NAME_LEN];
  char targetTabName[TSDB_TABLE_NAME_LEN];
  bool ignoreExists;
  SStreamOptions* pOptions;
  SNode* pQuery;
} SCreateStreamStmt;

typedef struct SDropStreamStmt {
  ENodeType type;
  char streamName[TSDB_TABLE_NAME_LEN];
  bool ignoreNotExists;
} SDropStreamStmt;

298 299 300 301 302 303 304 305 306 307
typedef struct SCreateFunctionStmt {
  ENodeType type;
  bool ignoreExists;
  char funcName[TSDB_FUNC_NAME_LEN];
  bool isAgg;
  char libraryPath[PATH_MAX];
  SDataType outputDt;
  int32_t bufSize;
} SCreateFunctionStmt;

308 309 310 311
#ifdef __cplusplus
}
#endif

312
#endif /*_TD_CMD_NODES_H_*/