tdef.h 18.4 KB
Newer Older
S
Shengliang Guan 已提交
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
Shengliang Guan 已提交
16 17
#ifndef _TD_UTIL_DEF_H_
#define _TD_UTIL_DEF_H_
S
Shengliang Guan 已提交
18

S
Shengliang Guan 已提交
19 20
#include "os.h"

S
Shengliang Guan 已提交
21 22 23 24 25 26
#ifdef __cplusplus
extern "C" {
#endif

#define TSDB__packed

S
Shengliang Guan 已提交
27 28
#define TSKEY             int64_t
#define TSKEY_MIN         INT64_MIN
29
#define TSKEY_MAX         INT64_MAX
H
Hongze Cheng 已提交
30
#define TSKEY_INITIAL_VAL TSKEY_MIN
S
Shengliang Guan 已提交
31

C
Cary Xu 已提交
32 33
#define TD_VER_MAX UINT64_MAX  // TODO: use the real max version from query handle

S
Shengliang Guan 已提交
34
// Bytes for each type.
S
Shungang Li 已提交
35
extern const int32_t TYPE_BYTES[21];
S
Shengliang Guan 已提交
36

37
// TODO: replace and remove code below
S
Shengliang Guan 已提交
38 39 40 41 42 43 44 45
#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)
wafwerar's avatar
wafwerar 已提交
46
#define TSDB_NCHAR_SIZE sizeof(TdUcs4)
S
Shengliang Guan 已提交
47 48

// NULL definition
S
Shengliang Guan 已提交
49 50 51
#define TSDB_DATA_BOOL_NULL      0x02
#define TSDB_DATA_TINYINT_NULL   0x80
#define TSDB_DATA_SMALLINT_NULL  0x8000
wafwerar's avatar
wafwerar 已提交
52 53
#define TSDB_DATA_INT_NULL       0x80000000LL
#define TSDB_DATA_BIGINT_NULL    0x8000000000000000LL
S
Shengliang Guan 已提交
54 55
#define TSDB_DATA_TIMESTAMP_NULL TSDB_DATA_BIGINT_NULL

D
Dingle Zhang 已提交
56 57 58 59 60
#define TSDB_DATA_FLOAT_NULL    0x7FF00000            // it is an NAN
#define TSDB_DATA_DOUBLE_NULL   0x7FFFFF0000000000LL  // an NAN
#define TSDB_DATA_NCHAR_NULL    0xFFFFFFFF
#define TSDB_DATA_BINARY_NULL   0xFF
#define TSDB_DATA_GEOMETRY_NULL 0xFF
S
Shengliang Guan 已提交
61 62 63 64 65 66 67 68 69 70 71

#define TSDB_DATA_UTINYINT_NULL  0xFF
#define TSDB_DATA_USMALLINT_NULL 0xFFFF
#define TSDB_DATA_UINT_NULL      0xFFFFFFFF
#define TSDB_DATA_UBIGINT_NULL   0xFFFFFFFFFFFFFFFFL

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

#define TSDB_NETTEST_USER "nettestinternal"
#define TSDB_DEFAULT_USER "root"
S
Shengliang Guan 已提交
72
#ifdef _TD_POWER_
S
Shengliang Guan 已提交
73
#define TSDB_DEFAULT_PASS "powerdb"
S
Shengliang Guan 已提交
74
#elif (_TD_TQ_ == true)
S
Shengliang Guan 已提交
75
#define TSDB_DEFAULT_PASS "tqueue"
S
Shengliang Guan 已提交
76
#elif (_TD_PRO_ == true)
S
Shengliang Guan 已提交
77
#define TSDB_DEFAULT_PASS "prodb"
S
Shengliang Guan 已提交
78
#else
S
Shengliang Guan 已提交
79
#define TSDB_DEFAULT_PASS "taosdata"
S
Shengliang Guan 已提交
80 81
#endif

S
Shengliang Guan 已提交
82 83 84
#define TSDB_TRUE  1
#define TSDB_FALSE 0
#define TSDB_OK    0
S
Shengliang Guan 已提交
85 86 87
#define TSDB_ERR   -1

#define TS_PATH_DELIMITER "."
88
#define TS_ESCAPE_CHAR    '`'
S
Shengliang Guan 已提交
89

L
Liu Jicong 已提交
90 91 92
#define TSDB_TIME_PRECISION_MILLI   0
#define TSDB_TIME_PRECISION_MICRO   1
#define TSDB_TIME_PRECISION_NANO    2
wmmhello's avatar
wmmhello 已提交
93 94 95
#define TSDB_TIME_PRECISION_HOURS   3
#define TSDB_TIME_PRECISION_MINUTES 4
#define TSDB_TIME_PRECISION_SECONDS 5
S
Shengliang Guan 已提交
96 97 98 99 100

#define TSDB_TIME_PRECISION_MILLI_STR "ms"
#define TSDB_TIME_PRECISION_MICRO_STR "us"
#define TSDB_TIME_PRECISION_NANO_STR  "ns"

101 102 103 104 105
#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

D
dapan1121 已提交
106 107
#define TSDB_INDEX_TYPE_SMA      "SMA"
#define TSDB_INDEX_TYPE_FULLTEXT "FULLTEXT"
dengyihao's avatar
dengyihao 已提交
108
#define TSDB_INDEX_TYPE_NORMAL   "NORMAL"
D
dapan1121 已提交
109

110
#define TSDB_INS_USER_STABLES_DBNAME_COLID 2
D
dapan1121 已提交
111

112 113 114 115
#define TSDB_TICK_PER_SECOND(precision)               \
  ((int64_t)((precision) == TSDB_TIME_PRECISION_MILLI \
                 ? 1000LL                             \
                 : ((precision) == TSDB_TIME_PRECISION_MICRO ? 1000000LL : 1000000000LL)))
S
Shengliang Guan 已提交
116 117

#define T_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
S
Shengliang Guan 已提交
118 119 120 121 122 123 124 125 126 127
#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)
L
Liu Jicong 已提交
128

D
dapan1121 已提交
129
typedef enum EOperatorType {
X
Xiaoyu Wang 已提交
130
  // binary arithmetic operator
D
dapan1121 已提交
131 132 133 134
  OP_TYPE_ADD = 1,
  OP_TYPE_SUB,
  OP_TYPE_MULTI,
  OP_TYPE_DIV,
135
  OP_TYPE_REM,
X
Xiaoyu Wang 已提交
136
  // unary arithmetic operator
137
  OP_TYPE_MINUS = 20,
D
dapan1121 已提交
138

X
Xiaoyu Wang 已提交
139
  // bitwise operator
140
  OP_TYPE_BIT_AND = 30,
D
dapan1121 已提交
141 142
  OP_TYPE_BIT_OR,

X
Xiaoyu Wang 已提交
143
  // binary comparison operator
144
  OP_TYPE_GREATER_THAN = 40,
D
dapan1121 已提交
145 146 147 148 149 150 151 152 153 154 155
  OP_TYPE_GREATER_EQUAL,
  OP_TYPE_LOWER_THAN,
  OP_TYPE_LOWER_EQUAL,
  OP_TYPE_EQUAL,
  OP_TYPE_NOT_EQUAL,
  OP_TYPE_IN,
  OP_TYPE_NOT_IN,
  OP_TYPE_LIKE,
  OP_TYPE_NOT_LIKE,
  OP_TYPE_MATCH,
  OP_TYPE_NMATCH,
X
Xiaoyu Wang 已提交
156
  // unary comparison operator
157
  OP_TYPE_IS_NULL = 100,
D
dapan1121 已提交
158 159 160 161 162 163 164 165 166
  OP_TYPE_IS_NOT_NULL,
  OP_TYPE_IS_TRUE,
  OP_TYPE_IS_FALSE,
  OP_TYPE_IS_UNKNOWN,
  OP_TYPE_IS_NOT_TRUE,
  OP_TYPE_IS_NOT_FALSE,
  OP_TYPE_IS_NOT_UNKNOWN,

  // json operator
167
  OP_TYPE_JSON_GET_VALUE = 150,
168 169 170
  OP_TYPE_JSON_CONTAINS,

  // internal operator
171
  OP_TYPE_ASSIGN = 200
D
dapan1121 已提交
172 173
} EOperatorType;

D
dapan1121 已提交
174 175
#define OP_TYPE_CALC_MAX OP_TYPE_BIT_OR

D
dapan1121 已提交
176
typedef enum ELogicConditionType {
X
Xiaoyu Wang 已提交
177
  LOGIC_COND_TYPE_AND = 1,
D
dapan1121 已提交
178 179 180
  LOGIC_COND_TYPE_OR,
  LOGIC_COND_TYPE_NOT,
} ELogicConditionType;
S
Shengliang Guan 已提交
181

S
Shengliang Guan 已提交
182
#define TSDB_NAME_DELIMITER_LEN 1
L
Liu Jicong 已提交
183

S
Shengliang Guan 已提交
184 185
#define TSDB_UNI_LEN  24
#define TSDB_USER_LEN TSDB_UNI_LEN
S
Shengliang Guan 已提交
186 187 188

// ACCOUNT is a 32 bit positive integer
// this is the length of its string representation, including the terminator zero
S
Shengliang Guan 已提交
189 190 191 192 193
#define TSDB_ACCT_ID_LEN 11

#define TSDB_MAX_COLUMNS 4096
#define TSDB_MIN_COLUMNS 2  // PRIMARY COLUMN(timestamp) + other columns

H
Hongze Cheng 已提交
194 195 196 197 198 199 200 201 202 203
#define TSDB_NODE_NAME_LEN            64
#define TSDB_TABLE_NAME_LEN           193                                // it is a null-terminated string
#define TSDB_TOPIC_NAME_LEN           193                                // it is a null-terminated string
#define TSDB_CGROUP_LEN               193                                // it is a null-terminated string
#define TSDB_OFFSET_LEN               64                                 // it is a null-terminated string
#define TSDB_USER_CGROUP_LEN          (TSDB_USER_LEN + TSDB_CGROUP_LEN)  // it is a null-terminated string
#define TSDB_STREAM_NAME_LEN          193                                // it is a null-terminated string
#define TSDB_DB_NAME_LEN              65
#define TSDB_DB_FNAME_LEN             (TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
#define TSDB_PRIVILEDGE_CONDITION_LEN 200
S
Shengliang Guan 已提交
204 205

#define TSDB_FUNC_NAME_LEN       65
206 207
#define TSDB_FUNC_COMMENT_LEN    1024 * 1024
#define TSDB_FUNC_CODE_LEN       10 * 1024 * 1024
208
#define TSDB_FUNC_BUF_SIZE       4096 * 64
S
Shengliang Guan 已提交
209 210
#define TSDB_FUNC_TYPE_SCALAR    1
#define TSDB_FUNC_TYPE_AGGREGATE 2
211
#define TSDB_FUNC_SCRIPT_BIN_LIB 0
212
#define TSDB_FUNC_SCRIPT_PYTHON  1
S
Shengliang Guan 已提交
213 214
#define TSDB_FUNC_MAX_RETRIEVE   1024

C
Cary Xu 已提交
215
#define TSDB_INDEX_NAME_LEN      65  // 64 + 1 '\0'
D
dapan1121 已提交
216 217 218
#define TSDB_INDEX_TYPE_LEN      10
#define TSDB_INDEX_EXTS_LEN      256
#define TSDB_INDEX_FNAME_LEN     (TSDB_DB_FNAME_LEN + TSDB_INDEX_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
S
Shengliang Guan 已提交
219 220
#define TSDB_TYPE_STR_MAX_LEN    32
#define TSDB_TABLE_FNAME_LEN     (TSDB_DB_FNAME_LEN + TSDB_TABLE_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
221 222
#define TSDB_TOPIC_FNAME_LEN     (TSDB_ACCT_ID_LEN + TSDB_TOPIC_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
#define TSDB_STREAM_FNAME_LEN    (TSDB_ACCT_ID_LEN + TSDB_STREAM_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
L
Liu Jicong 已提交
223 224
#define TSDB_SUBSCRIBE_KEY_LEN   (TSDB_CGROUP_LEN + TSDB_TOPIC_FNAME_LEN + 2)
#define TSDB_PARTITION_KEY_LEN   (TSDB_SUBSCRIBE_KEY_LEN + 20)
S
Shengliang Guan 已提交
225 226 227 228 229 230
#define TSDB_COL_NAME_LEN        65
#define TSDB_MAX_SAVED_SQL_LEN   TSDB_MAX_COLUMNS * 64
#define TSDB_MAX_SQL_LEN         TSDB_PAYLOAD_SIZE
#define TSDB_MAX_SQL_SHOW_LEN    1024
#define TSDB_MAX_ALLOWED_SQL_LEN (1 * 1024 * 1024u)  // sql length should be less than 1mb

231 232
#define TSDB_APP_NAME_LEN   TSDB_UNI_LEN
#define TSDB_TB_COMMENT_LEN 1025
D
dapan1121 已提交
233

234 235
#define TSDB_QUERY_ID_LEN   26
#define TSDB_TRANS_OPER_LEN 16
X
Xiaoyu Wang 已提交
236

237
#define TSDB_MAX_BYTES_PER_ROW 65531  // 49151:65531
238 239
#define TSDB_MAX_TAGS_LEN      16384
#define TSDB_MAX_TAGS          128
S
Shengliang Guan 已提交
240

D
dapan1121 已提交
241
#define TSDB_MAX_COL_TAG_NUM  (TSDB_MAX_COLUMNS + TSDB_MAX_TAGS)
H
Hongze Cheng 已提交
242
#define TSDB_MAX_JSON_TAG_LEN 16384
wmmhello's avatar
wmmhello 已提交
243
#define TSDB_MAX_JSON_KEY_LEN 256
244

S
Shengliang Guan 已提交
245 246 247
#define TSDB_AUTH_LEN          16
#define TSDB_PASSWORD_LEN      32
#define TSDB_USET_PASSWORD_LEN 129
D
dapan1121 已提交
248
#define TSDB_VERSION_LEN       32
S
Shengliang Guan 已提交
249
#define TSDB_LABEL_LEN         8
250
#define TSDB_JOB_STATUS_LEN    32
S
Shengliang Guan 已提交
251

H
Hongze Cheng 已提交
252 253 254 255 256 257
#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         2048
258
#define TSDB_SHOW_SCHEMA_JSON_LEN TSDB_MAX_COLUMNS * 256
H
Hongze Cheng 已提交
259 260
#define TSDB_SLOW_QUERY_SQL_LEN   512
#define TSDB_SHOW_SUBQUERY_LEN    1000
S
Shengliang Guan 已提交
261 262 263

#define TSDB_TRANS_STAGE_LEN 12
#define TSDB_TRANS_TYPE_LEN  16
264
#define TSDB_TRANS_ERROR_LEN 512
S
Shengliang Guan 已提交
265 266 267 268 269 270 271 272

#define TSDB_STEP_NAME_LEN 32
#define TSDB_STEP_DESC_LEN 128

#define TSDB_ERROR_MSG_LEN    1024
#define TSDB_DNODE_CONFIG_LEN 128
#define TSDB_DNODE_VALUE_LEN  256

273 274
#define TSDB_ACTIVE_KEY_LEN      109
#define TSDB_CONN_ACTIVE_KEY_LEN 255
K
kailixu 已提交
275

S
Shengliang Guan 已提交
276
#define TSDB_DEFAULT_PKT_SIZE 65480  // same as RPC_MAX_UDP_SIZE
S
Shengliang Guan 已提交
277 278

#define TSDB_PAYLOAD_SIZE         TSDB_DEFAULT_PKT_SIZE
S
Shengliang Guan 已提交
279
#define TSDB_DEFAULT_PAYLOAD_SIZE 5120  // default payload size, greater than PATH_MAX value
280
#define TSDB_MIN_VNODES           16
S
Shengliang Guan 已提交
281
#define TSDB_MAX_VNODES           512
L
Liu Jicong 已提交
282

S
Shengliang Guan 已提交
283 284 285
#define TSDB_DNODE_ROLE_ANY   0
#define TSDB_DNODE_ROLE_MGMT  1
#define TSDB_DNODE_ROLE_VNODE 2
S
Shengliang Guan 已提交
286

dengyihao's avatar
dengyihao 已提交
287
#define TSDB_MAX_REPLICA               5
C
cadem 已提交
288
#define TSDB_MAX_LEARNER_REPLICA       10
dengyihao's avatar
dengyihao 已提交
289
#define TSDB_SYNC_LOG_BUFFER_SIZE      4096
290 291 292
#define TSDB_SYNC_LOG_BUFFER_RETENTION 256
#define TSDB_SYNC_APPLYQ_SIZE_LIMIT    512
#define TSDB_SYNC_NEGOTIATION_WIN      512
S
Shengliang Guan 已提交
293

H
Haojun Liao 已提交
294
#define TSDB_TBNAME_COLUMN_INDEX     (-1)
S
Shengliang Guan 已提交
295
#define TSDB_MULTI_TABLEMETA_MAX_NUM 100000  // maximum batch size allowed to load table meta
S
Shengliang Guan 已提交
296

X
Xiaoyu Wang 已提交
297
#define TSDB_MIN_VNODES_PER_DB          1
298
#define TSDB_MAX_VNODES_PER_DB          1024
X
Xiaoyu Wang 已提交
299
#define TSDB_DEFAULT_VN_PER_DB          2
300 301
#define TSDB_MIN_BUFFER_PER_VNODE       3      // unit MB
#define TSDB_MAX_BUFFER_PER_VNODE       16384  // unit MB
H
Hongze Cheng 已提交
302
#define TSDB_DEFAULT_BUFFER_PER_VNODE   256
303
#define TSDB_MIN_PAGES_PER_VNODE        64
S
Shengliang Guan 已提交
304
#define TSDB_MAX_PAGES_PER_VNODE        (INT32_MAX - 1)
305 306 307
#define TSDB_DEFAULT_PAGES_PER_VNODE    256
#define TSDB_MIN_PAGESIZE_PER_VNODE     1  // unit KB
#define TSDB_MAX_PAGESIZE_PER_VNODE     16384
308 309 310
#define TSDB_DEFAULT_TSDB_PAGESIZE      4
#define TSDB_MIN_TSDB_PAGESIZE          1  // unit KB
#define TSDB_MAX_TSDB_PAGESIZE          16384
311
#define TSDB_DEFAULT_PAGESIZE_PER_VNODE 4
X
Xiaoyu Wang 已提交
312 313 314
#define TSDB_MIN_DAYS_PER_FILE          60  // unit minute
#define TSDB_MAX_DAYS_PER_FILE          (3650 * 1440)
#define TSDB_DEFAULT_DAYS_PER_FILE      (10 * 1440)
315 316 317
#define TSDB_MIN_DURATION_PER_FILE      60  // unit minute
#define TSDB_MAX_DURATION_PER_FILE      (3650 * 1440)
#define TSDB_DEFAULT_DURATION_PER_FILE  (10 * 1440)
K
kailixu 已提交
318 319 320
#define TSDB_MIN_KEEP                   (1 * 1440)          // data in db to be reserved. unit minute
#define TSDB_MAX_KEEP                   (365000 * 1440)     // data in db to be reserved.
#define TSDB_MAX_KEEP_NS                (365 * 292 * 1440)  // data in db to be reserved.
321
#define TSDB_DEFAULT_KEEP               (3650 * 1440)       // ten years
X
Xiaoyu Wang 已提交
322
#define TSDB_MIN_MINROWS_FBLOCK         10
D
dapan1121 已提交
323
#define TSDB_MAX_MINROWS_FBLOCK         1000000
X
Xiaoyu Wang 已提交
324 325
#define TSDB_DEFAULT_MINROWS_FBLOCK     100
#define TSDB_MIN_MAXROWS_FBLOCK         200
D
dapan1121 已提交
326
#define TSDB_MAX_MAXROWS_FBLOCK         10000000
X
Xiaoyu Wang 已提交
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342
#define TSDB_DEFAULT_MAXROWS_FBLOCK     4096
#define TSDB_MIN_FSYNC_PERIOD           0
#define TSDB_MAX_FSYNC_PERIOD           180000  // millisecond
#define TSDB_DEFAULT_FSYNC_PERIOD       3000    // three second
#define TSDB_MIN_WAL_LEVEL              1
#define TSDB_MAX_WAL_LEVEL              2
#define TSDB_DEFAULT_WAL_LEVEL          1
#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_DB_REPLICA             1
#define TSDB_MAX_DB_REPLICA             3
#define TSDB_DEFAULT_DB_REPLICA         1
343 344 345
#define TSDB_DB_STRICT_STR_LEN          sizeof(TSDB_DB_STRICT_OFF_STR)
#define TSDB_DB_STRICT_OFF_STR          "off"
#define TSDB_DB_STRICT_ON_STR           "on"
X
Xiaoyu Wang 已提交
346 347
#define TSDB_DB_STRICT_OFF              0
#define TSDB_DB_STRICT_ON               1
348
#define TSDB_DEFAULT_DB_STRICT          TSDB_DB_STRICT_ON
349 350 351 352 353 354 355 356 357 358 359 360 361
#define TSDB_CACHE_MODEL_STR_LEN        sizeof(TSDB_CACHE_MODEL_LAST_VALUE_STR)
#define TSDB_CACHE_MODEL_NONE_STR       "none"
#define TSDB_CACHE_MODEL_LAST_ROW_STR   "last_row"
#define TSDB_CACHE_MODEL_LAST_VALUE_STR "last_value"
#define TSDB_CACHE_MODEL_BOTH_STR       "both"
#define TSDB_CACHE_MODEL_NONE           0
#define TSDB_CACHE_MODEL_LAST_ROW       1
#define TSDB_CACHE_MODEL_LAST_VALUE     2
#define TSDB_CACHE_MODEL_BOTH           3
#define TSDB_DEFAULT_CACHE_MODEL        TSDB_CACHE_MODEL_NONE
#define TSDB_MIN_DB_CACHE_SIZE          1  // MB
#define TSDB_MAX_DB_CACHE_SIZE          65536
#define TSDB_DEFAULT_CACHE_SIZE         1
X
Xiaoyu Wang 已提交
362 363 364
#define TSDB_DB_STREAM_MODE_OFF         0
#define TSDB_DB_STREAM_MODE_ON          1
#define TSDB_DEFAULT_DB_STREAM_MODE     0
X
Xiaoyu Wang 已提交
365 366 367 368 369 370
#define TSDB_DB_SINGLE_STABLE_ON        1
#define TSDB_DB_SINGLE_STABLE_OFF       0
#define TSDB_DEFAULT_DB_SINGLE_STABLE   TSDB_DB_SINGLE_STABLE_OFF
#define TSDB_DB_SCHEMALESS_ON           1
#define TSDB_DB_SCHEMALESS_OFF          0
#define TSDB_DEFAULT_DB_SCHEMALESS      TSDB_DB_SCHEMALESS_OFF
H
Hongze Cheng 已提交
371 372
#define TSDB_MIN_STT_TRIGGER            1
#define TSDB_MAX_STT_TRIGGER            16
H
Hongze Cheng 已提交
373
#define TSDB_DEFAULT_SST_TRIGGER        2
374 375
#define TSDB_MIN_HASH_PREFIX            (2 - TSDB_TABLE_NAME_LEN)
#define TSDB_MAX_HASH_PREFIX            (TSDB_TABLE_NAME_LEN - 2)
376
#define TSDB_DEFAULT_HASH_PREFIX        0
377 378
#define TSDB_MIN_HASH_SUFFIX            (2 - TSDB_TABLE_NAME_LEN)
#define TSDB_MAX_HASH_SUFFIX            (TSDB_TABLE_NAME_LEN - 2)
379
#define TSDB_DEFAULT_HASH_SUFFIX        0
X
Xiaoyu Wang 已提交
380

381
#define TSDB_DB_MIN_WAL_RETENTION_PERIOD -1
382 383
#define TSDB_REP_DEF_DB_WAL_RET_PERIOD   3600
#define TSDB_REPS_DEF_DB_WAL_RET_PERIOD  3600
384 385
#define TSDB_DB_MIN_WAL_RETENTION_SIZE   -1
#define TSDB_REP_DEF_DB_WAL_RET_SIZE     0
386
#define TSDB_REPS_DEF_DB_WAL_RET_SIZE    0
387 388
#define TSDB_DB_MIN_WAL_ROLL_PERIOD      0
#define TSDB_REP_DEF_DB_WAL_ROLL_PERIOD  0
389
#define TSDB_REPS_DEF_DB_WAL_ROLL_PERIOD 0
390 391
#define TSDB_DB_MIN_WAL_SEGMENT_SIZE     0
#define TSDB_DEFAULT_DB_WAL_SEGMENT_SIZE 0
X
Xiaoyu Wang 已提交
392

393 394 395 396 397 398 399 400 401 402
#define TSDB_MIN_ROLLUP_MAX_DELAY       1  // unit millisecond
#define TSDB_MAX_ROLLUP_MAX_DELAY       (15 * 60 * 1000)
#define TSDB_MIN_ROLLUP_WATERMARK       0  // unit millisecond
#define TSDB_MAX_ROLLUP_WATERMARK       (15 * 60 * 1000)
#define TSDB_DEFAULT_ROLLUP_WATERMARK   5000
#define TSDB_MIN_ROLLUP_DELETE_MARK     0  // unit millisecond
#define TSDB_MAX_ROLLUP_DELETE_MARK     INT64_MAX
#define TSDB_DEFAULT_ROLLUP_DELETE_MARK 900000  // 900s
#define TSDB_MIN_TABLE_TTL              0
#define TSDB_DEFAULT_TABLE_TTL          0
X
Xiaoyu Wang 已提交
403 404 405 406

#define TSDB_MIN_EXPLAIN_RATIO     0
#define TSDB_MAX_EXPLAIN_RATIO     1
#define TSDB_DEFAULT_EXPLAIN_RATIO 0.001
X
Xiaoyu Wang 已提交
407

408 409
#define TSDB_DEFAULT_EXPLAIN_VERBOSE false

410
#define TSDB_EXPLAIN_RESULT_ROW_SIZE    (16 * 1024)
411
#define TSDB_EXPLAIN_RESULT_COLUMN_NAME "QUERY_PLAN"
412

H
Hongze Cheng 已提交
413 414 415 416
#define TSDB_MAX_FIELD_LEN    65519               // 16384:65519
#define TSDB_MAX_BINARY_LEN   TSDB_MAX_FIELD_LEN  // 16384-8:65519
#define TSDB_MAX_NCHAR_LEN    TSDB_MAX_FIELD_LEN  // 16384-8:65519
#define TSDB_MAX_GEOMETRY_LEN TSDB_MAX_FIELD_LEN  // 16384-8:65519
D
Dingle Zhang 已提交
417

S
Shengliang Guan 已提交
418 419
#define PRIMARYKEY_TIMESTAMP_COL_ID    1
#define COL_REACH_END(colId, maxColId) ((colId) > (maxColId))
S
Shengliang Guan 已提交
420

wafwerar's avatar
wafwerar 已提交
421 422 423
#ifdef WINDOWS
#define TSDB_MAX_RPC_THREADS 4  // windows pipe only support 4 connections.
#else
dengyihao's avatar
dengyihao 已提交
424
#define TSDB_MAX_RPC_THREADS 10
wafwerar's avatar
wafwerar 已提交
425
#endif
S
Shengliang Guan 已提交
426

427
#define TSDB_QUERY_TYPE_NON_TYPE 0x00u  // none type
S
Shengliang Guan 已提交
428

S
Shengliang Guan 已提交
429
#define TSDB_META_COMPACT_RATIO 0  // disable tsdb meta compact by default
S
Shengliang Guan 已提交
430

S
Shengliang Guan 已提交
431 432 433 434
/*
 * 1. ordinary sub query for select * from super_table
 * 2. all sqlobj generated by createSubqueryObj with this flag
 */
L
Liu Jicong 已提交
435 436 437
#define TSDB_QUERY_TYPE_INSERT      0x100u  // insert type
#define TSDB_QUERY_TYPE_FILE_INSERT 0x400u  // insert data from file
#define TSDB_QUERY_TYPE_STMT_INSERT 0x800u  // stmt insert type
S
Shengliang Guan 已提交
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456

#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

#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

457
#define TSDB_MAX_MSG_SIZE (1024 * 1024 * 10)
S
Shengliang Guan 已提交
458 459 460 461

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

#define TFS_MAX_TIERS          3
S
Shengliang Guan 已提交
462
#define TFS_MAX_DISKS_PER_TIER 16
S
Shengliang Guan 已提交
463 464 465 466 467
#define TFS_MAX_DISKS          (TFS_MAX_TIERS * TFS_MAX_DISKS_PER_TIER)
#define TFS_MIN_LEVEL          0
#define TFS_MAX_LEVEL          (TFS_MAX_TIERS - 1)
#define TFS_PRIMARY_LEVEL      0
#define TFS_PRIMARY_ID         0
S
Shengliang Guan 已提交
468
#define TFS_MIN_DISK_FREE_SIZE 50 * 1024 * 1024
S
Shengliang Guan 已提交
469

470 471
enum { TRANS_STAT_INIT = 0, TRANS_STAT_EXECUTING, TRANS_STAT_EXECUTED, TRANS_STAT_ROLLBACKING, TRANS_STAT_ROLLBACKED };
enum { TRANS_OPER_INIT = 0, TRANS_OPER_EXECUTE, TRANS_OPER_ROLLBACK };
S
Shengliang Guan 已提交
472

S
tcfg  
Shengliang Guan 已提交
473
typedef struct {
S
Shengliang Guan 已提交
474 475 476
  char    dir[TSDB_FILENAME_LEN];
  int32_t level;
  int32_t primary;
S
tcfg  
Shengliang Guan 已提交
477 478
} SDiskCfg;

L
Liu Jicong 已提交
479 480
#define TMQ_SEPARATOR ':'

L
Liu Jicong 已提交
481 482 483 484 485
enum {
  SND_WORKER_TYPE__SHARED = 1,
  SND_WORKER_TYPE__UNIQUE,
};

S
Shengliang Guan 已提交
486
#define DEFAULT_HANDLE 0
S
Shengliang Guan 已提交
487 488 489 490
#define MNODE_HANDLE   1
#define QNODE_HANDLE   -1
#define SNODE_HANDLE   -2
#define VNODE_HANDLE   -3
H
Hongze Cheng 已提交
491
#define CLIENT_HANDLE  -5
S
Shengliang Guan 已提交
492

D
dapan1121 已提交
493 494
#define TSDB_CONFIG_OPTION_LEN 32
#define TSDB_CONFIG_VALUE_LEN  64
G
Ganlin Zhao 已提交
495
#define TSDB_CONFIG_SCOPE_LEN  8
496
#define TSDB_CONFIG_NUMBER     8
497 498 499 500 501 502

#define QUERY_ID_SIZE      20
#define QUERY_OBJ_ID_SIZE  18
#define SUBQUERY_INFO_SIZE 6
#define QUERY_SAVE_SIZE    20

D
dapan1121 已提交
503 504
#define MAX_NUM_STR_SIZE 40

505
#define MAX_META_MSG_IN_BATCH   1048576
D
dapan1121 已提交
506
#define MAX_META_BATCH_RSP_SIZE (1 * 1048576 * 1024)
D
dapan1121 已提交
507

508 509 510
// sort page size by default
#define DEFAULT_PAGESIZE 4096

S
Shengliang Guan 已提交
511
#define VNODE_TIMEOUT_SEC 60
S
Shengliang Guan 已提交
512
#define MNODE_TIMEOUT_SEC 60
S
Shengliang Guan 已提交
513

S
Shengliang Guan 已提交
514 515 516 517 518
#ifdef __cplusplus
}
#endif

#endif