tdef.h 15.0 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 29
#define TSKEY             int64_t
#define TSKEY_MIN         INT64_MIN
#define TSKEY_MAX         (INT64_MAX - 1)
H
Hongze Cheng 已提交
30
#define TSKEY_INITIAL_VAL TSKEY_MIN
S
Shengliang Guan 已提交
31 32 33 34

// Bytes for each type.
extern const int32_t TYPE_BYTES[15];

35
// TODO: replace and remove code below
S
Shengliang Guan 已提交
36 37 38 39 40 41 42 43 44
#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)
#define TSDB_NCHAR_SIZE sizeof(int32_t)
S
Shengliang Guan 已提交
45 46

// NULL definition
S
Shengliang Guan 已提交
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
#define TSDB_DATA_BOOL_NULL      0x02
#define TSDB_DATA_TINYINT_NULL   0x80
#define TSDB_DATA_SMALLINT_NULL  0x8000
#define TSDB_DATA_INT_NULL       0x80000000L
#define TSDB_DATA_BIGINT_NULL    0x8000000000000000L
#define TSDB_DATA_TIMESTAMP_NULL TSDB_DATA_BIGINT_NULL

#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_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 已提交
69
#ifdef _TD_POWER_
S
Shengliang Guan 已提交
70
#define TSDB_DEFAULT_PASS "powerdb"
S
Shengliang Guan 已提交
71
#elif (_TD_TQ_ == true)
S
Shengliang Guan 已提交
72
#define TSDB_DEFAULT_PASS "tqueue"
S
Shengliang Guan 已提交
73
#elif (_TD_PRO_ == true)
S
Shengliang Guan 已提交
74
#define TSDB_DEFAULT_PASS "prodb"
S
Shengliang Guan 已提交
75
#else
S
Shengliang Guan 已提交
76
#define TSDB_DEFAULT_PASS "taosdata"
S
Shengliang Guan 已提交
77 78
#endif

S
Shengliang Guan 已提交
79
#define SHELL_MAX_PASSWORD_LEN 20
S
Shengliang Guan 已提交
80

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

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

S
Shengliang Guan 已提交
89 90 91
#define TSDB_TIME_PRECISION_MILLI 0
#define TSDB_TIME_PRECISION_MICRO 1
#define TSDB_TIME_PRECISION_NANO  2
S
Shengliang Guan 已提交
92 93 94 95 96

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

D
dapan1121 已提交
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
#define TSDB_INFORMATION_SCHEMA_DB            "information_schema"
#define TSDB_INS_TABLE_DNODES                 "dnodes"
#define TSDB_INS_TABLE_MNODES                 "mnodes"
#define TSDB_INS_TABLE_MODULES                "modules"
#define TSDB_INS_TABLE_QNODES                 "qnodes"
#define TSDB_INS_TABLE_USER_DATABASE          "user_database"
#define TSDB_INS_TABLE_USER_FUNCTIONS         "user_functions"
#define TSDB_INS_TABLE_USER_INDEXES           "user_indexes"
#define TSDB_INS_TABLE_USER_STABLES           "user_stables"
#define TSDB_INS_TABLE_USER_STREAMS           "user_streams"
#define TSDB_INS_TABLE_USER_TABLES            "user_tables"
#define TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED "user_table_distributed"
#define TSDB_INS_TABLE_USER_USERS             "user_users"
#define TSDB_INS_TABLE_VGROUPS                "vgroups"

S
Shengliang Guan 已提交
112 113 114
#define TSDB_TICK_PER_SECOND(precision)                      \
  ((int64_t)((precision) == TSDB_TIME_PRECISION_MILLI ? 1e3L \
                                                      : ((precision) == TSDB_TIME_PRECISION_MICRO ? 1e6L : 1e9L)))
S
Shengliang Guan 已提交
115 116

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

D
dapan1121 已提交
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
typedef enum EOperatorType {
  // arithmetic operator
  OP_TYPE_ADD = 1,
  OP_TYPE_SUB,
  OP_TYPE_MULTI,
  OP_TYPE_DIV,
  OP_TYPE_MOD,

  // bit operator
  OP_TYPE_BIT_AND,
  OP_TYPE_BIT_OR,

  // comparison operator
  OP_TYPE_GREATER_THAN,
  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,
  OP_TYPE_IS_NULL,
  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
  OP_TYPE_JSON_GET_VALUE,
  OP_TYPE_JSON_CONTAINS
} EOperatorType;

typedef enum ELogicConditionType {
  LOGIC_COND_TYPE_AND,
  LOGIC_COND_TYPE_OR,
  LOGIC_COND_TYPE_NOT,
} ELogicConditionType;
S
Shengliang Guan 已提交
172

S
Shengliang Guan 已提交
173 174 175 176
#define FUNCTION_CEIL  4500
#define FUNCTION_FLOOR 4501
#define FUNCTION_ABS   4502
#define FUNCTION_ROUND 4503
L
Liu Jicong 已提交
177

S
Shengliang Guan 已提交
178 179 180 181
#define FUNCTION_LENGTH 4800
#define FUNCTION_CONCAT 4801
#define FUNCTION_LTRIM  4802
#define FUNCTION_RTRIM  4803
L
Liu Jicong 已提交
182

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

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

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

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

#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
L
Liu Jicong 已提交
198
#define TSDB_CGROUP_LEN     193  // it is a null-terminated string
S
Shengliang Guan 已提交
199 200 201 202 203 204 205 206 207 208 209
#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_FUNC_NAME_LEN       65
#define TSDB_FUNC_COMMENT_LEN    4096
#define TSDB_FUNC_CODE_LEN       (65535 - 512)
#define TSDB_FUNC_BUF_SIZE       512
#define TSDB_FUNC_TYPE_SCALAR    1
#define TSDB_FUNC_TYPE_AGGREGATE 2
#define TSDB_FUNC_MAX_RETRIEVE   1024

C
Cary Xu 已提交
210
#define TSDB_INDEX_NAME_LEN      33  // 32 + 1 '\0'
S
Shengliang Guan 已提交
211 212 213
#define TSDB_TYPE_STR_MAX_LEN    32
#define TSDB_TABLE_FNAME_LEN     (TSDB_DB_FNAME_LEN + TSDB_TABLE_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
#define TSDB_TOPIC_FNAME_LEN     TSDB_TABLE_FNAME_LEN
L
Liu Jicong 已提交
214
#define TSDB_STREAM_FNAME_LEN    TSDB_TABLE_FNAME_LEN
L
Liu Jicong 已提交
215 216
#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 已提交
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
#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

#define TSDB_APP_NAME_LEN    TSDB_UNI_LEN
#define TSDB_STB_COMMENT_LEN 1024
/**
 *  In some scenarios uint16_t (0~65535) is used to store the row len.
 *  - Firstly, we use 65531(65535 - 4), as the SDataRow/SKVRow 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.
 */
#define TSDB_MAX_BYTES_PER_ROW  49151
#define TSDB_MAX_TAGS_LEN       16384
#define TSDB_MAX_TAGS           128
#define TSDB_MAX_TAG_CONDITIONS 1024

#define TSDB_AUTH_LEN          16
#define TSDB_PASSWORD_LEN      32
#define TSDB_USET_PASSWORD_LEN 129
#define TSDB_VERSION_LEN       12
#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_TRANS_STAGE_LEN 12
#define TSDB_TRANS_TYPE_LEN  16
#define TSDB_TRANS_ERROR_LEN 64

#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

#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

#define TSDB_DB_TYPE_DEFAULT 0
#define TSDB_DB_TYPE_TOPIC   1

#define TSDB_DEFAULT_PKT_SIZE 65480  // same as RPC_MAX_UDP_SIZE
S
Shengliang Guan 已提交
273 274

#define TSDB_PAYLOAD_SIZE         TSDB_DEFAULT_PKT_SIZE
S
Shengliang Guan 已提交
275 276
#define TSDB_DEFAULT_PAYLOAD_SIZE 5120  // default payload size, greater than PATH_MAX value
#define TSDB_EXTRA_PAYLOAD_SIZE   128   // extra bytes for auth
S
Shengliang Guan 已提交
277
#define TSDB_CQ_SQL_SIZE          1024
278
#define TSDB_MIN_VNODES           16
S
Shengliang Guan 已提交
279
#define TSDB_MAX_VNODES           512
280 281
#define TSDB_MIN_VNODES_PER_DB    1
#define TSDB_MAX_VNODES_PER_DB    4096
S
Shengliang Guan 已提交
282
#define TSDB_DEFAULT_VN_PER_DB    2
L
Liu Jicong 已提交
283

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

S
Shengliang Guan 已提交
288
#define TSDB_MAX_REPLICA 5
S
Shengliang Guan 已提交
289

S
Shengliang Guan 已提交
290 291 292
#define TSDB_TBNAME_COLUMN_INDEX (-1)
#define TSDB_UD_COLUMN_INDEX     (-1000)
#define TSDB_RES_COL_ID          (-5000)
S
Shengliang Guan 已提交
293

S
Shengliang Guan 已提交
294
#define TSDB_MULTI_TABLEMETA_MAX_NUM 100000  // maximum batch size allowed to load table meta
S
Shengliang Guan 已提交
295

S
Shengliang Guan 已提交
296 297 298
#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
S
Shengliang Guan 已提交
299

S
Shengliang Guan 已提交
300 301 302
#define TSDB_MIN_TOTAL_BLOCKS     3
#define TSDB_MAX_TOTAL_BLOCKS     10000
#define TSDB_DEFAULT_TOTAL_BLOCKS 6
S
Shengliang Guan 已提交
303

S
Shengliang Guan 已提交
304 305 306
#define TSDB_MIN_DAYS_PER_FILE     1
#define TSDB_MAX_DAYS_PER_FILE     3650
#define TSDB_DEFAULT_DAYS_PER_FILE 10
S
Shengliang Guan 已提交
307

S
Shengliang Guan 已提交
308 309 310
#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
S
Shengliang Guan 已提交
311

S
Shengliang Guan 已提交
312 313 314
#define TSDB_MIN_MIN_ROW_FBLOCK     10
#define TSDB_MAX_MIN_ROW_FBLOCK     1000
#define TSDB_DEFAULT_MIN_ROW_FBLOCK 100
S
Shengliang Guan 已提交
315

S
Shengliang Guan 已提交
316 317 318
#define TSDB_MIN_MAX_ROW_FBLOCK     200
#define TSDB_MAX_MAX_ROW_FBLOCK     10000
#define TSDB_DEFAULT_MAX_ROW_FBLOCK 4096
S
Shengliang Guan 已提交
319

S
Shengliang Guan 已提交
320 321 322
#define TSDB_MIN_COMMIT_TIME     30
#define TSDB_MAX_COMMIT_TIME     40960
#define TSDB_DEFAULT_COMMIT_TIME 3600
S
Shengliang Guan 已提交
323

S
Shengliang Guan 已提交
324 325 326
#define TSDB_MIN_FSYNC_PERIOD     0
#define TSDB_MAX_FSYNC_PERIOD     180000  // millisecond
#define TSDB_DEFAULT_FSYNC_PERIOD 3000    // three second
S
Shengliang Guan 已提交
327

S
Shengliang Guan 已提交
328 329 330
#define TSDB_MIN_WAL_LEVEL     0
#define TSDB_MAX_WAL_LEVEL     2
#define TSDB_DEFAULT_WAL_LEVEL 1
S
Shengliang Guan 已提交
331

S
Shengliang Guan 已提交
332 333 334
#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
Shengliang Guan 已提交
335

S
Shengliang Guan 已提交
336 337 338
#define TSDB_MIN_COMP_LEVEL     0
#define TSDB_MAX_COMP_LEVEL     2
#define TSDB_DEFAULT_COMP_LEVEL 2
S
Shengliang Guan 已提交
339

S
Shengliang Guan 已提交
340 341 342
#define TSDB_MIN_DB_REPLICA_OPTION     1
#define TSDB_MAX_DB_REPLICA_OPTION     3
#define TSDB_DEFAULT_DB_REPLICA_OPTION 1
S
Shengliang Guan 已提交
343

S
Shengliang Guan 已提交
344 345 346
#define TSDB_MIN_DB_QUORUM_OPTION     1
#define TSDB_MAX_DB_QUORUM_OPTION     2
#define TSDB_DEFAULT_DB_QUORUM_OPTION 1
S
Shengliang Guan 已提交
347

L
Liu Jicong 已提交
348 349
#define TSDB_MIN_DB_TTL_OPTION     1
#define TSDB_DEFAULT_DB_TTL_OPTION 0
350

L
Liu Jicong 已提交
351 352 353
#define TSDB_MIN_DB_SINGLE_STABLE_OPTION     0
#define TSDB_MAX_DB_SINGLE_STABLE_OPTION     1
#define TSDB_DEFAULT_DB_SINGLE_STABLE_OPTION 0
354

L
Liu Jicong 已提交
355 356 357
#define TSDB_MIN_DB_STREAM_MODE_OPTION     0
#define TSDB_MAX_DB_STREAM_MODE_OPTION     1
#define TSDB_DEFAULT_DB_STREAM_MODE_OPTION 0
358

L
Liu Jicong 已提交
359 360
#define TSDB_MAX_JOIN_TABLE_NUM 10
#define TSDB_MAX_UNION_CLAUSE   5
S
Shengliang Guan 已提交
361

S
Shengliang Guan 已提交
362 363 364
#define TSDB_MIN_DB_UPDATE            0
#define TSDB_MAX_DB_UPDATE            2
#define TSDB_DEFAULT_DB_UPDATE_OPTION 0
S
Shengliang Guan 已提交
365

S
Shengliang Guan 已提交
366 367 368
#define TSDB_MIN_DB_CACHE_LAST_ROW  0
#define TSDB_MAX_DB_CACHE_LAST_ROW  3
#define TSDB_DEFAULT_CACHE_LAST_ROW 0
S
Shengliang Guan 已提交
369

S
Shengliang Guan 已提交
370 371
#define TSDB_MAX_JOIN_TABLE_NUM 10
#define TSDB_MAX_UNION_CLAUSE   5
S
Shengliang Guan 已提交
372

S
Shengliang Guan 已提交
373 374 375 376 377
#define TSDB_MAX_FIELD_LEN             16384
#define TSDB_MAX_BINARY_LEN            (TSDB_MAX_FIELD_LEN - TSDB_KEYSIZE)  // keep 16384
#define TSDB_MAX_NCHAR_LEN             (TSDB_MAX_FIELD_LEN - TSDB_KEYSIZE)  // keep 16384
#define PRIMARYKEY_TIMESTAMP_COL_ID    1
#define COL_REACH_END(colId, maxColId) ((colId) > (maxColId))
S
Shengliang Guan 已提交
378

S
Shengliang Guan 已提交
379
#define TSDB_MAX_RPC_THREADS 5
S
Shengliang Guan 已提交
380

S
Shengliang Guan 已提交
381 382
#define TSDB_QUERY_TYPE_NON_TYPE      0x00u  // none type
#define TSDB_QUERY_TYPE_FREE_RESOURCE 0x01u  // free qhandle at vnode
S
Shengliang Guan 已提交
383

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

S
Shengliang Guan 已提交
386 387 388 389
/*
 * 1. ordinary sub query for select * from super_table
 * 2. all sqlobj generated by createSubqueryObj with this flag
 */
S
Shengliang Guan 已提交
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428
#define TSDB_QUERY_TYPE_SUBQUERY        0x02u
#define TSDB_QUERY_TYPE_STABLE_SUBQUERY 0x04u  // two-stage subquery for super table

#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

#define TSDB_QUERY_TYPE_TAG_FILTER_QUERY 0x400u
#define TSDB_QUERY_TYPE_INSERT           0x100u  // insert type
#define TSDB_QUERY_TYPE_MULTITABLE_QUERY 0x200u
#define TSDB_QUERY_TYPE_FILE_INSERT      0x400u   // insert data from file
#define TSDB_QUERY_TYPE_STMT_INSERT      0x800u   // stmt insert type
#define TSDB_QUERY_TYPE_NEST_SUBQUERY    0x1000u  // nested sub query

#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

#define TSDB_MAX_WAL_SIZE (1024 * 1024 * 3)

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

#define TFS_MAX_TIERS          3
S
Shengliang Guan 已提交
429
#define TFS_MAX_DISKS_PER_TIER 16
S
Shengliang Guan 已提交
430 431 432 433 434
#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 已提交
435
#define TFS_MIN_DISK_FREE_SIZE 50 * 1024 * 1024
S
Shengliang Guan 已提交
436

437 438
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 已提交
439

S
tcfg  
Shengliang Guan 已提交
440
typedef struct {
S
Shengliang Guan 已提交
441 442 443
  char    dir[TSDB_FILENAME_LEN];
  int32_t level;
  int32_t primary;
S
tcfg  
Shengliang Guan 已提交
444 445
} SDiskCfg;

L
Liu Jicong 已提交
446 447
#define TMQ_SEPARATOR ':'

L
Liu Jicong 已提交
448 449 450
#define SND_UNIQUE_THREAD_NUM 2
#define SND_SHARED_THREAD_NUM 2

S
Shengliang Guan 已提交
451 452 453 454 455
#ifdef __cplusplus
}
#endif

#endif