taosdef.h 17.8 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>
H
hzcheng 已提交
25
#include "taos.h"
H
hzcheng 已提交
26 27 28 29 30 31 32 33 34

#define TSDB__packed

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

35
#define TSWINDOW_INITIALIZER ((STimeWindow) {INT64_MIN, INT64_MAX})
D
fix bug  
dapan1121 已提交
36
#define TSWINDOW_DESC_INITIALIZER ((STimeWindow) {INT64_MAX, INT64_MIN})
W
wpan 已提交
37
#define IS_TSWINDOW_SPECIFIED(win) (((win).skey != INT64_MIN) || ((win).ekey != INT64_MAX))
D
fix bug  
dapan1121 已提交
38

39 40
#define TSKEY_INITIAL_VAL    INT64_MIN

H
hzcheng 已提交
41
// Bytes for each type.
42
extern const int32_t TYPE_BYTES[16];
H
Haojun Liao 已提交
43

H
hzcheng 已提交
44
// TODO: replace and remove code below
H
Haojun Liao 已提交
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
#define CHAR_BYTES    sizeof(char)
#define SHORT_BYTES   sizeof(int16_t)
#define INT_BYTES     sizeof(int32_t)
#define LONG_BYTES    sizeof(int64_t)
#define FLOAT_BYTES   sizeof(float)
#define DOUBLE_BYTES  sizeof(double)
#define POINTER_BYTES sizeof(void *)  // 8 by default  assert(sizeof(ptrdiff_t) == sizseof(void*)

#define TSDB_KEYSIZE            sizeof(TSKEY)

#if LINUX
#define TSDB_NCHAR_SIZE         sizeof(wchar_t)
#else
#define TSDB_NCHAR_SIZE         sizeof(int32_t)
#endif
H
hzcheng 已提交
60 61 62 63 64

// NULL definition
#define TSDB_DATA_BOOL_NULL             0x02
#define TSDB_DATA_TINYINT_NULL          0x80
#define TSDB_DATA_SMALLINT_NULL         0x8000
S
Shengliang Guan 已提交
65
#define TSDB_DATA_INT_NULL              0x80000000L
H
hzcheng 已提交
66
#define TSDB_DATA_BIGINT_NULL           0x8000000000000000L
H
TD-1548  
Hongze Cheng 已提交
67
#define TSDB_DATA_TIMESTAMP_NULL        TSDB_DATA_BIGINT_NULL
H
hzcheng 已提交
68 69 70 71 72

#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
73
#define TSDB_DATA_JSON_PLACEHOLDER      0x7F
74
#define TSDB_DATA_JSON_NULL             0xFFFFFFFF
wmmhello's avatar
wmmhello 已提交
75
#define TSDB_DATA_JSON_null             0xFFFFFFFE
76
#define TSDB_DATA_JSON_NOT_NULL         0x01
77
#define TSDB_DATA_JSON_CAN_NOT_COMPARE  0x7FFFFFFF
H
hzcheng 已提交
78

79 80 81 82 83
#define TSDB_DATA_UTINYINT_NULL         0xFF
#define TSDB_DATA_USMALLINT_NULL        0xFFFF
#define TSDB_DATA_UINT_NULL             0xFFFFFFFF
#define TSDB_DATA_UBIGINT_NULL          0xFFFFFFFFFFFFFFFFL

H
hzcheng 已提交
84 85
#define TSDB_DATA_NULL_STR              "NULL"
#define TSDB_DATA_NULL_STR_L            "null"
86 87 88
#define TSDB_DEFAULT_USER               "root"
#define TSDB_DEFAULT_PASS               "taosdata"

89
#define TSDB_PASS_LEN                   16
90

91
#define SHELL_MAX_PASSWORD_LEN          20
92 93 94
// user set query tags max len
#define TSDB_TAGS_LEN                   256

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

#define TS_PATH_DELIMITER "."
101 102
#define TS_BACKQUOTE_CHAR '`'
#define TS_BACKQUOTE_CHAR_SIZE 2
H
hzcheng 已提交
103 104 105

#define TSDB_TIME_PRECISION_MILLI 0
#define TSDB_TIME_PRECISION_MICRO 1
106
#define TSDB_TIME_PRECISION_NANO  2
H
hzcheng 已提交
107 108 109

#define TSDB_TIME_PRECISION_MILLI_STR "ms"
#define TSDB_TIME_PRECISION_MICRO_STR "us"
H
Haojun Liao 已提交
110 111
#define TSDB_TIME_PRECISION_NANO_STR  "ns"

112 113 114 115 116
#define TSDB_TIME_PRECISION_SEC_DIGITS 10
#define TSDB_TIME_PRECISION_MILLI_DIGITS 13
#define TSDB_TIME_PRECISION_MICRO_DIGITS 16
#define TSDB_TIME_PRECISION_NANO_DIGITS 19

H
Haojun Liao 已提交
117
#define TSDB_TICK_PER_SECOND(precision) ((int64_t)((precision)==TSDB_TIME_PRECISION_MILLI ? 1e3L : ((precision)==TSDB_TIME_PRECISION_MICRO ? 1e6L : 1e9L)))
H
hzcheng 已提交
118

H
TD-27  
hzcheng 已提交
119 120 121 122 123 124 125 126 127 128 129
#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 已提交
130

131 132 133 134 135 136 137 138
#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))
#define GET_UINT8_VAL(x)   (*(uint8_t*) (x))
#define GET_UINT16_VAL(x)  (*(uint16_t *)(x))
#define GET_UINT32_VAL(x)  (*(uint32_t *)(x))
#define GET_UINT64_VAL(x)  (*(uint64_t *)(x))
S
TD-1530  
Shengliang Guan 已提交
139

140
#ifdef _TD_ARM_32
S
TD-1530  
Shengliang Guan 已提交
141 142 143
  float  taos_align_get_float(const char* pBuf);
  double taos_align_get_double(const char* pBuf);

144 145 146 147 148 149 150
  #define GET_FLOAT_VAL(x)        taos_align_get_float(x)
  #define GET_DOUBLE_VAL(x)       taos_align_get_double(x)
  #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)); }
  #define SET_TIMESTAMP_VAL(x, y) { int64_t z = (int64_t)(y); (*(int64_t*) x = *(int64_t*)(&z)); }
  #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 已提交
151
#else
152 153 154 155 156 157 158
  #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_TIMESTAMP_VAL(x, y) { (*(int64_t *)(x)) = (int64_t)(y);    }
  #define SET_FLOAT_PTR(x, y)     { (*(float *)(x))  = (*(float *)(y));  }
  #define SET_DOUBLE_PTR(x, y)    { (*(double *)(x)) = (*(double *)(y)); }
H
hzcheng 已提交
159 160 161
#endif

// TODO: check if below is necessary
162
#define TSDB_RELATION_INVALID     0
H
hzcheng 已提交
163
#define TSDB_RELATION_LESS        1
164
#define TSDB_RELATION_GREATER     2
H
hzcheng 已提交
165 166
#define TSDB_RELATION_EQUAL       3
#define TSDB_RELATION_LESS_EQUAL  4
167
#define TSDB_RELATION_GREATER_EQUAL 5
H
hzcheng 已提交
168 169
#define TSDB_RELATION_NOT_EQUAL   6
#define TSDB_RELATION_LIKE        7
H
Haojun Liao 已提交
170 171 172 173 174 175 176 177
#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

178
#define TSDB_RELATION_MATCH       14
179
#define TSDB_RELATION_NMATCH      15
180

181
#define TSDB_RELATION_CONTAINS    16
wmmhello's avatar
wmmhello 已提交
182
#define TSDB_RELATION_ARROW       17
183

H
Haojun Liao 已提交
184 185 186 187 188
#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
X
xywang 已提交
189
#define TSDB_BINARY_OP_BITAND     35
X
xywang 已提交
190 191 192 193 194
#define TSDB_BINARY_OP_BITOR      36
#define TSDB_BINARY_OP_BITXOR     37
#define TSDB_BINARY_OP_BITNOT     38
#define TSDB_BINARY_OP_LSHIFT     39
#define TSDB_BINARY_OP_RSHIFT     40
D
fix bug  
dapan1121 已提交
195 196


Y
yihaoDeng 已提交
197
#define IS_RELATION_OPTR(op) (((op) >= TSDB_RELATION_LESS) && ((op) < TSDB_RELATION_IN))
X
xywang 已提交
198
#define IS_ARITHMETIC_OPTR(op) (((op) >= TSDB_BINARY_OP_ADD) && ((op) <= TSDB_BINARY_OP_RSHIFT))
D
fix bug  
dapan1121 已提交
199

H
hzcheng 已提交
200 201 202 203
#define TS_PATH_DELIMITER_LEN     1

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

B
Bomin Zhang 已提交
205
// ACCOUNT is a 32 bit positive integer
206 207
// this is the length of its string representation, including the terminator zero
#define TSDB_ACCT_ID_LEN          11
H
hzcheng 已提交
208

K
kailixu 已提交
209
#define TSDB_MAX_COLUMNS 4096
210

S
slguan 已提交
211
#define TSDB_MIN_COLUMNS          2       //PRIMARY COLUMN(timestamp) + other columns
H
hzcheng 已提交
212

S
slguan 已提交
213
#define TSDB_NODE_NAME_LEN        64
H
Haojun Liao 已提交
214
#define TSDB_TABLE_NAME_LEN       193     // it is a null-terminated string
B
Bomin Zhang 已提交
215
#define TSDB_DB_NAME_LEN          33
H
Haojun Liao 已提交
216
#define TSDB_FUNC_NAME_LEN        65
D
dapan1121 已提交
217
#define TSDB_FUNC_CODE_LEN        (65535 - 512)
D
dapan1121 已提交
218
#define TSDB_FUNC_BUF_SIZE        512
D
dapan1121 已提交
219
#define TSDB_TYPE_STR_MAX_LEN     32
220
#define TSDB_TABLE_FNAME_LEN      (TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN + TSDB_TABLE_NAME_LEN)
B
Bomin Zhang 已提交
221
#define TSDB_COL_NAME_LEN         65
B
Bomin Zhang 已提交
222
#define TSDB_MAX_SAVED_SQL_LEN    TSDB_MAX_COLUMNS * 64
S
slguan 已提交
223
#define TSDB_MAX_SQL_LEN          TSDB_PAYLOAD_SIZE
H
Haojun Liao 已提交
224
#define TSDB_MAX_SQL_SHOW_LEN     512
H
Haojun Liao 已提交
225
#define TSDB_MAX_ALLOWED_SQL_LEN  (1*1024*1024u)          // sql length should be less than 1mb
H
Haojun Liao 已提交
226 227

#define TSDB_APPNAME_LEN          TSDB_UNI_LEN
H
hzcheng 已提交
228

K
kailixu 已提交
229
#if 1
C
Cary Xu 已提交
230
  /**
K
kailixu 已提交
231
   *  In some scenarios uint16_t (0~65535) is used to store the row len.
C
Cary Xu 已提交
232
   *  - Firstly, we use 65531(65535 - 4), as the SDataRow/SKVRow contains 4 bits header.
233
   *  - Secondly, if all cols are VarDataT type except primary key, we need 4 bits to store the offset, thus
K
kailixu 已提交
234
   *    the final value is 65531-(4096-1)*4 = 49151.
C
Cary Xu 已提交
235
   */
K
kailixu 已提交
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
#define TSDB_MAX_BYTES_PER_ROW 65527
// 49151
// 65527
#endif

  /**
   *  In some scenarios uint16_t (0~65535) is used to store the row len.
   *  - Firstly, we use 65531(65535 - 4), as the SDataRow contains 4 bits header.
   *  - Secondly, if all cols are VarDataT type except primary key, we need 4 bits to store the offset, thus
   *    the final value is [65531 - (4096-1)*4 = 49151, 65531 - (2-1)*4 = 65527]
   *  -
   */
  // [49151, min(65527, RPC_MAX_UDP_SIZE)]

#if 0
#define TSDB_MAX_BYTES_PER_ROW_BY_COL(c) (65535 - (c) << 2)  // 65531 - (col-1)*4
252 253
#endif

K
kailixu 已提交
254 255 256 257 258
#define TSDB_MAX_TAGS_LEN 16384
#define TSDB_MAX_JSON_TAGS_LEN (4096 * TSDB_NCHAR_SIZE + 2 + 1)  // 2->var_header_len 1->type
#define TSDB_MAX_TAGS 128
#define TSDB_MAX_TAG_CONDITIONS 1024
#define TSDB_MAX_JSON_KEY_LEN 256
259
#define TSDB_MAX_JSON_KEY_MD5_LEN 16
H
hzcheng 已提交
260

K
kailixu 已提交
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372
#define TSDB_AUTH_LEN 16
#define TSDB_KEY_LEN 16
#define TSDB_VERSION_LEN 12
#define TSDB_LOCALE_LEN 64
#define TSDB_TIMEZONE_LEN 96
#define TSDB_LABEL_LEN 8

#define TSDB_CLUSTER_ID_LEN 40
#define TSDB_FQDN_LEN 128
#define TSDB_EP_LEN (TSDB_FQDN_LEN + 6)
#define TSDB_IPv4ADDR_LEN 16
#define TSDB_FILENAME_LEN 128
#define TSDB_SHOW_SQL_LEN 512
#define TSDB_SHOW_SUBQUERY_LEN 1000
#define TSDB_SLOW_QUERY_SQL_LEN 512

#define TSDB_STEP_NAME_LEN 32
#define TSDB_STEP_DESC_LEN 128

#define TSDB_DB_TYPE_DEFAULT 0
#define TSDB_DB_TYPE_TOPIC 1

#define TSDB_DEFAULT_PKT_SIZE 65480  // same as RPC_MAX_UDP_SIZE

#define TSDB_PAYLOAD_SIZE TSDB_DEFAULT_PKT_SIZE
#define TSDB_DEFAULT_PAYLOAD_SIZE 5120  // default payload size, greater than PATH_MAX value
#define TSDB_EXTRA_PAYLOAD_SIZE 128     // extra bytes for auth
#define TSDB_CQ_SQL_SIZE 1024
#define TSDB_MIN_VNODES 64
#define TSDB_MAX_VNODES 2048
#define TSDB_MIN_VNODES_PER_DB 2
#define TSDB_MAX_VNODES_PER_DB 64

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

#define TSDB_MAX_REPLICA 5

#define TSDB_TBNAME_COLUMN_INDEX (-1)
#define TSDB_TSWIN_START_COLUMN_INDEX (-2)
#define TSDB_TSWIN_STOP_COLUMN_INDEX (-3)
#define TSDB_TSWIN_DURATION_COLUMN_INDEX (-4)
#define TSDB_QUERY_START_COLUMN_INDEX (-5)
#define TSDB_QUERY_STOP_COLUMN_INDEX (-6)
#define TSDB_QUERY_DURATION_COLUMN_INDEX (-7)
#define TSDB_MIN_VALID_COLUMN_INDEX (-7)

#define TSDB_COL_IS_TSWIN_COL(_i) ((_i) <= TSDB_TSWIN_START_COLUMN_INDEX && (_i) >= TSDB_QUERY_DURATION_COLUMN_INDEX)

#define TSDB_UD_COLUMN_INDEX (-1000)
#define TSDB_RES_COL_ID (-5000)

#define TSDB_MULTI_TABLEMETA_MAX_NUM 100000  // maximum batch size allowed to load table meta

#define TSDB_MIN_CACHE_BLOCK_SIZE 1
#define TSDB_MAX_CACHE_BLOCK_SIZE 128  // 128MB for each vnode
#define TSDB_DEFAULT_CACHE_BLOCK_SIZE 16

#define TSDB_MIN_TOTAL_BLOCKS 3
#define TSDB_MAX_TOTAL_BLOCKS 10000
#define TSDB_DEFAULT_TOTAL_BLOCKS 6

#define TSDB_MIN_WAL_FLUSH_SIZE 128       // MB
#define TSDB_MAX_WAL_FLUSH_SIZE 10000000  // MB
#define TSDB_DEFAULT_WAL_FLUSH_SIZE 1024  // MB

#define TSDB_MIN_TABLES 4
#define TSDB_MAX_TABLES 10000000
#define TSDB_DEFAULT_TABLES 1000000
#define TSDB_TABLES_STEP 1000
#define TSDB_META_COMPACT_RATIO 0  // disable tsdb meta compact by default

#define TSDB_MIN_DAYS_PER_FILE 1
#define TSDB_MAX_DAYS_PER_FILE 3650
#define TSDB_DEFAULT_DAYS_PER_FILE 10

#define TSDB_MIN_KEEP 1         // data in db to be reserved.
#define TSDB_MAX_KEEP 36500     // data in db to be reserved.
#define TSDB_DEFAULT_KEEP 3650  // ten years

#define TSDB_DEFAULT_MIN_ROW_FBLOCK 100
#define TSDB_MIN_MIN_ROW_FBLOCK 10
#define TSDB_MAX_MIN_ROW_FBLOCK 1000

#define TSDB_DEFAULT_MAX_ROW_FBLOCK 4096
#define TSDB_MIN_MAX_ROW_FBLOCK 200
#define TSDB_MAX_MAX_ROW_FBLOCK 10000

#define TSDB_MIN_COMMIT_TIME 30
#define TSDB_MAX_COMMIT_TIME 40960
#define TSDB_DEFAULT_COMMIT_TIME 3600

#define TSDB_MIN_PRECISION TSDB_TIME_PRECISION_MILLI
#define TSDB_MAX_PRECISION TSDB_TIME_PRECISION_NANO
#define TSDB_DEFAULT_PRECISION TSDB_TIME_PRECISION_MILLI

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

#define TSDB_MIN_WAL_LEVEL 0
#define TSDB_MAX_WAL_LEVEL 2
#define TSDB_DEFAULT_WAL_LEVEL 1

#define TSDB_MIN_DB_UPDATE 0
#define TSDB_MAX_DB_UPDATE 2
#define TSDB_DEFAULT_DB_UPDATE_OPTION 0

#define TSDB_MIN_DB_CACHE_LAST_ROW 0
#define TSDB_MAX_DB_CACHE_LAST_ROW 3
#define TSDB_DEFAULT_CACHE_LAST_ROW 0
M
Minglei Jin 已提交
373

K
kailixu 已提交
374 375 376
#define TSDB_MIN_FSYNC_PERIOD 0
#define TSDB_MAX_FSYNC_PERIOD 180000    // millisecond
#define TSDB_DEFAULT_FSYNC_PERIOD 3000  // three second
陶建辉(Jeff)'s avatar
陶建辉(Jeff) 已提交
377

K
kailixu 已提交
378 379 380
#define TSDB_MIN_DB_REPLICA_OPTION 1
#define TSDB_MAX_DB_REPLICA_OPTION 3
#define TSDB_DEFAULT_DB_REPLICA_OPTION 1
S
TD-2677  
Shengliang Guan 已提交
381

K
kailixu 已提交
382 383
#define TSDB_MIN_DB_PARTITON_OPTION 0
#define TSDB_MAX_DB_PARTITON_OPTION 1000
S
Shengliang Guan 已提交
384 385
#define TSDB_DEFAULT_DB_PARTITON_OPTION 4

K
kailixu 已提交
386 387 388
#define TSDB_MIN_DB_QUORUM_OPTION 1
#define TSDB_MAX_DB_QUORUM_OPTION 2
#define TSDB_DEFAULT_DB_QUORUM_OPTION 1
H
hzcheng 已提交
389

K
kailixu 已提交
390 391
#define TSDB_MAX_JOIN_TABLE_NUM 10
#define TSDB_MAX_UNION_CLAUSE 5
H
hzcheng 已提交
392

K
kailixu 已提交
393 394 395 396 397 398 399 400 401
#define TSDB_MAX_FIELD_LEN 65519
// 16384
  // 65519

  // #define TSDB_MAX_BINARY_LEN (TSDB_MAX_FIELD_LEN - TSDB_KEYSIZE)  // keep 16384 => 65511
  // #define TSDB_MAX_NCHAR_LEN (TSDB_MAX_FIELD_LEN - TSDB_KEYSIZE)   // keep 16384 => 65511

#define TSDB_MAX_BINARY_LEN TSDB_MAX_FIELD_LEN  // keep 16384 => 65511
#define TSDB_MAX_NCHAR_LEN TSDB_MAX_FIELD_LEN   // keep 16384 => 65511
402

S
slguan 已提交
403
#define PRIMARYKEY_TIMESTAMP_COL_INDEX  0
H
hzcheng 已提交
404

S
slguan 已提交
405 406
#define TSDB_MAX_RPC_THREADS            5

H
Haojun Liao 已提交
407 408
#define TSDB_QUERY_TYPE_NON_TYPE               0x00u     // none type
#define TSDB_QUERY_TYPE_FREE_RESOURCE          0x01u     // free qhandle at vnode
S
slguan 已提交
409

410 411 412 413
#define TSDB_UDF_TYPE_SCALAR       1
#define TSDB_UDF_TYPE_AGGREGATE    2


S
slguan 已提交
414 415 416 417
/*
 * 1. ordinary sub query for select * from super_table
 * 2. all sqlobj generated by createSubqueryObj with this flag
 */
H
Haojun Liao 已提交
418 419
#define TSDB_QUERY_TYPE_SUBQUERY               0x02u
#define TSDB_QUERY_TYPE_STABLE_SUBQUERY        0x04u     // two-stage subquery for super table
420

H
Haojun Liao 已提交
421 422 423 424 425
#define TSDB_QUERY_TYPE_TABLE_QUERY            0x08u    // query ordinary table; below only apply to client side
#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 已提交
426

H
Haojun Liao 已提交
427 428 429
#define TSDB_QUERY_TYPE_TAG_FILTER_QUERY       0x400u
#define TSDB_QUERY_TYPE_INSERT                 0x100u    // insert type
#define TSDB_QUERY_TYPE_MULTITABLE_QUERY       0x200u
H
Haojun Liao 已提交
430
#define TSDB_QUERY_TYPE_FILE_INSERT            0x400u    // insert data from file
H
Haojun Liao 已提交
431
#define TSDB_QUERY_TYPE_STMT_INSERT            0x800u    // stmt insert type
432
#define TSDB_QUERY_TYPE_NEST_SUBQUERY          0x1000u   // nested sub query
433

H
Haojun Liao 已提交
434 435 436 437 438 439 440
#define TSDB_QUERY_HAS_TYPE(x, _type)          (((x) & (_type)) != 0)
#define TSDB_QUERY_SET_TYPE(x, _type)          ((x) |= (_type))
#define TSDB_QUERY_CLEAR_TYPE(x, _type)        ((x) &= (~_type))
#define TSDB_QUERY_RESET_TYPE(x)               ((x) = TSDB_QUERY_TYPE_NON_TYPE)

#define TSDB_ORDER_ASC                         1
#define TSDB_ORDER_DESC                        2
G
Ganlin Zhao 已提交
441

H
Haojun Liao 已提交
442 443 444 445 446 447 448 449 450 451
#define TSDB_DEFAULT_CLUSTER_HASH_SIZE         1
#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
#define TSDB_DEFAULT_CTABLES_HASH_SIZE         20000

C
Cary Xu 已提交
452 453 454 455
#define TSDB_SHORTCUT_RB_RPC_SEND_SUBMIT       0x01u  // RB: return before(global shortcut)
#define TSDB_SHORTCUT_RA_RPC_RECV_SUBMIT       0x02u  // RA: return after(global shortcut)
#define TSDB_SHORTCUT_NR_VNODE_WAL_WRITE       0x04u  // NR: no return and go on following actions(local shortcut)
#define TSDB_SHORTCUT_RB_TSDB_COMMIT           0x08u
456

H
Haojun Liao 已提交
457 458 459 460 461
#define TSDB_PORT_DNODESHELL                   0
#define TSDB_PORT_DNODEDNODE                   5
#define TSDB_PORT_SYNC                         10
#define TSDB_PORT_HTTP                         11
#define TSDB_PORT_ARBITRATOR                   12
J
jtao1735 已提交
462

463
#define TSDB_MAX_WAL_SIZE    (1024*1024*3)
H
Haojun Liao 已提交
464

465 466
#define TSDB_ARB_DUMMY_TIME                    4765104000000 // 2121-01-01 00:00:00.000, :P

S
TD-1915  
Shengliang Guan 已提交
467 468 469 470 471 472 473
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 已提交
474

475 476 477 478
#define TSDB_MAX_TIERS           3
#define TSDB_MAX_DISKS_PER_TIER 16
#define TSDB_MAX_DISKS           (TSDB_MAX_TIERS * TSDB_MAX_DISKS_PER_TIER)

S
[TD-10]  
slguan 已提交
479
typedef enum {
S
TD-1915  
Shengliang Guan 已提交
480 481
  TSDB_SUPER_TABLE  = 0,   // super table
  TSDB_CHILD_TABLE  = 1,   // table created from super table
H
Haojun Liao 已提交
482 483 484 485
  TSDB_NORMAL_TABLE = 2,   // ordinary table
  TSDB_STREAM_TABLE = 3,   // table created from stream computing
  TSDB_TEMP_TABLE   = 4,   // temp table created by nest query
  TSDB_TABLE_MAX    = 5
S
slguan 已提交
486 487 488
} ETableType;

typedef enum {
S
TD-1915  
Shengliang Guan 已提交
489 490 491
  TSDB_MOD_MNODE   = 0,
  TSDB_MOD_HTTP    = 1,
  TSDB_MOD_MONITOR = 2,
sangshuduo's avatar
sangshuduo 已提交
492
  TSDB_MOD_MAX     = 3
S
slguan 已提交
493
} EModuleType;
S
[TD-10]  
slguan 已提交
494

S
TD-1915  
Shengliang Guan 已提交
495 496 497 498 499
typedef enum {
  TSDB_CHECK_ITEM_NETWORK,
  TSDB_CHECK_ITEM_MEM,
  TSDB_CHECK_ITEM_CPU,
  TSDB_CHECK_ITEM_DISK,
H
Haojun Liao 已提交
500 501
  TSDB_CHECK_ITEM_OS,
  TSDB_CHECK_ITEM_ACCESS,
S
TD-1915  
Shengliang Guan 已提交
502 503 504 505
  TSDB_CHECK_ITEM_VERSION,
  TSDB_CHECK_ITEM_DATAFILE,
  TSDB_CHECK_ITEM_MAX
} ECheckItemType;
H
Hui Li 已提交
506

507 508 509 510 511 512
typedef enum {
  TD_ROW_DISCARD_UPDATE   = 0,
  TD_ROW_OVERWRITE_UPDATE = 1,
  TD_ROW_PARTIAL_UPDATE   = 2
} TDUpdateConfig;

C
Cary Xu 已提交
513 514 515 516 517
typedef enum {
  TSDB_STATIS_OK = 0,    // statis part exist and load successfully
  TSDB_STATIS_NONE = 1,  // statis part not exist
} ETsdbStatisStatus;

S
Shengliang Guan 已提交
518
extern char *qtypeStr[];
H
Hui Li 已提交
519

H
hzcheng 已提交
520 521 522 523 524
#ifdef __cplusplus
}
#endif

#endif