• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

taosdata / TDengine / #4541

19 Jul 2025 01:13AM UTC coverage: 56.753% (-1.6%) from 58.31%
#4541

push

travis-ci

web-flow
fix: subquery memleak (#32024)

124299 of 282344 branches covered (44.02%)

Branch coverage included in aggregate %.

181106 of 255787 relevant lines covered (70.8%)

24937406.43 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

39.99
/include/common/tmsg.h
1
/*
2
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
3
 *
4
 * This program is free software: you can use, redistribute, and/or modify
5
 * it under the terms of the GNU Affero General Public License, version 3
6
 * or later ("AGPL"), as published by the Free Software Foundation.
7
 *
8
 * This program is distributed in the hope that it will be useful, but WITHOUT
9
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
 * FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * You should have received a copy of the GNU Affero General Public License
13
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14
 */
15

16
#ifndef _TD_COMMON_TAOS_MSG_H_
17
#define _TD_COMMON_TAOS_MSG_H_
18

19
#include "taosdef.h"
20
#include "taoserror.h"
21
#include "tarray.h"
22
#include "tcoding.h"
23
#include "tcol.h"
24
#include "tencode.h"
25
#include "thash.h"
26
#include "tlist.h"
27
#include "tname.h"
28
#include "trow.h"
29
#include "tuuid.h"
30

31
#ifdef __cplusplus
32
extern "C" {
33
#endif
34

35
/* ------------------------ MESSAGE DEFINITIONS ------------------------ */
36

37
#define TD_MSG_NUMBER_
38
#undef TD_MSG_DICT_
39
#undef TD_MSG_INFO_
40
#undef TD_MSG_TYPE_INFO_
41
#undef TD_MSG_RANGE_CODE_
42
#undef TD_MSG_SEG_CODE_
43
#include "tmsgdef.h"
44

45
#undef TD_MSG_NUMBER_
46
#undef TD_MSG_DICT_
47
#undef TD_MSG_INFO_
48
#undef TD_MSG_TYPE_INFO_
49
#undef TD_MSG_RANGE_CODE_
50
#define TD_MSG_SEG_CODE_
51
#include "tmsgdef.h"
52

53
#undef TD_MSG_NUMBER_
54
#undef TD_MSG_DICT_
55
#undef TD_MSG_INFO_
56
#undef TD_MSG_TYPE_INFO_
57
#undef TD_MSG_SEG_CODE_
58
#undef TD_MSG_RANGE_CODE_
59
#include "tmsgdef.h"
60

61
extern char*   tMsgInfo[];
62
extern int32_t tMsgDict[];
63
extern int32_t tMsgRangeDict[];
64

65
typedef uint16_t tmsg_t;
66

67
#define TMSG_SEG_CODE(TYPE) (((TYPE)&0xff00) >> 8)
68
#define TMSG_SEG_SEQ(TYPE)  ((TYPE)&0xff)
69
#define TMSG_INDEX(TYPE)    (tMsgDict[TMSG_SEG_CODE(TYPE)] + TMSG_SEG_SEQ(TYPE))
70

71

72
#define DECODESQL()                                                               \
73
  do {                                                                            \
74
    if (!tDecodeIsEnd(&decoder)) {                                                \
75
      TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->sqlLen));                       \
76
      if (pReq->sqlLen > 0) {                                                     \
77
        TAOS_CHECK_EXIT(tDecodeBinaryAlloc(&decoder, (void **)&pReq->sql, NULL)); \
78
      }                                                                           \
79
    }                                                                             \
80
  } while (0)
81

82
#define ENCODESQL()                                                                       \
83
  do {                                                                                    \
84
    TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->sqlLen));                                  \
85
    if (pReq->sqlLen > 0) {                                                               \
86
      TAOS_CHECK_EXIT(tEncodeBinary(&encoder, (const uint8_t *)pReq->sql, pReq->sqlLen)); \
87
    }                                                                                     \
88
  } while (0)
89

90
#define FREESQL()                \
91
  do {                           \
92
    if (pReq->sql != NULL) {     \
93
      taosMemoryFree(pReq->sql); \
94
    }                            \
95
    pReq->sql = NULL;            \
96
  } while (0)
97

98

99
static inline bool tmsgIsValid(tmsg_t type) {
70,886,038✔
100
  // static int8_t sz = sizeof(tMsgRangeDict) / sizeof(tMsgRangeDict[0]);
101
  int8_t maxSegIdx = TMSG_SEG_CODE(TDMT_MAX_MSG_MIN);
70,886,038✔
102
  int    segIdx = TMSG_SEG_CODE(type);
70,886,038✔
103
  if (segIdx >= 0 && segIdx < maxSegIdx) {
70,886,038!
104
    return type < tMsgRangeDict[segIdx];
70,893,600✔
105
  }
106
  return false;
1✔
107
}
108

109
#define TMSG_INFO(type) (tmsgIsValid(type) ? tMsgInfo[TMSG_INDEX(type)] : "unKnown")
110

111
static inline bool vnodeIsMsgBlock(tmsg_t type) {
17,077,019✔
112
  return (type == TDMT_VND_CREATE_TABLE) || (type == TDMT_VND_ALTER_TABLE) || (type == TDMT_VND_DROP_TABLE) ||
17,024,231✔
113
         (type == TDMT_VND_UPDATE_TAG_VAL) || (type == TDMT_VND_ALTER_CONFIRM) || (type == TDMT_VND_COMMIT) ||
34,101,250✔
114
         (type == TDMT_SYNC_CONFIG_CHANGE);
115
}
116

117
static inline bool syncUtilUserCommit(tmsg_t msgType) {
73,322,709✔
118
  return msgType != TDMT_SYNC_NOOP && msgType != TDMT_SYNC_LEADER_TRANSFER;
73,322,709✔
119
}
120

121
/* ------------------------ OTHER DEFINITIONS ------------------------ */
122
// IE type
123
#define TSDB_IE_TYPE_SEC         1
124
#define TSDB_IE_TYPE_META        2
125
#define TSDB_IE_TYPE_MGMT_IP     3
126
#define TSDB_IE_TYPE_DNODE_CFG   4
127
#define TSDB_IE_TYPE_NEW_VERSION 5
128
#define TSDB_IE_TYPE_DNODE_EXT   6
129
#define TSDB_IE_TYPE_DNODE_STATE 7
130

131
enum {
132
  CONN_TYPE__QUERY = 1,
133
  CONN_TYPE__TMQ,
134
  CONN_TYPE__UDFD,
135
  CONN_TYPE__MAX,
136
};
137

138
enum {
139
  HEARTBEAT_KEY_USER_AUTHINFO = 1,
140
  HEARTBEAT_KEY_DBINFO,
141
  HEARTBEAT_KEY_STBINFO,
142
  HEARTBEAT_KEY_TMQ,
143
  HEARTBEAT_KEY_DYN_VIEW,
144
  HEARTBEAT_KEY_VIEWINFO,
145
  HEARTBEAT_KEY_TSMA,
146
};
147

148
typedef enum _mgmt_table {
149
  TSDB_MGMT_TABLE_START,
150
  TSDB_MGMT_TABLE_DNODE,
151
  TSDB_MGMT_TABLE_MNODE,
152
  TSDB_MGMT_TABLE_MODULE,
153
  TSDB_MGMT_TABLE_QNODE,
154
  TSDB_MGMT_TABLE_SNODE,
155
  TSDB_MGMT_TABLE_BACKUP_NODE,  // no longer used
156
  TSDB_MGMT_TABLE_CLUSTER,
157
  TSDB_MGMT_TABLE_DB,
158
  TSDB_MGMT_TABLE_FUNC,
159
  TSDB_MGMT_TABLE_INDEX,
160
  TSDB_MGMT_TABLE_STB,
161
  TSDB_MGMT_TABLE_STREAMS,
162
  TSDB_MGMT_TABLE_TABLE,
163
  TSDB_MGMT_TABLE_TAG,
164
  TSDB_MGMT_TABLE_COL,
165
  TSDB_MGMT_TABLE_USER,
166
  TSDB_MGMT_TABLE_GRANTS,
167
  TSDB_MGMT_TABLE_VGROUP,
168
  TSDB_MGMT_TABLE_TOPICS,
169
  TSDB_MGMT_TABLE_CONSUMERS,
170
  TSDB_MGMT_TABLE_SUBSCRIPTIONS,
171
  TSDB_MGMT_TABLE_TRANS,
172
  TSDB_MGMT_TABLE_SMAS,
173
  TSDB_MGMT_TABLE_CONFIGS,
174
  TSDB_MGMT_TABLE_CONNS,
175
  TSDB_MGMT_TABLE_QUERIES,
176
  TSDB_MGMT_TABLE_VNODES,
177
  TSDB_MGMT_TABLE_APPS,
178
  TSDB_MGMT_TABLE_STREAM_TASKS,
179
  TSDB_MGMT_TABLE_STREAM_RECALCULATES,
180
  TSDB_MGMT_TABLE_PRIVILEGES,
181
  TSDB_MGMT_TABLE_VIEWS,
182
  TSDB_MGMT_TABLE_TSMAS,
183
  TSDB_MGMT_TABLE_COMPACT,
184
  TSDB_MGMT_TABLE_COMPACT_DETAIL,
185
  TSDB_MGMT_TABLE_GRANTS_FULL,
186
  TSDB_MGMT_TABLE_GRANTS_LOGS,
187
  TSDB_MGMT_TABLE_MACHINES,
188
  TSDB_MGMT_TABLE_ARBGROUP,
189
  TSDB_MGMT_TABLE_ENCRYPTIONS,
190
  TSDB_MGMT_TABLE_USER_FULL,
191
  TSDB_MGMT_TABLE_ANODE,
192
  TSDB_MGMT_TABLE_ANODE_FULL,
193
  TSDB_MGMT_TABLE_USAGE,
194
  TSDB_MGMT_TABLE_FILESETS,
195
  TSDB_MGMT_TABLE_TRANSACTION_DETAIL,
196
  TSDB_MGMT_TABLE_VC_COL,
197
  TSDB_MGMT_TABLE_BNODE,
198
  TSDB_MGMT_TABLE_MOUNT,
199
  TSDB_MGMT_TABLE_SSMIGRATE,
200
  TSDB_MGMT_TABLE_MAX,
201
} EShowType;
202

203
#define TSDB_ALTER_TABLE_ADD_TAG                         1
204
#define TSDB_ALTER_TABLE_DROP_TAG                        2
205
#define TSDB_ALTER_TABLE_UPDATE_TAG_NAME                 3
206
#define TSDB_ALTER_TABLE_UPDATE_TAG_VAL                  4
207
#define TSDB_ALTER_TABLE_ADD_COLUMN                      5
208
#define TSDB_ALTER_TABLE_DROP_COLUMN                     6
209
#define TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES             7
210
#define TSDB_ALTER_TABLE_UPDATE_TAG_BYTES                8
211
#define TSDB_ALTER_TABLE_UPDATE_OPTIONS                  9
212
#define TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME              10
213
#define TSDB_ALTER_TABLE_ADD_TAG_INDEX                   11
214
#define TSDB_ALTER_TABLE_DROP_TAG_INDEX                  12
215
#define TSDB_ALTER_TABLE_UPDATE_COLUMN_COMPRESS          13
216
#define TSDB_ALTER_TABLE_ADD_COLUMN_WITH_COMPRESS_OPTION 14
217
#define TSDB_ALTER_TABLE_UPDATE_MULTI_TAG_VAL            15
218
#define TSDB_ALTER_TABLE_ALTER_COLUMN_REF                16
219
#define TSDB_ALTER_TABLE_REMOVE_COLUMN_REF               17
220
#define TSDB_ALTER_TABLE_ADD_COLUMN_WITH_COLUMN_REF      18
221

222
#define TSDB_FILL_NONE        0
223
#define TSDB_FILL_NULL        1
224
#define TSDB_FILL_NULL_F      2
225
#define TSDB_FILL_SET_VALUE   3
226
#define TSDB_FILL_SET_VALUE_F 4
227
#define TSDB_FILL_LINEAR      5
228
#define TSDB_FILL_PREV        6
229
#define TSDB_FILL_NEXT        7
230
#define TSDB_FILL_NEAR        8
231

232
#define TSDB_ALTER_USER_PASSWD          0x1
233
#define TSDB_ALTER_USER_SUPERUSER       0x2
234
#define TSDB_ALTER_USER_ENABLE          0x3
235
#define TSDB_ALTER_USER_SYSINFO         0x4
236
#define TSDB_ALTER_USER_ADD_PRIVILEGES  0x5
237
#define TSDB_ALTER_USER_DEL_PRIVILEGES  0x6
238
#define TSDB_ALTER_USER_ADD_WHITE_LIST  0x7
239
#define TSDB_ALTER_USER_DROP_WHITE_LIST 0x8
240
#define TSDB_ALTER_USER_CREATEDB        0x9
241

242
#define TSDB_KILL_MSG_LEN 30
243

244
#define TSDB_TABLE_NUM_UNIT 100000
245

246
#define TSDB_VN_READ_ACCCESS  ((char)0x1)
247
#define TSDB_VN_WRITE_ACCCESS ((char)0x2)
248
#define TSDB_VN_ALL_ACCCESS   (TSDB_VN_READ_ACCCESS | TSDB_VN_WRITE_ACCCESS)
249

250
#define TSDB_COL_NORMAL 0x0u  // the normal column of the table
251
#define TSDB_COL_TAG    0x1u  // the tag column type
252
#define TSDB_COL_UDC    0x2u  // the user specified normal string column, it is a dummy column
253
#define TSDB_COL_TMP    0x4u  // internal column generated by the previous operators
254
#define TSDB_COL_NULL   0x8u  // the column filter NULL or not
255

256
#define TSDB_COL_IS_TAG(f)        (((f & (~(TSDB_COL_NULL))) & TSDB_COL_TAG) != 0)
257
#define TSDB_COL_IS_NORMAL_COL(f) ((f & (~(TSDB_COL_NULL))) == TSDB_COL_NORMAL)
258
#define TSDB_COL_IS_UD_COL(f)     ((f & (~(TSDB_COL_NULL))) == TSDB_COL_UDC)
259
#define TSDB_COL_REQ_NULL(f)      (((f)&TSDB_COL_NULL) != 0)
260

261
#define TD_SUPER_TABLE          TSDB_SUPER_TABLE
262
#define TD_CHILD_TABLE          TSDB_CHILD_TABLE
263
#define TD_NORMAL_TABLE         TSDB_NORMAL_TABLE
264
#define TD_VIRTUAL_NORMAL_TABLE TSDB_VIRTUAL_NORMAL_TABLE
265
#define TD_VIRTUAL_CHILD_TABLE  TSDB_VIRTUAL_CHILD_TABLE
266

267
typedef enum ENodeType {
268
  // Syntax nodes are used in parser and planner module, and some are also used in executor module, such as COLUMN,
269
  // VALUE, OPERATOR, FUNCTION and so on.
270
  QUERY_NODE_COLUMN = 1,
271
  QUERY_NODE_VALUE,
272
  QUERY_NODE_OPERATOR,
273
  QUERY_NODE_LOGIC_CONDITION,
274
  QUERY_NODE_FUNCTION,
275
  QUERY_NODE_REAL_TABLE,
276
  QUERY_NODE_TEMP_TABLE,
277
  QUERY_NODE_JOIN_TABLE,
278
  QUERY_NODE_GROUPING_SET,
279
  QUERY_NODE_ORDER_BY_EXPR,
280
  QUERY_NODE_LIMIT,
281
  QUERY_NODE_STATE_WINDOW,
282
  QUERY_NODE_SESSION_WINDOW,
283
  QUERY_NODE_INTERVAL_WINDOW,
284
  QUERY_NODE_NODE_LIST,
285
  QUERY_NODE_FILL,
286
  QUERY_NODE_RAW_EXPR,  // Only be used in parser module.
287
  QUERY_NODE_TARGET,
288
  QUERY_NODE_DATABLOCK_DESC,
289
  QUERY_NODE_SLOT_DESC,
290
  QUERY_NODE_COLUMN_DEF,
291
  QUERY_NODE_DOWNSTREAM_SOURCE,
292
  QUERY_NODE_DATABASE_OPTIONS,
293
  QUERY_NODE_TABLE_OPTIONS,
294
  QUERY_NODE_INDEX_OPTIONS,
295
  QUERY_NODE_EXPLAIN_OPTIONS,
296
  QUERY_NODE_LEFT_VALUE,
297
  QUERY_NODE_COLUMN_REF,
298
  QUERY_NODE_WHEN_THEN,
299
  QUERY_NODE_CASE_WHEN,
300
  QUERY_NODE_EVENT_WINDOW,
301
  QUERY_NODE_HINT,
302
  QUERY_NODE_VIEW,
303
  QUERY_NODE_WINDOW_OFFSET,
304
  QUERY_NODE_COUNT_WINDOW,
305
  QUERY_NODE_COLUMN_OPTIONS,
306
  QUERY_NODE_TSMA_OPTIONS,
307
  QUERY_NODE_ANOMALY_WINDOW,
308
  QUERY_NODE_RANGE_AROUND,
309
  QUERY_NODE_STREAM_NOTIFY_OPTIONS,
310
  QUERY_NODE_VIRTUAL_TABLE,
311
  QUERY_NODE_SLIDING_WINDOW,
312
  QUERY_NODE_PERIOD_WINDOW,
313
  QUERY_NODE_STREAM_TRIGGER,
314
  QUERY_NODE_STREAM,
315
  QUERY_NODE_STREAM_TAG_DEF,
316
  QUERY_NODE_EXTERNAL_WINDOW,
317
  QUERY_NODE_STREAM_TRIGGER_OPTIONS,
318
  QUERY_NODE_PLACE_HOLDER_TABLE,
319
  QUERY_NODE_TIME_RANGE,
320
  QUERY_NODE_STREAM_OUT_TABLE,
321
  QUERY_NODE_STREAM_CALC_RANGE,
322
  QUERY_NODE_COUNT_WINDOW_ARGS,
323
  QUERY_NODE_BNODE_OPTIONS,
324

325
  // Statement nodes are used in parser and planner module.
326
  QUERY_NODE_SET_OPERATOR = 100,
327
  QUERY_NODE_SELECT_STMT,
328
  QUERY_NODE_VNODE_MODIFY_STMT,
329
  QUERY_NODE_CREATE_DATABASE_STMT,
330
  QUERY_NODE_DROP_DATABASE_STMT,
331
  QUERY_NODE_ALTER_DATABASE_STMT,
332
  QUERY_NODE_FLUSH_DATABASE_STMT,
333
  QUERY_NODE_TRIM_DATABASE_STMT,
334
  QUERY_NODE_CREATE_TABLE_STMT,
335
  QUERY_NODE_CREATE_SUBTABLE_CLAUSE,
336
  QUERY_NODE_CREATE_MULTI_TABLES_STMT,
337
  QUERY_NODE_DROP_TABLE_CLAUSE,
338
  QUERY_NODE_DROP_TABLE_STMT,
339
  QUERY_NODE_DROP_SUPER_TABLE_STMT,
340
  QUERY_NODE_ALTER_TABLE_STMT,
341
  QUERY_NODE_ALTER_SUPER_TABLE_STMT,
342
  QUERY_NODE_CREATE_USER_STMT,
343
  QUERY_NODE_ALTER_USER_STMT,
344
  QUERY_NODE_DROP_USER_STMT,
345
  QUERY_NODE_USE_DATABASE_STMT,
346
  QUERY_NODE_CREATE_DNODE_STMT,
347
  QUERY_NODE_DROP_DNODE_STMT,
348
  QUERY_NODE_ALTER_DNODE_STMT,
349
  QUERY_NODE_CREATE_INDEX_STMT,
350
  QUERY_NODE_DROP_INDEX_STMT,
351
  QUERY_NODE_CREATE_QNODE_STMT,
352
  QUERY_NODE_DROP_QNODE_STMT,
353
  QUERY_NODE_CREATE_BACKUP_NODE_STMT,  // no longer used
354
  QUERY_NODE_DROP_BACKUP_NODE_STMT,    // no longer used
355
  QUERY_NODE_CREATE_SNODE_STMT,
356
  QUERY_NODE_DROP_SNODE_STMT,
357
  QUERY_NODE_CREATE_MNODE_STMT,
358
  QUERY_NODE_DROP_MNODE_STMT,
359
  QUERY_NODE_CREATE_TOPIC_STMT,
360
  QUERY_NODE_DROP_TOPIC_STMT,
361
  QUERY_NODE_DROP_CGROUP_STMT,
362
  QUERY_NODE_ALTER_LOCAL_STMT,
363
  QUERY_NODE_EXPLAIN_STMT,
364
  QUERY_NODE_DESCRIBE_STMT,
365
  QUERY_NODE_RESET_QUERY_CACHE_STMT,
366
  QUERY_NODE_COMPACT_DATABASE_STMT,
367
  QUERY_NODE_COMPACT_VGROUPS_STMT,
368
  QUERY_NODE_CREATE_FUNCTION_STMT,
369
  QUERY_NODE_DROP_FUNCTION_STMT,
370
  QUERY_NODE_CREATE_STREAM_STMT,
371
  QUERY_NODE_DROP_STREAM_STMT,
372
  QUERY_NODE_BALANCE_VGROUP_STMT,
373
  QUERY_NODE_MERGE_VGROUP_STMT,
374
  QUERY_NODE_REDISTRIBUTE_VGROUP_STMT,
375
  QUERY_NODE_SPLIT_VGROUP_STMT,
376
  QUERY_NODE_SYNCDB_STMT,
377
  QUERY_NODE_GRANT_STMT,
378
  QUERY_NODE_REVOKE_STMT,
379
  QUERY_NODE_ALTER_CLUSTER_STMT,
380
  QUERY_NODE_SSMIGRATE_DATABASE_STMT,
381
  QUERY_NODE_CREATE_TSMA_STMT,
382
  QUERY_NODE_DROP_TSMA_STMT,
383
  QUERY_NODE_CREATE_VIRTUAL_TABLE_STMT,
384
  QUERY_NODE_CREATE_VIRTUAL_SUBTABLE_STMT,
385
  QUERY_NODE_DROP_VIRTUAL_TABLE_STMT,
386
  QUERY_NODE_ALTER_VIRTUAL_TABLE_STMT,
387
  QUERY_NODE_CREATE_MOUNT_STMT,
388
  QUERY_NODE_DROP_MOUNT_STMT,
389

390
  // placeholder for [154, 180]
391
  QUERY_NODE_SHOW_CREATE_VIEW_STMT = 181,
392
  QUERY_NODE_SHOW_CREATE_DATABASE_STMT,
393
  QUERY_NODE_SHOW_CREATE_TABLE_STMT,
394
  QUERY_NODE_SHOW_CREATE_STABLE_STMT,
395
  QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT,
396
  QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT,
397
  QUERY_NODE_SHOW_SCORES_STMT,
398
  QUERY_NODE_SHOW_TABLE_TAGS_STMT,
399
  QUERY_NODE_KILL_CONNECTION_STMT,
400
  QUERY_NODE_KILL_QUERY_STMT,
401
  QUERY_NODE_KILL_TRANSACTION_STMT,
402
  QUERY_NODE_KILL_COMPACT_STMT,
403
  QUERY_NODE_DELETE_STMT,
404
  QUERY_NODE_INSERT_STMT,
405
  QUERY_NODE_QUERY,
406
  QUERY_NODE_SHOW_DB_ALIVE_STMT,
407
  QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT,
408
  QUERY_NODE_BALANCE_VGROUP_LEADER_STMT,
409
  QUERY_NODE_BALANCE_VGROUP_LEADER_DATABASE_STMT,
410
  QUERY_NODE_RESTORE_DNODE_STMT,
411
  QUERY_NODE_RESTORE_QNODE_STMT,
412
  QUERY_NODE_RESTORE_MNODE_STMT,
413
  QUERY_NODE_RESTORE_VNODE_STMT,
414
  QUERY_NODE_PAUSE_STREAM_STMT,
415
  QUERY_NODE_RESUME_STREAM_STMT,
416
  QUERY_NODE_CREATE_VIEW_STMT,
417
  QUERY_NODE_DROP_VIEW_STMT,
418
  QUERY_NODE_CREATE_SUBTABLE_FROM_FILE_CLAUSE,
419
  QUERY_NODE_CREATE_ANODE_STMT,
420
  QUERY_NODE_DROP_ANODE_STMT,
421
  QUERY_NODE_UPDATE_ANODE_STMT,
422
  QUERY_NODE_ASSIGN_LEADER_STMT,
423
  QUERY_NODE_SHOW_CREATE_TSMA_STMT,
424
  QUERY_NODE_SHOW_CREATE_VTABLE_STMT,
425
  QUERY_NODE_RECALCULATE_STREAM_STMT,
426
  QUERY_NODE_CREATE_BNODE_STMT,
427
  QUERY_NODE_DROP_BNODE_STMT,
428

429
  // show statement nodes
430
  // see 'sysTableShowAdapter', 'SYSTABLE_SHOW_TYPE_OFFSET'
431
  QUERY_NODE_SHOW_DNODES_STMT = 400,
432
  QUERY_NODE_SHOW_MNODES_STMT,
433
  QUERY_NODE_SHOW_MODULES_STMT,
434
  QUERY_NODE_SHOW_QNODES_STMT,
435
  QUERY_NODE_SHOW_SNODES_STMT,
436
  QUERY_NODE_SHOW_BACKUP_NODES_STMT,  // no longer used
437
  QUERY_NODE_SHOW_ARBGROUPS_STMT,
438
  QUERY_NODE_SHOW_CLUSTER_STMT,
439
  QUERY_NODE_SHOW_DATABASES_STMT,
440
  QUERY_NODE_SHOW_FUNCTIONS_STMT,
441
  QUERY_NODE_SHOW_INDEXES_STMT,
442
  QUERY_NODE_SHOW_STABLES_STMT,
443
  QUERY_NODE_SHOW_STREAMS_STMT,
444
  QUERY_NODE_SHOW_TABLES_STMT,
445
  QUERY_NODE_SHOW_TAGS_STMT,
446
  QUERY_NODE_SHOW_USERS_STMT,
447
  QUERY_NODE_SHOW_USERS_FULL_STMT,
448
  QUERY_NODE_SHOW_LICENCES_STMT,
449
  QUERY_NODE_SHOW_VGROUPS_STMT,
450
  QUERY_NODE_SHOW_TOPICS_STMT,
451
  QUERY_NODE_SHOW_CONSUMERS_STMT,
452
  QUERY_NODE_SHOW_CONNECTIONS_STMT,
453
  QUERY_NODE_SHOW_QUERIES_STMT,
454
  QUERY_NODE_SHOW_APPS_STMT,
455
  QUERY_NODE_SHOW_VARIABLES_STMT,
456
  QUERY_NODE_SHOW_DNODE_VARIABLES_STMT,
457
  QUERY_NODE_SHOW_TRANSACTIONS_STMT,
458
  QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT,
459
  QUERY_NODE_SHOW_VNODES_STMT,
460
  QUERY_NODE_SHOW_USER_PRIVILEGES_STMT,
461
  QUERY_NODE_SHOW_VIEWS_STMT,
462
  QUERY_NODE_SHOW_COMPACTS_STMT,
463
  QUERY_NODE_SHOW_COMPACT_DETAILS_STMT,
464
  QUERY_NODE_SHOW_GRANTS_FULL_STMT,
465
  QUERY_NODE_SHOW_GRANTS_LOGS_STMT,
466
  QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT,
467
  QUERY_NODE_SHOW_ENCRYPTIONS_STMT,
468
  QUERY_NODE_SHOW_TSMAS_STMT,
469
  QUERY_NODE_SHOW_ANODES_STMT,
470
  QUERY_NODE_SHOW_ANODES_FULL_STMT,
471
  QUERY_NODE_SHOW_USAGE_STMT,
472
  QUERY_NODE_SHOW_FILESETS_STMT,
473
  QUERY_NODE_SHOW_TRANSACTION_DETAILS_STMT,
474
  QUERY_NODE_SHOW_VTABLES_STMT,
475
  QUERY_NODE_SHOW_BNODES_STMT,
476
  QUERY_NODE_SHOW_MOUNTS_STMT,
477

478
  // logic plan node
479
  QUERY_NODE_LOGIC_PLAN_SCAN = 1000,
480
  QUERY_NODE_LOGIC_PLAN_JOIN,
481
  QUERY_NODE_LOGIC_PLAN_AGG,
482
  QUERY_NODE_LOGIC_PLAN_PROJECT,
483
  QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY,
484
  QUERY_NODE_LOGIC_PLAN_EXCHANGE,
485
  QUERY_NODE_LOGIC_PLAN_MERGE,
486
  QUERY_NODE_LOGIC_PLAN_WINDOW,
487
  QUERY_NODE_LOGIC_PLAN_FILL,
488
  QUERY_NODE_LOGIC_PLAN_SORT,
489
  QUERY_NODE_LOGIC_PLAN_PARTITION,
490
  QUERY_NODE_LOGIC_PLAN_INDEF_ROWS_FUNC,
491
  QUERY_NODE_LOGIC_PLAN_INTERP_FUNC,
492
  QUERY_NODE_LOGIC_SUBPLAN,
493
  QUERY_NODE_LOGIC_PLAN,
494
  QUERY_NODE_LOGIC_PLAN_GROUP_CACHE,
495
  QUERY_NODE_LOGIC_PLAN_DYN_QUERY_CTRL,
496
  QUERY_NODE_LOGIC_PLAN_FORECAST_FUNC,
497
  QUERY_NODE_LOGIC_PLAN_VIRTUAL_TABLE_SCAN,
498

499
  // physical plan node
500
  QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN = 1100,
501
  QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN,
502
  QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN,  // INACTIVE
503
  QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN,
504
  QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN,
505
  QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN,
506
  QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN,
507
  QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN,
508
  QUERY_NODE_PHYSICAL_PLAN_PROJECT,
509
  QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN,
510
  QUERY_NODE_PHYSICAL_PLAN_HASH_AGG,
511
  QUERY_NODE_PHYSICAL_PLAN_EXCHANGE,
512
  QUERY_NODE_PHYSICAL_PLAN_MERGE,
×
513
  QUERY_NODE_PHYSICAL_PLAN_SORT,
×
514
  QUERY_NODE_PHYSICAL_PLAN_GROUP_SORT,
515
  QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL,
516
  QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL,  // INACTIVE
517
  QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL,
×
518
  QUERY_NODE_PHYSICAL_PLAN_FILL,
519
  QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION,
520
  QUERY_NODE_PHYSICAL_PLAN_MERGE_STATE,
126✔
521
  QUERY_NODE_PHYSICAL_PLAN_PARTITION,
126✔
522
  QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC,
126✔
523
  QUERY_NODE_PHYSICAL_PLAN_INTERP_FUNC,
524
  QUERY_NODE_PHYSICAL_PLAN_DISPATCH,
252✔
525
  QUERY_NODE_PHYSICAL_PLAN_INSERT,
126✔
526
  QUERY_NODE_PHYSICAL_PLAN_QUERY_INSERT,
126✔
527
  QUERY_NODE_PHYSICAL_PLAN_DELETE,
126✔
528
  QUERY_NODE_PHYSICAL_SUBPLAN,
126✔
529
  QUERY_NODE_PHYSICAL_PLAN,
126✔
530
  QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN,
531
  QUERY_NODE_PHYSICAL_PLAN_MERGE_EVENT,
126✔
532
  QUERY_NODE_PHYSICAL_PLAN_HASH_JOIN,
126✔
533
  QUERY_NODE_PHYSICAL_PLAN_GROUP_CACHE,
126✔
534
  QUERY_NODE_PHYSICAL_PLAN_DYN_QUERY_CTRL,
535
  QUERY_NODE_PHYSICAL_PLAN_MERGE_COUNT,
126✔
536
  QUERY_NODE_PHYSICAL_PLAN_MERGE_ANOMALY,
537
  QUERY_NODE_PHYSICAL_PLAN_FORECAST_FUNC,
538
  QUERY_NODE_PHYSICAL_PLAN_VIRTUAL_TABLE_SCAN,
180✔
539
  QUERY_NODE_PHYSICAL_PLAN_EXTERNAL_WINDOW,
540
  QUERY_NODE_PHYSICAL_PLAN_HASH_EXTERNAL,
180!
541
  QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_EXTERNAL,
×
542
  QUERY_NODE_PHYSICAL_PLAN_STREAM_INSERT,
×
543
} ENodeType;
544

545
typedef struct {
180✔
546
  int32_t     vgId;
180!
547
  uint8_t     option;         // 0x0 REQ_OPT_TBNAME, 0x01 REQ_OPT_TBUID
×
548
  uint8_t     autoCreateCtb;  // 0x0 not auto create, 0x01 auto create
549
  const char* dbFName;
180!
550
  const char* tbName;
×
551
} SBuildTableInput;
552

180!
553
typedef struct {
180!
554
  char    db[TSDB_DB_FNAME_LEN];
180!
555
  int64_t dbId;
180!
556
  int32_t vgVersion;
×
557
  int32_t numOfTable;  // unit is TSDB_TABLE_NUM_UNIT
×
558
  int64_t stateTs;
559
} SBuildUseDBInput;
180!
560

×
561
typedef struct SField {
×
562
  char    name[TSDB_COL_NAME_LEN];
563
  uint8_t type;
564
  int8_t  flags;
494✔
565
  int32_t bytes;
314✔
566
} SField;
567

314✔
568
typedef struct SFieldWithOptions {
569
  char     name[TSDB_COL_NAME_LEN];
314✔
570
  uint8_t  type;
314✔
571
  int8_t   flags;
314!
572
  int32_t  bytes;
×
573
  uint32_t compress;
574
  STypeMod typeMod;
575
} SFieldWithOptions;
314✔
576

314✔
577
typedef struct SRetention {
578
  int64_t freq;
180✔
579
  int64_t keep;
580
  int8_t  freqUnit;
581
  int8_t  keepUnit;
180✔
582
} SRetention;
180!
583

584
#define RETENTION_VALID(l, r) ((((l) == 0 && (r)->freq >= 0) || ((r)->freq > 0)) && ((r)->keep > 0))
×
585

586
#pragma pack(push, 1)
587
// null-terminated string instead of char array to avoid too many memory consumption in case of more than 1M tableMeta
180✔
588
typedef struct SEp {
589
  char     fqdn[TSDB_FQDN_LEN];
590
  uint16_t port;
218✔
591
} SEp;
218✔
592

218!
593
typedef struct {
×
594
  int32_t contLen;
595
  int32_t vgId;
218!
596
} SMsgHead;
597

218✔
598
// Submit message for one table
397✔
599
typedef struct SSubmitBlk {
179✔
600
  int64_t uid;        // table unique id
179!
601
  int64_t suid;       // stable id
×
602
  int32_t sversion;   // data schema version
603
  int32_t dataLen;    // data part length, not including the SSubmitBlk head
179✔
604
  int32_t schemaLen;  // schema length, if length is 0, no schema exists
179!
605
  int32_t numOfRows;  // total number of rows in current submit block
×
606
  char    data[];
607
} SSubmitBlk;
608

537✔
609
// Submit message for this TSDB
358✔
610
typedef struct {
358!
611
  SMsgHead header;
×
612
  int64_t  version;
×
613
  int32_t  length;
614
  int32_t  numOfBlocks;
358✔
615
  char     blocks[];
358✔
616
} SSubmitReq;
358✔
617

618
typedef struct {
358!
619
  int32_t totalLen;
×
620
  int32_t len;
×
621
  STSRow* row;
622
} SSubmitBlkIter;
623

624
typedef struct {
625
  int32_t totalLen;
218✔
626
  int32_t len;
218✔
627
  // head of SSubmitBlk
179!
628
  int64_t uid;        // table unique id
179✔
629
  int64_t suid;       // stable id
630
  int32_t sversion;   // data schema version
631
  int32_t dataLen;    // data part length, not including the SSubmitBlk head
39✔
632
  int32_t schemaLen;  // schema length, if length is 0, no schema exists
39!
633
  int32_t numOfRows;  // total number of rows in current submit block
×
634
  // head of SSubmitBlk
×
635
  int32_t     numOfBlocks;
636
  const void* pMsg;
637
} SSubmitMsgIter;
39✔
638

39!
639
int32_t tInitSubmitMsgIter(const SSubmitReq* pMsg, SSubmitMsgIter* pIter);
×
640
int32_t tGetSubmitMsgNext(SSubmitMsgIter* pIter, SSubmitBlk** pPBlock);
×
641
int32_t tInitSubmitBlkIter(SSubmitMsgIter* pMsgIter, SSubmitBlk* pBlock, SSubmitBlkIter* pIter);
642
STSRow* tGetSubmitBlkNext(SSubmitBlkIter* pIter);
39!
643
// for debug
×
644
int32_t tPrintFixedSchemaSubmitReq(SSubmitReq* pReq, STSchema* pSchema);
×
645

646
typedef struct {
647
  bool     hasRef;
39!
648
  col_id_t id;
649
  char     refDbName[TSDB_DB_NAME_LEN];
39✔
650
  char     refTableName[TSDB_TABLE_NAME_LEN];
651
  char     refColName[TSDB_COL_NAME_LEN];
218✔
652
} SColRef;
653

218✔
654
typedef struct {
655
  int32_t  nCols;
656
  int32_t  version;
×
657
  SColRef* pColRef;
×
658
} SColRefWrapper;
×
659

×
660
int32_t tEncodeSColRefWrapper(SEncoder *pCoder, const SColRefWrapper *pWrapper);
661
int32_t tDecodeSColRefWrapperEx(SDecoder *pDecoder, SColRefWrapper *pWrapper, bool decoderMalloc);
662
typedef struct {
×
663
  int32_t vgId;
×
664
  SColRef colRef;
×
665
} SColRefEx;
×
666

×
667
typedef struct {
×
668
  int16_t colId;
669
  char    refDbName[TSDB_DB_NAME_LEN];
×
670
  char    refTableName[TSDB_TABLE_NAME_LEN];
×
671
  char    refColName[TSDB_COL_NAME_LEN];
×
672
} SRefColInfo;
673

×
674
typedef struct SVCTableRefCols {
×
675
  uint64_t     uid;
676
  int32_t      numOfSrcTbls;
677
  int32_t      numOfColRefs;
×
678
  SRefColInfo* refCols;
×
679
} SVCTableRefCols;
×
680

×
681
typedef struct SVCTableMergeInfo {
682
  uint64_t uid;
683
  int32_t  numOfSrcTbls;
×
684
} SVCTableMergeInfo;
×
685

×
686
typedef struct {
×
687
  int32_t    nCols;
688
  SColRefEx* pColRefEx;
×
689
} SColRefExWrapper;
×
690

×
691
struct SSchema {
692
  int8_t   type;
693
  int8_t   flags;
×
694
  col_id_t colId;
695
  int32_t  bytes;
×
696
  char     name[TSDB_COL_NAME_LEN];
697
};
×
698
struct SSchemaExt {
699
  col_id_t colId;
×
700
  uint32_t compress;
701
  STypeMod typeMod;
702
};
91✔
703

91✔
704
//
91✔
705

91✔
706
struct SSchema2 {
707
  int8_t   type;
92✔
708
  int8_t   flags;
92✔
709
  col_id_t colId;
92✔
710
  int32_t  bytes;
92✔
711
  char     name[TSDB_COL_NAME_LEN];
92✔
712
  uint32_t compress;
713
};
92!
714

92✔
715
typedef struct {
716
  char        tbName[TSDB_TABLE_NAME_LEN];
92!
717
  char        stbName[TSDB_TABLE_NAME_LEN];
92✔
718
  char        dbFName[TSDB_DB_FNAME_LEN];
92!
719
  int64_t     dbId;
×
720
  int32_t     numOfTags;
×
721
  int32_t     numOfColumns;
722
  int8_t      precision;
92✔
723
  int8_t      tableType;
180✔
724
  int32_t     sversion;
88✔
725
  int32_t     tversion;
88!
726
  int32_t     rversion;
×
727
  uint64_t    suid;
728
  uint64_t    tuid;
729
  int32_t     vgId;
176!
730
  int8_t      sysInfo;
×
731
  SSchema*    pSchemas;
×
732
  SSchemaExt* pSchemaExt;
733
  int8_t      virtualStb;
734
  int32_t     numOfColRefs;
735
  SColRef*    pColRefs;
×
736
} STableMetaRsp;
737

×
738
typedef struct {
×
739
  int32_t        code;
×
740
  int64_t        uid;
×
741
  char*          tblFName;
×
742
  int32_t        numOfRows;
×
743
  int32_t        affectedRows;
×
744
  int64_t        sver;
745
  STableMetaRsp* pMeta;
746
} SSubmitBlkRsp;
×
747

×
748
typedef struct {
×
749
  int32_t numOfRows;
×
750
  int32_t affectedRows;
751
  int32_t nBlocks;
×
752
  union {
×
753
    SArray*        pArray;
×
754
    SSubmitBlkRsp* pBlocks;
×
755
  };
×
756
} SSubmitRsp;
×
757

×
758
// int32_t tEncodeSSubmitRsp(SEncoder* pEncoder, const SSubmitRsp* pRsp);
759
// int32_t tDecodeSSubmitRsp(SDecoder* pDecoder, SSubmitRsp* pRsp);
760
// void    tFreeSSubmitBlkRsp(void* param);
×
761
void tFreeSSubmitRsp(SSubmitRsp* pRsp);
×
762

×
763
#define COL_SMA_ON       ((int8_t)0x1)
764
#define COL_IDX_ON       ((int8_t)0x2)
765
#define COL_IS_KEY       ((int8_t)0x4)
×
766
#define COL_SET_NULL     ((int8_t)0x10)
×
767
#define COL_SET_VAL      ((int8_t)0x20)
×
768
#define COL_IS_SYSINFO   ((int8_t)0x40)
769
#define COL_HAS_TYPE_MOD ((int8_t)0x80)
770
#define COL_REF_BY_STM   ((int8_t)0x08)
771

772
#define COL_IS_SET(FLG)  (((FLG) & (COL_SET_VAL | COL_SET_NULL)) != 0)
773
#define COL_CLR_SET(FLG) ((FLG) &= (~(COL_SET_VAL | COL_SET_NULL)))
92✔
774

92✔
775
#define IS_BSMA_ON(s)  (((s)->flags & 0x01) == COL_SMA_ON)
776
#define IS_IDX_ON(s)   (((s)->flags & 0x02) == COL_IDX_ON)
×
777
#define IS_SET_NULL(s) (((s)->flags & COL_SET_NULL) == COL_SET_NULL)
778

×
779
#define SSCHMEA_SET_IDX_ON(s) \
×
780
  do {                        \
×
781
    (s)->flags |= COL_IDX_ON; \
×
782
  } while (0)
783

×
784
#define SSCHMEA_SET_IDX_OFF(s)   \
×
785
  do {                           \
×
786
    (s)->flags &= (~COL_IDX_ON); \
×
787
  } while (0)
788

789
#define SSCHEMA_SET_TYPE_MOD(s)     \
790
  do {                              \
×
791
    (s)->flags |= COL_HAS_TYPE_MOD; \
×
792
  } while (0)
×
793

×
794
#define HAS_TYPE_MOD(s) (((s)->flags & COL_HAS_TYPE_MOD))
×
795

×
796
#define SSCHMEA_TYPE(s)  ((s)->type)
×
797
#define SSCHMEA_FLAGS(s) ((s)->flags)
798
#define SSCHMEA_COLID(s) ((s)->colId)
799
#define SSCHMEA_BYTES(s) ((s)->bytes)
×
800
#define SSCHMEA_NAME(s)  ((s)->name)
801

802
typedef struct {
×
803
  bool    tsEnableMonitor;
×
804
  int32_t tsMonitorInterval;
805
  int32_t tsSlowLogThreshold;
×
806
  int32_t tsSlowLogMaxLen;
×
807
  int32_t tsSlowLogScope;
×
808
  int32_t tsSlowLogThresholdTest;  // Obsolete
809
  char    tsSlowLogExceptDb[TSDB_DB_NAME_LEN];
810
} SMonitorParas;
92✔
811

92✔
812
typedef struct {
92✔
813
  STypeMod typeMod;
814
} SExtSchema;
92✔
815

816
bool hasExtSchema(const SExtSchema* pExtSchema);
817

126✔
818
typedef struct {
126✔
819
  int32_t  nCols;
126✔
820
  int32_t  version;
126✔
821
  SSchema* pSchema;
822
} SSchemaWrapper;
126!
823

126✔
824
typedef struct {
825
  col_id_t id;
126✔
826
  uint32_t alg;
126✔
827
} SColCmpr;
91✔
828

91✔
829
typedef struct {
91✔
830
  int32_t   nCols;
91!
831
  int32_t   version;
×
832
  SColCmpr* pColCmpr;
833
} SColCmprWrapper;
834

91✔
835
static FORCE_INLINE int32_t tInitDefaultSColRefWrapperByCols(SColRefWrapper* pRef, int32_t nCols) {
91!
836
  if (pRef->pColRef) {
346!
837
    return TSDB_CODE_INVALID_PARA;
×
838
  }
839
  pRef->pColRef = (SColRef*)taosMemoryCalloc(nCols, sizeof(SColRef));
437!
840
  if (pRef->pColRef == NULL) {
528!
841
    return terrno;
91✔
842
  }
91✔
843
  pRef->nCols = nCols;
437✔
844
  for (int32_t i = 0; i < nCols; i++) {
4,536✔
845
    pRef->pColRef[i].hasRef = false;
4,190✔
846
    pRef->pColRef[i].id = (col_id_t)(i + 1);
4,099✔
847
  }
848
  return 0;
437✔
849
}
91!
850

×
851
static FORCE_INLINE SColCmprWrapper* tCloneSColCmprWrapper(const SColCmprWrapper* pSrcWrapper) {
852
  if (pSrcWrapper->pColCmpr == NULL || pSrcWrapper->nCols == 0) {
853
    terrno = TSDB_CODE_INVALID_PARA;
91!
854
    return NULL;
×
855
  }
×
856

857
  SColCmprWrapper* pDstWrapper = (SColCmprWrapper*)taosMemoryMalloc(sizeof(SColCmprWrapper));
858
  if (pDstWrapper == NULL) {
859
    return NULL;
860
  }
126✔
861
  pDstWrapper->nCols = pSrcWrapper->nCols;
126✔
862
  pDstWrapper->version = pSrcWrapper->version;
863

×
864
  int32_t size = sizeof(SColCmpr) * pDstWrapper->nCols;
865
  pDstWrapper->pColCmpr = (SColCmpr*)taosMemoryCalloc(1, size);
×
866
  if (pDstWrapper->pColCmpr == NULL) {
867
    taosMemoryFree(pDstWrapper);
×
868
    return NULL;
×
869
  }
870
  (void)memcpy(pDstWrapper->pColCmpr, pSrcWrapper->pColCmpr, size);
×
871

×
872
  return pDstWrapper;
×
873
}
874

875
static FORCE_INLINE int32_t tInitDefaultSColCmprWrapperByCols(SColCmprWrapper* pCmpr, int32_t nCols) {
126✔
876
  if (!(!pCmpr->pColCmpr)) {
13,664!
877
    return TSDB_CODE_INVALID_PARA;
126✔
878
  }
126✔
879
  pCmpr->pColCmpr = (SColCmpr*)taosMemoryCalloc(nCols, sizeof(SColCmpr));
13,664!
880
  if (pCmpr->pColCmpr == NULL) {
13,790!
881
    return terrno;
×
882
  }
883
  pCmpr->nCols = nCols;
13,790✔
884
  return 0;
13,790✔
885
}
886

126✔
887
static FORCE_INLINE int32_t tInitDefaultSColCmprWrapper(SColCmprWrapper* pCmpr, SSchemaWrapper* pSchema) {
126✔
888
  pCmpr->nCols = pSchema->nCols;
126✔
889
  if (!(!pCmpr->pColCmpr)) {
126✔
890
    return TSDB_CODE_INVALID_PARA;
252✔
891
  }
892
  pCmpr->pColCmpr = (SColCmpr*)taosMemoryCalloc(pCmpr->nCols, sizeof(SColCmpr));
126✔
893
  if (pCmpr->pColCmpr == NULL) {
894
    return terrno;
895
  }
896
  for (int32_t i = 0; i < pCmpr->nCols; i++) {
126✔
897
    SColCmpr* pColCmpr = &pCmpr->pColCmpr[i];
126✔
898
    SSchema*  pColSchema = &pSchema->pSchema[i];
899
    pColCmpr->id = pColSchema->colId;
900
    pColCmpr->alg = 0;
901
  }
126✔
902
  return 0;
903
}
126✔
904

126✔
905
static FORCE_INLINE void tDeleteSColCmprWrapper(SColCmprWrapper* pWrapper) {
906
  if (pWrapper == NULL) return;
907

126✔
908
  taosMemoryFreeClear(pWrapper->pColCmpr);
909
  taosMemoryFreeClear(pWrapper);
126✔
910
}
126✔
911
static FORCE_INLINE SSchemaWrapper* tCloneSSchemaWrapper(const SSchemaWrapper* pSchemaWrapper) {
912
  if (pSchemaWrapper->pSchema == NULL) return NULL;
8,654,691!
913

×
914
  SSchemaWrapper* pSW = (SSchemaWrapper*)taosMemoryMalloc(sizeof(SSchemaWrapper));
8,654,565!
915
  if (pSW == NULL) {
8,651,952!
916
    return NULL;
×
917
  }
×
918
  pSW->nCols = pSchemaWrapper->nCols;
8,651,952✔
919
  pSW->version = pSchemaWrapper->version;
8,651,952✔
920
  pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema));
8,652,078!
921
  if (pSW->pSchema == NULL) {
8,653,614!
922
    taosMemoryFree(pSW);
121!
923
    return NULL;
121!
924
  }
121✔
925

121✔
926
  (void)memcpy(pSW->pSchema, pSchemaWrapper->pSchema, pSW->nCols * sizeof(SSchema));
8,653,730✔
927
  return pSW;
8,653,609✔
928
}
929

121✔
930
static FORCE_INLINE void tDeleteSchemaWrapper(SSchemaWrapper* pSchemaWrapper) {
583,830✔
931
  if (pSchemaWrapper) {
845,110!
932
    taosMemoryFree(pSchemaWrapper->pSchema);
608,627!
933
    taosMemoryFree(pSchemaWrapper);
608,669!
934
  }
126✔
935
}
727,576✔
936

937
static FORCE_INLINE void tDeleteSSchemaWrapperForHash(void* pSchemaWrapper) {
179✔
938
  if (pSchemaWrapper != NULL && *(SSchemaWrapper**)pSchemaWrapper != NULL) {
179✔
939
    taosMemoryFree((*(SSchemaWrapper**)pSchemaWrapper)->pSchema);
179✔
940
    taosMemoryFree(*(SSchemaWrapper**)pSchemaWrapper);
179✔
941
  }
102✔
942
}
943

944
static FORCE_INLINE int32_t taosEncodeSSchema(void** buf, const SSchema* pSchema) {
77✔
945
  int32_t tlen = 0;
63,342✔
946
  tlen += taosEncodeFixedI8(buf, pSchema->type);
126,383✔
947
  tlen += taosEncodeFixedI8(buf, pSchema->flags);
63,265!
948
  tlen += taosEncodeFixedI32(buf, pSchema->bytes);
63,177!
949
  tlen += taosEncodeFixedI16(buf, pSchema->colId);
63,118!
950
  tlen += taosEncodeString(buf, pSchema->name);
63,118✔
951
  return tlen;
63,118✔
952
}
77✔
953

954
static FORCE_INLINE void* taosDecodeSSchema(const void* buf, SSchema* pSchema) {
955
  buf = taosDecodeFixedI8(buf, &pSchema->type);
59,308✔
956
  buf = taosDecodeFixedI8(buf, &pSchema->flags);
29,697✔
957
  buf = taosDecodeFixedI32(buf, &pSchema->bytes);
29,697!
958
  buf = taosDecodeFixedI16(buf, &pSchema->colId);
29,697!
959
  buf = taosDecodeStringTo(buf, pSchema->name);
29,697✔
960
  return (void*)buf;
29,697!
961
}
×
962

963
static FORCE_INLINE int32_t tEncodeSSchema(SEncoder* pEncoder, const SSchema* pSchema) {
964
  TAOS_CHECK_RETURN(tEncodeI8(pEncoder, pSchema->type));
1,322,345,742!
965
  TAOS_CHECK_RETURN(tEncodeI8(pEncoder, pSchema->flags));
1,378,825,148!
966
  TAOS_CHECK_RETURN(tEncodeI32v(pEncoder, pSchema->bytes));
1,378,825,062!
967
  TAOS_CHECK_RETURN(tEncodeI16v(pEncoder, pSchema->colId));
1,378,825,062!
968
  TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pSchema->name));
1,378,825,062!
969
  return 0;
689,412,710✔
970
}
93✔
971

93!
972
static FORCE_INLINE int32_t tDecodeSSchema(SDecoder* pDecoder, SSchema* pSchema) {
×
973
  TAOS_CHECK_RETURN(tDecodeI8(pDecoder, &pSchema->type));
1,370,055,854!
974
  TAOS_CHECK_RETURN(tDecodeI8(pDecoder, &pSchema->flags));
2,147,483,647!
975
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pSchema->bytes));
2,147,483,647!
976
  TAOS_CHECK_RETURN(tDecodeI16v(pDecoder, &pSchema->colId));
2,147,483,647!
977
  TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, pSchema->name));
1,358,317,410!
978
  return 0;
1,454,744,114✔
979
}
×
980

981
static FORCE_INLINE int32_t tEncodeSSchemaExt(SEncoder* pEncoder, const SSchemaExt* pSchemaExt) {
982
  TAOS_CHECK_RETURN(tEncodeI16v(pEncoder, pSchemaExt->colId));
797,616,258!
983
  TAOS_CHECK_RETURN(tEncodeU32(pEncoder, pSchemaExt->compress));
797,616,344!
984
  TAOS_CHECK_RETURN(tEncodeI32(pEncoder, pSchemaExt->typeMod));
797,616,344!
985
  return 0;
398,808,215✔
986
}
987

988
static FORCE_INLINE int32_t tDecodeSSchemaExt(SDecoder* pDecoder, SSchemaExt* pSchemaExt) {
86✔
989
  TAOS_CHECK_RETURN(tDecodeI16v(pDecoder, &pSchemaExt->colId));
7,224,511!
990
  TAOS_CHECK_RETURN(tDecodeU32(pDecoder, &pSchemaExt->compress));
7,224,580!
991
  TAOS_CHECK_RETURN(tDecodeI32(pDecoder, &pSchemaExt->typeMod));
7,224,472!
992
  return 0;
3,612,313✔
993
}
86✔
994

995
static FORCE_INLINE int32_t tEncodeSColRef(SEncoder* pEncoder, const SColRef* pColRef) {
996
  TAOS_CHECK_RETURN(tEncodeI8(pEncoder, pColRef->hasRef));
29,911!
997
  TAOS_CHECK_RETURN(tEncodeI16(pEncoder, pColRef->id));
29,911!
998
  if (pColRef->hasRef) {
14,954✔
999
    TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pColRef->refDbName));
17,040!
1000
    TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pColRef->refTableName));
17,712!
1001
    TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pColRef->refColName));
17,712!
1002
  }
1003
  return 0;
14,954✔
1004
}
594✔
1005

594✔
1006
static FORCE_INLINE int32_t tDecodeSColRef(SDecoder* pDecoder, SColRef* pColRef) {
11✔
1007
  TAOS_CHECK_RETURN(tDecodeI8(pDecoder, (int8_t*)&pColRef->hasRef));
22,358!
1008
  TAOS_CHECK_RETURN(tDecodeI16(pDecoder, &pColRef->id));
22,358!
1009
  if (pColRef->hasRef) {
11,762✔
1010
    TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, pColRef->refDbName));
7,518!
1011
    TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, pColRef->refTableName));
6,935!
1012
    TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, pColRef->refColName));
7,518!
1013
  }
583!
1014

×
1015
  return 0;
11,179✔
1016
}
1017

583✔
1018
static FORCE_INLINE int32_t taosEncodeSSchemaWrapper(void** buf, const SSchemaWrapper* pSW) {
583✔
1019
  int32_t tlen = 0;
9,366✔
1020
  tlen += taosEncodeVariantI32(buf, pSW->nCols);
9,949!
1021
  tlen += taosEncodeVariantI32(buf, pSW->version);
9,366✔
1022
  for (int32_t i = 0; i < pSW->nCols; i++) {
72,484✔
1023
    tlen += taosEncodeSSchema(buf, &pSW->pSchema[i]);
126,236!
1024
  }
×
1025
  return tlen;
9,366✔
1026
}
318✔
1027

318✔
1028
static FORCE_INLINE void* taosDecodeSSchemaWrapper(const void* buf, SSchemaWrapper* pSW) {
318✔
1029
  buf = taosDecodeVariantI32(buf, &pSW->nCols);
5,270✔
1030
  buf = taosDecodeVariantI32(buf, &pSW->version);
4,952✔
1031
  if (pSW->nCols > 0) {
4,384✔
1032
    pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema));
3,731!
1033
    if (pSW->pSchema == NULL) {
3,163!
1034
      return NULL;
318✔
1035
    }
1036

×
1037
    for (int32_t i = 0; i < pSW->nCols; i++) {
32,774✔
1038
      buf = taosDecodeSSchema(buf, &pSW->pSchema[i]);
59,222✔
1039
    }
1040
  } else {
179✔
1041
    pSW->pSchema = NULL;
1,400✔
1042
  }
1043
  return (void*)buf;
4,563✔
1044
}
179✔
1045

1046
static FORCE_INLINE int32_t tEncodeSSchemaWrapper(SEncoder* pEncoder, const SSchemaWrapper* pSW) {
86✔
1047
  if (pSW == NULL) {
731,891!
1048
    return TSDB_CODE_INVALID_PARA;
86✔
1049
  }
86✔
1050
  TAOS_CHECK_RETURN(tEncodeI32v(pEncoder, pSW->nCols));
1,463,782!
1051
  TAOS_CHECK_RETURN(tEncodeI32v(pEncoder, pSW->version));
1,463,782!
1052
  for (int32_t i = 0; i < pSW->nCols; i++) {
57,211,297!
1053
    TAOS_CHECK_RETURN(tEncodeSSchema(pEncoder, &pSW->pSchema[i]));
112,958,812!
1054
  }
×
1055
  return 0;
731,891✔
1056
}
1057

583✔
1058
static FORCE_INLINE int32_t tDecodeSSchemaWrapper(SDecoder* pDecoder, SSchemaWrapper* pSW) {
1059
  if (pSW == NULL) {
672,971!
1060
    return TSDB_CODE_INVALID_PARA;
451✔
1061
  }
451!
1062
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pSW->nCols));
1,345,934!
1063
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pSW->version));
1,345,888!
1064

×
1065
  pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema));
672,925✔
1066
  if (pSW->pSchema == NULL) {
673,044!
1067
    TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
×
1068
  }
×
1069
  for (int32_t i = 0; i < pSW->nCols; i++) {
9,226,197✔
1070
    TAOS_CHECK_RETURN(tDecodeSSchema(pDecoder, &pSW->pSchema[i]));
17,106,647!
1071
  }
×
1072

1073
  return 0;
672,703✔
1074
}
×
1075

×
1076
static FORCE_INLINE int32_t tDecodeSSchemaWrapperEx(SDecoder* pDecoder, SSchemaWrapper* pSW) {
1077
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pSW->nCols));
151,998,514!
1078
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pSW->version));
157,115,108!
1079

×
1080
  pSW->pSchema = (SSchema*)tDecoderMalloc(pDecoder, pSW->nCols * sizeof(SSchema));
78,531,522!
1081
  if (pSW->pSchema == NULL) {
79,005,835!
1082
    TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
3✔
1083
  }
3!
1084
  for (int32_t i = 0; i < pSW->nCols; i++) {
1,520,917,291!
1085
    TAOS_CHECK_RETURN(tDecodeSSchema(pDecoder, &pSW->pSchema[i]));
2,147,483,647!
1086
  }
3✔
1087

1088
  return 0;
75,225,456✔
1089
}
×
1090

×
1091
typedef struct {
×
1092
  char     name[TSDB_TABLE_FNAME_LEN];
1093
  int8_t   igExists;
×
1094
  int8_t   source;  // TD_REQ_FROM_TAOX-taosX or TD_REQ_FROM_APP-taosClient
×
1095
  int8_t   reserved[6];
×
1096
  tb_uid_t suid;
1097
  int64_t  delay1;
×
1098
  int64_t  delay2;
1099
  int64_t  watermark1;
1100
  int64_t  watermark2;
1101
  int32_t  ttl;
1102
  int32_t  colVer;
×
1103
  int32_t  tagVer;
×
1104
  int32_t  numOfColumns;
×
1105
  int32_t  numOfTags;
×
1106
  int32_t  numOfFuncs;
1107
  int32_t  commentLen;
×
1108
  int32_t  ast1Len;
×
1109
  int32_t  ast2Len;
×
1110
  SArray*  pColumns;  // array of SFieldWithOptions
1111
  SArray*  pTags;     // array of SField
1112
  SArray*  pFuncs;
×
1113
  char*    pComment;
×
1114
  char*    pAst1;
×
1115
  char*    pAst2;
×
1116
  int64_t  deleteMark1;
×
1117
  int64_t  deleteMark2;
×
1118
  int32_t  sqlLen;
1119
  char*    sql;
1120
  int64_t  keep;
1121
  int8_t   virtualStb;
×
1122
} SMCreateStbReq;
×
1123

×
1124
int32_t tSerializeSMCreateStbReq(void* buf, int32_t bufLen, SMCreateStbReq* pReq);
×
1125
int32_t tDeserializeSMCreateStbReq(void* buf, int32_t bufLen, SMCreateStbReq* pReq);
1126
void    tFreeSMCreateStbReq(SMCreateStbReq* pReq);
1127

×
1128
typedef struct {
×
1129
  STableMetaRsp* pMeta;
×
1130
} SMCreateStbRsp;
×
1131

×
1132
int32_t tEncodeSMCreateStbRsp(SEncoder* pEncoder, const SMCreateStbRsp* pRsp);
×
1133
int32_t tDecodeSMCreateStbRsp(SDecoder* pDecoder, SMCreateStbRsp* pRsp);
1134
void    tFreeSMCreateStbRsp(SMCreateStbRsp* pRsp);
×
1135

×
1136
typedef struct {
×
1137
  char     name[TSDB_TABLE_FNAME_LEN];
1138
  int8_t   igNotExists;
1139
  int8_t   source;  // TD_REQ_FROM_TAOX-taosX or TD_REQ_FROM_APP-taosClient
×
1140
  int8_t   reserved[6];
×
1141
  tb_uid_t suid;
×
1142
  int32_t  sqlLen;
×
1143
  char*    sql;
×
1144
} SMDropStbReq;
×
1145

1146
int32_t tSerializeSMDropStbReq(void* buf, int32_t bufLen, SMDropStbReq* pReq);
1147
int32_t tDeserializeSMDropStbReq(void* buf, int32_t bufLen, SMDropStbReq* pReq);
1148
void    tFreeSMDropStbReq(SMDropStbReq* pReq);
×
1149

1150
typedef struct {
1151
  char    name[TSDB_TABLE_FNAME_LEN];
1152
  int8_t  alterType;
×
1153
  int32_t numOfFields;
×
1154
  SArray* pFields;
1155
  int32_t ttl;
×
1156
  int32_t commentLen;
×
1157
  char*   comment;
1158
  int32_t sqlLen;
1159
  char*   sql;
×
1160
  int64_t keep;
×
1161
  SArray* pTypeMods;
×
1162
} SMAlterStbReq;
×
1163

×
1164
int32_t tSerializeSMAlterStbReq(void* buf, int32_t bufLen, SMAlterStbReq* pReq);
1165
int32_t tDeserializeSMAlterStbReq(void* buf, int32_t bufLen, SMAlterStbReq* pReq);
1166
void    tFreeSMAltertbReq(SMAlterStbReq* pReq);
×
1167

×
1168
typedef struct SEpSet {
×
1169
  int8_t inUse;
×
1170
  int8_t numOfEps;
1171
  SEp    eps[TSDB_MAX_REPLICA];
×
1172
} SEpSet;
×
1173

1174
int32_t tEncodeSEpSet(SEncoder* pEncoder, const SEpSet* pEp);
1175
int32_t tDecodeSEpSet(SDecoder* pDecoder, SEpSet* pEp);
×
1176
int32_t taosEncodeSEpSet(void** buf, const SEpSet* pEp);
×
1177
void*   taosDecodeSEpSet(const void* buf, SEpSet* pEp);
×
1178

×
1179
int32_t tSerializeSEpSet(void* buf, int32_t bufLen, const SEpSet* pEpset);
1180
int32_t tDeserializeSEpSet(void* buf, int32_t buflen, SEpSet* pEpset);
×
1181

1182
typedef struct {
1183
  int8_t  connType;
1184
  int32_t pid;
×
1185
  char    app[TSDB_APP_NAME_LEN];
1186
  char    db[TSDB_DB_NAME_LEN];
1187
  char    user[TSDB_USER_LEN];
×
1188
  char    passwd[TSDB_PASSWORD_LEN];
×
1189
  int64_t startTime;
×
1190
  char    sVer[TSDB_VERSION_LEN];
×
1191
} SConnectReq;
×
1192

1193
int32_t tSerializeSConnectReq(void* buf, int32_t bufLen, SConnectReq* pReq);
1194
int32_t tDeserializeSConnectReq(void* buf, int32_t bufLen, SConnectReq* pReq);
×
1195

×
1196
typedef struct {
×
1197
  int32_t       acctId;
×
1198
  int64_t       clusterId;
1199
  uint32_t      connId;
×
1200
  int32_t       dnodeNum;
1201
  int8_t        superUser;
1202
  int8_t        sysInfo;
1203
  int8_t        connType;
1204
  SEpSet        epSet;
1205
  int32_t       svrTimestamp;
468✔
1206
  int32_t       passVer;
468✔
1207
  int32_t       authVer;
468✔
1208
  char          sVer[TSDB_VERSION_LEN];
468✔
1209
  char          sDetailVer[128];
1210
  int64_t       whiteListVer;
468✔
1211
  SMonitorParas monitorParas;
468!
1212
  int8_t        enableAuditDelete;
468✔
1213
} SConnectRsp;
468✔
1214

1215
int32_t tSerializeSConnectRsp(void* buf, int32_t bufLen, SConnectRsp* pRsp);
1216
int32_t tDeserializeSConnectRsp(void* buf, int32_t bufLen, SConnectRsp* pRsp);
468✔
1217

468!
1218
typedef struct {
376!
1219
  char    user[TSDB_USER_LEN];
376✔
1220
  char    pass[TSDB_PASSWORD_LEN];
1221
  int32_t maxUsers;
1222
  int32_t maxDbs;
376✔
1223
  int32_t maxTimeSeries;
58✔
1224
  int32_t maxStreams;
58✔
1225
  int32_t accessState;  // Configured only by command
1226
  int64_t maxStorage;
1227
} SCreateAcctReq, SAlterAcctReq;
376✔
1228

1229
// int32_t tSerializeSCreateAcctReq(void* buf, int32_t bufLen, SCreateAcctReq* pReq);
1230
// int32_t tDeserializeSCreateAcctReq(void* buf, int32_t bufLen, SCreateAcctReq* pReq);
468!
1231

468!
1232
typedef struct {
1233
  char    user[TSDB_USER_LEN];
1234
  int32_t sqlLen;
468!
1235
  char*   sql;
×
1236
} SDropUserReq, SDropAcctReq;
1237

×
1238
int32_t tSerializeSDropUserReq(void* buf, int32_t bufLen, SDropUserReq* pReq);
×
1239
int32_t tDeserializeSDropUserReq(void* buf, int32_t bufLen, SDropUserReq* pReq);
1240
void    tFreeSDropUserReq(SDropUserReq* pReq);
×
1241

×
1242
typedef struct SIpV4Range {
1243
  uint32_t ip;
1244
  uint32_t mask;
468!
1245
} SIpV4Range;
468!
1246

×
1247
typedef struct SIpv6Range {
×
1248
  uint64_t addr[2];
1249
  uint32_t mask;
1250
} SIpV6Range;
1251

468✔
1252
typedef struct {
468✔
1253
  int8_t type;
468!
1254
  union {
×
1255
    SIpV4Range ipV4;
1256
    SIpV6Range ipV6;
1257
  };
919!
1258
} SIpRange;
451✔
1259

×
1260
typedef struct {
×
1261
  int32_t    num;
1262
  SIpV4Range pIpRange[];
1263
} SIpWhiteList;
468!
1264

×
1265
typedef struct {
1266
  int32_t  num;
468✔
1267
  SIpRange pIpRanges[];
468✔
1268
} SIpWhiteListDual;
1269

1270
SIpWhiteListDual* cloneIpWhiteList(SIpWhiteListDual* pIpWhiteList);
468✔
1271
int32_t           cvtIpWhiteListToDual(SIpWhiteList* pWhiteList, SIpWhiteListDual** pWhiteListDual);
1272
int32_t           cvtIpWhiteListDualToV4(SIpWhiteListDual* pWhiteListDual, SIpWhiteList** pWhiteList);
1273
int32_t           createDefaultIp6Range(SIpRange* pRange);
1274
int32_t           createDefaultIp4Range(SIpRange* pRange);
126✔
1275

126✔
1276
typedef struct {
126✔
1277
  int8_t  createType;
1278
  int8_t  superUser;  // denote if it is a super user or not
126!
1279
  int8_t  sysInfo;
126✔
1280
  int8_t  enable;
1281
  char    user[TSDB_USER_LEN];
1282
  char    pass[TSDB_USET_PASSWORD_LEN];
126!
1283
  int32_t numIpRanges;
126✔
1284

126✔
1285
  SIpV4Range* pIpRanges;
126✔
1286
  int32_t     sqlLen;
121✔
1287
  char*       sql;
5!
1288
  int8_t      isImport;
5✔
1289
  int8_t      createDb;
1290
  int8_t      passIsMd5;
1291
  SIpRange*   pIpDualRanges;
1292
} SCreateUserReq;
126✔
1293

126!
1294
int32_t tSerializeSCreateUserReq(void* buf, int32_t bufLen, SCreateUserReq* pReq);
×
1295
int32_t tDeserializeSCreateUserReq(void* buf, int32_t bufLen, SCreateUserReq* pReq);
×
1296
void    tFreeSCreateUserReq(SCreateUserReq* pReq);
×
1297

×
1298
typedef struct {
×
1299
  int32_t dnodeId;
1300
  int64_t analVer;
×
1301
} SRetrieveAnalyticsAlgoReq;
1302

1303
typedef struct {
×
1304
  int64_t   ver;
×
1305
  SHashObj* hash;  // algoname:algotype -> SAnalUrl
×
1306
} SRetrieveAnalyticAlgoRsp;
×
1307

1308
int32_t tSerializeRetrieveAnalyticAlgoReq(void* buf, int32_t bufLen, SRetrieveAnalyticsAlgoReq* pReq);
×
1309
int32_t tDeserializeRetrieveAnalyticAlgoReq(void* buf, int32_t bufLen, SRetrieveAnalyticsAlgoReq* pReq);
126✔
1310
int32_t tSerializeRetrieveAnalyticAlgoRsp(void* buf, int32_t bufLen, SRetrieveAnalyticAlgoRsp* pRsp);
126✔
1311
int32_t tDeserializeRetrieveAnalyticAlgoRsp(void* buf, int32_t bufLen, SRetrieveAnalyticAlgoRsp* pRsp);
126!
1312
void    tFreeRetrieveAnalyticAlgoRsp(SRetrieveAnalyticAlgoRsp* pRsp);
×
1313

×
1314
typedef struct {
1315
  int8_t alterType;
126✔
1316
  int8_t superUser;
126✔
1317
  int8_t sysInfo;
126!
1318
  int8_t enable;
126✔
1319
  int8_t isView;
126!
1320
  union {
126✔
1321
    uint8_t flag;
126✔
1322
    struct {
126!
1323
      uint8_t createdb : 1;
126✔
1324
      uint8_t reserve : 7;
1325
    };
126✔
1326
  };
1327
  char        user[TSDB_USER_LEN];
1328
  char        pass[TSDB_USET_PASSWORD_LEN];
126✔
1329
  char        objname[TSDB_DB_FNAME_LEN];  // db or topic
126✔
1330
  char        tabName[TSDB_TABLE_NAME_LEN];
1331
  char*       tagCond;
×
1332
  int32_t     tagCondLen;
×
1333
  int32_t     numIpRanges;
×
1334
  SIpV4Range* pIpRanges;
×
1335
  int64_t     privileges;
×
1336
  int32_t     sqlLen;
1337
  char*       sql;
1338
  int8_t      passIsMd5;
126!
1339
  SIpRange*   pIpDualRanges;
×
1340
} SAlterUserReq;
1341

1342
int32_t tSerializeSAlterUserReq(void* buf, int32_t bufLen, SAlterUserReq* pReq);
126!
1343
int32_t tDeserializeSAlterUserReq(void* buf, int32_t bufLen, SAlterUserReq* pReq);
×
1344
void    tFreeSAlterUserReq(SAlterUserReq* pReq);
×
1345

×
1346
typedef struct {
1347
  char user[TSDB_USER_LEN];
1348
} SGetUserAuthReq;
1349

1350
int32_t tSerializeSGetUserAuthReq(void* buf, int32_t bufLen, SGetUserAuthReq* pReq);
126!
1351
int32_t tDeserializeSGetUserAuthReq(void* buf, int32_t bufLen, SGetUserAuthReq* pReq);
126✔
1352

1353
typedef struct {
1354
  char      user[TSDB_USER_LEN];
126!
1355
  int32_t   version;
×
1356
  int32_t   passVer;
1357
  int8_t    superAuth;
1358
  int8_t    sysInfo;
126!
1359
  int8_t    enable;
×
1360
  int8_t    dropped;
×
1361
  SHashObj* createdDbs;
1362
  SHashObj* readDbs;
126✔
1363
  SHashObj* writeDbs;
1364
  SHashObj* readTbs;
468✔
1365
  SHashObj* writeTbs;
1366
  SHashObj* alterTbs;
468✔
1367
  SHashObj* readViews;
468✔
1368
  SHashObj* writeViews;
468✔
1369
  SHashObj* alterViews;
468✔
1370
  SHashObj* useDbs;
468✔
1371
  int64_t   whiteListVer;
1372
} SGetUserAuthRsp;
468!
1373

468✔
1374
int32_t tSerializeSGetUserAuthRsp(void* buf, int32_t bufLen, SGetUserAuthRsp* pRsp);
468!
1375
int32_t tDeserializeSGetUserAuthRsp(void* buf, int32_t bufLen, SGetUserAuthRsp* pRsp);
×
1376
void    tFreeSGetUserAuthRsp(SGetUserAuthRsp* pRsp);
1377

936✔
1378
int32_t tSerializeIpRange(SEncoder* encoder, SIpRange* pRange);
468✔
1379
int32_t tDeserializeIpRange(SDecoder* decoder, SIpRange* pRange);
468✔
1380
typedef struct {
468✔
1381
  int64_t ver;
468✔
1382
  char    user[TSDB_USER_LEN];
468✔
1383
  int32_t numOfRange;
468✔
1384
  union {
468✔
1385
    SIpV4Range* pIpRanges;
1386
    SIpRange*   pIpDualRanges;
468✔
1387
  };
468✔
1388
} SUpdateUserIpWhite;
468✔
1389

468✔
1390
typedef struct {
468!
1391
  int64_t             ver;
468✔
1392
  int                 numOfUser;
1393
  SUpdateUserIpWhite* pUserIpWhite;
468!
1394
} SUpdateIpWhite;
×
1395

1396
int32_t tSerializeSUpdateIpWhite(void* buf, int32_t bufLen, SUpdateIpWhite* pReq);
1397
int32_t tDeserializeSUpdateIpWhite(void* buf, int32_t bufLen, SUpdateIpWhite* pReq);
468✔
1398
void    tFreeSUpdateIpWhiteReq(SUpdateIpWhite* pReq);
468✔
1399
int32_t cloneSUpdateIpWhiteReq(SUpdateIpWhite* pReq, SUpdateIpWhite** pUpdate);
1400

1401
int32_t tSerializeSUpdateIpWhiteDual(void* buf, int32_t bufLen, SUpdateIpWhite* pReq);
1402
int32_t tDeserializeSUpdateIpWhiteDual(void* buf, int32_t bufLen, SUpdateIpWhite* pReq);
468✔
1403
void    tFreeSUpdateIpWhiteDualReq(SUpdateIpWhite* pReq);
468✔
1404

1405
typedef struct {
936!
1406
  int64_t ipWhiteVer;
468✔
1407
} SRetrieveIpWhiteReq;
468✔
1408

92✔
1409
int32_t tSerializeRetrieveIpWhite(void* buf, int32_t bufLen, SRetrieveIpWhiteReq* pReq);
1410
int32_t tDeserializeRetrieveIpWhite(void* buf, int32_t bufLen, SRetrieveIpWhiteReq* pReq);
1411
typedef struct {
468✔
1412
  char user[TSDB_USER_LEN];
468✔
1413
} SGetUserWhiteListReq;
468✔
1414

936✔
1415
int32_t tSerializeSGetUserWhiteListReq(void* buf, int32_t bufLen, SGetUserWhiteListReq* pReq);
1416
int32_t tDeserializeSGetUserWhiteListReq(void* buf, int32_t bufLen, SGetUserWhiteListReq* pReq);
468✔
1417

1418
typedef struct {
1419
  char    user[TSDB_USER_LEN];
1420
  int32_t numWhiteLists;
468✔
1421
  union {
468✔
1422
    SIpV4Range* pWhiteLists;
468✔
1423
    SIpRange*   pWhiteListsDual;
1424
  };
1425
} SGetUserWhiteListRsp;
1426

468✔
1427
int32_t tIpStrToUint(const SIpAddr* addr, SIpRange* range);
1428
int32_t tIpUintToStr(const SIpRange* range, SIpAddr* addr);
468✔
1429
int32_t tIpRangeSetMask(SIpRange* range, int32_t mask);
468✔
1430
void    tIpRangeSetDefaultMask(SIpRange* range);
1431

468!
1432
int32_t tSerializeSGetUserWhiteListRsp(void* buf, int32_t bufLen, SGetUserWhiteListRsp* pRsp);
468✔
1433
int32_t tDeserializeSGetUserWhiteListRsp(void* buf, int32_t bufLen, SGetUserWhiteListRsp* pRsp);
1434
void    tFreeSGetUserWhiteListRsp(SGetUserWhiteListRsp* pRsp);
1435

468✔
1436
int32_t tSerializeSGetUserWhiteListDualRsp(void* buf, int32_t bufLen, SGetUserWhiteListRsp* pRsp);
1437
int32_t tDeserializeSGetUserWhiteListDualRsp(void* buf, int32_t bufLen, SGetUserWhiteListRsp* pRsp);
×
1438
void    tFreeSGetUserWhiteListDualRsp(SGetUserWhiteListRsp* pRsp);
×
1439

1440
/*
×
1441
 * for client side struct, only column id, type, bytes are necessary
×
1442
 * But for data in vnode side, we need all the following information.
×
1443
 */
×
1444
typedef struct {
1445
  union {
1446
    col_id_t colId;
×
1447
    int16_t  slotId;
1448
  };
1449

1450
  uint8_t precision;
468✔
1451
  uint8_t scale;
1452
  int32_t bytes;
468✔
1453
  int8_t  type;
1454
  uint8_t pk;
1455
  bool    noData;
776✔
1456
} SColumnInfo;
776✔
1457

1458
typedef struct STimeWindow {
776!
1459
  TSKEY skey;
×
1460
  TSKEY ekey;
×
1461
} STimeWindow;
1462

1463
typedef struct SQueryHint {
776✔
1464
  bool batchScan;
776✔
1465
} SQueryHint;
308✔
1466

308✔
1467
typedef struct {
1468
  int32_t tsOffset;       // offset value in current msg body, NOTE: ts list is compressed
1469
  int32_t tsLen;          // total length of ts comp block
776!
1470
  int32_t tsNumOfBlocks;  // ts comp block numbers
776✔
1471
  int32_t tsOrder;        // ts comp block order
776✔
1472
} STsBufInfo;
776✔
1473

376✔
1474
typedef struct {
58✔
1475
  void*       timezone;
718✔
1476
  char        intervalUnit;
166✔
1477
  char        slidingUnit;
1478
  char        offsetUnit;
1479
  int8_t      precision;
1480
  int64_t     interval;
776!
1481
  int64_t     sliding;
85✔
1482
  int64_t     offset;
85✔
1483
  STimeWindow timeRange;
85✔
1484
} SInterval;
223✔
1485

223✔
1486
typedef struct STbVerInfo {
223✔
1487
  char    tbFName[TSDB_TABLE_FNAME_LEN];
468✔
1488
  int32_t sversion;
468✔
1489
  int32_t tversion;
468✔
1490
  int32_t rversion;  // virtual table's column ref's version
1491
} STbVerInfo;
×
1492

×
1493
typedef struct {
×
1494
  int32_t code;
×
1495
  int64_t affectedRows;
×
1496
  SArray* tbVerInfo;  // STbVerInfo
×
1497
} SQueryTableRsp;
×
1498

×
1499
int32_t tSerializeSQueryTableRsp(void* buf, int32_t bufLen, SQueryTableRsp* pRsp);
1500

1501
int32_t tDeserializeSQueryTableRsp(void* buf, int32_t bufLen, SQueryTableRsp* pRsp);
1502

×
1503
typedef struct {
×
1504
  SMsgHead header;
×
1505
  char     dbFName[TSDB_DB_FNAME_LEN];
×
1506
  char     tbName[TSDB_TABLE_NAME_LEN];
×
1507
} STableCfgReq;
1508

×
1509
typedef struct {
×
1510
  char        tbName[TSDB_TABLE_NAME_LEN];
1511
  char        stbName[TSDB_TABLE_NAME_LEN];
1512
  char        dbFName[TSDB_DB_FNAME_LEN];
×
1513
  int32_t     numOfTags;
×
1514
  int32_t     numOfColumns;
×
1515
  int8_t      tableType;
1516
  int64_t     delay1;
1517
  int64_t     delay2;
×
1518
  int64_t     watermark1;
×
1519
  int64_t     watermark2;
×
1520
  int32_t     ttl;
×
1521
  int32_t     keep;
1522
  SArray*     pFuncs;
×
1523
  int32_t     commentLen;
×
1524
  char*       pComment;
1525
  SSchema*    pSchemas;
1526
  int32_t     tagsLen;
×
1527
  char*       pTags;
×
1528
  SSchemaExt* pSchemaExt;
×
1529
  int8_t      virtualStb;
1530
  SColRef*    pColRefs;
1531
} STableCfg;
1532

×
1533
typedef STableCfg STableCfgRsp;
×
1534

1535
int32_t tSerializeSTableCfgReq(void* buf, int32_t bufLen, STableCfgReq* pReq);
1536
int32_t tDeserializeSTableCfgReq(void* buf, int32_t bufLen, STableCfgReq* pReq);
×
1537

×
1538
int32_t tSerializeSTableCfgRsp(void* buf, int32_t bufLen, STableCfgRsp* pRsp);
×
1539
int32_t tDeserializeSTableCfgRsp(void* buf, int32_t bufLen, STableCfgRsp* pRsp);
1540
void    tFreeSTableCfgRsp(STableCfgRsp* pRsp);
1541

1542
typedef struct {
×
1543
  SMsgHead header;
1544
  tb_uid_t suid;
1545
} SVSubTablesReq;
×
1546

×
1547
int32_t tSerializeSVSubTablesReq(void* buf, int32_t bufLen, SVSubTablesReq* pReq);
×
1548
int32_t tDeserializeSVSubTablesReq(void* buf, int32_t bufLen, SVSubTablesReq* pReq);
×
1549

×
1550
typedef struct {
×
1551
  int32_t vgId;
1552
  SArray* pTables;  // SArray<SVCTableRefCols*>
1553
} SVSubTablesRsp;
×
1554

×
1555
int32_t tSerializeSVSubTablesRsp(void* buf, int32_t bufLen, SVSubTablesRsp* pRsp);
×
1556
int32_t tDeserializeSVSubTablesRsp(void* buf, int32_t bufLen, SVSubTablesRsp* pRsp);
1557
void    tDestroySVSubTablesRsp(void* rsp);
×
1558

×
1559
typedef struct {
1560
  SMsgHead header;
×
1561
  tb_uid_t suid;
×
1562
} SVStbRefDbsReq;
1563

1564
int32_t tSerializeSVStbRefDbsReq(void* buf, int32_t bufLen, SVStbRefDbsReq* pReq);
×
1565
int32_t tDeserializeSVStbRefDbsReq(void* buf, int32_t bufLen, SVStbRefDbsReq* pReq);
×
1566

×
1567
typedef struct {
1568
  int32_t vgId;
1569
  SArray* pDbs;  // SArray<char* (db name)>
1570
} SVStbRefDbsRsp;
×
1571

1572
int32_t tSerializeSVStbRefDbsRsp(void* buf, int32_t bufLen, SVStbRefDbsRsp* pRsp);
1573
int32_t tDeserializeSVStbRefDbsRsp(void* buf, int32_t bufLen, SVStbRefDbsRsp* pRsp);
89✔
1574
void    tDestroySVStbRefDbsRsp(void* rsp);
89✔
1575

1576
typedef struct {
1577
  char    db[TSDB_DB_FNAME_LEN];
89✔
1578
  int32_t numOfVgroups;
89✔
1579
  int32_t numOfStables;  // single_stable
89✔
1580
  int32_t buffer;        // MB
1581
  int32_t pageSize;
89!
1582
  int32_t pages;
89!
1583
  int32_t cacheLastSize;
×
1584
  int32_t daysPerFile;
×
1585
  int32_t daysToKeep0;
1586
  int32_t daysToKeep1;
1587
  int32_t daysToKeep2;
89✔
1588
  int32_t keepTimeOffset;
89!
1589
  int32_t minRows;
×
1590
  int32_t maxRows;
×
1591
  int32_t walFsyncPeriod;
1592
  int8_t  walLevel;
1593
  int8_t  precision;  // time resolution
89✔
1594
  int8_t  compression;
89✔
1595
  int8_t  replications;
89!
1596
  int8_t  strict;
×
1597
  int8_t  cacheLast;
1598
  int8_t  schemaless;
×
1599
  int8_t  ignoreExist;
1600
  int32_t numOfRetensions;
89✔
1601
  SArray* pRetensions;  // SRetention
1602
  int32_t walRetentionPeriod;
1603
  int64_t walRetentionSize;
1604
  int32_t walRollPeriod;
89!
1605
  int64_t walSegmentSize;
5!
1606
  int32_t sstTrigger;
×
1607
  int16_t hashPrefix;
×
1608
  int16_t hashSuffix;
1609
  int32_t ssChunkSize;
1610
  int32_t ssKeepLocal;
5✔
1611
  int8_t  ssCompact;
5!
1612
  int32_t tsdbPageSize;
×
1613
  int32_t sqlLen;
1614
  char*   sql;
5✔
1615
  int8_t  withArbitrator;
5✔
1616
  int8_t  encryptAlgorithm;
5!
1617
  char    dnodeListStr[TSDB_DNODE_LIST_LEN];
×
1618
  // 1. add auto-compact parameters
1619
  int32_t compactInterval;    // minutes
×
1620
  int32_t compactStartTime;   // minutes
1621
  int32_t compactEndTime;     // minutes
5✔
1622
  int8_t  compactTimeOffset;  // hour
1623
} SCreateDbReq;
1624

1625
int32_t tSerializeSCreateDbReq(void* buf, int32_t bufLen, SCreateDbReq* pReq);
89!
1626
int32_t tDeserializeSCreateDbReq(void* buf, int32_t bufLen, SCreateDbReq* pReq);
×
1627
void    tFreeSCreateDbReq(SCreateDbReq* pReq);
×
1628

1629
typedef struct {
1630
  char    db[TSDB_DB_FNAME_LEN];
89✔
1631
  int32_t buffer;
1632
  int32_t pageSize;
1633
  int32_t pages;
89✔
1634
  int32_t cacheLastSize;
1635
  int32_t daysPerFile;
89✔
1636
  int32_t daysToKeep0;
89✔
1637
  int32_t daysToKeep1;
89!
1638
  int32_t daysToKeep2;
×
1639
  int32_t keepTimeOffset;
1640
  int32_t walFsyncPeriod;
1641
  int8_t  walLevel;
89✔
1642
  int8_t  strict;
89✔
1643
  int8_t  cacheLast;
89!
1644
  int8_t  replications;
×
1645
  int32_t sstTrigger;
×
1646
  int32_t minRows;
1647
  int32_t walRetentionPeriod;
1648
  int32_t walRetentionSize;
89!
1649
  int32_t ssKeepLocal;
89!
1650
  int8_t  ssCompact;
89✔
1651
  int32_t sqlLen;
1652
  char*   sql;
×
1653
  int8_t  withArbitrator;
1654
  // 1. add auto-compact parameters
1655
  int32_t compactInterval;
89✔
1656
  int32_t compactStartTime;
89✔
1657
  int32_t compactEndTime;
89!
1658
  int8_t  compactTimeOffset;
×
1659
} SAlterDbReq;
×
1660

1661
int32_t tSerializeSAlterDbReq(void* buf, int32_t bufLen, SAlterDbReq* pReq);
1662
int32_t tDeserializeSAlterDbReq(void* buf, int32_t bufLen, SAlterDbReq* pReq);
1663
void    tFreeSAlterDbReq(SAlterDbReq* pReq);
89✔
1664

89✔
1665
typedef struct {
89!
1666
  char    db[TSDB_DB_FNAME_LEN];
×
1667
  int8_t  ignoreNotExists;
×
1668
  int8_t  force;
×
1669
  int32_t sqlLen;
1670
  char*   sql;
89!
1671
} SDropDbReq;
×
1672

×
1673
int32_t tSerializeSDropDbReq(void* buf, int32_t bufLen, SDropDbReq* pReq);
×
1674
int32_t tDeserializeSDropDbReq(void* buf, int32_t bufLen, SDropDbReq* pReq);
1675
void    tFreeSDropDbReq(SDropDbReq* pReq);
89✔
1676

1!
1677
typedef struct {
1!
1678
  char    db[TSDB_DB_FNAME_LEN];
1679
  int64_t uid;
1✔
1680
} SDropDbRsp;
1✔
1681

1✔
1682
int32_t tSerializeSDropDbRsp(void* buf, int32_t bufLen, SDropDbRsp* pRsp);
1✔
1683
int32_t tDeserializeSDropDbRsp(void* buf, int32_t bufLen, SDropDbRsp* pRsp);
1✔
1684

1685
typedef struct {
88!
1686
  char    name[TSDB_MOUNT_NAME_LEN];
1687
  int64_t uid;
88✔
1688
} SDropMountRsp;
1689

88✔
1690
int32_t tSerializeSDropMountRsp(void* buf, int32_t bufLen, SDropMountRsp* pRsp);
1691
int32_t tDeserializeSDropMountRsp(void* buf, int32_t bufLen, SDropMountRsp* pRsp);
1692

89✔
1693
typedef struct {
89!
1694
  char    db[TSDB_DB_FNAME_LEN];
89!
1695
  int64_t dbId;
×
1696
  int32_t vgVersion;
1697
  int32_t numOfTable;  // unit is TSDB_TABLE_NUM_UNIT
1698
  int64_t stateTs;     // ms
89✔
1699
} SUseDbReq;
1700

89✔
1701
int32_t tSerializeSUseDbReq(void* buf, int32_t bufLen, SUseDbReq* pReq);
89✔
1702
int32_t tDeserializeSUseDbReq(void* buf, int32_t bufLen, SUseDbReq* pReq);
89✔
1703

89!
1704
typedef struct {
89!
1705
  char    db[TSDB_DB_FNAME_LEN];
×
1706
  int64_t uid;
×
1707
  int32_t vgVersion;
1708
  int32_t vgNum;
1709
  int16_t hashPrefix;
89✔
1710
  int16_t hashSuffix;
1711
  int8_t  hashMethod;
89✔
1712
  union {
89✔
1713
    uint8_t flags;
1714
    struct {
89✔
1715
      uint8_t isMount : 1;  // TS-5868
89!
1716
      uint8_t padding : 7;
×
1717
    };
89!
1718
  };
×
1719
  SArray* pVgroupInfos;  // Array of SVgroupInfo
×
1720
  int32_t errCode;
1721
  int64_t stateTs;  // ms
89!
1722
} SUseDbRsp;
1723

89✔
1724
int32_t tSerializeSUseDbRsp(void* buf, int32_t bufLen, const SUseDbRsp* pRsp);
89✔
1725
int32_t tDeserializeSUseDbRsp(void* buf, int32_t bufLen, SUseDbRsp* pRsp);
89✔
1726
int32_t tSerializeSUseDbRspImp(SEncoder* pEncoder, const SUseDbRsp* pRsp);
1727
int32_t tDeserializeSUseDbRspImp(SDecoder* pDecoder, SUseDbRsp* pRsp);
89✔
1728
void    tFreeSUsedbRsp(SUseDbRsp* pRsp);
89✔
1729

89✔
1730
typedef struct {
89✔
1731
  char db[TSDB_DB_FNAME_LEN];
1732
} SDbCfgReq;
89✔
1733

89!
1734
int32_t tSerializeSDbCfgReq(void* buf, int32_t bufLen, SDbCfgReq* pReq);
89!
1735
int32_t tDeserializeSDbCfgReq(void* buf, int32_t bufLen, SDbCfgReq* pReq);
×
1736

×
1737
typedef struct {
1738
  char    db[TSDB_DB_FNAME_LEN];
1739
  int32_t maxSpeed;
89!
1740
} STrimDbReq;
×
1741

×
1742
int32_t tSerializeSTrimDbReq(void* buf, int32_t bufLen, STrimDbReq* pReq);
×
1743
int32_t tDeserializeSTrimDbReq(void* buf, int32_t bufLen, STrimDbReq* pReq);
1744

1745
typedef struct {
89✔
1746
  int32_t timestamp;
89✔
1747
} SVTrimDbReq;
89✔
1748

1749
int32_t tSerializeSVTrimDbReq(void* buf, int32_t bufLen, SVTrimDbReq* pReq);
1750
int32_t tDeserializeSVTrimDbReq(void* buf, int32_t bufLen, SVTrimDbReq* pReq);
1,426✔
1751

1,426✔
1752
typedef struct {
716✔
1753
  char db[TSDB_DB_FNAME_LEN];
1754
} SSsMigrateDbReq;
1755

710!
1756
int32_t tSerializeSSsMigrateDbReq(void* buf, int32_t bufLen, SSsMigrateDbReq* pReq);
×
1757
int32_t tDeserializeSSsMigrateDbReq(void* buf, int32_t bufLen, SSsMigrateDbReq* pReq);
×
1758

×
1759
typedef struct {
1760
  int32_t ssMigrateId;
×
1761
  bool    bAccepted;
1762
} SSsMigrateDbRsp;
1763

×
1764
int32_t tSerializeSSsMigrateDbRsp(void* buf, int32_t bufLen, SSsMigrateDbRsp* pRsp);
×
1765
int32_t tDeserializeSSsMigrateDbRsp(void* buf, int32_t bufLen, SSsMigrateDbRsp* pRsp);
×
1766

×
1767
typedef struct {
×
1768
  int32_t ssMigrateId;
1769
  int32_t nodeId; // node id of the leader vnode
×
1770
  int64_t timestamp;
710✔
1771
} SSsMigrateVgroupReq;
694✔
1772

694!
1773
int32_t tSerializeSSsMigrateVgroupReq(void* buf, int32_t bufLen, SSsMigrateVgroupReq* pReq);
×
1774
int32_t tDeserializeSSsMigrateVgroupReq(void* buf, int32_t bufLen, SSsMigrateVgroupReq* pReq);
1775

×
1776
typedef struct {
1777
  int32_t ssMigrateId;
1778
  int32_t vgId;   // vgroup id
694✔
1779
  int32_t nodeId; // node id of the leader vnode
694✔
1780
} SSsMigrateVgroupRsp;
694!
1781

×
1782
int32_t tSerializeSSsMigrateVgroupRsp(void* buf, int32_t bufLen, SSsMigrateVgroupRsp* pRsp);
1783
int32_t tDeserializeSSsMigrateVgroupRsp(void* buf, int32_t bufLen, SSsMigrateVgroupRsp* pRsp);
×
1784

1785
typedef struct {
1786
  int32_t ssMigrateId;
694✔
1787
  int32_t vgId;
694!
1788
} SQuerySsMigrateProgressReq;
×
1789

1790
int32_t tSerializeSQuerySsMigrateProgressReq(void* buf, int32_t bufLen, SQuerySsMigrateProgressReq* pReq);
×
1791
int32_t tDeserializeSQuerySsMigrateProgressReq(void* buf, int32_t bufLen, SQuerySsMigrateProgressReq* pReq);
1792

694!
1793
#define FILE_SET_MIGRATE_STATE_IN_PROGRESS  0
694✔
1794
#define FILE_SET_MIGRATE_STATE_SUCCEEDED    1
1795
#define FILE_SET_MIGRATE_STATE_SKIPPED      2
16✔
1796
#define FILE_SET_MIGRATE_STATE_FAILED       3
16!
1797

16✔
1798
typedef struct {
1799
  int32_t fid;  // file set id
1800
  int32_t state;
1801
} SFileSetSsMigrateState;
1,426✔
1802

1,426✔
1803
typedef struct {
1,426!
1804
  // if all taosd were restarted during the migration, then vnode migrate id will be 0,
×
1805
  // that's mnode will repeatedly request the migration progress. to avoid this, we need
×
1806
  // to save mnode migrate id in the response, so that mnode can drop it.
×
1807
  int32_t mnodeMigrateId; // migrate id requested by mnode
×
1808
  int32_t vnodeMigrateId; // migrate id reponsed by vnode
1809
  int32_t dnodeId;
1810
  int32_t vgId;
1,426✔
1811
  int64_t startTimeSec;
1812
  SArray* pFileSetStates;
1,426✔
1813
} SVnodeSsMigrateState;
1,426✔
1814

1,426!
1815
int32_t tSerializeSVnodeSsMigrateState(void* buf, int32_t bufLen, SVnodeSsMigrateState* pState);
1816
int32_t tDeserializeSVnodeSsMigrateState(void* buf, int32_t bufLen, SVnodeSsMigrateState* pState);
1,426!
1817
void tFreeSVnodeSsMigrateState(SVnodeSsMigrateState* pState);
1818

1819
typedef SVnodeSsMigrateState SQuerySsMigrateProgressRsp;
1,426✔
1820
#define tSerializeSQuerySsMigrateProgressRsp(buf, bufLen, pRsp) \
1,282✔
1821
  tSerializeSVnodeSsMigrateState(buf, bufLen, pRsp)
1,282✔
1822
#define tDeserializeSQuerySsMigrateProgressRsp(buf, bufLen, pRsp) \
1,280!
1823
  tDeserializeSVnodeSsMigrateState(buf, bufLen, pRsp)
×
1824
#define tFreeSQuerySsMigrateProgressRsp(pRsp) \
1825
  tFreeSVnodeSsMigrateState(pRsp)
1826

×
1827
typedef SVnodeSsMigrateState SFollowerSsMigrateReq;
×
1828
#define tSerializeSFollowerSsMigrateReq(buf, bufLen, pReq) \
1829
  tSerializeSVnodeSsMigrateState(buf, bufLen, pReq)
×
1830
#define tDeserializeSFollowerSsMigrateReq(buf, bufLen, pReq) \
×
1831
  tDeserializeSVnodeSsMigrateState(buf, bufLen, pReq)
×
1832
#define tFreeSFollowerSsMigrateReq(pReq) \
×
1833
  tFreeSVnodeSsMigrateState(pReq)
1834

1,280✔
1835
typedef struct {
1836
  int32_t timestampSec;
1837
  int32_t ttlDropMaxCount;
1838
  int32_t nUids;
1,426✔
1839
  SArray* pTbUids;
1840
} SVDropTtlTableReq;
1,426✔
1841

1,426✔
1842
int32_t tSerializeSVDropTtlTableReq(void* buf, int32_t bufLen, SVDropTtlTableReq* pReq);
1843
int32_t tDeserializeSVDropTtlTableReq(void* buf, int32_t bufLen, SVDropTtlTableReq* pReq);
1,426✔
1844

1,426✔
1845
typedef struct {
1846
  char    db[TSDB_DB_FNAME_LEN];
1847
  int64_t dbId;
1,426✔
1848
  int32_t cfgVersion;
1,357!
1849
  int32_t numOfVgroups;
1,356!
1850
  int32_t numOfStables;
×
1851
  int32_t buffer;
1852
  int32_t cacheSize;
1,356✔
1853
  int32_t pageSize;
1854
  int32_t pages;
1855
  int32_t daysPerFile;
1856
  int32_t daysToKeep0;
1,425✔
1857
  int32_t daysToKeep1;
1858
  int32_t daysToKeep2;
1,426✔
1859
  int32_t keepTimeOffset;
1,280✔
1860
  int32_t minRows;
1,280!
1861
  int32_t maxRows;
×
1862
  int32_t walFsyncPeriod;
×
1863
  int16_t hashPrefix;
×
1864
  int16_t hashSuffix;
1865
  int8_t  hashMethod;
1866
  int8_t  walLevel;
1867
  int8_t  precision;
1,426✔
1868
  int8_t  compression;
1,425✔
1869
  int8_t  replications;
1,426✔
1870
  int8_t  strict;
1871
  int8_t  cacheLast;
1872
  int8_t  encryptAlgorithm;
1,426✔
1873
  int32_t ssChunkSize;
1,426✔
1874
  int32_t ssKeepLocal;
1,426✔
1875
  int8_t  ssCompact;
1,426!
1876
  union {
1,426✔
1877
    uint8_t flags;
1878
    struct {
1879
      uint8_t isMount : 1;  // TS-5868
1,426✔
1880
      uint8_t padding : 7;
1,426✔
1881
    };
1,426✔
1882
  };
1883
  int8_t  compactTimeOffset;
1,426!
1884
  int32_t compactInterval;
1885
  int32_t compactStartTime;
1,426✔
1886
  int32_t compactEndTime;
710!
1887
  int32_t tsdbPageSize;
710!
1888
  int32_t walRetentionPeriod;
×
1889
  int32_t walRollPeriod;
×
1890
  int64_t walRetentionSize;
×
1891
  int64_t walSegmentSize;
1892
  int32_t numOfRetensions;
710✔
1893
  SArray* pRetensions;
1894
  int8_t  schemaless;
1895
  int16_t sstTrigger;
1896
  int8_t  withArbitrator;
1,426✔
1897
} SDbCfgRsp;
1898

89!
1899
typedef SDbCfgRsp SDbCfgInfo;
×
1900

89!
1901
int32_t tSerializeSDbCfgRspImpl(SEncoder* encoder, const SDbCfgRsp* pRsp);
×
1902
int32_t tSerializeSDbCfgRsp(void* buf, int32_t bufLen, const SDbCfgRsp* pRsp);
1903
int32_t tDeserializeSDbCfgRsp(void* buf, int32_t bufLen, SDbCfgRsp* pRsp);
1904
int32_t tDeserializeSDbCfgRspImpl(SDecoder* decoder, SDbCfgRsp* pRsp);
1905
void    tFreeSDbCfgRsp(SDbCfgRsp* pRsp);
1,337!
1906

×
1907
typedef struct {
1908
  int32_t rowNum;
1909
} SQnodeListReq;
1910

1,426!
1911
int32_t tSerializeSQnodeListReq(void* buf, int32_t bufLen, SQnodeListReq* pReq);
1,426!
1912
int32_t tDeserializeSQnodeListReq(void* buf, int32_t bufLen, SQnodeListReq* pReq);
×
1913

×
1914
typedef struct {
×
1915
  int32_t rowNum;
1916
} SDnodeListReq;
1917

1,426✔
1918
int32_t tSerializeSDnodeListReq(void* buf, int32_t bufLen, SDnodeListReq* pReq);
1,426✔
1919

1920
typedef struct {
1,426!
1921
  int32_t useless;  // useless
×
1922
} SServerVerReq;
×
1923

×
1924
int32_t tSerializeSServerVerReq(void* buf, int32_t bufLen, SServerVerReq* pReq);
1925
// int32_t tDeserializeSServerVerReq(void* buf, int32_t bufLen, SServerVerReq* pReq);
1,426✔
1926

1927
typedef struct {
×
1928
  char ver[TSDB_VERSION_LEN];
×
1929
} SServerVerRsp;
×
1930

×
1931
int32_t tSerializeSServerVerRsp(void* buf, int32_t bufLen, SServerVerRsp* pRsp);
×
1932
int32_t tDeserializeSServerVerRsp(void* buf, int32_t bufLen, SServerVerRsp* pRsp);
1933

1934
typedef struct SQueryNodeAddr {
1935
  int32_t nodeId;  // vgId or qnodeId
×
1936
  SEpSet  epSet;
×
1937
} SQueryNodeAddr;
×
1938

×
1939
typedef struct {
1940
  SQueryNodeAddr addr;
1941
  uint64_t       load;
×
1942
} SQueryNodeLoad;
×
1943

×
1944
typedef struct {
1945
  SArray* qnodeList;  // SArray<SQueryNodeLoad>
1946
} SQnodeListRsp;
×
1947

×
1948
int32_t tSerializeSQnodeListRsp(void* buf, int32_t bufLen, SQnodeListRsp* pRsp);
×
1949
int32_t tDeserializeSQnodeListRsp(void* buf, int32_t bufLen, SQnodeListRsp* pRsp);
×
1950
void    tFreeSQnodeListRsp(SQnodeListRsp* pRsp);
×
1951

×
1952
typedef struct SDNodeAddr {
1953
  int32_t nodeId;  // dnodeId
×
1954
  SEpSet  epSet;
×
1955
} SDNodeAddr;
1956

1957
typedef struct {
×
1958
  SArray* dnodeList;  // SArray<SDNodeAddr>
1959
} SDnodeListRsp;
1960

1961
int32_t tSerializeSDnodeListRsp(void* buf, int32_t bufLen, SDnodeListRsp* pRsp);
1962
int32_t tDeserializeSDnodeListRsp(void* buf, int32_t bufLen, SDnodeListRsp* pRsp);
1963
void    tFreeSDnodeListRsp(SDnodeListRsp* pRsp);
1964

1965
typedef struct {
1966
  SArray* pTsmas;  // SArray<STableTSMAInfo*>
1967
} STableTSMAInfoRsp;
1968

1969
typedef struct {
1970
  SUseDbRsp*         useDbRsp;
1971
  SDbCfgRsp*         cfgRsp;
1972
  STableTSMAInfoRsp* pTsmaRsp;
1973
  int32_t            dbTsmaVersion;
1974
  char               db[TSDB_DB_FNAME_LEN];
1,490✔
1975
  int64_t            dbId;
6,297✔
1976
} SDbHbRsp;
4,807✔
1977

1978
typedef struct {
4,807✔
1979
  SArray* pArray;  // Array of SDbHbRsp
4,807✔
1980
} SDbHbBatchRsp;
1981

4,807!
1982
int32_t tSerializeSDbHbBatchRsp(void* buf, int32_t bufLen, SDbHbBatchRsp* pRsp);
9,096!
1983
int32_t tDeserializeSDbHbBatchRsp(void* buf, int32_t bufLen, SDbHbBatchRsp* pRsp);
4,542✔
1984
void    tFreeSDbHbBatchRsp(SDbHbBatchRsp* pRsp);
1985

4,542!
1986
typedef struct {
×
1987
  SArray* pArray;  // Array of SGetUserAuthRsp
×
1988
} SUserAuthBatchRsp;
1989

4,542✔
1990
int32_t tSerializeSUserAuthBatchRsp(void* buf, int32_t bufLen, SUserAuthBatchRsp* pRsp);
4,542✔
1991
int32_t tDeserializeSUserAuthBatchRsp(void* buf, int32_t bufLen, SUserAuthBatchRsp* pRsp);
1992
void    tFreeSUserAuthBatchRsp(SUserAuthBatchRsp* pRsp);
1993

12✔
1994
typedef struct {
12✔
1995
  char        db[TSDB_DB_FNAME_LEN];
1996
  STimeWindow timeRange;
1997
  int32_t     sqlLen;
253✔
1998
  char*       sql;
247✔
1999
  SArray*     vgroupIds;
247✔
2000
  int8_t      metaOnly;
2001
} SCompactDbReq;
6✔
2002

6✔
2003
int32_t tSerializeSCompactDbReq(void* buf, int32_t bufLen, SCompactDbReq* pReq);
2004
int32_t tDeserializeSCompactDbReq(void* buf, int32_t bufLen, SCompactDbReq* pReq);
2005
void    tFreeSCompactDbReq(SCompactDbReq* pReq);
2006

1,490✔
2007
typedef struct {
2008
  int32_t compactId;
×
2009
  int8_t  bAccepted;
×
2010
} SCompactDbRsp;
×
2011

2012
int32_t tSerializeSCompactDbRsp(void* buf, int32_t bufLen, SCompactDbRsp* pRsp);
2013
int32_t tDeserializeSCompactDbRsp(void* buf, int32_t bufLen, SCompactDbRsp* pRsp);
×
2014

×
2015
typedef struct {
2016
  int32_t compactId;
×
2017
  int32_t sqlLen;
×
2018
  char*   sql;
×
2019
} SKillCompactReq;
2020

2021
int32_t tSerializeSKillCompactReq(void* buf, int32_t bufLen, SKillCompactReq* pReq);
×
2022
int32_t tDeserializeSKillCompactReq(void* buf, int32_t bufLen, SKillCompactReq* pReq);
×
2023
void    tFreeSKillCompactReq(SKillCompactReq* pReq);
2024

×
2025
typedef struct {
×
2026
  char    name[TSDB_FUNC_NAME_LEN];
×
2027
  int8_t  igExists;
×
2028
  int8_t  funcType;
2029
  int8_t  scriptType;
2030
  int8_t  outputType;
×
2031
  int32_t outputLen;
×
2032
  int32_t bufSize;
×
2033
  int32_t codeLen;
×
2034
  int64_t signature;
×
2035
  char*   pComment;
2036
  char*   pCode;
2037
  int8_t  orReplace;
×
2038
} SCreateFuncReq;
2039

2040
int32_t tSerializeSCreateFuncReq(void* buf, int32_t bufLen, SCreateFuncReq* pReq);
2041
int32_t tDeserializeSCreateFuncReq(void* buf, int32_t bufLen, SCreateFuncReq* pReq);
×
2042
void    tFreeSCreateFuncReq(SCreateFuncReq* pReq);
×
2043

×
2044
typedef struct {
2045
  char   name[TSDB_FUNC_NAME_LEN];
×
2046
  int8_t igNotExists;
×
2047
} SDropFuncReq;
2048

2049
int32_t tSerializeSDropFuncReq(void* buf, int32_t bufLen, SDropFuncReq* pReq);
2050
int32_t tDeserializeSDropFuncReq(void* buf, int32_t bufLen, SDropFuncReq* pReq);
×
2051

×
2052
typedef struct {
×
2053
  int32_t numOfFuncs;
2054
  bool    ignoreCodeComment;
2055
  SArray* pFuncNames;
×
2056
} SRetrieveFuncReq;
2057

2058
int32_t tSerializeSRetrieveFuncReq(void* buf, int32_t bufLen, SRetrieveFuncReq* pReq);
94✔
2059
int32_t tDeserializeSRetrieveFuncReq(void* buf, int32_t bufLen, SRetrieveFuncReq* pReq);
94✔
2060
void    tFreeSRetrieveFuncReq(SRetrieveFuncReq* pReq);
94!
2061

×
2062
typedef struct {
2063
  char    name[TSDB_FUNC_NAME_LEN];
94✔
2064
  int8_t  funcType;
2065
  int8_t  scriptType;
1,665✔
2066
  int8_t  outputType;
1,665!
2067
  int32_t outputLen;
×
2068
  int32_t bufSize;
2069
  int64_t signature;
2070
  int32_t commentSize;
1,665✔
2071
  int32_t codeSize;
1,665✔
2072
  char*   pComment;
2073
  char*   pCode;
269✔
2074
} SFuncInfo;
175✔
2075

175✔
2076
typedef struct {
2077
  int32_t funcVersion;
2078
  int64_t funcCreatedTime;
2079
} SFuncExtraInfo;
94✔
2080

2081
typedef struct {
94!
2082
  int32_t numOfFuncs;
×
2083
  SArray* pFuncInfos;
2084
  SArray* pFuncExtraInfos;
94✔
2085
} SRetrieveFuncRsp;
94!
2086

×
2087
int32_t tSerializeSRetrieveFuncRsp(void* buf, int32_t bufLen, SRetrieveFuncRsp* pRsp);
2088
int32_t tDeserializeSRetrieveFuncRsp(void* buf, int32_t bufLen, SRetrieveFuncRsp* pRsp);
94!
2089
void    tFreeSFuncInfo(SFuncInfo* pInfo);
×
2090
void    tFreeSRetrieveFuncRsp(SRetrieveFuncRsp* pRsp);
2091

94✔
2092
typedef struct {
2093
  int32_t       statusInterval;
2094
  int64_t       checkTime;                  // 1970-01-01 00:00:00.000
1,490!
2095
  char          timezone[TD_TIMEZONE_LEN];  // tsTimezone
×
2096
  char          locale[TD_LOCALE_LEN];      // tsLocale
2097
  char          charset[TD_LOCALE_LEN];     // tsCharset
1,490!
2098
  int8_t        ttlChangeOnWrite;
1,490✔
2099
  int8_t        enableWhiteList;
1,490✔
2100
  int8_t        encryptionKeyStat;
2101
  uint32_t      encryptionKeyChksum;
2102
  SMonitorParas monitorParas;
1,490✔
2103
} SClusterCfg;
2104

2105
typedef struct {
2106
  int32_t openVnodes;
177✔
2107
  int32_t dropVnodes;
177✔
2108
  int32_t totalVnodes;
176!
2109
  int32_t masterNum;
176!
2110
  int64_t numOfSelectReqs;
176!
2111
  int64_t numOfInsertReqs;
176!
2112
  int64_t numOfInsertSuccessReqs;
2113
  int64_t numOfBatchInsertReqs;
176!
2114
  int64_t numOfBatchInsertSuccessReqs;
×
2115
  int64_t errors;
×
2116
} SVnodesStat;
×
2117

×
2118
typedef struct {
×
2119
  int32_t vgId;
2120
  int8_t  syncState;
2121
  int8_t  syncRestore;
2122
  int64_t syncTerm;
177✔
2123
  int64_t roleTimeMs;
2124
  int64_t startTimeMs;
2125
  int8_t  syncCanRead;
177✔
2126
  int64_t cacheUsage;
177✔
2127
  int64_t numOfTables;
177✔
2128
  int64_t numOfTimeSeries;
177!
2129
  int64_t totalStorage;
2130
  int64_t compStorage;
488✔
2131
  int64_t pointsWritten;
311✔
2132
  int64_t numOfSelectReqs;
2133
  int64_t numOfInsertReqs;
311✔
2134
  int64_t numOfInsertSuccessReqs;
2135
  int64_t numOfBatchInsertReqs;
311!
2136
  int64_t numOfBatchInsertSuccessReqs;
12!
2137
  int32_t numOfCachedTables;
12!
2138
  int32_t learnerProgress;  // use one reservered
×
2139
  int64_t syncAppliedIndex;
×
2140
  int64_t syncCommitIndex;
2141
  int64_t bufferSegmentUsed;
2142
  int64_t bufferSegmentSize;
12✔
2143
} SVnodeLoad;
2144

12✔
2145
typedef struct {
24✔
2146
  int64_t total_requests;
12!
2147
  int64_t total_rows;
12✔
2148
  int64_t total_bytes;
2149
  double  write_size;
12✔
2150
  double  cache_hit_ratio;
12!
2151
  int64_t rpc_queue_wait;
×
2152
  int64_t preprocess_time;
2153

2154
  int64_t memory_table_size;
2155
  int64_t commit_count;
×
2156
  int64_t merge_count;
×
2157
  double  commit_time;
2158
  double  merge_time;
2159
  int64_t block_commit_time;
12✔
2160
  int64_t memtable_wait_time;
12✔
2161
} SVnodeMetrics;
12✔
2162

2163
typedef struct {
2164
  int32_t     vgId;
2165
  int64_t     numOfTables;
12✔
2166
  int64_t     memSize;
12✔
2167
  int64_t     l1Size;
2168
  int64_t     l2Size;
2169
  int64_t     l3Size;
177✔
2170
  int64_t     cacheSize;
177✔
2171
  int64_t     walSize;
2172
  int64_t     metaSize;
2173
  int64_t     rawDataSize;
177✔
2174
  int64_t     ssSize;
488✔
2175
  const char* dbname;
311✔
2176
} SDbSizeStatisInfo;
311✔
2177

311✔
2178
typedef struct {
311✔
2179
  int32_t vgId;
311✔
2180
  int64_t nTimeSeries;
311!
2181
} SVnodeLoadLite;
311✔
2182

2183
typedef struct {
×
2184
  int8_t  syncState;
×
2185
  int64_t syncTerm;
×
2186
  int8_t  syncRestore;
×
2187
  int64_t roleTimeMs;
2188
} SMnodeLoad;
×
2189

×
2190
typedef struct {
2191
  int32_t dnodeId;
×
2192
  int64_t numOfProcessedQuery;
×
2193
  int64_t numOfProcessedCQuery;
×
2194
  int64_t numOfProcessedFetch;
×
2195
  int64_t numOfProcessedDrop;
×
2196
  int64_t numOfProcessedNotify;
×
2197
  int64_t numOfProcessedHb;
2198
  int64_t numOfProcessedDelete;
2199
  int64_t cacheDataSize;
×
2200
  int64_t numOfQueryInQueue;
×
2201
  int64_t numOfFetchInQueue;
2202
  int64_t timeInQueryQueue;
177✔
2203
  int64_t timeInFetchQueue;
2204
} SQnodeLoad;
2205

2✔
2206
typedef struct {
2✔
2207
  int32_t     sver;      // software version
2208
  int64_t     dnodeVer;  // dnode table version in sdb
2209
  int32_t     dnodeId;
2210
  int64_t     clusterId;
1✔
2211
  int64_t     rebootTime;
1✔
2212
  int64_t     updateTime;
1✔
2213
  float       numOfCores;
2214
  int32_t     numOfSupportVnodes;
1✔
2215
  int32_t     numOfDiskCfg;
1✔
2216
  int64_t     memTotal;
2217
  int64_t     memAvail;
2218
  char        dnodeEp[TSDB_EP_LEN];
2219
  char        machineId[TSDB_MACHINE_ID_LEN + 1];
1✔
2220
  SMnodeLoad  mload;
1!
2221
  SQnodeLoad  qload;
×
2222
  SClusterCfg clusterCfg;
×
2223
  SArray*     pVloads;  // array of SVnodeLoad
2224
  int32_t     statusSeq;
2225
  int64_t     ipWhiteVer;
1✔
2226
  int64_t     analVer;
1✔
2227
  int64_t     timestamp;
1✔
2228
} SStatusReq;
2229

1✔
2230
int32_t tSerializeSStatusReq(void* buf, int32_t bufLen, SStatusReq* pReq);
2✔
2231
int32_t tDeserializeSStatusReq(void* buf, int32_t bufLen, SStatusReq* pReq);
1!
2232
void    tFreeSStatusReq(SStatusReq* pReq);
2233

1!
2234
typedef struct {
1✔
2235
  int32_t forceReadConfig;
1✔
2236
  int32_t cver;
1✔
2237
  SArray* array;
1✔
2238
} SConfigReq;
2239

1✔
2240
int32_t tSerializeSConfigReq(void* buf, int32_t bufLen, SConfigReq* pReq);
2✔
2241
int32_t tDeserializeSConfigReq(void* buf, int32_t bufLen, SConfigReq* pReq);
1!
2242
void    tFreeSConfigReq(SConfigReq* pReq);
×
2243

2244
typedef struct {
1✔
2245
  int32_t dnodeId;
2246
  char    machineId[TSDB_MACHINE_ID_LEN + 1];
1✔
2247
} SDnodeInfoReq;
1✔
2248

1!
2249
int32_t tSerializeSDnodeInfoReq(void* buf, int32_t bufLen, SDnodeInfoReq* pReq);
×
2250
int32_t tDeserializeSDnodeInfoReq(void* buf, int32_t bufLen, SDnodeInfoReq* pReq);
1!
2251

1✔
2252
typedef enum {
×
2253
  MONITOR_TYPE_COUNTER = 0,
×
2254
  MONITOR_TYPE_SLOW_LOG = 1,
×
2255
} MONITOR_TYPE;
×
2256

×
2257
typedef struct {
×
2258
  int32_t      contLen;
×
2259
  char*        pCont;
×
2260
  MONITOR_TYPE type;
2261
} SStatisReq;
×
2262

×
2263
int32_t tSerializeSStatisReq(void* buf, int32_t bufLen, SStatisReq* pReq);
2264
int32_t tDeserializeSStatisReq(void* buf, int32_t bufLen, SStatisReq* pReq);
2265
void    tFreeSStatisReq(SStatisReq* pReq);
1✔
2266

×
2267
typedef struct {
×
2268
  char    db[TSDB_DB_FNAME_LEN];
×
2269
  char    table[TSDB_TABLE_NAME_LEN];
×
2270
  char    operation[AUDIT_OPERATION_LEN];
2271
  int32_t sqlLen;
×
2272
  char*   pSql;
×
2273
} SAuditReq;
×
2274
int32_t tSerializeSAuditReq(void* buf, int32_t bufLen, SAuditReq* pReq);
2275
int32_t tDeserializeSAuditReq(void* buf, int32_t bufLen, SAuditReq* pReq);
1✔
2276
void    tFreeSAuditReq(SAuditReq* pReq);
2277

2278
typedef struct {
2279
  int32_t dnodeId;
2280
  int64_t clusterId;
1✔
2281
  SArray* pVloads;
1✔
2282
} SNotifyReq;
2283

2284
int32_t tSerializeSNotifyReq(void* buf, int32_t bufLen, SNotifyReq* pReq);
177✔
2285
int32_t tDeserializeSNotifyReq(void* buf, int32_t bufLen, SNotifyReq* pReq);
177✔
2286
void    tFreeSNotifyReq(SNotifyReq* pReq);
177✔
2287

177✔
2288
typedef struct {
487✔
2289
  int32_t dnodeId;
311✔
2290
  int64_t clusterId;
1✔
2291
} SDnodeCfg;
1✔
2292

2293
typedef struct {
2294
  int32_t id;
2295
  int8_t  isMnode;
177✔
2296
  SEp     ep;
176✔
2297
} SDnodeEp;
2298

2299
typedef struct {
1!
2300
  int32_t id;
2301
  int8_t  isMnode;
1✔
2302
  int8_t  offlineReason;
1✔
2303
  SEp     ep;
1✔
2304
  char    active[TSDB_ACTIVE_KEY_LEN];
1!
2305
  char    connActive[TSDB_CONN_ACTIVE_KEY_LEN];
×
2306
} SDnodeInfo;
×
2307

2308
typedef struct {
2309
  int64_t   dnodeVer;
1!
2310
  SDnodeCfg dnodeCfg;
1!
2311
  SArray*   pDnodeEps;  // Array of SDnodeEp
1!
2312
  int32_t   statusSeq;
1✔
2313
  int64_t   ipWhiteVer;
2314
  int64_t   analVer;
1✔
2315
} SStatusRsp;
1✔
2316

1!
2317
int32_t tSerializeSStatusRsp(void* buf, int32_t bufLen, SStatusRsp* pRsp);
×
2318
int32_t tDeserializeSStatusRsp(void* buf, int32_t bufLen, SStatusRsp* pRsp);
×
2319
void    tFreeSStatusRsp(SStatusRsp* pRsp);
2320

2321
typedef struct {
1✔
2322
  int32_t forceReadConfig;
1✔
2323
  int32_t isConifgVerified;
2324
  int32_t isVersionVerified;
1✔
2325
  int32_t cver;
1✔
2326
  SArray* array;
1✔
2327
} SConfigRsp;
2328

1✔
2329
int32_t tSerializeSConfigRsp(void* buf, int32_t bufLen, SConfigRsp* pRsp);
1✔
2330
int32_t tDeserializeSConfigRsp(void* buf, int32_t bufLen, SConfigRsp* pRsp);
1✔
2331
void    tFreeSConfigRsp(SConfigRsp* pRsp);
1✔
2332

1✔
2333
typedef struct {
1✔
2334
  int32_t reserved;
1✔
2335
} SMTimerReq;
2336

1✔
2337
int32_t tSerializeSMTimerMsg(void* buf, int32_t bufLen, SMTimerReq* pReq);
1✔
2338
// int32_t tDeserializeSMTimerMsg(void* buf, int32_t bufLen, SMTimerReq* pReq);
2✔
2339

1!
2340
typedef struct SOrphanTask {
1!
2341
  int64_t streamId;
1!
2342
  int32_t taskId;
×
2343
  int32_t nodeId;
×
2344
} SOrphanTask;
2345

1!
2346
typedef struct SMStreamDropOrphanMsg {
1✔
2347
  SArray* pList;  // SArray<SOrphanTask>
1✔
2348
} SMStreamDropOrphanMsg;
1✔
2349

1✔
2350
int32_t tSerializeDropOrphanTaskMsg(void* buf, int32_t bufLen, SMStreamDropOrphanMsg* pMsg);
1✔
2351
int32_t tDeserializeDropOrphanTaskMsg(void* buf, int32_t bufLen, SMStreamDropOrphanMsg* pMsg);
1✔
2352
void    tDestroyDropOrphanTaskMsg(SMStreamDropOrphanMsg* pMsg);
1✔
2353

2354
typedef struct {
1✔
2355
  int32_t  id;
2✔
2356
  uint16_t port;                 // node sync Port
1!
2357
  char     fqdn[TSDB_FQDN_LEN];  // node FQDN
×
2358
} SReplica;
2359

1✔
2360
typedef struct {
2361
  int32_t  vgId;
1✔
2362
  char     db[TSDB_DB_FNAME_LEN];
1✔
2363
  int64_t  dbUid;
1✔
2364
  int32_t  vgVersion;
1!
2365
  int32_t  numOfStables;
×
2366
  int32_t  buffer;
×
2367
  int32_t  pageSize;
1!
2368
  int32_t  pages;
1✔
2369
  int32_t  cacheLastSize;
1✔
2370
  int32_t  daysPerFile;
1!
2371
  int32_t  daysToKeep0;
×
2372
  int32_t  daysToKeep1;
×
2373
  int32_t  daysToKeep2;
2374
  int32_t  keepTimeOffset;
1✔
2375
  int32_t  minRows;
1!
2376
  int32_t  maxRows;
×
2377
  int32_t  walFsyncPeriod;
×
2378
  uint32_t hashBegin;
×
2379
  uint32_t hashEnd;
2380
  int8_t   hashMethod;
×
2381
  int8_t   walLevel;
×
2382
  int8_t   precision;
2383
  int8_t   compression;
×
2384
  int8_t   strict;
2385
  int8_t   cacheLast;
×
2386
  int8_t   isTsma;
×
2387
  int8_t   replica;
×
2388
  int8_t   selfIndex;
×
2389
  SReplica replicas[TSDB_MAX_REPLICA];
×
2390
  int32_t  numOfRetensions;
×
2391
  SArray*  pRetensions;  // SRetention
×
2392
  void*    pTsma;
×
2393
  int32_t  walRetentionPeriod;
×
2394
  int64_t  walRetentionSize;
×
2395
  int32_t  walRollPeriod;
2396
  int64_t  walSegmentSize;
×
2397
  int16_t  sstTrigger;
×
2398
  int16_t  hashPrefix;
2399
  int16_t  hashSuffix;
2400
  int32_t  tsdbPageSize;
1✔
2401
  int32_t  ssChunkSize;
1✔
2402
  int32_t  ssKeepLocal;
1✔
2403
  int8_t   ssCompact;
2404
  int64_t  reserved[6];
1✔
2405
  int8_t   learnerReplica;
1✔
2406
  int8_t   learnerSelfIndex;
1!
2407
  SReplica learnerReplicas[TSDB_MAX_LEARNER_REPLICA];
×
2408
  int32_t  changeVersion;
×
2409
  int8_t   encryptAlgorithm;
×
2410
} SCreateVnodeReq;
×
2411

×
2412
int32_t tSerializeSCreateVnodeReq(void* buf, int32_t bufLen, SCreateVnodeReq* pReq);
×
2413
int32_t tDeserializeSCreateVnodeReq(void* buf, int32_t bufLen, SCreateVnodeReq* pReq);
×
2414
int32_t tFreeSCreateVnodeReq(SCreateVnodeReq* pReq);
×
2415

2416
typedef struct {
×
2417
  int32_t compactId;
×
2418
  int32_t vgId;
×
2419
  int32_t dnodeId;
×
2420
} SQueryCompactProgressReq;
×
2421

×
2422
int32_t tSerializeSQueryCompactProgressReq(void* buf, int32_t bufLen, SQueryCompactProgressReq* pReq);
×
2423
int32_t tDeserializeSQueryCompactProgressReq(void* buf, int32_t bufLen, SQueryCompactProgressReq* pReq);
2424

1✔
2425
typedef struct {
1✔
2426
  int32_t compactId;
2427
  int32_t vgId;
2428
  int32_t dnodeId;
2429
  int32_t numberFileset;
2430
  int32_t finished;
2431
  int32_t progress;
1✔
2432
  int64_t remainingTime;
2433
} SQueryCompactProgressRsp;
1✔
2434

1✔
2435
int32_t tSerializeSQueryCompactProgressRsp(void* buf, int32_t bufLen, SQueryCompactProgressRsp* pReq);
1✔
2436
int32_t tDeserializeSQueryCompactProgressRsp(void* buf, int32_t bufLen, SQueryCompactProgressRsp* pReq);
2437

2438
typedef struct {
177✔
2439
  int32_t vgId;
177✔
2440
  int32_t dnodeId;
177!
2441
  int64_t dbUid;
×
2442
  char    db[TSDB_DB_FNAME_LEN];
×
2443
  int64_t reserved[8];
2444
} SDropVnodeReq;
2445

177!
2446
int32_t tSerializeSDropVnodeReq(void* buf, int32_t bufLen, SDropVnodeReq* pReq);
×
2447
int32_t tDeserializeSDropVnodeReq(void* buf, int32_t bufLen, SDropVnodeReq* pReq);
2448

2449
typedef struct {
177!
2450
  char    colName[TSDB_COL_NAME_LEN];
×
2451
  char    stb[TSDB_TABLE_FNAME_LEN];
×
2452
  int64_t stbUid;
2453
  int64_t dbUid;
2454
  int64_t reserved[8];
177✔
2455
} SDropIndexReq;
177!
2456

×
2457
int32_t tSerializeSDropIdxReq(void* buf, int32_t bufLen, SDropIndexReq* pReq);
2458
int32_t tDeserializeSDropIdxReq(void* buf, int32_t bufLen, SDropIndexReq* pReq);
177✔
2459

177!
2460
typedef struct {
×
2461
  int64_t     dbUid;
2462
  char        db[TSDB_DB_FNAME_LEN];
2463
  int64_t     compactStartTime;
177✔
2464
  STimeWindow tw;
2465
  int32_t     compactId;
2466
  int8_t      metaOnly;
177✔
2467
} SCompactVnodeReq;
177✔
2468

2469
int32_t tSerializeSCompactVnodeReq(void* buf, int32_t bufLen, SCompactVnodeReq* pReq);
177✔
2470
int32_t tDeserializeSCompactVnodeReq(void* buf, int32_t bufLen, SCompactVnodeReq* pReq);
177✔
2471

2472
typedef struct {
177✔
2473
  int32_t compactId;
177✔
2474
  int32_t vgId;
2475
  int32_t dnodeId;
177✔
2476
} SVKillCompactReq;
177✔
2477

2478
int32_t tSerializeSVKillCompactReq(void* buf, int32_t bufLen, SVKillCompactReq* pReq);
177!
2479
int32_t tDeserializeSVKillCompactReq(void* buf, int32_t bufLen, SVKillCompactReq* pReq);
×
2480

2481
typedef struct {
×
2482
  int32_t vgVersion;
2483
  int32_t buffer;
2484
  int32_t pageSize;
177✔
2485
  int32_t pages;
177✔
2486
  int32_t cacheLastSize;
2487
  int32_t daysPerFile;
177✔
2488
  int32_t daysToKeep0;
177✔
2489
  int32_t daysToKeep1;
2490
  int32_t daysToKeep2;
2491
  int32_t keepTimeOffset;
488✔
2492
  int32_t walFsyncPeriod;
311✔
2493
  int8_t  walLevel;
311✔
2494
  int8_t  strict;
2495
  int8_t  cacheLast;
311✔
2496
  int64_t reserved[7];
311✔
2497
  // 1st modification
2498
  int16_t sttTrigger;
311!
2499
  int32_t minRows;
×
2500
  // 2nd modification
2501
  int32_t walRetentionPeriod;
2502
  int32_t walRetentionSize;
2503
  int32_t ssKeepLocal;
177✔
2504
  int8_t  ssCompact;
177✔
2505
} SAlterVnodeConfigReq;
2506

177✔
2507
int32_t tSerializeSAlterVnodeConfigReq(void* buf, int32_t bufLen, SAlterVnodeConfigReq* pReq);
488✔
2508
int32_t tDeserializeSAlterVnodeConfigReq(void* buf, int32_t bufLen, SAlterVnodeConfigReq* pReq);
311!
2509

×
2510
typedef struct {
×
2511
  int32_t  vgId;
2512
  int8_t   strict;
311!
2513
  int8_t   selfIndex;
311✔
2514
  int8_t   replica;
2515
  SReplica replicas[TSDB_MAX_REPLICA];
311!
2516
  int64_t  reserved[8];
×
2517
  int8_t   learnerSelfIndex;
×
2518
  int8_t   learnerReplica;
2519
  SReplica learnerReplicas[TSDB_MAX_LEARNER_REPLICA];
311!
2520
  int32_t  changeVersion;
×
2521
} SAlterVnodeReplicaReq, SAlterVnodeTypeReq, SCheckLearnCatchupReq;
×
2522

2523
int32_t tSerializeSAlterVnodeReplicaReq(void* buf, int32_t bufLen, SAlterVnodeReplicaReq* pReq);
311!
2524
int32_t tDeserializeSAlterVnodeReplicaReq(void* buf, int32_t bufLen, SAlterVnodeReplicaReq* pReq);
124✔
2525

124✔
2526
typedef struct {
2527
  int32_t vgId;
187✔
2528
  int8_t  disable;
187✔
2529
} SDisableVnodeWriteReq;
2530

2531
int32_t tSerializeSDisableVnodeWriteReq(void* buf, int32_t bufLen, SDisableVnodeWriteReq* pReq);
311✔
2532
int32_t tDeserializeSDisableVnodeWriteReq(void* buf, int32_t bufLen, SDisableVnodeWriteReq* pReq);
622✔
2533

311✔
2534
typedef struct {
311✔
2535
  int32_t  srcVgId;
2536
  int32_t  dstVgId;
311✔
2537
  uint32_t hashBegin;
2538
  uint32_t hashEnd;
2539
  int32_t  changeVersion;
177✔
2540
  int32_t  reserved;
2541
} SAlterVnodeHashRangeReq;
177✔
2542

177✔
2543
int32_t tSerializeSAlterVnodeHashRangeReq(void* buf, int32_t bufLen, SAlterVnodeHashRangeReq* pReq);
177!
2544
int32_t tDeserializeSAlterVnodeHashRangeReq(void* buf, int32_t bufLen, SAlterVnodeHashRangeReq* pReq);
×
2545

×
2546
#define REQ_OPT_TBNAME 0x0
2547
#define REQ_OPT_TBUID  0x01
2548
typedef struct {
2549
  SMsgHead header;
177!
2550
  char     dbFName[TSDB_DB_FNAME_LEN];
177✔
2551
  char     tbName[TSDB_TABLE_NAME_LEN];
2552
  uint8_t  option;
2553
  uint8_t  autoCreateCtb;
177!
2554
} STableInfoReq;
177✔
2555

2556
int32_t tSerializeSTableInfoReq(void* buf, int32_t bufLen, STableInfoReq* pReq);
177✔
2557
int32_t tDeserializeSTableInfoReq(void* buf, int32_t bufLen, STableInfoReq* pReq);
2558

2559
typedef struct {
1,193✔
2560
  int8_t  metaClone;  // create local clone of the cached table meta
1,193✔
2561
  int32_t numOfVgroups;
1,193✔
2562
  int32_t numOfTables;
1,193✔
2563
  int32_t numOfUdfs;
1,193✔
2564
  char    tableNames[];
1,193✔
2565
} SMultiTableInfoReq;
531!
2566

531!
2567
// todo refactor
×
2568
typedef struct SVgroupInfo {
2569
  int32_t  vgId;
2570
  uint32_t hashBegin;
2571
  uint32_t hashEnd;
1,193✔
2572
  SEpSet   epSet;
1,193✔
2573
  union {
2574
    int32_t numOfTable;  // unit is TSDB_TABLE_NUM_UNIT
2575
    int32_t taskId;      // used in stream
40✔
2576
  };
40!
2577
} SVgroupInfo;
×
2578

×
2579
typedef struct {
2580
  int32_t     numOfVgroups;
2581
  SVgroupInfo vgroups[];
40✔
2582
} SVgroupsInfo;
40✔
2583

40✔
2584
typedef struct {
2585
  STableMetaRsp* pMeta;
2586
} SMAlterStbRsp;
×
2587

×
2588
int32_t tEncodeSMAlterStbRsp(SEncoder* pEncoder, const SMAlterStbRsp* pRsp);
×
2589
int32_t tDecodeSMAlterStbRsp(SDecoder* pDecoder, SMAlterStbRsp* pRsp);
2590
void    tFreeSMAlterStbRsp(SMAlterStbRsp* pRsp);
2591

×
2592
int32_t tSerializeSTableMetaRsp(void* buf, int32_t bufLen, STableMetaRsp* pRsp);
×
2593
int32_t tDeserializeSTableMetaRsp(void* buf, int32_t bufLen, STableMetaRsp* pRsp);
×
2594
void    tFreeSTableMetaRsp(void* pRsp);
2595
void    tFreeSTableIndexRsp(void* info);
2596

177✔
2597
typedef struct {
2598
  SArray* pMetaRsp;   // Array of STableMetaRsp
177!
2599
  SArray* pIndexRsp;  // Array of STableIndexRsp;
×
2600
} SSTbHbRsp;
×
2601

2602
int32_t tSerializeSSTbHbRsp(void* buf, int32_t bufLen, SSTbHbRsp* pRsp);
2603
int32_t tDeserializeSSTbHbRsp(void* buf, int32_t bufLen, SSTbHbRsp* pRsp);
177!
2604
void    tFreeSSTbHbRsp(SSTbHbRsp* pRsp);
177✔
2605

177✔
2606
typedef struct {
177✔
2607
  SArray* pViewRsp;  // Array of SViewMetaRsp*;
177✔
2608
} SViewHbRsp;
177✔
2609

2610
int32_t tSerializeSViewHbRsp(void* buf, int32_t bufLen, SViewHbRsp* pRsp);
2611
int32_t tDeserializeSViewHbRsp(void* buf, int32_t bufLen, SViewHbRsp* pRsp);
177✔
2612
void    tFreeSViewHbRsp(SViewHbRsp* pRsp);
2613

177!
2614
typedef struct {
×
2615
  int32_t numOfTables;
×
2616
  int32_t numOfVgroup;
×
2617
  int32_t numOfUdf;
×
2618
  int32_t contLen;
×
2619
  int8_t  compressed;  // denote if compressed or not
2620
  int32_t rawLen;      // size before compress
×
2621
  uint8_t metaClone;   // make meta clone after retrieve meta from mnode
2622
  char    meta[];
×
2623
} SMultiTableMeta;
×
2624

×
2625
typedef struct {
×
2626
  int32_t dataLen;
×
2627
  char    name[TSDB_TABLE_FNAME_LEN];
2628
  char*   data;
2629
} STagData;
×
2630

×
2631
typedef struct {
2632
  int32_t  opType;
2633
  uint32_t valLen;
2634
  char*    val;
2635
} SShowVariablesReq;
177!
2636

177✔
2637
int32_t tSerializeSShowVariablesReq(void* buf, int32_t bufLen, SShowVariablesReq* pReq);
177✔
2638
int32_t tDeserializeSShowVariablesReq(void* buf, int32_t bufLen, SShowVariablesReq* pReq);
2639
void    tFreeSShowVariablesReq(SShowVariablesReq* pReq);
177✔
2640

2641
typedef struct {
177!
2642
  char name[TSDB_CONFIG_OPTION_LEN + 1];
×
2643
  char value[TSDB_CONFIG_PATH_LEN + 1];
×
2644
  char scope[TSDB_CONFIG_SCOPE_LEN + 1];
×
2645
  char category[TSDB_CONFIG_CATEGORY_LEN + 1];
×
2646
  char info[TSDB_CONFIG_INFO_LEN + 1];
2647
} SVariablesInfo;
×
2648

×
2649
typedef struct {
×
2650
  SArray* variables;  // SArray<SVariablesInfo>
2651
} SShowVariablesRsp;
×
2652

×
2653
int32_t tSerializeSShowVariablesRsp(void* buf, int32_t bufLen, SShowVariablesRsp* pReq);
2654
int32_t tDeserializeSShowVariablesRsp(void* buf, int32_t bufLen, SShowVariablesRsp* pReq);
177✔
2655

177✔
2656
void tFreeSShowVariablesRsp(SShowVariablesRsp* pRsp);
177!
2657

×
2658
/*
×
2659
 * sql: show tables like '%a_%'
2660
 * payload is the query condition, e.g., '%a_%'
2661
 * payloadLen is the length of payload
2662
 */
2663
typedef struct {
2664
  int32_t type;
177✔
2665
  char    db[TSDB_DB_FNAME_LEN];
2666
  int32_t payloadLen;
177✔
2667
  char*   payload;
177✔
2668
} SShowReq;
2669

2670
int32_t tSerializeSShowReq(void* buf, int32_t bufLen, SShowReq* pReq);
×
2671
// int32_t tDeserializeSShowReq(void* buf, int32_t bufLen, SShowReq* pReq);
×
2672
void tFreeSShowReq(SShowReq* pReq);
×
2673

×
2674
typedef struct {
×
2675
  int64_t       showId;
×
2676
  STableMetaRsp tableMeta;
×
2677
} SShowRsp, SVShowTablesRsp;
×
2678

×
2679
// int32_t tSerializeSShowRsp(void* buf, int32_t bufLen, SShowRsp* pRsp);
2680
// int32_t tDeserializeSShowRsp(void* buf, int32_t bufLen, SShowRsp* pRsp);
×
2681
// void    tFreeSShowRsp(SShowRsp* pRsp);
×
2682

×
2683
typedef struct {
×
2684
  char    db[TSDB_DB_FNAME_LEN];
×
2685
  char    tb[TSDB_TABLE_NAME_LEN];
×
2686
  char    user[TSDB_USER_LEN];
×
2687
  char    filterTb[TSDB_TABLE_NAME_LEN];  // for ins_columns
×
2688
  int64_t showId;
2689
  int64_t compactId;  // for compact
×
2690
  bool    withFull;   // for show users full
×
2691
} SRetrieveTableReq;
×
2692

×
2693
typedef struct SSysTableSchema {
×
2694
  int8_t   type;
×
2695
  col_id_t colId;
×
2696
  int32_t  bytes;
×
2697
} SSysTableSchema;
×
2698

×
2699
int32_t tSerializeSRetrieveTableReq(void* buf, int32_t bufLen, SRetrieveTableReq* pReq);
2700
int32_t tDeserializeSRetrieveTableReq(void* buf, int32_t bufLen, SRetrieveTableReq* pReq);
2701

×
2702
#define RETRIEVE_TABLE_RSP_VERSION         0
×
2703
#define RETRIEVE_TABLE_RSP_TMQ_VERSION     1
×
2704
#define RETRIEVE_TABLE_RSP_TMQ_RAW_VERSION 2
×
2705

×
2706
typedef struct {
2707
  int64_t useconds;
2708
  int8_t  completed;  // all results are returned to client
×
2709
  int8_t  precision;
×
2710
  int8_t  compressed;
2711
  int8_t  streamBlockType;
2712
  int32_t payloadLen;
×
2713
  int32_t compLen;
×
2714
  int32_t numOfBlocks;
2715
  int64_t numOfRows;  // from int32_t change to int64_t
2716
  int64_t numOfCols;
×
2717
  int64_t skey;
×
2718
  int64_t ekey;
×
2719
  int64_t version;                         // for stream
×
2720
  TSKEY   watermark;                       // for stream
×
2721
  char    parTbName[TSDB_TABLE_NAME_LEN];  // for stream
×
2722
  char    data[];
2723
} SRetrieveTableRsp;
2724

×
2725
#define PAYLOAD_PREFIX_LEN ((sizeof(int32_t)) << 1)
×
2726

×
2727
#define SET_PAYLOAD_LEN(_p, _compLen, _fullLen) \
2728
  do {                                          \
2729
    ((int32_t*)(_p))[0] = (_compLen);           \
×
2730
    ((int32_t*)(_p))[1] = (_fullLen);           \
×
2731
  } while (0);
×
2732

2733
typedef struct {
2734
  int64_t version;
×
2735
  int64_t numOfRows;
×
2736
  int8_t  compressed;
×
2737
  int8_t  precision;
2738
  char    data[];
2739
} SRetrieveTableRspForTmq;
×
2740

×
2741
typedef struct {
×
2742
  int64_t handle;
2743
  int64_t useconds;
×
2744
  int8_t  completed;  // all results are returned to client
×
2745
  int8_t  precision;
2746
  int8_t  compressed;
×
2747
  int32_t compLen;
2748
  int32_t numOfRows;
2749
  int32_t fullLen;
×
2750
  char    data[];
2751
} SRetrieveMetaTableRsp;
×
2752

2753
typedef struct SExplainExecInfo {
×
2754
  double   startupCost;
×
2755
  double   totalCost;
2756
  uint64_t numOfRows;
2757
  uint32_t verboseLen;
×
2758
  void*    verboseInfo;
×
2759
} SExplainExecInfo;
×
2760

×
2761
typedef struct {
×
2762
  int32_t           numOfPlans;
×
2763
  SExplainExecInfo* subplanInfo;
×
2764
} SExplainRsp;
×
2765

×
2766
typedef struct {
2767
  SExplainRsp rsp;
×
2768
  uint64_t    qId;
×
2769
  uint64_t    cId;
×
2770
  uint64_t    tId;
2771
  int64_t     rId;
2772
  int32_t     eId;
×
2773
} SExplainLocalRsp;
×
2774

2775
typedef struct STableScanAnalyzeInfo {
2776
  uint64_t totalRows;
×
2777
  uint64_t totalCheckedRows;
×
2778
  uint32_t totalBlocks;
2779
  uint32_t loadBlocks;
2780
  uint32_t loadBlockStatis;
×
2781
  uint32_t skipBlocks;
×
2782
  uint32_t filterOutBlocks;
2783
  double   elapsedTime;
2784
  double   filterTime;
×
2785
} STableScanAnalyzeInfo;
×
2786

2787
int32_t tSerializeSExplainRsp(void* buf, int32_t bufLen, SExplainRsp* pRsp);
×
2788
int32_t tDeserializeSExplainRsp(void* buf, int32_t bufLen, SExplainRsp* pRsp);
×
2789
void    tFreeSExplainRsp(SExplainRsp* pRsp);
×
2790

×
2791
typedef struct {
2792
  char    config[TSDB_DNODE_CONFIG_LEN];
2793
  char    value[TSDB_CLUSTER_VALUE_LEN];
2794
  int32_t sqlLen;
×
2795
  char*   sql;
×
2796
} SMCfgClusterReq;
×
2797

2798
int32_t tSerializeSMCfgClusterReq(void* buf, int32_t bufLen, SMCfgClusterReq* pReq);
×
2799
int32_t tDeserializeSMCfgClusterReq(void* buf, int32_t bufLen, SMCfgClusterReq* pReq);
×
2800
void    tFreeSMCfgClusterReq(SMCfgClusterReq* pReq);
×
2801

2802
typedef struct {
×
2803
  char    fqdn[TSDB_FQDN_LEN];  // end point, hostname:port
2804
  int32_t port;
2805
  int32_t sqlLen;
×
2806
  char*   sql;
2807
} SCreateDnodeReq;
2808

×
2809
int32_t tSerializeSCreateDnodeReq(void* buf, int32_t bufLen, SCreateDnodeReq* pReq);
×
2810
int32_t tDeserializeSCreateDnodeReq(void* buf, int32_t bufLen, SCreateDnodeReq* pReq);
×
2811
void    tFreeSCreateDnodeReq(SCreateDnodeReq* pReq);
×
2812

2813
typedef struct {
2814
  int32_t dnodeId;
×
2815
  char    fqdn[TSDB_FQDN_LEN];
×
2816
  int32_t port;
×
2817
  int8_t  force;
2818
  int8_t  unsafe;
×
2819
  int32_t sqlLen;
2820
  char*   sql;
2821
} SDropDnodeReq;
2822

×
2823
int32_t tSerializeSDropDnodeReq(void* buf, int32_t bufLen, SDropDnodeReq* pReq);
×
2824
int32_t tDeserializeSDropDnodeReq(void* buf, int32_t bufLen, SDropDnodeReq* pReq);
2825
void    tFreeSDropDnodeReq(SDropDnodeReq* pReq);
×
2826

×
2827
enum {
×
2828
  RESTORE_TYPE__ALL = 1,
×
2829
  RESTORE_TYPE__MNODE,
2830
  RESTORE_TYPE__VNODE,
2831
  RESTORE_TYPE__QNODE,
×
2832
};
×
2833

×
2834
typedef struct {
2835
  int32_t dnodeId;
2836
  int8_t  restoreType;
×
2837
  int32_t sqlLen;
2838
  char*   sql;
2839
} SRestoreDnodeReq;
×
2840

×
2841
int32_t tSerializeSRestoreDnodeReq(void* buf, int32_t bufLen, SRestoreDnodeReq* pReq);
×
2842
int32_t tDeserializeSRestoreDnodeReq(void* buf, int32_t bufLen, SRestoreDnodeReq* pReq);
×
2843
void    tFreeSRestoreDnodeReq(SRestoreDnodeReq* pReq);
×
2844

2845
typedef struct {
×
2846
  int32_t dnodeId;
2847
  char    config[TSDB_DNODE_CONFIG_LEN];
2848
  char    value[TSDB_DNODE_VALUE_LEN];
2849
  int32_t sqlLen;
×
2850
  char*   sql;
2851
} SMCfgDnodeReq;
2852

×
2853
int32_t tSerializeSMCfgDnodeReq(void* buf, int32_t bufLen, SMCfgDnodeReq* pReq);
×
2854
int32_t tDeserializeSMCfgDnodeReq(void* buf, int32_t bufLen, SMCfgDnodeReq* pReq);
×
2855
void    tFreeSMCfgDnodeReq(SMCfgDnodeReq* pReq);
2856

×
2857
typedef struct {
2858
  char    config[TSDB_DNODE_CONFIG_LEN];
2859
  char    value[TSDB_DNODE_VALUE_LEN];
×
2860
  int32_t version;
×
2861
} SDCfgDnodeReq;
×
2862

2863
int32_t tSerializeSDCfgDnodeReq(void* buf, int32_t bufLen, SDCfgDnodeReq* pReq);
×
2864
int32_t tDeserializeSDCfgDnodeReq(void* buf, int32_t bufLen, SDCfgDnodeReq* pReq);
×
2865

2866
typedef struct {
×
2867
  int32_t dnodeId;
×
2868
  int32_t sqlLen;
×
2869
  char*   sql;
2870
} SMCreateMnodeReq, SMDropMnodeReq, SDDropMnodeReq, SMCreateQnodeReq, SMDropQnodeReq, SDCreateQnodeReq, SDDropQnodeReq,
×
2871
    SMCreateSnodeReq, SMDropSnodeReq,     SDDropSnodeReq;
2872

2873

×
2874
int32_t tSerializeSCreateDropMQSNodeReq(void* buf, int32_t bufLen, SMCreateQnodeReq* pReq);
×
2875
int32_t tDeserializeSCreateDropMQSNodeReq(void* buf, int32_t bufLen, SMCreateQnodeReq* pReq);
×
2876

2877

×
2878
typedef struct {
×
2879
  int32_t nodeId;
2880
  SEpSet  epSet;
2881
} SNodeEpSet;
×
2882

×
2883

×
2884
typedef struct {
2885
  int32_t    snodeId;
2886
  SNodeEpSet leaders[2];
×
2887
  SNodeEpSet replica;
×
2888
  int32_t    sqlLen;
×
2889
  char*      sql;
×
2890
} SDCreateSnodeReq;
2891

2892
int32_t tSerializeSDCreateSNodeReq(void *buf, int32_t bufLen, SDCreateSnodeReq *pReq);
×
2893
int32_t tDeserializeSDCreateSNodeReq(void *buf, int32_t bufLen, SDCreateSnodeReq *pReq);
×
2894
void tFreeSDCreateSnodeReq(SDCreateSnodeReq *pReq);
×
2895

2896

×
2897
void    tFreeSMCreateQnodeReq(SMCreateQnodeReq* pReq);
2898
void    tFreeSDDropQnodeReq(SDDropQnodeReq* pReq);
2899
typedef struct {
×
2900
  int8_t   replica;
×
2901
  SReplica replicas[TSDB_MAX_REPLICA];
×
2902
  int8_t   learnerReplica;
×
2903
  SReplica learnerReplicas[TSDB_MAX_LEARNER_REPLICA];
2904
  int64_t  lastIndex;
×
2905
} SDCreateMnodeReq, SDAlterMnodeReq, SDAlterMnodeTypeReq;
×
2906

2907
int32_t tSerializeSDCreateMnodeReq(void* buf, int32_t bufLen, SDCreateMnodeReq* pReq);
×
2908
int32_t tDeserializeSDCreateMnodeReq(void* buf, int32_t bufLen, SDCreateMnodeReq* pReq);
2909

2910
typedef struct {
×
2911
  int32_t urlLen;
2912
  int32_t sqlLen;
2913
  char*   url;
×
2914
  char*   sql;
×
2915
} SMCreateAnodeReq;
×
2916

×
2917
int32_t tSerializeSMCreateAnodeReq(void* buf, int32_t bufLen, SMCreateAnodeReq* pReq);
2918
int32_t tDeserializeSMCreateAnodeReq(void* buf, int32_t bufLen, SMCreateAnodeReq* pReq);
×
2919
void    tFreeSMCreateAnodeReq(SMCreateAnodeReq* pReq);
×
2920

×
2921
typedef struct {
×
2922
  int32_t anodeId;
×
2923
  int32_t sqlLen;
2924
  char*   sql;
×
2925
} SMDropAnodeReq, SMUpdateAnodeReq;
2926

2927
int32_t tSerializeSMDropAnodeReq(void* buf, int32_t bufLen, SMDropAnodeReq* pReq);
×
2928
int32_t tDeserializeSMDropAnodeReq(void* buf, int32_t bufLen, SMDropAnodeReq* pReq);
2929
void    tFreeSMDropAnodeReq(SMDropAnodeReq* pReq);
×
2930
int32_t tSerializeSMUpdateAnodeReq(void* buf, int32_t bufLen, SMUpdateAnodeReq* pReq);
2931
int32_t tDeserializeSMUpdateAnodeReq(void* buf, int32_t bufLen, SMUpdateAnodeReq* pReq);
×
2932
void    tFreeSMUpdateAnodeReq(SMUpdateAnodeReq* pReq);
2933

×
2934
typedef struct {
2935
  int32_t dnodeId;
×
2936
  int32_t bnodeProto;
×
2937
  int32_t sqlLen;
×
2938
  char*   sql;
×
2939
} SMCreateBnodeReq, SDCreateBnodeReq;
×
2940

2941
int32_t tSerializeSMCreateBnodeReq(void* buf, int32_t bufLen, SMCreateBnodeReq* pReq);
2942
int32_t tDeserializeSMCreateBnodeReq(void* buf, int32_t bufLen, SMCreateBnodeReq* pReq);
×
2943
void    tFreeSMCreateBnodeReq(SMCreateBnodeReq* pReq);
2944

×
2945
typedef struct {
2946
  int32_t dnodeId;
2947
  int32_t sqlLen;
×
2948
  char*   sql;
×
2949
} SMDropBnodeReq, SDDropBnodeReq;
×
2950

2951
int32_t tSerializeSMDropBnodeReq(void* buf, int32_t bufLen, SMDropBnodeReq* pReq);
×
2952
int32_t tDeserializeSMDropBnodeReq(void* buf, int32_t bufLen, SMDropBnodeReq* pReq);
×
2953
void    tFreeSMDropBnodeReq(SMDropBnodeReq* pReq);
2954

×
2955
typedef struct {
2956
  int32_t vgId;
802✔
2957
  int32_t hbSeq;
802✔
2958
} SVArbHbReqMember;
802✔
2959

2960
typedef struct {
802!
2961
  int32_t dnodeId;
802✔
2962
  char*   arbToken;
802✔
2963
  int64_t arbTerm;
2964
  SArray* hbMembers;  // SVArbHbReqMember
2965
} SVArbHeartBeatReq;
802!
2966

×
2967
int32_t tSerializeSVArbHeartBeatReq(void* buf, int32_t bufLen, SVArbHeartBeatReq* pReq);
2968
int32_t tDeserializeSVArbHeartBeatReq(void* buf, int32_t bufLen, SVArbHeartBeatReq* pReq);
802✔
2969
void    tFreeSVArbHeartBeatReq(SVArbHeartBeatReq* pReq);
2970

803✔
2971
typedef struct {
2972
  int32_t vgId;
803!
2973
  char    memberToken[TSDB_ARB_TOKEN_SIZE];
×
2974
  int32_t hbSeq;
×
2975
} SVArbHbRspMember;
×
2976

2977
typedef struct {
2978
  char    arbToken[TSDB_ARB_TOKEN_SIZE];
×
2979
  int32_t dnodeId;
2980
  SArray* hbMembers;  // SVArbHbRspMember
2981
} SVArbHeartBeatRsp;
803✔
2982

803!
2983
int32_t tSerializeSVArbHeartBeatRsp(void* buf, int32_t bufLen, SVArbHeartBeatRsp* pRsp);
×
2984
int32_t tDeserializeSVArbHeartBeatRsp(void* buf, int32_t bufLen, SVArbHeartBeatRsp* pRsp);
×
2985
void    tFreeSVArbHeartBeatRsp(SVArbHeartBeatRsp* pRsp);
×
2986

×
2987
typedef struct {
2988
  char*   arbToken;
2989
  int64_t arbTerm;
803!
2990
  char*   member0Token;
2991
  char*   member1Token;
803✔
2992
} SVArbCheckSyncReq;
803✔
2993

803!
2994
int32_t tSerializeSVArbCheckSyncReq(void* buf, int32_t bufLen, SVArbCheckSyncReq* pReq);
×
2995
int32_t tDeserializeSVArbCheckSyncReq(void* buf, int32_t bufLen, SVArbCheckSyncReq* pReq);
×
2996
void    tFreeSVArbCheckSyncReq(SVArbCheckSyncReq* pRsp);
×
2997

2998
typedef struct {
2999
  char*   arbToken;
803✔
3000
  char*   member0Token;
803✔
3001
  char*   member1Token;
803✔
3002
  int32_t vgId;
3003
  int32_t errCode;
3004
} SVArbCheckSyncRsp;
×
3005

3006
int32_t tSerializeSVArbCheckSyncRsp(void* buf, int32_t bufLen, SVArbCheckSyncRsp* pRsp);
×
3007
int32_t tDeserializeSVArbCheckSyncRsp(void* buf, int32_t bufLen, SVArbCheckSyncRsp* pRsp);
×
3008
void    tFreeSVArbCheckSyncRsp(SVArbCheckSyncRsp* pRsp);
×
3009

×
3010
typedef struct {
3011
  char*   arbToken;
3012
  int64_t arbTerm;
×
3013
  char*   memberToken;
3014
  int8_t  force;
3015
} SVArbSetAssignedLeaderReq;
×
3016

×
3017
int32_t tSerializeSVArbSetAssignedLeaderReq(void* buf, int32_t bufLen, SVArbSetAssignedLeaderReq* pReq);
×
3018
int32_t tDeserializeSVArbSetAssignedLeaderReq(void* buf, int32_t bufLen, SVArbSetAssignedLeaderReq* pReq);
3019
void    tFreeSVArbSetAssignedLeaderReq(SVArbSetAssignedLeaderReq* pReq);
×
3020

×
3021
typedef struct {
×
3022
  char*   arbToken;
3023
  char*   memberToken;
3024
  int32_t vgId;
×
3025
} SVArbSetAssignedLeaderRsp;
3026

×
3027
int32_t tSerializeSVArbSetAssignedLeaderRsp(void* buf, int32_t bufLen, SVArbSetAssignedLeaderRsp* pRsp);
×
3028
int32_t tDeserializeSVArbSetAssignedLeaderRsp(void* buf, int32_t bufLen, SVArbSetAssignedLeaderRsp* pRsp);
×
3029
void    tFreeSVArbSetAssignedLeaderRsp(SVArbSetAssignedLeaderRsp* pRsp);
×
3030

×
3031
typedef struct {
×
3032
  int32_t dnodeId;
3033
  char*   token;
3034
} SMArbUpdateGroupMember;
×
3035

×
3036
typedef struct {
3037
  int32_t dnodeId;
3038
  char*   token;
802✔
3039
  int8_t  acked;
802!
3040
} SMArbUpdateGroupAssigned;
×
3041

×
3042
typedef struct {
3043
  int32_t                  vgId;
3044
  int64_t                  dbUid;
802!
3045
  SMArbUpdateGroupMember   members[2];
802!
3046
  int8_t                   isSync;
×
3047
  int8_t                   assignedAcked;
3048
  SMArbUpdateGroupAssigned assignedLeader;
802✔
3049
  int64_t                  version;
802!
3050
  int32_t                  code;
×
3051
  int64_t                  updateTimeMs;
×
3052
} SMArbUpdateGroup;
3053

3054
typedef struct {
802✔
3055
  SArray* updateArray;  // SMArbUpdateGroup
802✔
3056
} SMArbUpdateGroupBatchReq;
802!
3057

×
3058
int32_t tSerializeSMArbUpdateGroupBatchReq(void* buf, int32_t bufLen, SMArbUpdateGroupBatchReq* pReq);
×
3059
int32_t tDeserializeSMArbUpdateGroupBatchReq(void* buf, int32_t bufLen, SMArbUpdateGroupBatchReq* pReq);
3060
void    tFreeSMArbUpdateGroupBatchReq(SMArbUpdateGroupBatchReq* pReq);
802✔
3061

802!
3062
typedef struct {
×
3063
  char queryStrId[TSDB_QUERY_ID_LEN];
3064
} SKillQueryReq;
3065

802✔
3066
int32_t tSerializeSKillQueryReq(void* buf, int32_t bufLen, SKillQueryReq* pReq);
802!
3067
int32_t tDeserializeSKillQueryReq(void* buf, int32_t bufLen, SKillQueryReq* pReq);
802✔
3068

802✔
3069
typedef struct {
802✔
3070
  uint32_t connId;
3071
} SKillConnReq;
802!
3072

3073
int32_t tSerializeSKillConnReq(void* buf, int32_t bufLen, SKillConnReq* pReq);
3074
int32_t tDeserializeSKillConnReq(void* buf, int32_t bufLen, SKillConnReq* pReq);
3075

3076
typedef struct {
802✔
3077
  int32_t transId;
3078
} SKillTransReq;
3079

×
3080
int32_t tSerializeSKillTransReq(void* buf, int32_t bufLen, SKillTransReq* pReq);
×
3081
int32_t tDeserializeSKillTransReq(void* buf, int32_t bufLen, SKillTransReq* pReq);
×
3082

×
3083
typedef struct {
3084
  int32_t useless;  // useless
3085
  int32_t sqlLen;
×
3086
  char*   sql;
×
3087
} SBalanceVgroupReq;
×
3088

3089
int32_t tSerializeSBalanceVgroupReq(void* buf, int32_t bufLen, SBalanceVgroupReq* pReq);
×
3090
int32_t tDeserializeSBalanceVgroupReq(void* buf, int32_t bufLen, SBalanceVgroupReq* pReq);
×
3091
void    tFreeSBalanceVgroupReq(SBalanceVgroupReq* pReq);
×
3092

×
3093
typedef struct {
3094
  int32_t useless;  // useless
3095
  int32_t sqlLen;
×
3096
  char*   sql;
×
3097
} SAssignLeaderReq;
×
3098

×
3099
int32_t tSerializeSAssignLeaderReq(void* buf, int32_t bufLen, SAssignLeaderReq* pReq);
×
3100
int32_t tDeserializeSAssignLeaderReq(void* buf, int32_t bufLen, SAssignLeaderReq* pReq);
3101
void    tFreeSAssignLeaderReq(SAssignLeaderReq* pReq);
×
3102
typedef struct {
×
3103
  int32_t vgId1;
×
3104
  int32_t vgId2;
×
3105
} SMergeVgroupReq;
3106

×
3107
int32_t tSerializeSMergeVgroupReq(void* buf, int32_t bufLen, SMergeVgroupReq* pReq);
3108
int32_t tDeserializeSMergeVgroupReq(void* buf, int32_t bufLen, SMergeVgroupReq* pReq);
3109

3110
typedef struct {
3111
  int32_t vgId;
×
3112
  int32_t dnodeId1;
3113
  int32_t dnodeId2;
3114
  int32_t dnodeId3;
94✔
3115
  int32_t sqlLen;
94✔
3116
  char*   sql;
3117
} SRedistributeVgroupReq;
94✔
3118

3119
int32_t tSerializeSRedistributeVgroupReq(void* buf, int32_t bufLen, SRedistributeVgroupReq* pReq);
94!
3120
int32_t tDeserializeSRedistributeVgroupReq(void* buf, int32_t bufLen, SRedistributeVgroupReq* pReq);
3121
void    tFreeSRedistributeVgroupReq(SRedistributeVgroupReq* pReq);
3122

94✔
3123
typedef struct {
94✔
3124
  int32_t reserved;
3125
  int32_t vgId;
94!
3126
  int32_t sqlLen;
×
3127
  char*   sql;
×
3128
  char    db[TSDB_DB_FNAME_LEN];
×
3129
} SBalanceVgroupLeaderReq;
×
3130

3131
int32_t tSerializeSBalanceVgroupLeaderReq(void* buf, int32_t bufLen, SBalanceVgroupLeaderReq* pReq);
3132
int32_t tDeserializeSBalanceVgroupLeaderReq(void* buf, int32_t bufLen, SBalanceVgroupLeaderReq* pReq);
94!
3133
void    tFreeSBalanceVgroupLeaderReq(SBalanceVgroupLeaderReq* pReq);
×
3134

×
3135
typedef struct {
×
3136
  int32_t vgId;
3137
} SForceBecomeFollowerReq;
3138

188✔
3139
int32_t tSerializeSForceBecomeFollowerReq(void* buf, int32_t bufLen, SForceBecomeFollowerReq* pReq);
94✔
3140
// int32_t tDeserializeSForceBecomeFollowerReq(void* buf, int32_t bufLen, SForceBecomeFollowerReq* pReq);
94!
3141

×
3142
typedef struct {
×
3143
  int32_t vgId;
3144
  bool    force;
3145
} SSplitVgroupReq;
94!
3146

3147
int32_t tSerializeSSplitVgroupReq(void* buf, int32_t bufLen, SSplitVgroupReq* pReq);
3148
int32_t tDeserializeSSplitVgroupReq(void* buf, int32_t bufLen, SSplitVgroupReq* pReq);
3149

94✔
3150
typedef struct {
94✔
3151
  char user[TSDB_USER_LEN];
94✔
3152
  char spi;
3153
  char encrypt;
3154
  char secret[TSDB_PASSWORD_LEN];
94✔
3155
  char ckey[TSDB_PASSWORD_LEN];
3156
} SAuthReq, SAuthRsp;
3157

94✔
3158
// int32_t tSerializeSAuthReq(void* buf, int32_t bufLen, SAuthReq* pReq);
94✔
3159
// int32_t tDeserializeSAuthReq(void* buf, int32_t bufLen, SAuthReq* pReq);
94✔
3160

3161
typedef struct {
94✔
3162
  int32_t statusCode;
3163
  char    details[1024];
3164
} SServerStatusRsp;
94!
3165

×
3166
int32_t tSerializeSServerStatusRsp(void* buf, int32_t bufLen, SServerStatusRsp* pRsp);
×
3167
int32_t tDeserializeSServerStatusRsp(void* buf, int32_t bufLen, SServerStatusRsp* pRsp);
×
3168

3169
/**
3170
 * The layout of the query message payload is as following:
3171
 * +--------------------+---------------------------------+
94!
3172
 * |Sql statement       | Physical plan                   |
3173
 * |(denoted by sqlLen) |(In JSON, denoted by contentLen) |
×
3174
 * +--------------------+---------------------------------+
×
3175
 */
×
3176
typedef struct SSubQueryMsg {
×
3177
  SMsgHead header;
3178
  uint64_t sId;
×
3179
  uint64_t queryId;
3180
  uint64_t clientId;
3181
  uint64_t taskId;
×
3182
  int64_t  refId;
3183
  int32_t  execId;
3184
  int32_t  msgMask;
×
3185
  int8_t   taskType;
×
3186
  int8_t   explain;
3187
  int8_t   needFetch;
3188
  int8_t   compress;
94✔
3189
  uint32_t sqlLen;
3190
  char*    sql;
3191
  uint32_t msgLen;
3192
  char*    msg;
3193
} SSubQueryMsg;
3194

94✔
3195
int32_t tSerializeSSubQueryMsg(void* buf, int32_t bufLen, SSubQueryMsg* pReq);
94!
3196
int32_t tDeserializeSSubQueryMsg(void* buf, int32_t bufLen, SSubQueryMsg* pReq);
×
3197
void    tFreeSSubQueryMsg(SSubQueryMsg* pReq);
3198

3199
typedef struct {
3200
  SMsgHead header;
3201
  uint64_t sId;
818✔
3202
  uint64_t queryId;
818✔
3203
  uint64_t taskId;
818✔
3204
} SSinkDataReq;
818!
3205

×
3206
typedef struct {
×
3207
  SMsgHead header;
×
3208
  uint64_t sId;
3209
  uint64_t queryId;
3210
  uint64_t clientId;
818!
3211
  uint64_t taskId;
3212
  int32_t  execId;
3213
} SQueryContinueReq;
818!
3214

818✔
3215
typedef struct {
3216
  SMsgHead header;
3217
  uint64_t sId;
818✔
3218
  uint64_t queryId;
818✔
3219
  uint64_t taskId;
807✔
3220
} SResReadyReq;
807✔
3221

3222
typedef struct {
818✔
3223
  int32_t code;
3224
  char    tbFName[TSDB_TABLE_FNAME_LEN];
×
3225
  int32_t sversion;
3226
  int32_t tversion;
3227
} SResReadyRsp;
3228

3229
typedef struct SOperatorParam {
×
3230
  int32_t opType;
3231
  int32_t downstreamIdx;
3232
  void*   value;
3233
  SArray* pChildren;  // SArray<SOperatorParam*>
3234
  bool    reUse;
3235
} SOperatorParam;
3236

3237
typedef struct SColIdNameKV {
3238
  col_id_t colId;
3239
  char     colName[TSDB_COL_NAME_LEN];
3240
} SColIdNameKV;
3241

3242
typedef struct SColIdPair {
3243
  col_id_t vtbColId;
3244
  col_id_t orgColId;
3245
} SColIdPair;
3246

3247
typedef struct SOrgTbInfo {
3248
  int32_t vgId;
3249
  char    tbName[TSDB_TABLE_FNAME_LEN];
3250
  SArray* colMap;  // SArray<SColIdNameKV>
3251
} SOrgTbInfo;
3252

3253
typedef struct STableScanOperatorParam {
3254
  bool        tableSeq;
3255
  SArray*     pUidList;
3256
  SOrgTbInfo* pOrgTbInfo;
3257
  STimeWindow window;
3258
} STableScanOperatorParam;
3259

3260
typedef struct STagScanOperatorParam {
3261
  tb_uid_t       vcUid;
3262
} STagScanOperatorParam;
3263

3264
typedef struct SVTableScanOperatorParam {
3265
  uint64_t        uid;
3266
  SOperatorParam* pTagScanOp;
3267
  SArray*         pOpParamArray;  // SArray<SOperatorParam>
3268
} SVTableScanOperatorParam;
3269

3270
struct SStreamRuntimeFuncInfo;
3271
typedef struct {
3272
  SMsgHead                       header;
3273
  uint64_t                       sId;
3274
  uint64_t                       queryId;
3275
  uint64_t                       clientId;
3276
  uint64_t                       taskId;
3277
  int32_t                        execId;
3278
  SOperatorParam*                pOpParam;
3279

3280
  // used for new-stream
3281
  struct SStreamRuntimeFuncInfo* pStRtFuncInfo;
3282
  bool                           reset;
3283
  bool                           dynTbname;
3284
  // used for new-stream
3285
} SResFetchReq;
3286

3287
int32_t tSerializeSResFetchReq(void* buf, int32_t bufLen, SResFetchReq* pReq);
3288
int32_t tDeserializeSResFetchReq(void* buf, int32_t bufLen, SResFetchReq* pReq);
3289
void    tDestroySResFetchReq(SResFetchReq* pReq);
3290
typedef struct {
3291
  SMsgHead header;
3292
  uint64_t clientId;
3293
} SSchTasksStatusReq;
3294

3295
typedef struct {
3296
  uint64_t queryId;
3297
  uint64_t clientId;
3298
  uint64_t taskId;
3299
  int64_t  refId;
3300
  int32_t  execId;
3301
  int8_t   status;
3302
} STaskStatus;
3303

3304
typedef struct {
3305
  int64_t refId;
3306
  SArray* taskStatus;  // SArray<STaskStatus>
3307
} SSchedulerStatusRsp;
3308

3309
typedef struct {
3310
  uint64_t queryId;
3311
  uint64_t taskId;
3312
  int8_t   action;
3313
} STaskAction;
3314

3315
typedef struct SQueryNodeEpId {
3316
  int32_t nodeId;  // vgId or qnodeId
3317
  SEp     ep;
3318
} SQueryNodeEpId;
3319

3320
typedef struct {
3321
  SMsgHead       header;
3322
  uint64_t       clientId;
3323
  SQueryNodeEpId epId;
3324
  SArray*        taskAction;  // SArray<STaskAction>
3325
} SSchedulerHbReq;
3326

3327
int32_t tSerializeSSchedulerHbReq(void* buf, int32_t bufLen, SSchedulerHbReq* pReq);
3328
int32_t tDeserializeSSchedulerHbReq(void* buf, int32_t bufLen, SSchedulerHbReq* pReq);
3329
void    tFreeSSchedulerHbReq(SSchedulerHbReq* pReq);
3330

3331
typedef struct {
3332
  SQueryNodeEpId epId;
3333
  SArray*        taskStatus;  // SArray<STaskStatus>
3334
} SSchedulerHbRsp;
3335

3336
int32_t tSerializeSSchedulerHbRsp(void* buf, int32_t bufLen, SSchedulerHbRsp* pRsp);
3337
int32_t tDeserializeSSchedulerHbRsp(void* buf, int32_t bufLen, SSchedulerHbRsp* pRsp);
3338
void    tFreeSSchedulerHbRsp(SSchedulerHbRsp* pRsp);
3339

3340
typedef struct {
3341
  SMsgHead header;
3342
  uint64_t sId;
3343
  uint64_t queryId;
3344
  uint64_t clientId;
3345
  uint64_t taskId;
3346
  int64_t  refId;
3347
  int32_t  execId;
3348
} STaskCancelReq;
3349

3350
typedef struct {
3351
  int32_t code;
3352
} STaskCancelRsp;
3353

3354
typedef struct {
3355
  SMsgHead header;
3356
  uint64_t sId;
3357
  uint64_t queryId;
3358
  uint64_t clientId;
3359
  uint64_t taskId;
3360
  int64_t  refId;
3361
  int32_t  execId;
3362
} STaskDropReq;
3363

3364
int32_t tSerializeSTaskDropReq(void* buf, int32_t bufLen, STaskDropReq* pReq);
3365
int32_t tDeserializeSTaskDropReq(void* buf, int32_t bufLen, STaskDropReq* pReq);
3366

3367
typedef enum {
3368
  TASK_NOTIFY_FINISHED = 1,
3369
} ETaskNotifyType;
3370

3371
typedef struct {
3372
  SMsgHead        header;
3373
  uint64_t        sId;
3374
  uint64_t        queryId;
3375
  uint64_t        clientId;
3376
  uint64_t        taskId;
3377
  int64_t         refId;
3378
  int32_t         execId;
3379
  ETaskNotifyType type;
3380
} STaskNotifyReq;
3381

3382
int32_t tSerializeSTaskNotifyReq(void* buf, int32_t bufLen, STaskNotifyReq* pReq);
3383
int32_t tDeserializeSTaskNotifyReq(void* buf, int32_t bufLen, STaskNotifyReq* pReq);
3384

3385
int32_t tSerializeSQueryTableRsp(void* buf, int32_t bufLen, SQueryTableRsp* pRsp);
3386
int32_t tDeserializeSQueryTableRsp(void* buf, int32_t bufLen, SQueryTableRsp* pRsp);
3387

3388
typedef struct {
3389
  int32_t code;
3390
} STaskDropRsp;
3391

3392
#define STREAM_TRIGGER_AT_ONCE                 1
3393
#define STREAM_TRIGGER_WINDOW_CLOSE            2
3394
#define STREAM_TRIGGER_MAX_DELAY               3
3395
#define STREAM_TRIGGER_FORCE_WINDOW_CLOSE      4
3396
#define STREAM_TRIGGER_CONTINUOUS_WINDOW_CLOSE 5
3397

3398
#define STREAM_DEFAULT_IGNORE_EXPIRED 1
3399
#define STREAM_FILL_HISTORY_ON        1
3400
#define STREAM_FILL_HISTORY_OFF       0
3401
#define STREAM_DEFAULT_FILL_HISTORY   STREAM_FILL_HISTORY_OFF
3402
#define STREAM_DEFAULT_IGNORE_UPDATE  1
3403
#define STREAM_CREATE_STABLE_TRUE     1
3404
#define STREAM_CREATE_STABLE_FALSE    0
3405

3406
typedef struct SVgroupVer {
3407
  int32_t vgId;
3408
  int64_t ver;
3409
} SVgroupVer;
3410

3411
typedef struct STaskNotifyEventStat {
3412
  int64_t notifyEventAddTimes;     // call times of add function
3413
  int64_t notifyEventAddElems;     // elements added by add function
3414
  double  notifyEventAddCostSec;   // time cost of add function
3415
  int64_t notifyEventPushTimes;    // call times of push function
3416
  int64_t notifyEventPushElems;    // elements pushed by push function
3417
  double  notifyEventPushCostSec;  // time cost of push function
3418
  int64_t notifyEventPackTimes;    // call times of pack function
3419
  int64_t notifyEventPackElems;    // elements packed by pack function
3420
  double  notifyEventPackCostSec;  // time cost of pack function
3421
  int64_t notifyEventSendTimes;    // call times of send function
3422
  int64_t notifyEventSendElems;    // elements sent by send function
3423
  double  notifyEventSendCostSec;  // time cost of send function
3424
  int64_t notifyEventHoldElems;    // elements hold due to watermark
3425
} STaskNotifyEventStat;
3426

3427
enum {
3428
  TOPIC_SUB_TYPE__DB = 1,
3429
  TOPIC_SUB_TYPE__TABLE,
3430
  TOPIC_SUB_TYPE__COLUMN,
3431
};
3432

3433
#define DEFAULT_MAX_POLL_INTERVAL  300000
3434
#define DEFAULT_SESSION_TIMEOUT    12000
3435
#define DEFAULT_MAX_POLL_WAIT_TIME 1000
3436
#define DEFAULT_MIN_POLL_ROWS      4096
3437

3438
typedef struct {
3439
  char   name[TSDB_TOPIC_FNAME_LEN];  // accout.topic
3440
  int8_t igExists;
3441
  int8_t subType;
3442
  int8_t withMeta;
3443
  char*  sql;
3444
  char   subDbName[TSDB_DB_FNAME_LEN];
3445
  char*  ast;
3446
  char   subStbName[TSDB_TABLE_FNAME_LEN];
3447
} SCMCreateTopicReq;
3448

3449
int32_t tSerializeSCMCreateTopicReq(void* buf, int32_t bufLen, const SCMCreateTopicReq* pReq);
3450
int32_t tDeserializeSCMCreateTopicReq(void* buf, int32_t bufLen, SCMCreateTopicReq* pReq);
3451
void    tFreeSCMCreateTopicReq(SCMCreateTopicReq* pReq);
3452

3453
typedef struct {
3454
  int64_t consumerId;
3455
} SMqConsumerRecoverMsg, SMqConsumerClearMsg;
3456

3457
typedef struct {
3458
  int64_t consumerId;
3459
  char    cgroup[TSDB_CGROUP_LEN];
3460
  char    clientId[TSDB_CLIENT_ID_LEN];
3461
  char    user[TSDB_USER_LEN];
3462
  char    fqdn[TSDB_FQDN_LEN];
3463
  SArray* topicNames;  // SArray<char**>
3464

3465
  int8_t  withTbName;
3466
  int8_t  autoCommit;
3467
  int32_t autoCommitInterval;
3468
  int8_t  resetOffsetCfg;
3469
  int8_t  enableReplay;
3470
  int8_t  enableBatchMeta;
3471
  int32_t sessionTimeoutMs;
3472
  int32_t maxPollIntervalMs;
3473
} SCMSubscribeReq;
3474

3475
static FORCE_INLINE int32_t tSerializeSCMSubscribeReq(void** buf, const SCMSubscribeReq* pReq) {
3476
  int32_t tlen = 0;
2,460✔
3477
  tlen += taosEncodeFixedI64(buf, pReq->consumerId);
2,460!
3478
  tlen += taosEncodeString(buf, pReq->cgroup);
2,460✔
3479
  tlen += taosEncodeString(buf, pReq->clientId);
2,460✔
3480

3481
  int32_t topicNum = taosArrayGetSize(pReq->topicNames);
2,460!
3482
  tlen += taosEncodeFixedI32(buf, topicNum);
2,460✔
3483

3484
  for (int32_t i = 0; i < topicNum; i++) {
3,482✔
3485
    tlen += taosEncodeString(buf, (char*)taosArrayGetP(pReq->topicNames, i));
2,044✔
3486
  }
3487

3488
  tlen += taosEncodeFixedI8(buf, pReq->withTbName);
2,460!
3489
  tlen += taosEncodeFixedI8(buf, pReq->autoCommit);
2,460!
3490
  tlen += taosEncodeFixedI32(buf, pReq->autoCommitInterval);
2,460!
3491
  tlen += taosEncodeFixedI8(buf, pReq->resetOffsetCfg);
2,460!
3492
  tlen += taosEncodeFixedI8(buf, pReq->enableReplay);
2,460!
3493
  tlen += taosEncodeFixedI8(buf, pReq->enableBatchMeta);
2,460!
3494
  tlen += taosEncodeFixedI32(buf, pReq->sessionTimeoutMs);
2,460!
3495
  tlen += taosEncodeFixedI32(buf, pReq->maxPollIntervalMs);
2,460!
3496
  tlen += taosEncodeString(buf, pReq->user);
2,460✔
3497
  tlen += taosEncodeString(buf, pReq->fqdn);
2,460✔
3498

3499
  return tlen;
2,460✔
3500
}
3501

3502
static FORCE_INLINE int32_t tDeserializeSCMSubscribeReq(void* buf, SCMSubscribeReq* pReq, int32_t len) {
3503
  void* start = buf;
1,325✔
3504
  buf = taosDecodeFixedI64(buf, &pReq->consumerId);
1,325!
3505
  buf = taosDecodeStringTo(buf, pReq->cgroup);
1,325✔
3506
  buf = taosDecodeStringTo(buf, pReq->clientId);
1,325✔
3507

3508
  int32_t topicNum = 0;
1,325!
3509
  buf = taosDecodeFixedI32(buf, &topicNum);
1,325✔
3510

3511
  pReq->topicNames = taosArrayInit(topicNum, sizeof(void*));
1,325✔
3512
  if (pReq->topicNames == NULL) {
1,325!
3513
    return terrno;
×
3514
  }
3515
  for (int32_t i = 0; i < topicNum; i++) {
1,937✔
3516
    char* name = NULL;
612✔
3517
    buf = taosDecodeString(buf, &name);
612✔
3518
    if (taosArrayPush(pReq->topicNames, &name) == NULL) {
1,224!
3519
      return terrno;
×
3520
    }
3521
  }
3522

3523
  buf = taosDecodeFixedI8(buf, &pReq->withTbName);
1,325✔
3524
  buf = taosDecodeFixedI8(buf, &pReq->autoCommit);
1,325✔
3525
  buf = taosDecodeFixedI32(buf, &pReq->autoCommitInterval);
1,325!
3526
  buf = taosDecodeFixedI8(buf, &pReq->resetOffsetCfg);
1,325✔
3527
  buf = taosDecodeFixedI8(buf, &pReq->enableReplay);
1,325✔
3528
  buf = taosDecodeFixedI8(buf, &pReq->enableBatchMeta);
1,325✔
3529
  if ((char*)buf - (char*)start < len) {
1,325!
3530
    buf = taosDecodeFixedI32(buf, &pReq->sessionTimeoutMs);
1,325!
3531
    buf = taosDecodeFixedI32(buf, &pReq->maxPollIntervalMs);
1,325!
3532
    buf = taosDecodeStringTo(buf, pReq->user);
1,325✔
3533
    buf = taosDecodeStringTo(buf, pReq->fqdn);
2,650✔
3534
  } else {
3535
    pReq->sessionTimeoutMs = DEFAULT_SESSION_TIMEOUT;
×
3536
    pReq->maxPollIntervalMs = DEFAULT_MAX_POLL_INTERVAL;
×
3537
  }
3538

3539
  return 0;
1,325✔
3540
}
3541

3542
typedef struct {
3543
  char    key[TSDB_SUBSCRIBE_KEY_LEN];
3544
  SArray* removedConsumers;  // SArray<int64_t>
3545
  SArray* newConsumers;      // SArray<int64_t>
3546
} SMqRebInfo;
3547

3548
static FORCE_INLINE SMqRebInfo* tNewSMqRebSubscribe(const char* key) {
3549
  SMqRebInfo* pRebInfo = (SMqRebInfo*)taosMemoryCalloc(1, sizeof(SMqRebInfo));
1,320!
3550
  if (pRebInfo == NULL) {
1,320!
3551
    return NULL;
×
3552
  }
3553
  tstrncpy(pRebInfo->key, key, TSDB_SUBSCRIBE_KEY_LEN);
1,320✔
3554
  pRebInfo->removedConsumers = taosArrayInit(0, sizeof(int64_t));
1,320✔
3555
  if (pRebInfo->removedConsumers == NULL) {
1,320!
3556
    goto _err;
×
3557
  }
3558
  pRebInfo->newConsumers = taosArrayInit(0, sizeof(int64_t));
1,320✔
3559
  if (pRebInfo->newConsumers == NULL) {
1,320!
3560
    goto _err;
×
3561
  }
3562
  return pRebInfo;
1,320✔
3563
_err:
×
3564
  taosArrayDestroy(pRebInfo->removedConsumers);
×
3565
  taosArrayDestroy(pRebInfo->newConsumers);
×
3566
  taosMemoryFreeClear(pRebInfo);
×
3567
  return NULL;
×
3568
}
3569

3570
typedef struct {
3571
  int64_t streamId;
3572
  int64_t checkpointId;
3573
  char    streamName[TSDB_STREAM_FNAME_LEN];
3574
} SMStreamDoCheckpointMsg;
3575

3576
typedef struct {
3577
  int64_t status;
3578
} SMVSubscribeRsp;
3579

3580
typedef struct {
3581
  char    name[TSDB_TOPIC_FNAME_LEN];
3582
  int8_t  igNotExists;
3583
  int32_t sqlLen;
3584
  char*   sql;
3585
  int8_t  force;
3586
} SMDropTopicReq;
3587

3588
int32_t tSerializeSMDropTopicReq(void* buf, int32_t bufLen, SMDropTopicReq* pReq);
3589
int32_t tDeserializeSMDropTopicReq(void* buf, int32_t bufLen, SMDropTopicReq* pReq);
3590
void    tFreeSMDropTopicReq(SMDropTopicReq* pReq);
3591

3592
typedef struct {
3593
  char   topic[TSDB_TOPIC_FNAME_LEN];
3594
  char   cgroup[TSDB_CGROUP_LEN];
3595
  int8_t igNotExists;
3596
  int8_t force;
3597
} SMDropCgroupReq;
3598

3599
int32_t tSerializeSMDropCgroupReq(void* buf, int32_t bufLen, SMDropCgroupReq* pReq);
3600
int32_t tDeserializeSMDropCgroupReq(void* buf, int32_t bufLen, SMDropCgroupReq* pReq);
3601

3602
typedef struct {
3603
  int8_t reserved;
3604
} SMDropCgroupRsp;
3605

3606
typedef struct {
3607
  char    name[TSDB_TABLE_FNAME_LEN];
3608
  int8_t  alterType;
3609
  SSchema schema;
3610
} SAlterTopicReq;
3611

3612
typedef struct {
3613
  SMsgHead head;
3614
  char     name[TSDB_TABLE_FNAME_LEN];
3615
  int64_t  tuid;
3616
  int32_t  sverson;
3617
  int32_t  execLen;
3618
  char*    executor;
3619
  int32_t  sqlLen;
3620
  char*    sql;
3621
} SDCreateTopicReq;
3622

3623
typedef struct {
3624
  SMsgHead head;
3625
  char     name[TSDB_TABLE_FNAME_LEN];
3626
  int64_t  tuid;
3627
} SDDropTopicReq;
3628

3629
typedef struct {
3630
  int64_t maxdelay[2];
3631
  int64_t watermark[2];
3632
  int64_t deleteMark[2];
3633
  int32_t qmsgLen[2];
3634
  char*   qmsg[2];  // pAst:qmsg:SRetention => trigger aggr task1/2
3635
} SRSmaParam;
3636

3637
int32_t tEncodeSRSmaParam(SEncoder* pCoder, const SRSmaParam* pRSmaParam);
3638
int32_t tDecodeSRSmaParam(SDecoder* pCoder, SRSmaParam* pRSmaParam);
3639

3640
// TDMT_VND_CREATE_STB ==============
3641
typedef struct SVCreateStbReq {
3642
  char*           name;
3643
  tb_uid_t        suid;
3644
  int8_t          rollup;
3645
  SSchemaWrapper  schemaRow;
3646
  SSchemaWrapper  schemaTag;
3647
  SRSmaParam      rsmaParam;
3648
  int32_t         alterOriDataLen;
3649
  void*           alterOriData;
3650
  int8_t          source;
3651
  int8_t          colCmpred;
3652
  SColCmprWrapper colCmpr;
3653
  int64_t         keep;
3654
  SExtSchema*     pExtSchemas;
3655
  int8_t          virtualStb;
3656
} SVCreateStbReq;
3657

3658
int tEncodeSVCreateStbReq(SEncoder* pCoder, const SVCreateStbReq* pReq);
3659
int tDecodeSVCreateStbReq(SDecoder* pCoder, SVCreateStbReq* pReq);
3660

3661
// TDMT_VND_DROP_STB ==============
3662
typedef struct SVDropStbReq {
3663
  char*    name;
3664
  tb_uid_t suid;
3665
} SVDropStbReq;
3666

3667
int32_t tEncodeSVDropStbReq(SEncoder* pCoder, const SVDropStbReq* pReq);
3668
int32_t tDecodeSVDropStbReq(SDecoder* pCoder, SVDropStbReq* pReq);
3669

3670
// TDMT_VND_CREATE_TABLE ==============
3671
#define TD_CREATE_IF_NOT_EXISTS       0x1
3672
#define TD_CREATE_NORMAL_TB_IN_STREAM 0x2
3673
#define TD_CREATE_SUB_TB_IN_STREAM    0x4
3674
typedef struct SVCreateTbReq {
3675
  int32_t  flags;
3676
  char*    name;
3677
  tb_uid_t uid;
3678
  int64_t  btime;
3679
  int32_t  ttl;
3680
  int32_t  commentLen;
3681
  char*    comment;
3682
  int8_t   type;
3683
  union {
3684
    struct {
3685
      char*    stbName;  // super table name
3686
      uint8_t  tagNum;
3687
      tb_uid_t suid;
3688
      SArray*  tagName;
3689
      uint8_t* pTag;
3690
    } ctb;
3691
    struct {
3692
      SSchemaWrapper schemaRow;
3693
    } ntb;
3694
  };
3695
  int32_t         sqlLen;
3696
  char*           sql;
3697
  SColCmprWrapper colCmpr;
3698
  SExtSchema*     pExtSchemas;
3699
  SColRefWrapper  colRef;  // col reference for virtual table
3700
} SVCreateTbReq;
3701

3702
int  tEncodeSVCreateTbReq(SEncoder* pCoder, const SVCreateTbReq* pReq);
3703
int  tDecodeSVCreateTbReq(SDecoder* pCoder, SVCreateTbReq* pReq);
3704
void tDestroySVCreateTbReq(SVCreateTbReq* pReq, int32_t flags);
3705

3706
static FORCE_INLINE void tdDestroySVCreateTbReq(SVCreateTbReq* req) {
3707
  if (NULL == req) {
37,829,919!
3708
    return;
37,516,391✔
3709
  }
3710

3711
  taosMemoryFreeClear(req->sql);
313,528!
3712
  taosMemoryFreeClear(req->name);
313,528!
3713
  taosMemoryFreeClear(req->comment);
313,574!
3714
  if (req->type == TSDB_CHILD_TABLE || req->type == TSDB_VIRTUAL_CHILD_TABLE) {
313,574!
3715
    taosMemoryFreeClear(req->ctb.pTag);
299,745!
3716
    taosMemoryFreeClear(req->ctb.stbName);
299,818!
3717
    taosArrayDestroy(req->ctb.tagName);
299,829✔
3718
    req->ctb.tagName = NULL;
299,792✔
3719
  } else if (req->type == TSDB_NORMAL_TABLE || req->type == TSDB_VIRTUAL_NORMAL_TABLE) {
13,829!
3720
    taosMemoryFreeClear(req->ntb.schemaRow.pSchema);
13,829!
3721
  }
3722
  taosMemoryFreeClear(req->colCmpr.pColCmpr);
313,621!
3723
  taosMemoryFreeClear(req->pExtSchemas);
313,621!
3724
  taosMemoryFreeClear(req->colRef.pColRef);
313,621!
3725
}
3726

3727
typedef struct {
3728
  int32_t nReqs;
3729
  union {
3730
    SVCreateTbReq* pReqs;
3731
    SArray*        pArray;
3732
  };
3733
  int8_t source;  // TD_REQ_FROM_TAOX-taosX or TD_REQ_FROM_APP-taosClient
3734
} SVCreateTbBatchReq;
3735

3736
int  tEncodeSVCreateTbBatchReq(SEncoder* pCoder, const SVCreateTbBatchReq* pReq);
3737
int  tDecodeSVCreateTbBatchReq(SDecoder* pCoder, SVCreateTbBatchReq* pReq);
3738
void tDeleteSVCreateTbBatchReq(SVCreateTbBatchReq* pReq);
3739

3740
typedef struct {
3741
  int32_t        code;
3742
  STableMetaRsp* pMeta;
3743
} SVCreateTbRsp, SVUpdateTbRsp;
3744

3745
int  tEncodeSVCreateTbRsp(SEncoder* pCoder, const SVCreateTbRsp* pRsp);
3746
int  tDecodeSVCreateTbRsp(SDecoder* pCoder, SVCreateTbRsp* pRsp);
3747
void tFreeSVCreateTbRsp(void* param);
3748

3749
int32_t tSerializeSVCreateTbReq(void** buf, SVCreateTbReq* pReq);
3750
void*   tDeserializeSVCreateTbReq(void* buf, SVCreateTbReq* pReq);
3751

3752
typedef struct {
3753
  int32_t nRsps;
3754
  union {
3755
    SVCreateTbRsp* pRsps;
3756
    SArray*        pArray;
3757
  };
3758
} SVCreateTbBatchRsp;
3759

3760
int tEncodeSVCreateTbBatchRsp(SEncoder* pCoder, const SVCreateTbBatchRsp* pRsp);
3761
int tDecodeSVCreateTbBatchRsp(SDecoder* pCoder, SVCreateTbBatchRsp* pRsp);
3762

3763
// int32_t tSerializeSVCreateTbBatchRsp(void* buf, int32_t bufLen, SVCreateTbBatchRsp* pRsp);
3764
// int32_t tDeserializeSVCreateTbBatchRsp(void* buf, int32_t bufLen, SVCreateTbBatchRsp* pRsp);
3765

3766
// TDMT_VND_DROP_TABLE =================
3767
typedef struct {
3768
  char*    name;
3769
  uint64_t suid;  // for tmq in wal format
3770
  int64_t  uid;
3771
  int8_t   igNotExists;
3772
  int8_t   isVirtual;
3773
} SVDropTbReq;
3774

3775
typedef struct {
3776
  int32_t code;
3777
} SVDropTbRsp;
3778

3779
typedef struct {
3780
  int32_t nReqs;
3781
  union {
3782
    SVDropTbReq* pReqs;
3783
    SArray*      pArray;
3784
  };
3785
} SVDropTbBatchReq;
3786

3787
int32_t tEncodeSVDropTbBatchReq(SEncoder* pCoder, const SVDropTbBatchReq* pReq);
3788
int32_t tDecodeSVDropTbBatchReq(SDecoder* pCoder, SVDropTbBatchReq* pReq);
3789

3790
typedef struct {
3791
  int32_t nRsps;
3792
  union {
3793
    SVDropTbRsp* pRsps;
3794
    SArray*      pArray;
3795
  };
3796
} SVDropTbBatchRsp;
3797

3798
int32_t tEncodeSVDropTbBatchRsp(SEncoder* pCoder, const SVDropTbBatchRsp* pRsp);
3799
int32_t tDecodeSVDropTbBatchRsp(SDecoder* pCoder, SVDropTbBatchRsp* pRsp);
3800

3801
// TDMT_VND_ALTER_TABLE =====================
3802
typedef struct SMultiTagUpateVal {
3803
  char*    tagName;
3804
  int32_t  colId;
3805
  int8_t   tagType;
3806
  int8_t   tagFree;
3807
  uint32_t nTagVal;
3808
  uint8_t* pTagVal;
3809
  int8_t   isNull;
3810
  SArray*  pTagArray;
3811
} SMultiTagUpateVal;
3812
typedef struct SVAlterTbReq {
3813
  char*   tbName;
3814
  int8_t  action;
3815
  char*   colName;
3816
  int32_t colId;
3817
  // TSDB_ALTER_TABLE_ADD_COLUMN
3818
  int8_t  type;
3819
  int8_t  flags;
3820
  int32_t bytes;
3821
  // TSDB_ALTER_TABLE_DROP_COLUMN
3822
  // TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES
3823
  int8_t   colModType;
3824
  int32_t  colModBytes;
3825
  char*    colNewName;  // TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME
3826
  char*    tagName;     // TSDB_ALTER_TABLE_UPDATE_TAG_VAL
3827
  int8_t   isNull;
3828
  int8_t   tagType;
3829
  int8_t   tagFree;
3830
  uint32_t nTagVal;
3831
  uint8_t* pTagVal;
3832
  SArray*  pTagArray;
3833
  // TSDB_ALTER_TABLE_UPDATE_OPTIONS
3834
  int8_t   updateTTL;
3835
  int32_t  newTTL;
3836
  int32_t  newCommentLen;
3837
  char*    newComment;
3838
  int64_t  ctimeMs;    // fill by vnode
3839
  int8_t   source;     // TD_REQ_FROM_TAOX-taosX or TD_REQ_FROM_APP-taosClient
3840
  uint32_t compress;   // TSDB_ALTER_TABLE_UPDATE_COLUMN_COMPRESS
3841
  SArray*  pMultiTag;  // TSDB_ALTER_TABLE_ADD_MULTI_TAGS
3842
  // for Add column
3843
  STypeMod typeMod;
3844
  // TSDB_ALTER_TABLE_ALTER_COLUMN_REF
3845
  char* refDbName;
3846
  char* refTbName;
3847
  char* refColName;
3848
  // TSDB_ALTER_TABLE_REMOVE_COLUMN_REF
3849
} SVAlterTbReq;
3850

3851
int32_t tEncodeSVAlterTbReq(SEncoder* pEncoder, const SVAlterTbReq* pReq);
3852
int32_t tDecodeSVAlterTbReq(SDecoder* pDecoder, SVAlterTbReq* pReq);
3853
int32_t tDecodeSVAlterTbReqSetCtime(SDecoder* pDecoder, SVAlterTbReq* pReq, int64_t ctimeMs);
3854
void    tfreeMultiTagUpateVal(void* pMultiTag);
3855

3856
typedef struct {
3857
  int32_t        code;
3858
  STableMetaRsp* pMeta;
3859
} SVAlterTbRsp;
3860

3861
int32_t tEncodeSVAlterTbRsp(SEncoder* pEncoder, const SVAlterTbRsp* pRsp);
3862
int32_t tDecodeSVAlterTbRsp(SDecoder* pDecoder, SVAlterTbRsp* pRsp);
3863
// ======================
3864

3865
typedef struct {
3866
  SMsgHead head;
3867
  int64_t  uid;
3868
  int32_t  tid;
3869
  int16_t  tversion;
3870
  int16_t  colId;
3871
  int8_t   type;
3872
  int16_t  bytes;
3873
  int32_t  tagValLen;
3874
  int16_t  numOfTags;
3875
  int32_t  schemaLen;
3876
  char     data[];
3877
} SUpdateTagValReq;
3878

3879
typedef struct {
3880
  SMsgHead head;
3881
} SUpdateTagValRsp;
3882

3883
typedef struct {
3884
  SMsgHead head;
3885
} SVShowTablesReq;
3886

3887
typedef struct {
3888
  SMsgHead head;
3889
  int32_t  id;
3890
} SVShowTablesFetchReq;
3891

3892
typedef struct {
3893
  int64_t useconds;
3894
  int8_t  completed;  // all results are returned to client
3895
  int8_t  precision;
3896
  int8_t  compressed;
3897
  int32_t compLen;
3898
  int32_t numOfRows;
3899
  char    data[];
3900
} SVShowTablesFetchRsp;
3901

3902
typedef struct {
3903
  int64_t consumerId;
3904
  int32_t epoch;
3905
  char    cgroup[TSDB_CGROUP_LEN];
3906
} SMqAskEpReq;
3907

3908
typedef struct {
3909
  int32_t key;
3910
  int32_t valueLen;
3911
  void*   value;
3912
} SKv;
3913

3914
typedef struct {
3915
  int64_t tscRid;
3916
  int8_t  connType;
3917
} SClientHbKey;
3918

3919
typedef struct {
3920
  int64_t tid;
3921
  char    status[TSDB_JOB_STATUS_LEN];
3922
} SQuerySubDesc;
3923

3924
typedef struct {
3925
  char     sql[TSDB_SHOW_SQL_LEN];
3926
  uint64_t queryId;
3927
  int64_t  useconds;
3928
  int64_t  stime;  // timestamp precision ms
3929
  int64_t  reqRid;
3930
  bool     stableQuery;
3931
  bool     isSubQuery;
3932
  char     fqdn[TSDB_FQDN_LEN];
3933
  int32_t  subPlanNum;
3934
  SArray*  subDesc;  // SArray<SQuerySubDesc>
3935
} SQueryDesc;
3936

3937
typedef struct {
3938
  uint32_t connId;
3939
  SArray*  queryDesc;  // SArray<SQueryDesc>
3940
} SQueryHbReqBasic;
3941

3942
typedef struct {
3943
  uint32_t connId;
3944
  uint64_t killRid;
3945
  int32_t  totalDnodes;
3946
  int32_t  onlineDnodes;
3947
  int8_t   killConnection;
3948
  int8_t   align[3];
3949
  SEpSet   epSet;
3950
  SArray*  pQnodeList;
3951
} SQueryHbRspBasic;
3952

3953
typedef struct SAppClusterSummary {
3954
  uint64_t numOfInsertsReq;
3955
  uint64_t numOfInsertRows;
3956
  uint64_t insertElapsedTime;
3957
  uint64_t insertBytes;  // submit to tsdb since launched.
3958

3959
  uint64_t fetchBytes;
3960
  uint64_t numOfQueryReq;
3961
  uint64_t queryElapsedTime;
3962
  uint64_t numOfSlowQueries;
3963
  uint64_t totalRequests;
3964
  uint64_t currentRequests;  // the number of SRequestObj
3965
} SAppClusterSummary;
3966

3967
typedef struct {
3968
  int64_t            appId;
3969
  int32_t            pid;
3970
  char               name[TSDB_APP_NAME_LEN];
3971
  int64_t            startTime;
3972
  SAppClusterSummary summary;
3973
} SAppHbReq;
3974

3975
typedef struct {
3976
  SClientHbKey      connKey;
3977
  int64_t           clusterId;
3978
  SAppHbReq         app;
3979
  SQueryHbReqBasic* query;
3980
  SHashObj*         info;  // hash<Skv.key, Skv>
3981
  char              userApp[TSDB_APP_NAME_LEN];
3982
  uint32_t          userIp;
3983
  SIpRange          userDualIp;
3984
} SClientHbReq;
3985

3986
typedef struct {
3987
  int64_t reqId;
3988
  SArray* reqs;  // SArray<SClientHbReq>
3989
  int64_t ipWhiteListVer;
3990
} SClientHbBatchReq;
3991

3992
typedef struct {
3993
  SClientHbKey      connKey;
3994
  int32_t           status;
3995
  SQueryHbRspBasic* query;
3996
  SArray*           info;  // Array<Skv>
3997
} SClientHbRsp;
3998

3999
typedef struct {
4000
  int64_t       reqId;
4001
  int64_t       rspId;
4002
  int32_t       svrTimestamp;
4003
  SArray*       rsps;  // SArray<SClientHbRsp>
4004
  SMonitorParas monitorParas;
4005
  int8_t        enableAuditDelete;
4006
  int8_t        enableStrongPass;
4007
} SClientHbBatchRsp;
4008

4009
static FORCE_INLINE uint32_t hbKeyHashFunc(const char* key, uint32_t keyLen) { return taosIntHash_64(key, keyLen); }
393,987✔
4010

4011
static FORCE_INLINE void tFreeReqKvHash(SHashObj* info) {
4012
  void* pIter = taosHashIterate(info, NULL);
697,762✔
4013
  while (pIter != NULL) {
1,104,692!
4014
    SKv* kv = (SKv*)pIter;
406,883✔
4015
    taosMemoryFreeClear(kv->value);
406,883!
4016
    pIter = taosHashIterate(info, pIter);
406,881✔
4017
  }
4018
}
697,809✔
4019

4020
static FORCE_INLINE void tFreeClientHbQueryDesc(void* pDesc) {
531,660✔
4021
  SQueryDesc* desc = (SQueryDesc*)pDesc;
531,660✔
4022
  if (desc->subDesc) {
531,660✔
4023
    taosArrayDestroy(desc->subDesc);
523,090✔
4024
    desc->subDesc = NULL;
523,081✔
4025
  }
4026
}
531,651✔
4027

4028
static FORCE_INLINE void tFreeClientHbReq(void* pReq) {
874,501✔
4029
  SClientHbReq* req = (SClientHbReq*)pReq;
910,133✔
4030
  if (req->query) {
910,133!
4031
    if (req->query->queryDesc) {
861,162!
4032
      taosArrayDestroyEx(req->query->queryDesc, tFreeClientHbQueryDesc);
56,697✔
4033
    }
4034
    taosMemoryFreeClear(req->query);
861,162!
4035
  }
4036

4037
  if (req->info) {
910,132!
4038
    tFreeReqKvHash(req->info);
697,762✔
4039
    taosHashCleanup(req->info);
697,809✔
4040
    req->info = NULL;
697,785✔
4041
  }
4042
}
693,623✔
4043

4044
int32_t tSerializeSClientHbBatchReq(void* buf, int32_t bufLen, const SClientHbBatchReq* pReq);
4045
int32_t tDeserializeSClientHbBatchReq(void* buf, int32_t bufLen, SClientHbBatchReq* pReq);
4046

4047
static FORCE_INLINE void tFreeClientHbBatchReq(void* pReq) {
4048
  if (pReq == NULL) return;
50,343!
4049
  SClientHbBatchReq* req = (SClientHbBatchReq*)pReq;
50,343✔
4050
  taosArrayDestroyEx(req->reqs, tFreeClientHbReq);
50,343✔
4051
  taosMemoryFree(pReq);
50,343!
4052
}
4053

4054
static FORCE_INLINE void tFreeClientKv(void* pKv) {
140,602✔
4055
  SKv* kv = (SKv*)pKv;
140,602✔
4056
  if (kv) {
140,602!
4057
    taosMemoryFreeClear(kv->value);
140,602!
4058
  }
4059
}
140,601✔
4060

4061
static FORCE_INLINE void tFreeClientHbRsp(void* pRsp) {
871,930✔
4062
  SClientHbRsp* rsp = (SClientHbRsp*)pRsp;
871,930✔
4063
  if (rsp->query) {
871,930✔
4064
    taosArrayDestroy(rsp->query->pQnodeList);
858,663✔
4065
    taosMemoryFreeClear(rsp->query);
858,740!
4066
  }
4067
  if (rsp->info) taosArrayDestroyEx(rsp->info, tFreeClientKv);
872,049!
4068
}
214,109✔
4069

4070
static FORCE_INLINE void tFreeClientHbBatchRsp(void* pRsp) {
4071
  SClientHbBatchRsp* rsp = (SClientHbBatchRsp*)pRsp;
463,709✔
4072
  taosArrayDestroyEx(rsp->rsps, tFreeClientHbRsp);
463,709✔
4073
}
463,786✔
4074

4075
int32_t tSerializeSClientHbBatchRsp(void* buf, int32_t bufLen, const SClientHbBatchRsp* pBatchRsp);
4076
int32_t tDeserializeSClientHbBatchRsp(void* buf, int32_t bufLen, SClientHbBatchRsp* pBatchRsp);
4077
void    tFreeSClientHbBatchRsp(SClientHbBatchRsp* pBatchRsp);
4078

4079
static FORCE_INLINE int32_t tEncodeSKv(SEncoder* pEncoder, const SKv* pKv) {
4080
  TAOS_CHECK_RETURN(tEncodeI32(pEncoder, pKv->key));
712,928!
4081
  TAOS_CHECK_RETURN(tEncodeI32(pEncoder, pKv->valueLen));
712,928!
4082
  TAOS_CHECK_RETURN(tEncodeBinary(pEncoder, (uint8_t*)pKv->value, pKv->valueLen));
712,928!
4083
  return 0;
356,464✔
4084
}
4085

4086
static FORCE_INLINE int32_t tDecodeSKv(SDecoder* pDecoder, SKv* pKv) {
4087
  TAOS_CHECK_RETURN(tDecodeI32(pDecoder, &pKv->key));
738,469!
4088
  TAOS_CHECK_RETURN(tDecodeI32(pDecoder, &pKv->valueLen));
738,472!
4089
  pKv->value = taosMemoryMalloc(pKv->valueLen + 1);
369,237!
4090
  if (pKv->value == NULL) {
369,233!
4091
    TAOS_CHECK_RETURN(TSDB_CODE_OUT_OF_MEMORY);
×
4092
  }
4093
  TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, (char*)pKv->value));
369,233!
4094
  return 0;
369,233✔
4095
}
4096

4097
static FORCE_INLINE int32_t tEncodeSClientHbKey(SEncoder* pEncoder, const SClientHbKey* pKey) {
4098
  TAOS_CHECK_RETURN(tEncodeI64(pEncoder, pKey->tscRid));
3,495,150!
4099
  TAOS_CHECK_RETURN(tEncodeI8(pEncoder, pKey->connType));
3,495,150!
4100
  return 0;
1,747,575✔
4101
}
4102

4103
static FORCE_INLINE int32_t tDecodeSClientHbKey(SDecoder* pDecoder, SClientHbKey* pKey) {
4104
  TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &pKey->tscRid));
1,744,123!
4105
  TAOS_CHECK_RETURN(tDecodeI8(pDecoder, &pKey->connType));
1,744,129!
4106
  return 0;
872,066✔
4107
}
4108

4109
typedef struct {
4110
  int32_t vgId;
4111
  // TODO stas
4112
} SMqReportVgInfo;
4113

4114
static FORCE_INLINE int32_t taosEncodeSMqVgInfo(void** buf, const SMqReportVgInfo* pVgInfo) {
4115
  int32_t tlen = 0;
4116
  tlen += taosEncodeFixedI32(buf, pVgInfo->vgId);
4117
  return tlen;
4118
}
4119

4120
static FORCE_INLINE void* taosDecodeSMqVgInfo(void* buf, SMqReportVgInfo* pVgInfo) {
4121
  buf = taosDecodeFixedI32(buf, &pVgInfo->vgId);
4122
  return buf;
4123
}
4124

4125
typedef struct {
4126
  int32_t epoch;
4127
  int64_t topicUid;
4128
  char    name[TSDB_TOPIC_FNAME_LEN];
4129
  SArray* pVgInfo;  // SArray<SMqHbVgInfo>
4130
} SMqTopicInfo;
4131

4132
static FORCE_INLINE int32_t taosEncodeSMqTopicInfoMsg(void** buf, const SMqTopicInfo* pTopicInfo) {
4133
  int32_t tlen = 0;
4134
  tlen += taosEncodeFixedI32(buf, pTopicInfo->epoch);
4135
  tlen += taosEncodeFixedI64(buf, pTopicInfo->topicUid);
4136
  tlen += taosEncodeString(buf, pTopicInfo->name);
4137
  int32_t sz = taosArrayGetSize(pTopicInfo->pVgInfo);
4138
  tlen += taosEncodeFixedI32(buf, sz);
4139
  for (int32_t i = 0; i < sz; i++) {
4140
    SMqReportVgInfo* pVgInfo = (SMqReportVgInfo*)taosArrayGet(pTopicInfo->pVgInfo, i);
4141
    tlen += taosEncodeSMqVgInfo(buf, pVgInfo);
4142
  }
4143
  return tlen;
4144
}
4145

4146
static FORCE_INLINE void* taosDecodeSMqTopicInfoMsg(void* buf, SMqTopicInfo* pTopicInfo) {
4147
  buf = taosDecodeFixedI32(buf, &pTopicInfo->epoch);
4148
  buf = taosDecodeFixedI64(buf, &pTopicInfo->topicUid);
4149
  buf = taosDecodeStringTo(buf, pTopicInfo->name);
4150
  int32_t sz;
4151
  buf = taosDecodeFixedI32(buf, &sz);
4152
  if ((pTopicInfo->pVgInfo = taosArrayInit(sz, sizeof(SMqReportVgInfo))) == NULL) {
4153
    return NULL;
4154
  }
4155
  for (int32_t i = 0; i < sz; i++) {
4156
    SMqReportVgInfo vgInfo;
4157
    buf = taosDecodeSMqVgInfo(buf, &vgInfo);
4158
    if (taosArrayPush(pTopicInfo->pVgInfo, &vgInfo) == NULL) {
4159
      return NULL;
4160
    }
4161
  }
4162
  return buf;
4163
}
4164

4165
typedef struct {
4166
  int32_t status;  // ask hb endpoint
4167
  int32_t epoch;
4168
  int64_t consumerId;
4169
  SArray* pTopics;  // SArray<SMqHbTopicInfo>
4170
} SMqReportReq;
4171

4172
static FORCE_INLINE int32_t taosEncodeSMqReportMsg(void** buf, const SMqReportReq* pMsg) {
4173
  int32_t tlen = 0;
4174
  tlen += taosEncodeFixedI32(buf, pMsg->status);
4175
  tlen += taosEncodeFixedI32(buf, pMsg->epoch);
4176
  tlen += taosEncodeFixedI64(buf, pMsg->consumerId);
4177
  int32_t sz = taosArrayGetSize(pMsg->pTopics);
4178
  tlen += taosEncodeFixedI32(buf, sz);
4179
  for (int32_t i = 0; i < sz; i++) {
4180
    SMqTopicInfo* topicInfo = (SMqTopicInfo*)taosArrayGet(pMsg->pTopics, i);
4181
    tlen += taosEncodeSMqTopicInfoMsg(buf, topicInfo);
4182
  }
4183
  return tlen;
4184
}
4185

4186
static FORCE_INLINE void* taosDecodeSMqReportMsg(void* buf, SMqReportReq* pMsg) {
4187
  buf = taosDecodeFixedI32(buf, &pMsg->status);
4188
  buf = taosDecodeFixedI32(buf, &pMsg->epoch);
4189
  buf = taosDecodeFixedI64(buf, &pMsg->consumerId);
4190
  int32_t sz;
4191
  buf = taosDecodeFixedI32(buf, &sz);
4192
  if ((pMsg->pTopics = taosArrayInit(sz, sizeof(SMqTopicInfo))) == NULL) {
4193
    return NULL;
4194
  }
4195
  for (int32_t i = 0; i < sz; i++) {
4196
    SMqTopicInfo topicInfo;
4197
    buf = taosDecodeSMqTopicInfoMsg(buf, &topicInfo);
4198
    if (taosArrayPush(pMsg->pTopics, &topicInfo) == NULL) {
4199
      return NULL;
4200
    }
4201
  }
4202
  return buf;
4203
}
4204

4205
typedef struct {
4206
  SMsgHead head;
4207
  int64_t  leftForVer;
4208
  int32_t  vgId;
4209
  int64_t  consumerId;
4210
  char     subKey[TSDB_SUBSCRIBE_KEY_LEN];
4211
} SMqVDeleteReq;
4212

4213
typedef struct {
4214
  int8_t reserved;
4215
} SMqVDeleteRsp;
4216

4217
typedef struct {
4218
  char*   name;
4219
  int8_t  igNotExists;
4220
} SMDropStreamReq;
4221

4222
typedef struct {
4223
  int8_t reserved;
4224
} SMDropStreamRsp;
4225

4226
typedef struct {
4227
  SMsgHead head;
4228
  int64_t  resetRelHalt;  // reset related stream task halt status
4229
  int64_t  streamId;
4230
  int32_t  taskId;
4231
} SVDropStreamTaskReq;
4232

4233
typedef struct {
4234
  int8_t reserved;
4235
} SVDropStreamTaskRsp;
4236

4237
int32_t tSerializeSMDropStreamReq(void* buf, int32_t bufLen, const SMDropStreamReq* pReq);
4238
int32_t tDeserializeSMDropStreamReq(void* buf, int32_t bufLen, SMDropStreamReq* pReq);
4239
void    tFreeMDropStreamReq(SMDropStreamReq* pReq);
4240

4241
typedef struct {
4242
  char*  name;
4243
  int8_t igNotExists;
4244
} SMPauseStreamReq;
4245

4246
int32_t tSerializeSMPauseStreamReq(void* buf, int32_t bufLen, const SMPauseStreamReq* pReq);
4247
int32_t tDeserializeSMPauseStreamReq(void* buf, int32_t bufLen, SMPauseStreamReq* pReq);
4248
void    tFreeMPauseStreamReq(SMPauseStreamReq *pReq);
4249

4250
typedef struct {
4251
  char*  name;
4252
  int8_t igNotExists;
4253
  int8_t igUntreated;
4254
} SMResumeStreamReq;
4255

4256
int32_t tSerializeSMResumeStreamReq(void* buf, int32_t bufLen, const SMResumeStreamReq* pReq);
4257
int32_t tDeserializeSMResumeStreamReq(void* buf, int32_t bufLen, SMResumeStreamReq* pReq);
4258
void    tFreeMResumeStreamReq(SMResumeStreamReq *pReq);
4259

4260
typedef struct {
4261
  char*       name;
4262
  int8_t      calcAll;
4263
  STimeWindow timeRange;
4264
} SMRecalcStreamReq;
4265

4266
int32_t tSerializeSMRecalcStreamReq(void* buf, int32_t bufLen, const SMRecalcStreamReq* pReq);
4267
int32_t tDeserializeSMRecalcStreamReq(void* buf, int32_t bufLen, SMRecalcStreamReq* pReq);
4268
void    tFreeMRecalcStreamReq(SMRecalcStreamReq *pReq);
4269

4270
typedef struct SVUpdateCheckpointInfoReq {
4271
  SMsgHead head;
4272
  int64_t  streamId;
4273
  int32_t  taskId;
4274
  int64_t  checkpointId;
4275
  int64_t  checkpointVer;
4276
  int64_t  checkpointTs;
4277
  int32_t  transId;
4278
  int64_t  hStreamId;  // add encode/decode
4279
  int64_t  hTaskId;
4280
  int8_t   dropRelHTask;
4281
} SVUpdateCheckpointInfoReq;
4282

4283
typedef struct {
4284
  int64_t leftForVer;
4285
  int32_t vgId;
4286
  int64_t oldConsumerId;
4287
  int64_t newConsumerId;
4288
  char    subKey[TSDB_SUBSCRIBE_KEY_LEN];
4289
  int8_t  subType;
4290
  int8_t  withMeta;
4291
  char*   qmsg;  // SubPlanToString
4292
  int64_t suid;
4293
} SMqRebVgReq;
4294

4295
int32_t tEncodeSMqRebVgReq(SEncoder* pCoder, const SMqRebVgReq* pReq);
4296
int32_t tDecodeSMqRebVgReq(SDecoder* pCoder, SMqRebVgReq* pReq);
4297

4298
typedef struct {
4299
  char    topic[TSDB_TOPIC_FNAME_LEN];
4300
  int64_t ntbUid;
4301
  SArray* colIdList;  // SArray<int16_t>
4302
} STqCheckInfo;
4303

4304
int32_t tEncodeSTqCheckInfo(SEncoder* pEncoder, const STqCheckInfo* pInfo);
4305
int32_t tDecodeSTqCheckInfo(SDecoder* pDecoder, STqCheckInfo* pInfo);
4306
void    tDeleteSTqCheckInfo(STqCheckInfo* pInfo);
4307

4308
// tqOffset
4309
enum {
4310
  TMQ_OFFSET__RESET_NONE = -3,
4311
  TMQ_OFFSET__RESET_EARLIEST = -2,
4312
  TMQ_OFFSET__RESET_LATEST = -1,
4313
  TMQ_OFFSET__LOG = 1,
4314
  TMQ_OFFSET__SNAPSHOT_DATA = 2,
4315
  TMQ_OFFSET__SNAPSHOT_META = 3,
4316
};
4317

4318
enum {
4319
  WITH_DATA = 0,
4320
  WITH_META = 1,
4321
  ONLY_META = 2,
4322
};
4323

4324
#define TQ_OFFSET_VERSION 1
4325

4326
typedef struct {
4327
  int8_t type;
4328
  union {
4329
    // snapshot
4330
    struct {
4331
      int64_t uid;
4332
      int64_t ts;
4333
      SValue  primaryKey;
4334
    };
4335
    // log
4336
    struct {
4337
      int64_t version;
4338
    };
4339
  };
4340
} STqOffsetVal;
4341

4342
static FORCE_INLINE void tqOffsetResetToData(STqOffsetVal* pOffsetVal, int64_t uid, int64_t ts, SValue primaryKey) {
4343
  pOffsetVal->type = TMQ_OFFSET__SNAPSHOT_DATA;
744✔
4344
  pOffsetVal->uid = uid;
744✔
4345
  pOffsetVal->ts = ts;
744✔
4346
  if (IS_VAR_DATA_TYPE(pOffsetVal->primaryKey.type)) {
744!
4347
    taosMemoryFree(pOffsetVal->primaryKey.pData);
×
4348
  }
4349
  pOffsetVal->primaryKey = primaryKey;
744✔
4350
}
744✔
4351

4352
static FORCE_INLINE void tqOffsetResetToMeta(STqOffsetVal* pOffsetVal, int64_t uid) {
4353
  pOffsetVal->type = TMQ_OFFSET__SNAPSHOT_META;
15✔
4354
  pOffsetVal->uid = uid;
15✔
4355
}
15✔
4356

4357
static FORCE_INLINE void tqOffsetResetToLog(STqOffsetVal* pOffsetVal, int64_t ver) {
4358
  pOffsetVal->type = TMQ_OFFSET__LOG;
12,536✔
4359
  pOffsetVal->version = ver;
12,536✔
4360
}
12,536✔
4361

4362
int32_t tEncodeSTqOffsetVal(SEncoder* pEncoder, const STqOffsetVal* pOffsetVal);
4363
int32_t tDecodeSTqOffsetVal(SDecoder* pDecoder, STqOffsetVal* pOffsetVal);
4364
void    tFormatOffset(char* buf, int32_t maxLen, const STqOffsetVal* pVal);
4365
bool    tOffsetEqual(const STqOffsetVal* pLeft, const STqOffsetVal* pRight);
4366
void    tOffsetCopy(STqOffsetVal* pLeft, const STqOffsetVal* pRight);
4367
void    tOffsetDestroy(void* pVal);
4368

4369
typedef struct {
4370
  STqOffsetVal val;
4371
  char         subKey[TSDB_SUBSCRIBE_KEY_LEN];
4372
} STqOffset;
4373

4374
int32_t tEncodeSTqOffset(SEncoder* pEncoder, const STqOffset* pOffset);
4375
int32_t tDecodeSTqOffset(SDecoder* pDecoder, STqOffset* pOffset);
4376
void    tDeleteSTqOffset(void* val);
4377

4378
typedef struct SMqVgOffset {
4379
  int64_t   consumerId;
4380
  STqOffset offset;
4381
} SMqVgOffset;
4382

4383
int32_t tEncodeMqVgOffset(SEncoder* pEncoder, const SMqVgOffset* pOffset);
4384
int32_t tDecodeMqVgOffset(SDecoder* pDecoder, SMqVgOffset* pOffset);
4385

4386
typedef struct {
4387
  char    name[TSDB_TABLE_FNAME_LEN];
4388
  char    stb[TSDB_TABLE_FNAME_LEN];
4389
  int8_t  igExists;
4390
  int8_t  intervalUnit;
4391
  int8_t  slidingUnit;
4392
  int8_t  timezone;  // int8_t is not enough, timezone is unit of second
4393
  int32_t dstVgId;   // for stream
4394
  int64_t interval;
4395
  int64_t offset;
4396
  int64_t sliding;
4397
  int64_t maxDelay;
4398
  int64_t watermark;
4399
  int32_t exprLen;        // strlen + 1
4400
  int32_t tagsFilterLen;  // strlen + 1
4401
  int32_t sqlLen;         // strlen + 1
4402
  int32_t astLen;         // strlen + 1
4403
  char*   expr;
4404
  char*   tagsFilter;
4405
  char*   sql;
4406
  char*   ast;
4407
  int64_t deleteMark;
4408
  int64_t lastTs;
4409
  int64_t normSourceTbUid;  // the Uid of source tb if its a normal table, otherwise 0
4410
  SArray* pVgroupVerList;
4411
  int8_t  recursiveTsma;
4412
  char    baseTsmaName[TSDB_TABLE_FNAME_LEN];  // base tsma name for recursively created tsma
4413
  char*   createStreamReq;
4414
  int32_t streamReqLen;
4415
  char*   dropStreamReq;
4416
  int32_t dropStreamReqLen;
4417
  int64_t uid;
4418
} SMCreateSmaReq;
4419

4420
int32_t tSerializeSMCreateSmaReq(void* buf, int32_t bufLen, SMCreateSmaReq* pReq);
4421
int32_t tDeserializeSMCreateSmaReq(void* buf, int32_t bufLen, SMCreateSmaReq* pReq);
4422
void    tFreeSMCreateSmaReq(SMCreateSmaReq* pReq);
4423

4424
typedef struct {
4425
  char   name[TSDB_TABLE_FNAME_LEN];
4426
  int8_t igNotExists;
4427
  char*   dropStreamReq;
4428
  int32_t dropStreamReqLen;
4429
} SMDropSmaReq;
4430

4431
int32_t tSerializeSMDropSmaReq(void* buf, int32_t bufLen, SMDropSmaReq* pReq);
4432
int32_t tDeserializeSMDropSmaReq(void* buf, int32_t bufLen, SMDropSmaReq* pReq);
4433

4434
typedef struct {
4435
  char   dbFName[TSDB_DB_FNAME_LEN];
4436
  char   stbName[TSDB_TABLE_NAME_LEN];
4437
  char   colName[TSDB_COL_NAME_LEN];
4438
  char   idxName[TSDB_INDEX_FNAME_LEN];
4439
  int8_t idxType;
4440
} SCreateTagIndexReq;
4441

4442
int32_t tSerializeSCreateTagIdxReq(void* buf, int32_t bufLen, SCreateTagIndexReq* pReq);
4443
int32_t tDeserializeSCreateTagIdxReq(void* buf, int32_t bufLen, SCreateTagIndexReq* pReq);
4444

4445
typedef SMDropSmaReq SDropTagIndexReq;
4446

4447
// int32_t tSerializeSDropTagIdxReq(void* buf, int32_t bufLen, SDropTagIndexReq* pReq);
4448
int32_t tDeserializeSDropTagIdxReq(void* buf, int32_t bufLen, SDropTagIndexReq* pReq);
4449

4450
typedef struct {
4451
  int8_t         version;       // for compatibility(default 0)
4452
  int8_t         intervalUnit;  // MACRO: TIME_UNIT_XXX
4453
  int8_t         slidingUnit;   // MACRO: TIME_UNIT_XXX
4454
  int8_t         timezoneInt;   // sma data expired if timezone changes.
4455
  int32_t        dstVgId;
4456
  char           indexName[TSDB_INDEX_NAME_LEN];
4457
  int32_t        exprLen;
4458
  int32_t        tagsFilterLen;
4459
  int64_t        indexUid;
4460
  tb_uid_t       tableUid;  // super/child/common table uid
4461
  tb_uid_t       dstTbUid;  // for dstVgroup
4462
  int64_t        interval;
4463
  int64_t        offset;  // use unit by precision of DB
4464
  int64_t        sliding;
4465
  char*          dstTbName;  // for dstVgroup
4466
  char*          expr;       // sma expression
4467
  char*          tagsFilter;
4468
  SSchemaWrapper schemaRow;  // for dstVgroup
4469
  SSchemaWrapper schemaTag;  // for dstVgroup
4470
} STSma;                     // Time-range-wise SMA
4471

4472
typedef STSma SVCreateTSmaReq;
4473

4474
typedef struct {
4475
  int8_t  type;  // 0 status report, 1 update data
4476
  int64_t indexUid;
4477
  int64_t skey;  // start TS key of interval/sliding window
4478
} STSmaMsg;
4479

4480
typedef struct {
4481
  int64_t indexUid;
4482
  char    indexName[TSDB_INDEX_NAME_LEN];
4483
} SVDropTSmaReq;
4484

4485
typedef struct {
4486
  int tmp;  // TODO: to avoid compile error
4487
} SVCreateTSmaRsp, SVDropTSmaRsp;
4488

4489
#if 0
4490
int32_t tSerializeSVCreateTSmaReq(void** buf, SVCreateTSmaReq* pReq);
4491
void*   tDeserializeSVCreateTSmaReq(void* buf, SVCreateTSmaReq* pReq);
4492
int32_t tSerializeSVDropTSmaReq(void** buf, SVDropTSmaReq* pReq);
4493
void*   tDeserializeSVDropTSmaReq(void* buf, SVDropTSmaReq* pReq);
4494
#endif
4495

4496
int32_t tEncodeSVCreateTSmaReq(SEncoder* pCoder, const SVCreateTSmaReq* pReq);
4497
int32_t tDecodeSVCreateTSmaReq(SDecoder* pCoder, SVCreateTSmaReq* pReq);
4498
int32_t tEncodeSVDropTSmaReq(SEncoder* pCoder, const SVDropTSmaReq* pReq);
4499
// int32_t tDecodeSVDropTSmaReq(SDecoder* pCoder, SVDropTSmaReq* pReq);
4500

4501
typedef struct {
4502
  int32_t number;
4503
  STSma*  tSma;
4504
} STSmaWrapper;
4505

4506
static FORCE_INLINE void tDestroyTSma(STSma* pSma) {
4507
  if (pSma) {
×
4508
    taosMemoryFreeClear(pSma->dstTbName);
×
4509
    taosMemoryFreeClear(pSma->expr);
×
4510
    taosMemoryFreeClear(pSma->tagsFilter);
×
4511
  }
4512
}
×
4513

4514
static FORCE_INLINE void tDestroyTSmaWrapper(STSmaWrapper* pSW, bool deepCopy) {
4515
  if (pSW) {
×
4516
    if (pSW->tSma) {
×
4517
      if (deepCopy) {
×
4518
        for (uint32_t i = 0; i < pSW->number; ++i) {
×
4519
          tDestroyTSma(pSW->tSma + i);
×
4520
        }
4521
      }
4522
      taosMemoryFreeClear(pSW->tSma);
×
4523
    }
4524
  }
4525
}
×
4526

4527
static FORCE_INLINE void* tFreeTSmaWrapper(STSmaWrapper* pSW, bool deepCopy) {
4528
  tDestroyTSmaWrapper(pSW, deepCopy);
×
4529
  taosMemoryFreeClear(pSW);
×
4530
  return NULL;
×
4531
}
4532

4533
int32_t tEncodeSVCreateTSmaReq(SEncoder* pCoder, const SVCreateTSmaReq* pReq);
4534
int32_t tDecodeSVCreateTSmaReq(SDecoder* pCoder, SVCreateTSmaReq* pReq);
4535

4536
int32_t tEncodeTSma(SEncoder* pCoder, const STSma* pSma);
4537
int32_t tDecodeTSma(SDecoder* pCoder, STSma* pSma, bool deepCopy);
4538

4539
static int32_t tEncodeTSmaWrapper(SEncoder* pEncoder, const STSmaWrapper* pReq) {
×
4540
  TAOS_CHECK_RETURN(tEncodeI32(pEncoder, pReq->number));
×
4541
  for (int32_t i = 0; i < pReq->number; ++i) {
×
4542
    TAOS_CHECK_RETURN(tEncodeTSma(pEncoder, pReq->tSma + i));
×
4543
  }
4544
  return 0;
×
4545
}
4546

4547
static int32_t tDecodeTSmaWrapper(SDecoder* pDecoder, STSmaWrapper* pReq, bool deepCopy) {
×
4548
  TAOS_CHECK_RETURN(tDecodeI32(pDecoder, &pReq->number));
×
4549
  for (int32_t i = 0; i < pReq->number; ++i) {
×
4550
    TAOS_CHECK_RETURN(tDecodeTSma(pDecoder, pReq->tSma + i, deepCopy));
×
4551
  }
4552
  return 0;
×
4553
}
4554

4555
typedef struct {
4556
  int idx;
4557
} SMCreateFullTextReq;
4558

4559
int32_t tSerializeSMCreateFullTextReq(void* buf, int32_t bufLen, SMCreateFullTextReq* pReq);
4560
int32_t tDeserializeSMCreateFullTextReq(void* buf, int32_t bufLen, SMCreateFullTextReq* pReq);
4561
void    tFreeSMCreateFullTextReq(SMCreateFullTextReq* pReq);
4562

4563
typedef struct {
4564
  char   name[TSDB_TABLE_FNAME_LEN];
4565
  int8_t igNotExists;
4566
} SMDropFullTextReq;
4567

4568
// int32_t tSerializeSMDropFullTextReq(void* buf, int32_t bufLen, SMDropFullTextReq* pReq);
4569
// int32_t tDeserializeSMDropFullTextReq(void* buf, int32_t bufLen, SMDropFullTextReq* pReq);
4570

4571
typedef struct {
4572
  char indexFName[TSDB_INDEX_FNAME_LEN];
4573
} SUserIndexReq;
4574

4575
int32_t tSerializeSUserIndexReq(void* buf, int32_t bufLen, SUserIndexReq* pReq);
4576
int32_t tDeserializeSUserIndexReq(void* buf, int32_t bufLen, SUserIndexReq* pReq);
4577

4578
typedef struct {
4579
  char dbFName[TSDB_DB_FNAME_LEN];
4580
  char tblFName[TSDB_TABLE_FNAME_LEN];
4581
  char colName[TSDB_COL_NAME_LEN];
4582
  char indexType[TSDB_INDEX_TYPE_LEN];
4583
  char indexExts[TSDB_INDEX_EXTS_LEN];
4584
} SUserIndexRsp;
4585

4586
int32_t tSerializeSUserIndexRsp(void* buf, int32_t bufLen, const SUserIndexRsp* pRsp);
4587
int32_t tDeserializeSUserIndexRsp(void* buf, int32_t bufLen, SUserIndexRsp* pRsp);
4588

4589
typedef struct {
4590
  char tbFName[TSDB_TABLE_FNAME_LEN];
4591
} STableIndexReq;
4592

4593
int32_t tSerializeSTableIndexReq(void* buf, int32_t bufLen, STableIndexReq* pReq);
4594
int32_t tDeserializeSTableIndexReq(void* buf, int32_t bufLen, STableIndexReq* pReq);
4595

4596
typedef struct {
4597
  int8_t  intervalUnit;
4598
  int8_t  slidingUnit;
4599
  int64_t interval;
4600
  int64_t offset;
4601
  int64_t sliding;
4602
  int64_t dstTbUid;
4603
  int32_t dstVgId;
4604
  SEpSet  epSet;
4605
  char*   expr;
4606
} STableIndexInfo;
4607

4608
typedef struct {
4609
  char     tbName[TSDB_TABLE_NAME_LEN];
4610
  char     dbFName[TSDB_DB_FNAME_LEN];
4611
  uint64_t suid;
4612
  int32_t  version;
4613
  int32_t  indexSize;
4614
  SArray*  pIndex;  // STableIndexInfo
4615
} STableIndexRsp;
4616

4617
int32_t tSerializeSTableIndexRsp(void* buf, int32_t bufLen, const STableIndexRsp* pRsp);
4618
int32_t tDeserializeSTableIndexRsp(void* buf, int32_t bufLen, STableIndexRsp* pRsp);
4619
void    tFreeSerializeSTableIndexRsp(STableIndexRsp* pRsp);
4620

4621
void tFreeSTableIndexInfo(void* pInfo);
4622

4623
typedef struct {
4624
  int8_t  mqMsgType;
4625
  int32_t code;
4626
  int32_t epoch;
4627
  int64_t consumerId;
4628
  int64_t walsver;
4629
  int64_t walever;
4630
} SMqRspHead;
4631

4632
typedef struct {
4633
  SMsgHead     head;
4634
  char         subKey[TSDB_SUBSCRIBE_KEY_LEN];
4635
  int8_t       withTbName;
4636
  int8_t       useSnapshot;
4637
  int32_t      epoch;
4638
  uint64_t     reqId;
4639
  int64_t      consumerId;
4640
  int64_t      timeout;
4641
  STqOffsetVal reqOffset;
4642
  int8_t       enableReplay;
4643
  int8_t       sourceExcluded;
4644
  int8_t       rawData;
4645
  int32_t      minPollRows;
4646
  int8_t       enableBatchMeta;
4647
  SHashObj*    uidHash;  // to find if uid is duplicated
4648
} SMqPollReq;
4649

4650
int32_t tSerializeSMqPollReq(void* buf, int32_t bufLen, SMqPollReq* pReq);
4651
int32_t tDeserializeSMqPollReq(void* buf, int32_t bufLen, SMqPollReq* pReq);
4652
void    tDestroySMqPollReq(SMqPollReq* pReq);
4653

4654
typedef struct {
4655
  int32_t vgId;
4656
  int64_t offset;
4657
  SEpSet  epSet;
4658
} SMqSubVgEp;
4659

4660
static FORCE_INLINE int32_t tEncodeSMqSubVgEp(void** buf, const SMqSubVgEp* pVgEp) {
4661
  int32_t tlen = 0;
9,304✔
4662
  tlen += taosEncodeFixedI32(buf, pVgEp->vgId);
9,304✔
4663
  tlen += taosEncodeFixedI64(buf, pVgEp->offset);
9,304✔
4664
  tlen += taosEncodeSEpSet(buf, &pVgEp->epSet);
9,304✔
4665
  return tlen;
9,304✔
4666
}
4667

4668
static FORCE_INLINE void* tDecodeSMqSubVgEp(void* buf, SMqSubVgEp* pVgEp) {
4669
  buf = taosDecodeFixedI32(buf, &pVgEp->vgId);
4,504!
4670
  buf = taosDecodeFixedI64(buf, &pVgEp->offset);
4,504!
4671
  buf = taosDecodeSEpSet(buf, &pVgEp->epSet);
4,504✔
4672
  return buf;
4,504✔
4673
}
4674

4675
typedef struct {
4676
  char           topic[TSDB_TOPIC_FNAME_LEN];
4677
  char           db[TSDB_DB_FNAME_LEN];
4678
  SArray*        vgs;  // SArray<SMqSubVgEp>
4679
  SSchemaWrapper schema;
4680
} SMqSubTopicEp;
4681

4682
int32_t tEncodeMqSubTopicEp(void** buf, const SMqSubTopicEp* pTopicEp);
4683
void*   tDecodeMqSubTopicEp(void* buf, SMqSubTopicEp* pTopicEp);
4684
void    tDeleteMqSubTopicEp(SMqSubTopicEp* pSubTopicEp);
4685

4686
typedef struct {
4687
  SMqRspHead   head;
4688
  STqOffsetVal rspOffset;
4689
  int16_t      resMsgType;
4690
  int32_t      metaRspLen;
4691
  void*        metaRsp;
4692
} SMqMetaRsp;
4693

4694
int32_t tEncodeMqMetaRsp(SEncoder* pEncoder, const SMqMetaRsp* pRsp);
4695
int32_t tDecodeMqMetaRsp(SDecoder* pDecoder, SMqMetaRsp* pRsp);
4696
void    tDeleteMqMetaRsp(SMqMetaRsp* pRsp);
4697

4698
#define MQ_DATA_RSP_VERSION 100
4699

4700
typedef struct {
4701
  SMqRspHead   head;
4702
  STqOffsetVal rspOffset;
4703
  STqOffsetVal reqOffset;
4704
  int32_t      blockNum;
4705
  int8_t       withTbName;
4706
  int8_t       withSchema;
4707
  SArray*      blockDataLen;
4708
  SArray*      blockData;
4709
  SArray*      blockTbName;
4710
  SArray*      blockSchema;
4711

4712
  union {
4713
    struct {
4714
      int64_t sleepTime;
4715
    };
4716
    struct {
4717
      int32_t createTableNum;
4718
      SArray* createTableLen;
4719
      SArray* createTableReq;
4720
    };
4721
    struct {
4722
      int32_t len;
4723
      void*   rawData;
4724
    };
4725
  };
4726
  void* data;                  // for free in client, only effected if type is data or metadata. raw data not effected
4727
  bool  blockDataElementFree;  // if true, free blockDataElement in blockData,(true in server, false in client)
4728
} SMqDataRsp;
4729

4730
int32_t tEncodeMqDataRsp(SEncoder* pEncoder, const SMqDataRsp* pObj);
4731
int32_t tDecodeMqDataRsp(SDecoder* pDecoder, SMqDataRsp* pRsp);
4732
int32_t tDecodeMqRawDataRsp(SDecoder* pDecoder, SMqDataRsp* pRsp);
4733
void    tDeleteMqDataRsp(SMqDataRsp* pRsp);
4734
void    tDeleteMqRawDataRsp(SMqDataRsp* pRsp);
4735

4736
int32_t tEncodeSTaosxRsp(SEncoder* pEncoder, const SMqDataRsp* pRsp);
4737
int32_t tDecodeSTaosxRsp(SDecoder* pDecoder, SMqDataRsp* pRsp);
4738
void    tDeleteSTaosxRsp(SMqDataRsp* pRsp);
4739

4740
typedef struct SMqBatchMetaRsp {
4741
  SMqRspHead   head;  // not serialize
4742
  STqOffsetVal rspOffset;
4743
  SArray*      batchMetaLen;
4744
  SArray*      batchMetaReq;
4745
  void*        pMetaBuff;    // not serialize
4746
  uint32_t     metaBuffLen;  // not serialize
4747
} SMqBatchMetaRsp;
4748

4749
int32_t tEncodeMqBatchMetaRsp(SEncoder* pEncoder, const SMqBatchMetaRsp* pRsp);
4750
int32_t tDecodeMqBatchMetaRsp(SDecoder* pDecoder, SMqBatchMetaRsp* pRsp);
4751
int32_t tSemiDecodeMqBatchMetaRsp(SDecoder* pDecoder, SMqBatchMetaRsp* pRsp);
4752
void    tDeleteMqBatchMetaRsp(SMqBatchMetaRsp* pRsp);
4753

4754
typedef struct {
4755
  SMqRspHead head;
4756
  char       cgroup[TSDB_CGROUP_LEN];
4757
  SArray*    topics;  // SArray<SMqSubTopicEp>
4758
} SMqAskEpRsp;
4759

4760
static FORCE_INLINE int32_t tEncodeSMqAskEpRsp(void** buf, const SMqAskEpRsp* pRsp) {
4761
  int32_t tlen = 0;
18,450✔
4762
  // tlen += taosEncodeString(buf, pRsp->cgroup);
4763
  int32_t sz = taosArrayGetSize(pRsp->topics);
18,450!
4764
  tlen += taosEncodeFixedI32(buf, sz);
18,450✔
4765
  for (int32_t i = 0; i < sz; i++) {
25,916✔
4766
    SMqSubTopicEp* pVgEp = (SMqSubTopicEp*)taosArrayGet(pRsp->topics, i);
7,466✔
4767
    tlen += tEncodeMqSubTopicEp(buf, pVgEp);
7,466✔
4768
  }
4769
  return tlen;
18,450✔
4770
}
4771

4772
static FORCE_INLINE void* tDecodeSMqAskEpRsp(void* buf, SMqAskEpRsp* pRsp) {
4773
  // buf = taosDecodeStringTo(buf, pRsp->cgroup);
4774
  int32_t sz;
4775
  buf = taosDecodeFixedI32(buf, &sz);
8,525✔
4776
  pRsp->topics = taosArrayInit(sz, sizeof(SMqSubTopicEp));
8,525✔
4777
  if (pRsp->topics == NULL) {
8,525!
4778
    return NULL;
×
4779
  }
4780
  for (int32_t i = 0; i < sz; i++) {
12,158✔
4781
    SMqSubTopicEp topicEp;
4782
    buf = tDecodeMqSubTopicEp(buf, &topicEp);
3,633✔
4783
    if (buf == NULL) {
3,633!
4784
      return NULL;
×
4785
    }
4786
    if ((taosArrayPush(pRsp->topics, &topicEp) == NULL)) {
7,266!
4787
      return NULL;
×
4788
    }
4789
  }
4790
  return buf;
8,525✔
4791
}
4792

4793
static FORCE_INLINE void tDeleteSMqAskEpRsp(SMqAskEpRsp* pRsp) {
4794
  taosArrayDestroyEx(pRsp->topics, (FDelete)tDeleteMqSubTopicEp);
20,681✔
4795
}
20,681✔
4796

4797
typedef struct {
4798
  int32_t      vgId;
4799
  STqOffsetVal offset;
4800
  int64_t      rows;
4801
  int64_t      ever;
4802
} OffsetRows;
4803

4804
typedef struct {
4805
  char    topicName[TSDB_TOPIC_FNAME_LEN];
4806
  SArray* offsetRows;
4807
} TopicOffsetRows;
4808

4809
typedef struct {
4810
  int64_t consumerId;
4811
  int32_t epoch;
4812
  SArray* topics;
4813
  int8_t  pollFlag;
4814
} SMqHbReq;
4815

4816
typedef struct {
4817
  char   topic[TSDB_TOPIC_FNAME_LEN];
4818
  int8_t noPrivilege;
4819
} STopicPrivilege;
4820

4821
typedef struct {
4822
  SArray* topicPrivileges;  // SArray<STopicPrivilege>
4823
  int32_t debugFlag;
4824
} SMqHbRsp;
4825

4826
typedef struct {
4827
  SMsgHead head;
4828
  int64_t  consumerId;
4829
  char     subKey[TSDB_SUBSCRIBE_KEY_LEN];
4830
} SMqSeekReq;
4831

4832
#define TD_AUTO_CREATE_TABLE 0x1
4833
typedef struct {
4834
  int64_t       suid;
4835
  int64_t       uid;
4836
  int32_t       sver;
4837
  uint32_t      nData;
4838
  uint8_t*      pData;
4839
  SVCreateTbReq cTbReq;
4840
} SVSubmitBlk;
4841

4842
typedef struct {
4843
  SMsgHead header;
4844
  uint64_t sId;
4845
  uint64_t queryId;
4846
  uint64_t clientId;
4847
  uint64_t taskId;
4848
  uint32_t sqlLen;
4849
  uint32_t phyLen;
4850
  char*    sql;
4851
  char*    msg;
4852
  int8_t   source;
4853
} SVDeleteReq;
4854

4855
int32_t tSerializeSVDeleteReq(void* buf, int32_t bufLen, SVDeleteReq* pReq);
4856
int32_t tDeserializeSVDeleteReq(void* buf, int32_t bufLen, SVDeleteReq* pReq);
4857

4858
typedef struct {
4859
  int64_t affectedRows;
4860
} SVDeleteRsp;
4861

4862
int32_t tEncodeSVDeleteRsp(SEncoder* pCoder, const SVDeleteRsp* pReq);
4863
int32_t tDecodeSVDeleteRsp(SDecoder* pCoder, SVDeleteRsp* pReq);
4864

4865
typedef struct SDeleteRes {
4866
  uint64_t suid;
4867
  SArray*  uidList;
4868
  int64_t  skey;
4869
  int64_t  ekey;
4870
  int64_t  affectedRows;
4871
  char     tableFName[TSDB_TABLE_NAME_LEN];
4872
  char     tsColName[TSDB_COL_NAME_LEN];
4873
  int64_t  ctimeMs;  // fill by vnode
4874
  int8_t   source;
4875
} SDeleteRes;
4876

4877
int32_t tEncodeDeleteRes(SEncoder* pCoder, const SDeleteRes* pRes);
4878
int32_t tDecodeDeleteRes(SDecoder* pCoder, SDeleteRes* pRes);
4879

4880
typedef struct {
4881
  // int64_t uid;
4882
  char    tbname[TSDB_TABLE_NAME_LEN];
4883
  int64_t startTs;
4884
  int64_t endTs;
4885
} SSingleDeleteReq;
4886

4887
int32_t tEncodeSSingleDeleteReq(SEncoder* pCoder, const SSingleDeleteReq* pReq);
4888
int32_t tDecodeSSingleDeleteReq(SDecoder* pCoder, SSingleDeleteReq* pReq);
4889

4890
typedef struct {
4891
  int64_t suid;
4892
  SArray* deleteReqs;  // SArray<SSingleDeleteReq>
4893
  int64_t ctimeMs;     // fill by vnode
4894
  int8_t  level;       // 0 tsdb(default), 1 rsma1 , 2 rsma2
4895
} SBatchDeleteReq;
4896

4897
int32_t tEncodeSBatchDeleteReq(SEncoder* pCoder, const SBatchDeleteReq* pReq);
4898
int32_t tDecodeSBatchDeleteReq(SDecoder* pCoder, SBatchDeleteReq* pReq);
4899
int32_t tDecodeSBatchDeleteReqSetCtime(SDecoder* pDecoder, SBatchDeleteReq* pReq, int64_t ctimeMs);
4900

4901
typedef struct {
4902
  int32_t msgIdx;
4903
  int32_t msgType;
4904
  int32_t msgLen;
4905
  void*   msg;
4906
} SBatchMsg;
4907

4908
typedef struct {
4909
  SMsgHead header;
4910
  SArray*  pMsgs;  // SArray<SBatchMsg>
4911
} SBatchReq;
4912

4913
typedef struct {
4914
  int32_t reqType;
4915
  int32_t msgIdx;
4916
  int32_t msgLen;
4917
  int32_t rspCode;
4918
  void*   msg;
4919
} SBatchRspMsg;
4920

4921
typedef struct {
4922
  SArray* pRsps;  // SArray<SBatchRspMsg>
4923
} SBatchRsp;
4924

4925
int32_t                  tSerializeSBatchReq(void* buf, int32_t bufLen, SBatchReq* pReq);
4926
int32_t                  tDeserializeSBatchReq(void* buf, int32_t bufLen, SBatchReq* pReq);
4927
static FORCE_INLINE void tFreeSBatchReqMsg(void* msg) {
18,861,654✔
4928
  if (NULL == msg) {
18,861,654!
4929
    return;
×
4930
  }
4931
  SBatchMsg* pMsg = (SBatchMsg*)msg;
18,861,654✔
4932
  taosMemoryFree(pMsg->msg);
18,861,654!
4933
}
4934

4935
int32_t tSerializeSBatchRsp(void* buf, int32_t bufLen, SBatchRsp* pRsp);
4936
int32_t tDeserializeSBatchRsp(void* buf, int32_t bufLen, SBatchRsp* pRsp);
4937

4938
static FORCE_INLINE void tFreeSBatchRspMsg(void* p) {
4,451,766✔
4939
  if (NULL == p) {
4,451,766!
4940
    return;
×
4941
  }
4942

4943
  SBatchRspMsg* pRsp = (SBatchRspMsg*)p;
4,451,766✔
4944
  taosMemoryFree(pRsp->msg);
4,451,766!
4945
}
4946

4947
int32_t tSerializeSMqAskEpReq(void* buf, int32_t bufLen, SMqAskEpReq* pReq);
4948
int32_t tDeserializeSMqAskEpReq(void* buf, int32_t bufLen, SMqAskEpReq* pReq);
4949
int32_t tSerializeSMqHbReq(void* buf, int32_t bufLen, SMqHbReq* pReq);
4950
int32_t tDeserializeSMqHbReq(void* buf, int32_t bufLen, SMqHbReq* pReq);
4951
void    tDestroySMqHbReq(SMqHbReq* pReq);
4952

4953
int32_t tSerializeSMqHbRsp(void* buf, int32_t bufLen, SMqHbRsp* pRsp);
4954
int32_t tDeserializeSMqHbRsp(void* buf, int32_t bufLen, SMqHbRsp* pRsp);
4955
void    tDestroySMqHbRsp(SMqHbRsp* pRsp);
4956

4957
int32_t tSerializeSMqSeekReq(void* buf, int32_t bufLen, SMqSeekReq* pReq);
4958
int32_t tDeserializeSMqSeekReq(void* buf, int32_t bufLen, SMqSeekReq* pReq);
4959

4960
#define TD_REQ_FROM_APP               0x0
4961
#define SUBMIT_REQ_AUTO_CREATE_TABLE  0x1
4962
#define SUBMIT_REQ_COLUMN_DATA_FORMAT 0x2
4963
#define SUBMIT_REQ_FROM_FILE          0x4
4964
#define TD_REQ_FROM_TAOX              0x8
4965
#define TD_REQ_FROM_SML               0x10
4966
#define SUBMIT_REQUEST_VERSION        (1)
4967
#define SUBMIT_REQ_WITH_BLOB          0x10
4968

4969
#define TD_REQ_FROM_TAOX_OLD 0x1  // for compatibility
4970

4971
typedef struct {
4972
  int32_t        flags;
4973
  SVCreateTbReq* pCreateTbReq;
4974
  int64_t        suid;
4975
  int64_t        uid;
4976
  int32_t        sver;
4977
  union {
4978
    SArray* aRowP;
4979
    SArray* aCol;
4980
  };
4981
  int64_t    ctimeMs;
4982
  SBlobRow2* pBlobRow;
4983
} SSubmitTbData;
4984

4985
typedef struct {
4986
  SArray* aSubmitTbData;  // SArray<SSubmitTbData>
4987
  SArray* aSubmitBlobData;
4988
  bool    raw;
4989
} SSubmitReq2;
4990

4991
typedef struct {
4992
  SMsgHead header;
4993
  int64_t  version;
4994
  char     data[];  // SSubmitReq2
4995
} SSubmitReq2Msg;
4996

4997
int32_t transformRawSSubmitTbData(void* data, int64_t suid, int64_t uid, int32_t sver);
4998
int32_t tEncodeSubmitReq(SEncoder* pCoder, const SSubmitReq2* pReq);
4999
int32_t tDecodeSubmitReq(SDecoder* pCoder, SSubmitReq2* pReq, SArray* rawList);
5000
void    tDestroySubmitTbData(SSubmitTbData* pTbData, int32_t flag);
5001
void    tDestroySubmitReq(SSubmitReq2* pReq, int32_t flag);
5002

5003
typedef struct {
5004
  int32_t affectedRows;
5005
  SArray* aCreateTbRsp;  // SArray<SVCreateTbRsp>
5006
} SSubmitRsp2;
5007

5008
int32_t tEncodeSSubmitRsp2(SEncoder* pCoder, const SSubmitRsp2* pRsp);
5009
int32_t tDecodeSSubmitRsp2(SDecoder* pCoder, SSubmitRsp2* pRsp);
5010
void    tDestroySSubmitRsp2(SSubmitRsp2* pRsp, int32_t flag);
5011

5012
#define TSDB_MSG_FLG_ENCODE 0x1
5013
#define TSDB_MSG_FLG_DECODE 0x2
5014
#define TSDB_MSG_FLG_CMPT   0x3
5015

5016
typedef struct {
5017
  union {
5018
    struct {
5019
      void*   msgStr;
5020
      int32_t msgLen;
5021
      int64_t ver;
5022
    };
5023
    void* pDataBlock;
5024
  };
5025
} SPackedData;
5026

5027
typedef struct {
5028
  char     fullname[TSDB_VIEW_FNAME_LEN];
5029
  char     name[TSDB_VIEW_NAME_LEN];
5030
  char     dbFName[TSDB_DB_FNAME_LEN];
5031
  char*    querySql;
5032
  char*    sql;
5033
  int8_t   orReplace;
5034
  int8_t   precision;
5035
  int32_t  numOfCols;
5036
  SSchema* pSchema;
5037
} SCMCreateViewReq;
5038

5039
int32_t tSerializeSCMCreateViewReq(void* buf, int32_t bufLen, const SCMCreateViewReq* pReq);
5040
int32_t tDeserializeSCMCreateViewReq(void* buf, int32_t bufLen, SCMCreateViewReq* pReq);
5041
void    tFreeSCMCreateViewReq(SCMCreateViewReq* pReq);
5042

5043
typedef struct {
5044
  char   fullname[TSDB_VIEW_FNAME_LEN];
5045
  char   name[TSDB_VIEW_NAME_LEN];
5046
  char   dbFName[TSDB_DB_FNAME_LEN];
5047
  char*  sql;
5048
  int8_t igNotExists;
5049
} SCMDropViewReq;
5050

5051
int32_t tSerializeSCMDropViewReq(void* buf, int32_t bufLen, const SCMDropViewReq* pReq);
5052
int32_t tDeserializeSCMDropViewReq(void* buf, int32_t bufLen, SCMDropViewReq* pReq);
5053
void    tFreeSCMDropViewReq(SCMDropViewReq* pReq);
5054

5055
typedef struct {
5056
  char fullname[TSDB_VIEW_FNAME_LEN];
5057
} SViewMetaReq;
5058
int32_t tSerializeSViewMetaReq(void* buf, int32_t bufLen, const SViewMetaReq* pReq);
5059
int32_t tDeserializeSViewMetaReq(void* buf, int32_t bufLen, SViewMetaReq* pReq);
5060

5061
typedef struct {
5062
  char     name[TSDB_VIEW_NAME_LEN];
5063
  char     dbFName[TSDB_DB_FNAME_LEN];
5064
  char*    user;
5065
  uint64_t dbId;
5066
  uint64_t viewId;
5067
  char*    querySql;
5068
  int8_t   precision;
5069
  int8_t   type;
5070
  int32_t  version;
5071
  int32_t  numOfCols;
5072
  SSchema* pSchema;
5073
} SViewMetaRsp;
5074
int32_t tSerializeSViewMetaRsp(void* buf, int32_t bufLen, const SViewMetaRsp* pRsp);
5075
int32_t tDeserializeSViewMetaRsp(void* buf, int32_t bufLen, SViewMetaRsp* pRsp);
5076
void    tFreeSViewMetaRsp(SViewMetaRsp* pRsp);
5077
typedef struct {
5078
  char name[TSDB_TABLE_FNAME_LEN];  // table name or tsma name
5079
  bool fetchingWithTsmaName;        // if we are fetching with tsma name
5080
} STableTSMAInfoReq;
5081

5082
int32_t tSerializeTableTSMAInfoReq(void* buf, int32_t bufLen, const STableTSMAInfoReq* pReq);
5083
int32_t tDeserializeTableTSMAInfoReq(void* buf, int32_t bufLen, STableTSMAInfoReq* pReq);
5084

5085
typedef struct {
5086
  int32_t  funcId;
5087
  col_id_t colId;
5088
} STableTSMAFuncInfo;
5089

5090
typedef struct {
5091
  char     name[TSDB_TABLE_NAME_LEN];
5092
  uint64_t tsmaId;
5093
  char     targetTb[TSDB_TABLE_NAME_LEN];
5094
  char     targetDbFName[TSDB_DB_FNAME_LEN];
5095
  char     tb[TSDB_TABLE_NAME_LEN];
5096
  char     dbFName[TSDB_DB_FNAME_LEN];
5097
  uint64_t suid;
5098
  uint64_t destTbUid;
5099
  uint64_t dbId;
5100
  int32_t  version;
5101
  int64_t  interval;
5102
  int8_t   unit;
5103
  SArray*  pFuncs;     // SArray<STableTSMAFuncInfo>
5104
  SArray*  pTags;      // SArray<SSchema>
5105
  SArray*  pUsedCols;  // SArray<SSchema>
5106
  char*    ast;
5107

5108
  int64_t streamUid;
5109
  int64_t reqTs;
5110
  int64_t rspTs;
5111
  int64_t delayDuration;  // ms
5112
  bool    fillHistoryFinished;
5113

5114
  void*   streamAddr;  // for stream task, the address of the stream task
5115
} STableTSMAInfo;
5116

5117
int32_t tSerializeTableTSMAInfoRsp(void* buf, int32_t bufLen, const STableTSMAInfoRsp* pRsp);
5118
int32_t tDeserializeTableTSMAInfoRsp(void* buf, int32_t bufLen, STableTSMAInfoRsp* pRsp);
5119
int32_t tCloneTbTSMAInfo(STableTSMAInfo* pInfo, STableTSMAInfo** pRes);
5120
void    tFreeTableTSMAInfo(void* p);
5121
void    tFreeAndClearTableTSMAInfo(void* p);
5122
void    tFreeTableTSMAInfoRsp(STableTSMAInfoRsp* pRsp);
5123

5124
#define STSMAHbRsp            STableTSMAInfoRsp
5125
#define tSerializeTSMAHbRsp   tSerializeTableTSMAInfoRsp
5126
#define tDeserializeTSMAHbRsp tDeserializeTableTSMAInfoRsp
5127
#define tFreeTSMAHbRsp        tFreeTableTSMAInfoRsp
5128

5129
typedef struct SDropCtbWithTsmaSingleVgReq {
5130
  SVgroupInfo vgInfo;
5131
  SArray*     pTbs;  // SVDropTbReq
5132
} SMDropTbReqsOnSingleVg;
5133

5134
int32_t tEncodeSMDropTbReqOnSingleVg(SEncoder* pEncoder, const SMDropTbReqsOnSingleVg* pReq);
5135
int32_t tDecodeSMDropTbReqOnSingleVg(SDecoder* pDecoder, SMDropTbReqsOnSingleVg* pReq);
5136
void    tFreeSMDropTbReqOnSingleVg(void* p);
5137

5138
typedef struct SDropTbsReq {
5139
  SArray* pVgReqs;  // SMDropTbReqsOnSingleVg
5140
} SMDropTbsReq;
5141

5142
int32_t tSerializeSMDropTbsReq(void* buf, int32_t bufLen, const SMDropTbsReq* pReq);
5143
int32_t tDeserializeSMDropTbsReq(void* buf, int32_t bufLen, SMDropTbsReq* pReq);
5144
void    tFreeSMDropTbsReq(void*);
5145

5146
typedef struct SVFetchTtlExpiredTbsRsp {
5147
  SArray* pExpiredTbs;  // SVDropTbReq
5148
  int32_t vgId;
5149
} SVFetchTtlExpiredTbsRsp;
5150

5151
int32_t tEncodeVFetchTtlExpiredTbsRsp(SEncoder* pCoder, const SVFetchTtlExpiredTbsRsp* pRsp);
5152
int32_t tDecodeVFetchTtlExpiredTbsRsp(SDecoder* pCoder, SVFetchTtlExpiredTbsRsp* pRsp);
5153

5154
void tFreeFetchTtlExpiredTbsRsp(void* p);
5155

5156
void setDefaultOptionsForField(SFieldWithOptions* field);
5157
void setFieldWithOptions(SFieldWithOptions* fieldWithOptions, SField* field);
5158

5159
int32_t tSerializeSVSubTablesRspImpl(SEncoder* pEncoder, SVSubTablesRsp *pRsp);
5160
int32_t tDeserializeSVSubTablesRspImpl(SDecoder* pDecoder, SVSubTablesRsp *pRsp);
5161

5162
#ifdef USE_MOUNT
5163
typedef struct {
5164
  char     mountName[TSDB_MOUNT_NAME_LEN];
5165
  int8_t   ignoreExist;
5166
  int16_t  nMounts;
5167
  int32_t* dnodeIds;
5168
  char**   mountPaths;
5169
  int32_t  sqlLen;
5170
  char*    sql;
5171
} SCreateMountReq;
5172

5173
int32_t tSerializeSCreateMountReq(void* buf, int32_t bufLen, SCreateMountReq* pReq);
5174
int32_t tDeserializeSCreateMountReq(void* buf, int32_t bufLen, SCreateMountReq* pReq);
5175
void    tFreeSCreateMountReq(SCreateMountReq* pReq);
5176

5177
typedef struct {
5178
  char    mountName[TSDB_MOUNT_NAME_LEN];
5179
  int8_t  ignoreNotExists;
5180
  int32_t sqlLen;
5181
  char*   sql;
5182
} SDropMountReq;
5183

5184
int32_t tSerializeSDropMountReq(void* buf, int32_t bufLen, SDropMountReq* pReq);
5185
int32_t tDeserializeSDropMountReq(void* buf, int32_t bufLen, SDropMountReq* pReq);
5186
void    tFreeSDropMountReq(SDropMountReq* pReq);
5187

5188
typedef struct {
5189
  char     mountName[TSDB_MOUNT_NAME_LEN];
5190
  char     mountPath[TSDB_MOUNT_PATH_LEN];
5191
  int64_t  mountUid;
5192
  int32_t  dnodeId;
5193
  uint32_t valLen;
5194
  int8_t   ignoreExist;
5195
  void*    pVal;
5196
} SRetrieveMountPathReq;
5197

5198
int32_t tSerializeSRetrieveMountPathReq(void* buf, int32_t bufLen, SRetrieveMountPathReq* pReq);
5199
int32_t tDeserializeSRetrieveMountPathReq(void* buf, int32_t bufLen, SRetrieveMountPathReq* pReq);
5200

5201
typedef struct {
5202
  // path
5203
  int32_t diskPrimary;
5204
  // vgInfo
5205
  int32_t  vgId;
5206
  int32_t  cacheLastSize;
5207
  int32_t  szPage;
5208
  int32_t  szCache;
5209
  uint64_t szBuf;
5210
  int8_t   cacheLast;
5211
  int8_t   standby;
5212
  int8_t   hashMethod;
5213
  uint32_t hashBegin;
5214
  uint32_t hashEnd;
5215
  int16_t  hashPrefix;
5216
  int16_t  hashSuffix;
5217
  int16_t  sttTrigger;
5218
  // syncInfo
5219
  int32_t replications;
5220
  // tsdbInfo
5221
  int8_t  precision;
5222
  int8_t  compression;
5223
  int8_t  slLevel;
5224
  int32_t daysPerFile;
5225
  int32_t keep0;
5226
  int32_t keep1;
5227
  int32_t keep2;
5228
  int32_t keepTimeOffset;
5229
  int32_t minRows;
5230
  int32_t maxRows;
5231
  int32_t tsdbPageSize;
5232
  int32_t ssChunkSize;
5233
  int32_t ssKeepLocal;
5234
  int8_t  ssCompact;
5235
  // walInfo
5236
  int32_t walFsyncPeriod;      // millisecond
5237
  int32_t walRetentionPeriod;  // secs
5238
  int32_t walRollPeriod;       // secs
5239
  int64_t walRetentionSize;
5240
  int64_t walSegSize;
5241
  int32_t walLevel;
5242
  // encryptInfo
5243
  int32_t encryptAlgorithm;
5244
  // SVState
5245
  int64_t committed;
5246
  int64_t commitID;
5247
  int64_t commitTerm;
5248
  // stats
5249
  int64_t numOfSTables;
5250
  int64_t numOfCTables;
5251
  int64_t numOfNTables;
5252
  // dbInfo
5253
  uint64_t dbId;
5254
} SMountVgInfo;
5255

5256
typedef struct {
5257
  SMCreateStbReq req;
5258
  SArray*        pColExts;  // element: column id
5259
  SArray*        pTagExts;  // element: tag id
5260
} SMountStbInfo;
5261

5262
int32_t tSerializeSMountStbInfo(void* buf, int32_t bufLen, int32_t* pFLen, SMountStbInfo* pInfo);
5263
int32_t tDeserializeSMountStbInfo(void* buf, int32_t bufLen, int32_t flen, SMountStbInfo* pInfo);
5264

5265
typedef struct {
5266
  char     dbName[TSDB_DB_FNAME_LEN];
5267
  uint64_t dbId;
5268
  SArray*  pVgs;      // SMountVgInfo
5269
  SArray*  pStbs;     // 0 serialized binary of SMountStbInfo, 1 SMountStbInfo
5270
} SMountDbInfo;
5271

5272
typedef struct {
5273
  // common fields
5274
  char     mountName[TSDB_MOUNT_NAME_LEN];
5275
  char     mountPath[TSDB_MOUNT_PATH_LEN];
5276
  int8_t   ignoreExist;
5277
  int64_t  mountUid;
5278
  int64_t  clusterId;
5279
  int32_t  dnodeId;
5280
  uint32_t valLen;
5281
  void*    pVal;
5282

5283
  // response fields
5284
  SArray* pDbs;  // SMountDbInfo
5285

5286
  // memory fields, no serialized
5287
  SArray*   pDisks[TFS_MAX_TIERS];
5288
  TdFilePtr pFile;
5289
} SMountInfo;
5290

5291
int32_t tSerializeSMountInfo(void* buf, int32_t bufLen, SMountInfo* pReq);
5292
int32_t tDeserializeSMountInfo(SDecoder* decoder, SMountInfo* pReq, bool extractStb);
5293
void    tFreeMountInfo(SMountInfo* pReq, bool stbExtracted);
5294

5295
typedef struct {
5296
  SCreateVnodeReq createReq;
5297
  char            mountPath[TSDB_MOUNT_FPATH_LEN];
5298
  char            mountName[TSDB_MOUNT_NAME_LEN];
5299
  int64_t         mountId;
5300
  int32_t         diskPrimary;
5301
  int32_t         mountVgId;
5302
  int64_t         committed;
5303
  int64_t         commitID;
5304
  int64_t         commitTerm;
5305
  int64_t         numOfSTables;
5306
  int64_t         numOfCTables;
5307
  int64_t         numOfNTables;
5308
} SMountVnodeReq;
5309

5310
int32_t tSerializeSMountVnodeReq(void *buf, int32_t *cBufLen, int32_t *tBufLen, SMountVnodeReq *pReq);
5311
int32_t tDeserializeSMountVnodeReq(void* buf, int32_t bufLen, SMountVnodeReq* pReq);
5312
int32_t tFreeSMountVnodeReq(SMountVnodeReq* pReq);
5313

5314
#endif  // USE_MOUNT
5315

5316
#pragma pack(pop)
5317

5318
#ifdef __cplusplus
5319
}
5320
#endif
5321

5322
#endif /*_TD_COMMON_TAOS_MSG_H_*/
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc