taosdef.h 17.1 KB
Newer Older
H
hzcheng 已提交
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/>.
 */

S
#1177  
slguan 已提交
16 17
#ifndef TDENGINE_TAOS_DEF_H
#define TDENGINE_TAOS_DEF_H
H
hzcheng 已提交
18 19 20 21 22 23

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>
H
hzcheng 已提交
24
#include <stdbool.h>
S
Shengliang Guan 已提交
25
#include "osDef.h"
H
hzcheng 已提交
26
#include "taos.h"
H
hzcheng 已提交
27 28 29 30 31 32 33 34 35

#define TSDB__packed

#ifdef TSKEY32
#define TSKEY int32_t;
#else
#define TSKEY int64_t
#endif

36
#define TSWINDOW_INITIALIZER ((STimeWindow) {INT64_MIN, INT64_MAX})
37 38
#define TSKEY_INITIAL_VAL    INT64_MIN

H
TD-166  
hzcheng 已提交
39 40 41
// ----------------- For variable data types such as TSDB_DATA_TYPE_BINARY and TSDB_DATA_TYPE_NCHAR
typedef int32_t VarDataOffsetT;
typedef int16_t VarDataLenT;
42

H
hjxilinx 已提交
43 44 45 46 47
typedef struct tstr {
  VarDataLenT len;
  char        data[];
} tstr;

48 49
#define VARSTR_HEADER_SIZE  sizeof(VarDataLenT)

50 51
#define varDataLen(v)       ((VarDataLenT *)(v))[0]
#define varDataTLen(v)      (sizeof(VarDataLenT) + varDataLen(v))
52
#define varDataVal(v)       ((void *)((char *)v + VARSTR_HEADER_SIZE))
53
#define varDataCopy(dst, v) memcpy((dst), (void*) (v), varDataTLen(v))
54
#define varDataLenByData(v) (*(VarDataLenT *)(((char*)(v)) - VARSTR_HEADER_SIZE))
55
#define varDataSetLen(v, _len) (((VarDataLenT *)(v))[0] = (VarDataLenT) (_len))
H
Hongze Cheng 已提交
56
#define IS_VAR_DATA_TYPE(t) (((t) == TSDB_DATA_TYPE_BINARY) || ((t) == TSDB_DATA_TYPE_NCHAR))
H
TD-166  
hzcheng 已提交
57

58 59
// this data type is internally used only in 'in' query to hold the values
#define TSDB_DATA_TYPE_ARRAY      (TSDB_DATA_TYPE_NCHAR + 1)
60

weixin_48148422's avatar
weixin_48148422 已提交
61

H
hzcheng 已提交
62
// Bytes for each type.
H
hzcheng 已提交
63 64
extern const int32_t TYPE_BYTES[11];
// TODO: replace and remove code below
H
hzcheng 已提交
65
#define CHAR_BYTES   sizeof(char)
66
#define SHORT_BYTES  sizeof(int16_t)
S
Shengliang Guan 已提交
67
#define INT_BYTES    sizeof(int32_t)
H
hzcheng 已提交
68 69 70 71 72 73 74 75
#define LONG_BYTES   sizeof(int64_t)
#define FLOAT_BYTES  sizeof(float)
#define DOUBLE_BYTES sizeof(double)

// NULL definition
#define TSDB_DATA_BOOL_NULL             0x02
#define TSDB_DATA_TINYINT_NULL          0x80
#define TSDB_DATA_SMALLINT_NULL         0x8000
S
Shengliang Guan 已提交
76
#define TSDB_DATA_INT_NULL              0x80000000L
H
hzcheng 已提交
77
#define TSDB_DATA_BIGINT_NULL           0x8000000000000000L
H
TD-1548  
Hongze Cheng 已提交
78
#define TSDB_DATA_TIMESTAMP_NULL        TSDB_DATA_BIGINT_NULL
H
hzcheng 已提交
79 80 81 82 83 84 85 86 87

#define TSDB_DATA_FLOAT_NULL            0x7FF00000              // it is an NAN
#define TSDB_DATA_DOUBLE_NULL           0x7FFFFF0000000000L     // an NAN
#define TSDB_DATA_NCHAR_NULL            0xFFFFFFFF
#define TSDB_DATA_BINARY_NULL           0xFF

#define TSDB_DATA_NULL_STR              "NULL"
#define TSDB_DATA_NULL_STR_L            "null"

88
#define TSDB_DEFAULT_USER               "root"
H
Hui Li 已提交
89
#ifdef _TD_POWER_
H
Hui Li 已提交
90 91
#define TSDB_DEFAULT_PASS               "powerdb"
#else
92
#define TSDB_DEFAULT_PASS               "taosdata"
H
Hui Li 已提交
93
#endif
94

H
hjxilinx 已提交
95 96 97 98
#define TSDB_TRUE   1
#define TSDB_FALSE  0
#define TSDB_OK     0
#define TSDB_ERR   -1
H
hzcheng 已提交
99 100 101 102 103

#define TS_PATH_DELIMITER "."

#define TSDB_TIME_PRECISION_MILLI 0
#define TSDB_TIME_PRECISION_MICRO 1
104
#define TSDB_TIME_PRECISION_NANO  2
B
Bomin Zhang 已提交
105
#define TSDB_TICK_PER_SECOND(precision) ((precision)==TSDB_TIME_PRECISION_MILLI ? 1e3L : ((precision)==TSDB_TIME_PRECISION_MICRO ? 1e6L : 1e9L))
H
hzcheng 已提交
106 107 108 109

#define TSDB_TIME_PRECISION_MILLI_STR "ms"
#define TSDB_TIME_PRECISION_MICRO_STR "us"

H
TD-27  
hzcheng 已提交
110 111 112 113 114 115 116 117 118 119 120
#define T_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
#define T_APPEND_MEMBER(dst, ptr, type, member) \
do {\
  memcpy((void *)(dst), (void *)(&((ptr)->member)), T_MEMBER_SIZE(type, member));\
  dst = (void *)((char *)(dst) + T_MEMBER_SIZE(type, member));\
} while(0)
#define T_READ_MEMBER(src, type, target) \
do { \
  (target) = *(type *)(src); \
  (src) = (void *)((char *)src + sizeof(type));\
} while(0)
H
hzcheng 已提交
121 122

#define TSDB_KEYSIZE              sizeof(TSKEY)
S
slguan 已提交
123

S
slguan 已提交
124 125 126 127 128
#if LINUX
  #define TSDB_NCHAR_SIZE         sizeof(wchar_t)
#else
  #define TSDB_NCHAR_SIZE         4
#endif
S
slguan 已提交
129
//#define TSDB_CHAR_TERMINATED_SPACE 1
H
hzcheng 已提交
130

H
hzcheng 已提交
131 132 133 134
#define GET_INT8_VAL(x)   (*(int8_t *)(x))
#define GET_INT16_VAL(x)  (*(int16_t *)(x))
#define GET_INT32_VAL(x)  (*(int32_t *)(x))
#define GET_INT64_VAL(x)  (*(int64_t *)(x))
S
TD-1530  
Shengliang Guan 已提交
135
#ifdef _TD_ARM_32
H
hzcheng 已提交
136 137 138 139 140

  //#define __float_align_declear()  float __underlyFloat = 0.0;
  //#define __float_align_declear()
  //#define GET_FLOAT_VAL_ALIGN(x) (*(int32_t*)&(__underlyFloat) = *(int32_t*)(x); __underlyFloat);
  // notes: src must be float or double type variable !!!
S
TD-1530  
Shengliang Guan 已提交
141 142 143 144 145 146 147 148
  //#define SET_FLOAT_VAL_ALIGN(dst, src) (*(int32_t*) dst = *(int32_t*)src);
  //#define SET_DOUBLE_VAL_ALIGN(dst, src) (*(int64_t*) dst = *(int64_t*)src);

  float  taos_align_get_float(const char* pBuf);
  double taos_align_get_double(const char* pBuf);

  #define GET_FLOAT_VAL(x)       taos_align_get_float(x)
  #define GET_DOUBLE_VAL(x)      taos_align_get_double(x)
S
TD-1530  
Shengliang Guan 已提交
149 150
  #define SET_FLOAT_VAL(x, y)  { float z = (float)(y);   (*(int32_t*) x = *(int32_t*)(&z)); }
  #define SET_DOUBLE_VAL(x, y) { double z = (double)(y); (*(int64_t*) x = *(int64_t*)(&z)); }
S
TD-1530  
Shengliang Guan 已提交
151 152
  #define SET_FLOAT_PTR(x, y)  { (*(int32_t*) x = *(int32_t*)y); }
  #define SET_DOUBLE_PTR(x, y) { (*(int64_t*) x = *(int64_t*)y); }
H
hzcheng 已提交
153
#else
S
TD-1530  
Shengliang Guan 已提交
154 155 156 157 158 159
  #define GET_FLOAT_VAL(x)       (*(float *)(x))
  #define GET_DOUBLE_VAL(x)      (*(double *)(x))
  #define SET_FLOAT_VAL(x, y)  { (*(float *)(x))  = (float)(y);       }
  #define SET_DOUBLE_VAL(x, y) { (*(double *)(x)) = (double)(y);      }
  #define SET_FLOAT_PTR(x, y)  { (*(float *)(x))  = (*(float *)(y));  }
  #define SET_DOUBLE_PTR(x, y) { (*(double *)(x)) = (*(double *)(y)); }
H
hzcheng 已提交
160 161 162 163 164 165 166
#endif

typedef struct tDataTypeDescriptor {
  int16_t nType;
  int16_t nameLen;
  int32_t nSize;
  char *  aName;
H
TD-166  
hzcheng 已提交
167 168 169 170
  int (*compFunc)(const char *const input, int inputSize, const int nelements, char *const output, int outputSize,
                  char algorithm, char *const buffer, int bufferSize);
  int (*decompFunc)(const char *const input, int compressedSize, const int nelements, char *const output,
                    int outputSize, char algorithm, char *const buffer, int bufferSize);
H
TD-321  
Hongze Cheng 已提交
171 172
  void (*getStatisFunc)(const TSKEY *primaryKey, const void *pData, int32_t numofrow, int64_t *min, int64_t *max,
                         int64_t *sum, int16_t *minindex, int16_t *maxindex, int16_t *numofnull);
H
hzcheng 已提交
173 174 175 176 177
} tDataTypeDescriptor;

extern tDataTypeDescriptor tDataTypeDesc[11];
#define POINTER_BYTES sizeof(void *)  // 8 by default  assert(sizeof(ptrdiff_t) == sizseof(void*)

178
bool isValidDataType(int32_t type);
H
Haojun Liao 已提交
179
//bool isNull(const char *val, int32_t type);
S
Shengliang Guan 已提交
180
static FORCE_INLINE bool isNull(const char *val, int32_t type) {
H
Haojun Liao 已提交
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
  switch (type) {
    case TSDB_DATA_TYPE_BOOL:
      return *(uint8_t *)val == TSDB_DATA_BOOL_NULL;
    case TSDB_DATA_TYPE_TINYINT:
      return *(uint8_t *)val == TSDB_DATA_TINYINT_NULL;
    case TSDB_DATA_TYPE_SMALLINT:
      return *(uint16_t *)val == TSDB_DATA_SMALLINT_NULL;
    case TSDB_DATA_TYPE_INT:
      return *(uint32_t *)val == TSDB_DATA_INT_NULL;
    case TSDB_DATA_TYPE_BIGINT:
    case TSDB_DATA_TYPE_TIMESTAMP:
      return *(uint64_t *)val == TSDB_DATA_BIGINT_NULL;
    case TSDB_DATA_TYPE_FLOAT:
      return *(uint32_t *)val == TSDB_DATA_FLOAT_NULL;
    case TSDB_DATA_TYPE_DOUBLE:
      return *(uint64_t *)val == TSDB_DATA_DOUBLE_NULL;
    case TSDB_DATA_TYPE_NCHAR:
198
      return varDataLen(val) == sizeof(int32_t) && *(uint32_t*) varDataVal(val) == TSDB_DATA_NCHAR_NULL;
H
Haojun Liao 已提交
199
    case TSDB_DATA_TYPE_BINARY:
200
      return varDataLen(val) == sizeof(int8_t) && *(uint8_t *) varDataVal(val) == TSDB_DATA_BINARY_NULL;
H
Haojun Liao 已提交
201 202 203 204
    default:
      return false;
  };
}
H
hzcheng 已提交
205

206
void setVardataNull(char* val, int32_t type);
H
hzcheng 已提交
207 208
void setNull(char *val, int32_t type, int32_t bytes);
void setNullN(char *val, int32_t type, int32_t bytes, int32_t numOfElems);
209
void* getNullValue(int32_t type);
H
hzcheng 已提交
210 211

void assignVal(char *val, const char *src, int32_t len, int32_t type);
H
Haojun Liao 已提交
212
void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void* buf);
H
hzcheng 已提交
213 214

// TODO: check if below is necessary
215
#define TSDB_RELATION_INVALID     0
H
hzcheng 已提交
216
#define TSDB_RELATION_LESS        1
217
#define TSDB_RELATION_GREATER     2
H
hzcheng 已提交
218 219
#define TSDB_RELATION_EQUAL       3
#define TSDB_RELATION_LESS_EQUAL  4
220
#define TSDB_RELATION_GREATER_EQUAL 5
H
hzcheng 已提交
221 222
#define TSDB_RELATION_NOT_EQUAL   6
#define TSDB_RELATION_LIKE        7
H
Haojun Liao 已提交
223 224 225 226 227 228 229 230 231 232 233 234 235
#define TSDB_RELATION_ISNULL      8
#define TSDB_RELATION_NOTNULL     9
#define TSDB_RELATION_IN          10

#define TSDB_RELATION_AND         11
#define TSDB_RELATION_OR          12
#define TSDB_RELATION_NOT         13

#define TSDB_BINARY_OP_ADD        30
#define TSDB_BINARY_OP_SUBTRACT   31
#define TSDB_BINARY_OP_MULTIPLY   32
#define TSDB_BINARY_OP_DIVIDE     33
#define TSDB_BINARY_OP_REMAINDER  34
H
hzcheng 已提交
236 237 238 239
#define TS_PATH_DELIMITER_LEN     1

#define TSDB_UNI_LEN              24
#define TSDB_USER_LEN             TSDB_UNI_LEN
H
Haojun Liao 已提交
240

B
Bomin Zhang 已提交
241 242 243 244
// ACCOUNT is a 32 bit positive integer
// this is the length of its string representation
// including the terminator zero
#define TSDB_ACCT_LEN             11
H
hzcheng 已提交
245 246
#define TSDB_PASSWORD_LEN         TSDB_UNI_LEN

B
Bomin Zhang 已提交
247
#define TSDB_MAX_COLUMNS          1024
S
slguan 已提交
248
#define TSDB_MIN_COLUMNS          2       //PRIMARY COLUMN(timestamp) + other columns
H
hzcheng 已提交
249

S
slguan 已提交
250
#define TSDB_NODE_NAME_LEN        64
H
Haojun Liao 已提交
251
#define TSDB_TABLE_NAME_LEN       193     // it is a null-terminated string
B
Bomin Zhang 已提交
252
#define TSDB_DB_NAME_LEN          33
H
Haojun Liao 已提交
253
#define TSDB_TABLE_FNAME_LEN      (TSDB_ACCT_LEN + TSDB_DB_NAME_LEN + TSDB_TABLE_NAME_LEN)
B
Bomin Zhang 已提交
254
#define TSDB_COL_NAME_LEN         65
B
Bomin Zhang 已提交
255
#define TSDB_MAX_SAVED_SQL_LEN    TSDB_MAX_COLUMNS * 64
S
slguan 已提交
256
#define TSDB_MAX_SQL_LEN          TSDB_PAYLOAD_SIZE
H
Haojun Liao 已提交
257 258 259 260
#define TSDB_MAX_SQL_SHOW_LEN     512
#define TSDB_MAX_ALLOWED_SQL_LEN  (8*1024*1024U)          // sql length should be less than 8mb

#define TSDB_APPNAME_LEN          TSDB_UNI_LEN
H
hzcheng 已提交
261

262 263
#define TSDB_MAX_BYTES_PER_ROW    16384
#define TSDB_MAX_TAGS_LEN         16384
B
Bomin Zhang 已提交
264
#define TSDB_MAX_TAGS             128
dengyihao's avatar
dengyihao 已提交
265
#define TSDB_MAX_TAG_CONDITIONS   1024
H
hzcheng 已提交
266 267 268 269 270 271 272 273 274

#define TSDB_AUTH_LEN             16
#define TSDB_KEY_LEN              16
#define TSDB_VERSION_LEN          12
#define TSDB_STREET_LEN           64
#define TSDB_CITY_LEN             20
#define TSDB_STATE_LEN            20
#define TSDB_COUNTRY_LEN          20
#define TSDB_LOCALE_LEN           64
S
Shengliang Guan 已提交
275
#define TSDB_TIMEZONE_LEN         96
276
#define TSDB_LABEL_LEN            8 
H
hzcheng 已提交
277

278
#define TSDB_CLUSTER_ID_LEN       40
陶建辉(Jeff)'s avatar
陶建辉(Jeff) 已提交
279 280
#define TSDB_FQDN_LEN             128
#define TSDB_EP_LEN               (TSDB_FQDN_LEN+6)
S
slguan 已提交
281
#define TSDB_IPv4ADDR_LEN      	  16
H
hzcheng 已提交
282 283 284 285 286 287
#define TSDB_FILENAME_LEN         128
#define TSDB_METER_VNODE_BITS     20
#define TSDB_METER_SID_MASK       0xFFFFF
#define TSDB_SHELL_VNODE_BITS     24
#define TSDB_SHELL_SID_MASK       0xFF
#define TSDB_HTTP_TOKEN_LEN       20
H
Haojun Liao 已提交
288
#define TSDB_SHOW_SQL_LEN         512
289
#define TSDB_SLOW_QUERY_SQL_LEN   512
H
hzcheng 已提交
290

S
TD-1310  
Shengliang Guan 已提交
291 292 293 294 295 296 297
#define TSDB_MQTT_HOSTNAME_LEN    64
#define TSDB_MQTT_PORT_LEN        8
#define TSDB_MQTT_USER_LEN        24
#define TSDB_MQTT_PASS_LEN        24
#define TSDB_MQTT_TOPIC_LEN       64
#define TSDB_MQTT_CLIENT_ID_LEN   32

H
hzcheng 已提交
298 299 300
#define TSDB_METER_STATE_OFFLINE  0
#define TSDB_METER_STATE_ONLLINE  1

S
slguan 已提交
301
#define TSDB_DEFAULT_PKT_SIZE     65480  //same as RPC_MAX_UDP_SIZE
H
hzcheng 已提交
302

303
#define TSDB_PAYLOAD_SIZE         TSDB_DEFAULT_PKT_SIZE
H
Haojun Liao 已提交
304
#define TSDB_DEFAULT_PAYLOAD_SIZE 5120   // default payload size, greater than PATH_MAX value
S
slguan 已提交
305
#define TSDB_EXTRA_PAYLOAD_SIZE   128    // extra bytes for auth
306
#define TSDB_CQ_SQL_SIZE          1024
S
Shengliang Guan 已提交
307
#define TSDB_MIN_VNODES           64
308
#define TSDB_MAX_VNODES           2048
S
Shengliang Guan 已提交
309
#define TSDB_MIN_VNODES_PER_DB    2
S
Shengliang Guan 已提交
310
#define TSDB_MAX_VNODES_PER_DB    64
H
hzcheng 已提交
311 312 313 314 315

#define TSDB_DNODE_ROLE_ANY       0
#define TSDB_DNODE_ROLE_MGMT      1
#define TSDB_DNODE_ROLE_VNODE     2

J
jtao1735 已提交
316
#define TSDB_MAX_REPLICA          5
S
slguan 已提交
317

H
Haojun Liao 已提交
318
#define TSDB_TBNAME_COLUMN_INDEX        (-1)
319
#define TSDB_UD_COLUMN_INDEX            (-100)
S
slguan 已提交
320
#define TSDB_MULTI_METERMETA_MAX_NUM    100000  // maximum batch size allowed to load metermeta
H
hzcheng 已提交
321

S
slguan 已提交
322
#define TSDB_MIN_CACHE_BLOCK_SIZE       1
323
#define TSDB_MAX_CACHE_BLOCK_SIZE       128     // 128MB for each vnode
S
slguan 已提交
324
#define TSDB_DEFAULT_CACHE_BLOCK_SIZE   16
H
hzcheng 已提交
325

H
Hongze Cheng 已提交
326
#define TSDB_MIN_TOTAL_BLOCKS           3
S
slguan 已提交
327
#define TSDB_MAX_TOTAL_BLOCKS           10000
328
#define TSDB_DEFAULT_TOTAL_BLOCKS       6
H
hzcheng 已提交
329

S
slguan 已提交
330
#define TSDB_MIN_TABLES                 4
331 332 333
#define TSDB_MAX_TABLES                 10000000
#define TSDB_DEFAULT_TABLES             1000000
#define TSDB_TABLES_STEP                1000
H
hzcheng 已提交
334

S
slguan 已提交
335 336
#define TSDB_MIN_DAYS_PER_FILE          1
#define TSDB_MAX_DAYS_PER_FILE          3650 
S
TD-1096  
Shengliang Guan 已提交
337
#define TSDB_DEFAULT_DAYS_PER_FILE      2 
H
hzcheng 已提交
338

S
slguan 已提交
339 340 341
#define TSDB_MIN_KEEP                   1        // data in db to be reserved.
#define TSDB_MAX_KEEP                   365000   // data in db to be reserved.
#define TSDB_DEFAULT_KEEP               3650     // ten years
H
hzcheng 已提交
342

S
slguan 已提交
343 344 345
#define TSDB_DEFAULT_MIN_ROW_FBLOCK     100
#define TSDB_MIN_MIN_ROW_FBLOCK         10
#define TSDB_MAX_MIN_ROW_FBLOCK         1000
H
hzcheng 已提交
346

S
slguan 已提交
347 348 349
#define TSDB_DEFAULT_MAX_ROW_FBLOCK     4096
#define TSDB_MIN_MAX_ROW_FBLOCK         200
#define TSDB_MAX_MAX_ROW_FBLOCK         10000
H
hzcheng 已提交
350

S
slguan 已提交
351 352 353
#define TSDB_MIN_COMMIT_TIME            30
#define TSDB_MAX_COMMIT_TIME            40960
#define TSDB_DEFAULT_COMMIT_TIME        3600
H
hzcheng 已提交
354

355 356 357
#define TSDB_MIN_PRECISION              TSDB_TIME_PRECISION_MILLI
#define TSDB_MAX_PRECISION              TSDB_TIME_PRECISION_NANO
#define TSDB_DEFAULT_PRECISION          TSDB_TIME_PRECISION_MILLI
S
slguan 已提交
358 359 360 361 362

#define TSDB_MIN_COMP_LEVEL             0
#define TSDB_MAX_COMP_LEVEL             2
#define TSDB_DEFAULT_COMP_LEVEL         2

363 364 365
#define TSDB_MIN_WAL_LEVEL              1
#define TSDB_MAX_WAL_LEVEL              2
#define TSDB_DEFAULT_WAL_LEVEL          1
S
slguan 已提交
366

S
Shengliang Guan 已提交
367 368 369 370
#define TSDB_MIN_DB_UPDATE              0
#define TSDB_MAX_DB_UPDATE              1
#define TSDB_DEFAULT_DB_UPDATE_OPTION   0

陶建辉(Jeff)'s avatar
陶建辉(Jeff) 已提交
371 372
#define TSDB_MIN_FSYNC_PERIOD           0
#define TSDB_MAX_FSYNC_PERIOD           180000   // millisecond
373
#define TSDB_DEFAULT_FSYNC_PERIOD       3000     // three second
陶建辉(Jeff)'s avatar
陶建辉(Jeff) 已提交
374

375 376 377
#define TSDB_MIN_DB_REPLICA_OPTION      1
#define TSDB_MAX_DB_REPLICA_OPTION      3
#define TSDB_DEFAULT_DB_REPLICA_OPTION  1
378
#define TSDB_DEFAULT_DB_QUORUM_OPTION   1
H
hzcheng 已提交
379

S
slguan 已提交
380
#define TSDB_MAX_JOIN_TABLE_NUM         5
381
#define TSDB_MAX_UNION_CLAUSE           5
H
hzcheng 已提交
382

S
slguan 已提交
383 384 385
#define TSDB_MAX_BINARY_LEN            (TSDB_MAX_BYTES_PER_ROW-TSDB_KEYSIZE)
#define TSDB_MAX_NCHAR_LEN             (TSDB_MAX_BYTES_PER_ROW-TSDB_KEYSIZE)
#define PRIMARYKEY_TIMESTAMP_COL_INDEX  0
H
hzcheng 已提交
386

S
slguan 已提交
387 388
#define TSDB_MAX_RPC_THREADS            5

H
hjxilinx 已提交
389 390
#define TSDB_QUERY_TYPE_NON_TYPE                       0x00u     // none type
#define TSDB_QUERY_TYPE_FREE_RESOURCE                  0x01u     // free qhandle at vnode
S
slguan 已提交
391 392 393 394 395

/*
 * 1. ordinary sub query for select * from super_table
 * 2. all sqlobj generated by createSubqueryObj with this flag
 */
H
hjxilinx 已提交
396 397
#define TSDB_QUERY_TYPE_SUBQUERY                       0x02u
#define TSDB_QUERY_TYPE_STABLE_SUBQUERY                0x04u     // two-stage subquery for super table
398

H
Haojun Liao 已提交
399
#define TSDB_QUERY_TYPE_TABLE_QUERY                    0x08u    // query ordinary table; below only apply to client side
H
hjxilinx 已提交
400 401 402 403
#define TSDB_QUERY_TYPE_STABLE_QUERY                   0x10u    // query on super table
#define TSDB_QUERY_TYPE_JOIN_QUERY                     0x20u    // join query
#define TSDB_QUERY_TYPE_PROJECTION_QUERY               0x40u    // select *,columns... query
#define TSDB_QUERY_TYPE_JOIN_SEC_STAGE                 0x80u    // join sub query at the second stage
H
hzcheng 已提交
404

H
hjxilinx 已提交
405 406
#define TSDB_QUERY_TYPE_TAG_FILTER_QUERY              0x400u
#define TSDB_QUERY_TYPE_INSERT                        0x100u    // insert type
H
Haojun Liao 已提交
407
#define TSDB_QUERY_TYPE_MULTITABLE_QUERY              0x200u
H
Hui Li 已提交
408
#define TSDB_QUERY_TYPE_STMT_INSERT                   0x800u    // stmt insert type
409 410 411

#define TSDB_QUERY_HAS_TYPE(x, _type)         (((x) & (_type)) != 0)
#define TSDB_QUERY_SET_TYPE(x, _type)         ((x) |= (_type))
412
#define TSDB_QUERY_CLEAR_TYPE(x, _type)       ((x) &= (~_type))
413 414
#define TSDB_QUERY_RESET_TYPE(x)              ((x) = TSDB_QUERY_TYPE_NON_TYPE)

415 416
#define TSDB_ORDER_ASC   1
#define TSDB_ORDER_DESC  2
H
hjxilinx 已提交
417

S
Shengliang Guan 已提交
418
#define TSDB_DEFAULT_CLUSTER_HASH_SIZE  1
S
Shengliang Guan 已提交
419 420 421 422 423 424 425
#define TSDB_DEFAULT_MNODES_HASH_SIZE   5
#define TSDB_DEFAULT_DNODES_HASH_SIZE   10
#define TSDB_DEFAULT_ACCOUNTS_HASH_SIZE 10
#define TSDB_DEFAULT_USERS_HASH_SIZE    20
#define TSDB_DEFAULT_DBS_HASH_SIZE      100
#define TSDB_DEFAULT_VGROUPS_HASH_SIZE  100
#define TSDB_DEFAULT_STABLES_HASH_SIZE  100
S
Shengliang Guan 已提交
426
#define TSDB_DEFAULT_CTABLES_HASH_SIZE  20000
S
slguan 已提交
427

J
jtao1735 已提交
428
#define TSDB_PORT_DNODESHELL 0 
J
jtao1735 已提交
429 430
#define TSDB_PORT_DNODEDNODE 5 
#define TSDB_PORT_SYNC       10 
431
#define TSDB_PORT_HTTP       11 
S
TD-1915  
Shengliang Guan 已提交
432
#define TSDB_PORT_ARBITRATOR 12
J
jtao1735 已提交
433

S
TD-2041  
Shengliang Guan 已提交
434 435
#define TSDB_MAX_WAL_SIZE    (1024*1024)

S
TD-1915  
Shengliang Guan 已提交
436 437 438 439 440 441 442
typedef enum {
  TAOS_QTYPE_RPC   = 0,
  TAOS_QTYPE_FWD   = 1,
  TAOS_QTYPE_WAL   = 2,
  TAOS_QTYPE_CQ    = 3,
  TAOS_QTYPE_QUERY = 4
} EQType;
J
jtao1735 已提交
443

S
[TD-10]  
slguan 已提交
444
typedef enum {
S
TD-1915  
Shengliang Guan 已提交
445 446 447 448 449
  TSDB_SUPER_TABLE  = 0,   // super table
  TSDB_CHILD_TABLE  = 1,   // table created from super table
  TSDB_NORMAL_TABLE = 2,  // ordinary table
  TSDB_STREAM_TABLE = 3,  // table created from stream computing
  TSDB_TABLE_MAX    = 4
S
slguan 已提交
450 451 452
} ETableType;

typedef enum {
S
TD-1915  
Shengliang Guan 已提交
453 454 455 456 457
  TSDB_MOD_MNODE   = 0,
  TSDB_MOD_HTTP    = 1,
  TSDB_MOD_MONITOR = 2,
  TSDB_MOD_MQTT    = 3,
  TSDB_MOD_MAX     = 4
S
slguan 已提交
458
} EModuleType;
S
[TD-10]  
slguan 已提交
459

S
TD-1915  
Shengliang Guan 已提交
460 461 462 463 464 465 466 467 468 469 470
typedef enum {
  TSDB_CHECK_ITEM_NETWORK,
  TSDB_CHECK_ITEM_MEM,
  TSDB_CHECK_ITEM_CPU,
  TSDB_CHECK_ITEM_DISK,
  TSDB_CHECK_ITEM_OS,    
  TSDB_CHECK_ITEM_ACCESS,    
  TSDB_CHECK_ITEM_VERSION,
  TSDB_CHECK_ITEM_DATAFILE,
  TSDB_CHECK_ITEM_MAX
} ECheckItemType;
H
Hui Li 已提交
471

S
Shengliang Guan 已提交
472 473
extern char *qtypeStr[];

H
hzcheng 已提交
474 475 476 477 478
#ifdef __cplusplus
}
#endif

#endif