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

taosdata / TDengine / #4885

15 Dec 2025 03:26AM UTC coverage: 65.258% (+4.6%) from 60.617%
#4885

push

travis-ci

web-flow
feat(tmq): [TS-6379]remove limition for table operation in tmq  (#33834)

872 of 1074 new or added lines in 16 files covered. (81.19%)

659 existing lines in 92 files now uncovered.

177890 of 272597 relevant lines covered (65.26%)

103732965.73 hits per line

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

84.31
/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
static inline bool tmsgIsValid(tmsg_t type) {
2,147,483,647✔
99
  // static int8_t sz = sizeof(tMsgRangeDict) / sizeof(tMsgRangeDict[0]);
100
  int8_t maxSegIdx = TMSG_SEG_CODE(TDMT_MAX_MSG_MIN);
2,147,483,647✔
101
  int    segIdx = TMSG_SEG_CODE(type);
2,147,483,647✔
102
  if (segIdx >= 0 && segIdx < maxSegIdx) {
2,147,483,647✔
103
    return type < tMsgRangeDict[segIdx];
2,147,483,647✔
104
  }
105
  return false;
509✔
106
}
107

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

110
static inline bool vnodeIsMsgBlock(tmsg_t type) {
766,404,011✔
111
  return (type == TDMT_VND_CREATE_TABLE) || (type == TDMT_VND_ALTER_TABLE) || (type == TDMT_VND_DROP_TABLE) ||
725,602,279✔
112
         (type == TDMT_VND_UPDATE_TAG_VAL) || (type == TDMT_VND_ALTER_CONFIRM) || (type == TDMT_VND_COMMIT) ||
1,492,006,290✔
113
         (type == TDMT_SYNC_CONFIG_CHANGE);
114
}
115

116
static inline bool syncUtilUserCommit(tmsg_t msgType) {
1,942,099,448✔
117
  return msgType != TDMT_SYNC_NOOP && msgType != TDMT_SYNC_LEADER_TRANSFER;
1,942,099,448✔
118
}
119

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

130
enum {
131
  CONN_TYPE__QUERY = 1,
132
  CONN_TYPE__TMQ,
133
  CONN_TYPE__UDFD,
134
  CONN_TYPE__AUTH_TEST, // only for test authentication
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_SCAN,
201
  TSDB_MGMT_TABLE_SCAN_DETAIL,
202
  TSDB_MGMT_TABLE_RSMA,
203
  TSDB_MGMT_TABLE_RETENTION,
204
  TSDB_MGMT_TABLE_RETENTION_DETAIL,
205
  TSDB_MGMT_TABLE_INSTANCE,
206
  TSDB_MGMT_TABLE_ENCRYPT_ALGORITHMS,
207
  TSDB_MGMT_TABLE_MAX,
208
} EShowType;
209

210
typedef enum {
211
  TSDB_OPTR_NORMAL = 0,  // default
212
  TSDB_OPTR_SSMIGRATE = 1,
213
  TSDB_OPTR_ROLLUP = 2,
214
} ETsdbOpType;
215

216
typedef enum {
217
  TSDB_TRIGGER_MANUAL = 0,  // default
218
  TSDB_TRIGGER_AUTO = 1,
219
} ETriggerType;
220

221
#define TSDB_ALTER_TABLE_ADD_TAG                         1
222
#define TSDB_ALTER_TABLE_DROP_TAG                        2
223
#define TSDB_ALTER_TABLE_UPDATE_TAG_NAME                 3
224
#define TSDB_ALTER_TABLE_UPDATE_TAG_VAL                  4
225
#define TSDB_ALTER_TABLE_ADD_COLUMN                      5
226
#define TSDB_ALTER_TABLE_DROP_COLUMN                     6
227
#define TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES             7
228
#define TSDB_ALTER_TABLE_UPDATE_TAG_BYTES                8
229
#define TSDB_ALTER_TABLE_UPDATE_OPTIONS                  9
230
#define TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME              10
231
#define TSDB_ALTER_TABLE_ADD_TAG_INDEX                   11
232
#define TSDB_ALTER_TABLE_DROP_TAG_INDEX                  12
233
#define TSDB_ALTER_TABLE_UPDATE_COLUMN_COMPRESS          13
234
#define TSDB_ALTER_TABLE_ADD_COLUMN_WITH_COMPRESS_OPTION 14
235
#define TSDB_ALTER_TABLE_UPDATE_MULTI_TAG_VAL            15
236
#define TSDB_ALTER_TABLE_ALTER_COLUMN_REF                16
237
#define TSDB_ALTER_TABLE_REMOVE_COLUMN_REF               17
238
#define TSDB_ALTER_TABLE_ADD_COLUMN_WITH_COLUMN_REF      18
239

240
#define TSDB_FILL_NONE        0
241
#define TSDB_FILL_NULL        1
242
#define TSDB_FILL_NULL_F      2
243
#define TSDB_FILL_SET_VALUE   3
244
#define TSDB_FILL_SET_VALUE_F 4
245
#define TSDB_FILL_LINEAR      5
246
#define TSDB_FILL_PREV        6
247
#define TSDB_FILL_NEXT        7
248
#define TSDB_FILL_NEAR        8
249

250

251
#define TSDB_ALTER_USER_BASIC_INFO             1
252
// these definitions start from 5 is to keep compatible with old versions
253
#define TSDB_ALTER_USER_ADD_PRIVILEGES         5
254
#define TSDB_ALTER_USER_DEL_PRIVILEGES         6
255

256

257
#define TSDB_ALTER_RSMA_FUNCTION        0x1
258

259
#define TSDB_KILL_MSG_LEN 30
260

261
#define TSDB_TABLE_NUM_UNIT 100000
262

263
#define TSDB_VN_READ_ACCCESS  ((char)0x1)
264
#define TSDB_VN_WRITE_ACCCESS ((char)0x2)
265
#define TSDB_VN_ALL_ACCCESS   (TSDB_VN_READ_ACCCESS | TSDB_VN_WRITE_ACCCESS)
266

267
#define TSDB_COL_NORMAL 0x0u  // the normal column of the table
268
#define TSDB_COL_TAG    0x1u  // the tag column type
269
#define TSDB_COL_UDC    0x2u  // the user specified normal string column, it is a dummy column
270
#define TSDB_COL_TMP    0x4u  // internal column generated by the previous operators
271
#define TSDB_COL_NULL   0x8u  // the column filter NULL or not
272

273
#define TSDB_COL_IS_TAG(f)        (((f & (~(TSDB_COL_NULL))) & TSDB_COL_TAG) != 0)
274
#define TSDB_COL_IS_NORMAL_COL(f) ((f & (~(TSDB_COL_NULL))) == TSDB_COL_NORMAL)
275
#define TSDB_COL_IS_UD_COL(f)     ((f & (~(TSDB_COL_NULL))) == TSDB_COL_UDC)
276
#define TSDB_COL_REQ_NULL(f)      (((f)&TSDB_COL_NULL) != 0)
277

278
#define TD_SUPER_TABLE          TSDB_SUPER_TABLE
279
#define TD_CHILD_TABLE          TSDB_CHILD_TABLE
280
#define TD_NORMAL_TABLE         TSDB_NORMAL_TABLE
281
#define TD_VIRTUAL_NORMAL_TABLE TSDB_VIRTUAL_NORMAL_TABLE
282
#define TD_VIRTUAL_CHILD_TABLE  TSDB_VIRTUAL_CHILD_TABLE
283

284
typedef enum ENodeType {
285
  // Syntax nodes are used in parser and planner module, and some are also used in executor module, such as COLUMN,
286
  // VALUE, OPERATOR, FUNCTION and so on.
287
  QUERY_NODE_COLUMN = 1,
288
  QUERY_NODE_VALUE,
289
  QUERY_NODE_OPERATOR,
290
  QUERY_NODE_LOGIC_CONDITION,
291
  QUERY_NODE_FUNCTION,
292
  QUERY_NODE_REAL_TABLE,
293
  QUERY_NODE_TEMP_TABLE,
294
  QUERY_NODE_JOIN_TABLE,
295
  QUERY_NODE_GROUPING_SET,
296
  QUERY_NODE_ORDER_BY_EXPR,
297
  QUERY_NODE_LIMIT,
298
  QUERY_NODE_STATE_WINDOW,
299
  QUERY_NODE_SESSION_WINDOW,
300
  QUERY_NODE_INTERVAL_WINDOW,
301
  QUERY_NODE_NODE_LIST,
302
  QUERY_NODE_FILL,
303
  QUERY_NODE_RAW_EXPR,  // Only be used in parser module.
304
  QUERY_NODE_TARGET,
305
  QUERY_NODE_DATABLOCK_DESC,
306
  QUERY_NODE_SLOT_DESC,
307
  QUERY_NODE_COLUMN_DEF,
308
  QUERY_NODE_DOWNSTREAM_SOURCE,
309
  QUERY_NODE_DATABASE_OPTIONS,
310
  QUERY_NODE_TABLE_OPTIONS,
311
  QUERY_NODE_INDEX_OPTIONS,
312
  QUERY_NODE_EXPLAIN_OPTIONS,
313
  QUERY_NODE_LEFT_VALUE,
314
  QUERY_NODE_COLUMN_REF,
315
  QUERY_NODE_WHEN_THEN,
316
  QUERY_NODE_CASE_WHEN,
317
  QUERY_NODE_EVENT_WINDOW,
318
  QUERY_NODE_HINT,
319
  QUERY_NODE_VIEW,
320
  QUERY_NODE_WINDOW_OFFSET,
321
  QUERY_NODE_COUNT_WINDOW,
322
  QUERY_NODE_COLUMN_OPTIONS,
323
  QUERY_NODE_TSMA_OPTIONS,
324
  QUERY_NODE_ANOMALY_WINDOW,
325
  QUERY_NODE_RANGE_AROUND,
326
  QUERY_NODE_STREAM_NOTIFY_OPTIONS,
327
  QUERY_NODE_VIRTUAL_TABLE,
328
  QUERY_NODE_SLIDING_WINDOW,
329
  QUERY_NODE_PERIOD_WINDOW,
330
  QUERY_NODE_STREAM_TRIGGER,
331
  QUERY_NODE_STREAM,
332
  QUERY_NODE_STREAM_TAG_DEF,
333
  QUERY_NODE_EXTERNAL_WINDOW,
334
  QUERY_NODE_STREAM_TRIGGER_OPTIONS,
335
  QUERY_NODE_PLACE_HOLDER_TABLE,
336
  QUERY_NODE_TIME_RANGE,
337
  QUERY_NODE_STREAM_OUT_TABLE,
338
  QUERY_NODE_STREAM_CALC_RANGE,
339
  QUERY_NODE_COUNT_WINDOW_ARGS,
340
  QUERY_NODE_BNODE_OPTIONS,
341
  QUERY_NODE_DATE_TIME_RANGE,
342
  QUERY_NODE_IP_RANGE,
343
  QUERY_NODE_USER_OPTIONS,
344

345
  // Statement nodes are used in parser and planner module.
346
  QUERY_NODE_SET_OPERATOR = 100,
347
  QUERY_NODE_SELECT_STMT,
348
  QUERY_NODE_VNODE_MODIFY_STMT,
349
  QUERY_NODE_CREATE_DATABASE_STMT,
350
  QUERY_NODE_DROP_DATABASE_STMT,
351
  QUERY_NODE_ALTER_DATABASE_STMT,
352
  QUERY_NODE_FLUSH_DATABASE_STMT,
353
  QUERY_NODE_TRIM_DATABASE_STMT,
354
  QUERY_NODE_CREATE_TABLE_STMT,
355
  QUERY_NODE_CREATE_SUBTABLE_CLAUSE,
356
  QUERY_NODE_CREATE_MULTI_TABLES_STMT,
357
  QUERY_NODE_DROP_TABLE_CLAUSE,
358
  QUERY_NODE_DROP_TABLE_STMT,
359
  QUERY_NODE_DROP_SUPER_TABLE_STMT,
360
  QUERY_NODE_ALTER_TABLE_STMT,
361
  QUERY_NODE_ALTER_SUPER_TABLE_STMT,
362
  QUERY_NODE_CREATE_USER_STMT,
363
  QUERY_NODE_ALTER_USER_STMT,
364
  QUERY_NODE_DROP_USER_STMT,
365
  QUERY_NODE_USE_DATABASE_STMT,
366
  QUERY_NODE_CREATE_DNODE_STMT,
367
  QUERY_NODE_DROP_DNODE_STMT,
368
  QUERY_NODE_ALTER_DNODE_STMT,
369
  QUERY_NODE_CREATE_INDEX_STMT,
370
  QUERY_NODE_DROP_INDEX_STMT,
371
  QUERY_NODE_CREATE_QNODE_STMT,
372
  QUERY_NODE_DROP_QNODE_STMT,
373
  QUERY_NODE_CREATE_BACKUP_NODE_STMT,  // no longer used
374
  QUERY_NODE_DROP_BACKUP_NODE_STMT,    // no longer used
375
  QUERY_NODE_CREATE_SNODE_STMT,
376
  QUERY_NODE_DROP_SNODE_STMT,
377
  QUERY_NODE_CREATE_MNODE_STMT,
378
  QUERY_NODE_DROP_MNODE_STMT,
379
  QUERY_NODE_CREATE_TOPIC_STMT,
380
  QUERY_NODE_DROP_TOPIC_STMT,
381
  QUERY_NODE_DROP_CGROUP_STMT,
382
  QUERY_NODE_ALTER_LOCAL_STMT,
383
  QUERY_NODE_EXPLAIN_STMT,
384
  QUERY_NODE_DESCRIBE_STMT,
385
  QUERY_NODE_RESET_QUERY_CACHE_STMT,
386
  QUERY_NODE_COMPACT_DATABASE_STMT,
387
  QUERY_NODE_COMPACT_VGROUPS_STMT,
388
  QUERY_NODE_CREATE_FUNCTION_STMT,
389
  QUERY_NODE_DROP_FUNCTION_STMT,
390
  QUERY_NODE_CREATE_STREAM_STMT,
391
  QUERY_NODE_DROP_STREAM_STMT,
392
  QUERY_NODE_BALANCE_VGROUP_STMT,
393
  QUERY_NODE_MERGE_VGROUP_STMT,
394
  QUERY_NODE_REDISTRIBUTE_VGROUP_STMT,
395
  QUERY_NODE_SPLIT_VGROUP_STMT,
396
  QUERY_NODE_SYNCDB_STMT,
397
  QUERY_NODE_GRANT_STMT,
398
  QUERY_NODE_REVOKE_STMT,
399
  QUERY_NODE_ALTER_CLUSTER_STMT,
400
  QUERY_NODE_SSMIGRATE_DATABASE_STMT,
401
  QUERY_NODE_CREATE_TSMA_STMT,
402
  QUERY_NODE_DROP_TSMA_STMT,
403
  QUERY_NODE_CREATE_VIRTUAL_TABLE_STMT,
404
  QUERY_NODE_CREATE_VIRTUAL_SUBTABLE_STMT,
405
  QUERY_NODE_DROP_VIRTUAL_TABLE_STMT,
406
  QUERY_NODE_ALTER_VIRTUAL_TABLE_STMT,
407
  QUERY_NODE_CREATE_MOUNT_STMT,
408
  QUERY_NODE_DROP_MOUNT_STMT,
409
  QUERY_NODE_SCAN_DATABASE_STMT,
410
  QUERY_NODE_SCAN_VGROUPS_STMT,
411
  QUERY_NODE_TRIM_DATABASE_WAL_STMT,
412

413
  // placeholder for [154, 180]
414
  QUERY_NODE_SHOW_CREATE_VIEW_STMT = 181,
415
  QUERY_NODE_SHOW_CREATE_DATABASE_STMT,
416
  QUERY_NODE_SHOW_CREATE_TABLE_STMT,
417
  QUERY_NODE_SHOW_CREATE_STABLE_STMT,
418
  QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT,
419
  QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT,
420
  QUERY_NODE_SHOW_SCORES_STMT,
421
  QUERY_NODE_SHOW_TABLE_TAGS_STMT,
422
  QUERY_NODE_KILL_CONNECTION_STMT,
423
  QUERY_NODE_KILL_QUERY_STMT,
424
  QUERY_NODE_KILL_TRANSACTION_STMT,
425
  QUERY_NODE_KILL_COMPACT_STMT,
426
  QUERY_NODE_DELETE_STMT,
427
  QUERY_NODE_INSERT_STMT,
428
  QUERY_NODE_QUERY,
429
  QUERY_NODE_SHOW_DB_ALIVE_STMT,
430
  QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT,
431
  QUERY_NODE_BALANCE_VGROUP_LEADER_STMT,
432
  QUERY_NODE_BALANCE_VGROUP_LEADER_DATABASE_STMT,
433
  QUERY_NODE_RESTORE_DNODE_STMT,
434
  QUERY_NODE_RESTORE_QNODE_STMT,
435
  QUERY_NODE_RESTORE_MNODE_STMT,
436
  QUERY_NODE_RESTORE_VNODE_STMT,
437
  QUERY_NODE_PAUSE_STREAM_STMT,
438
  QUERY_NODE_RESUME_STREAM_STMT,
439
  QUERY_NODE_CREATE_VIEW_STMT,
440
  QUERY_NODE_DROP_VIEW_STMT,
441
  QUERY_NODE_CREATE_SUBTABLE_FROM_FILE_CLAUSE,
442
  QUERY_NODE_CREATE_ANODE_STMT,
443
  QUERY_NODE_DROP_ANODE_STMT,
444
  QUERY_NODE_UPDATE_ANODE_STMT,
445
  QUERY_NODE_ASSIGN_LEADER_STMT,
446
  QUERY_NODE_SHOW_CREATE_TSMA_STMT,
447
  QUERY_NODE_SHOW_CREATE_VTABLE_STMT,
448
  QUERY_NODE_RECALCULATE_STREAM_STMT,
449
  QUERY_NODE_CREATE_BNODE_STMT,
450
  QUERY_NODE_DROP_BNODE_STMT,
451
  QUERY_NODE_KILL_SSMIGRATE_STMT,
452
  QUERY_NODE_KILL_SCAN_STMT,
453
  QUERY_NODE_CREATE_RSMA_STMT,
454
  QUERY_NODE_DROP_RSMA_STMT,
455
  QUERY_NODE_ALTER_RSMA_STMT,
456
  QUERY_NODE_SHOW_CREATE_RSMA_STMT,
457
  QUERY_NODE_ROLLUP_DATABASE_STMT,
458
  QUERY_NODE_ROLLUP_VGROUPS_STMT,
459
  QUERY_NODE_KILL_RETENTION_STMT,
460
  QUERY_NODE_SET_VGROUP_KEEP_VERSION_STMT,
461
  QUERY_NODE_CREATE_ENCRYPT_ALGORITHMS_STMT,
462
  QUERY_NODE_DROP_ENCRYPT_ALGR_STMT,
463

464
  // show statement nodes
465
  // see 'sysTableShowAdapter', 'SYSTABLE_SHOW_TYPE_OFFSET'
466
  QUERY_NODE_SHOW_DNODES_STMT = 400,
467
  QUERY_NODE_SHOW_MNODES_STMT,
468
  QUERY_NODE_SHOW_MODULES_STMT,
469
  QUERY_NODE_SHOW_QNODES_STMT,
470
  QUERY_NODE_SHOW_SNODES_STMT,
471
  QUERY_NODE_SHOW_BACKUP_NODES_STMT,  // no longer used
472
  QUERY_NODE_SHOW_ARBGROUPS_STMT,
473
  QUERY_NODE_SHOW_CLUSTER_STMT,
474
  QUERY_NODE_SHOW_DATABASES_STMT,
475
  QUERY_NODE_SHOW_FUNCTIONS_STMT,
476
  QUERY_NODE_SHOW_INDEXES_STMT,
477
  QUERY_NODE_SHOW_STABLES_STMT,
478
  QUERY_NODE_SHOW_STREAMS_STMT,
479
  QUERY_NODE_SHOW_TABLES_STMT,
480
  QUERY_NODE_SHOW_TAGS_STMT,
481
  QUERY_NODE_SHOW_USERS_STMT,
482
  QUERY_NODE_SHOW_USERS_FULL_STMT,
483
  QUERY_NODE_SHOW_LICENCES_STMT,
484
  QUERY_NODE_SHOW_VGROUPS_STMT,
485
  QUERY_NODE_SHOW_TOPICS_STMT,
486
  QUERY_NODE_SHOW_CONSUMERS_STMT,
487
  QUERY_NODE_SHOW_CONNECTIONS_STMT,
488
  QUERY_NODE_SHOW_QUERIES_STMT,
489
  QUERY_NODE_SHOW_APPS_STMT,
490
  QUERY_NODE_SHOW_VARIABLES_STMT,
491
  QUERY_NODE_SHOW_DNODE_VARIABLES_STMT,
492
  QUERY_NODE_SHOW_TRANSACTIONS_STMT,
493
  QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT,
494
  QUERY_NODE_SHOW_VNODES_STMT,
495
  QUERY_NODE_SHOW_USER_PRIVILEGES_STMT,
496
  QUERY_NODE_SHOW_VIEWS_STMT,
497
  QUERY_NODE_SHOW_COMPACTS_STMT,
498
  QUERY_NODE_SHOW_COMPACT_DETAILS_STMT,
499
  QUERY_NODE_SHOW_GRANTS_FULL_STMT,
500
  QUERY_NODE_SHOW_GRANTS_LOGS_STMT,
501
  QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT,
502
  QUERY_NODE_SHOW_ENCRYPTIONS_STMT,
503
  QUERY_NODE_SHOW_TSMAS_STMT,
504
  QUERY_NODE_SHOW_ANODES_STMT,
505
  QUERY_NODE_SHOW_ANODES_FULL_STMT,
506
  QUERY_NODE_SHOW_USAGE_STMT,
507
  QUERY_NODE_SHOW_FILESETS_STMT,
508
  QUERY_NODE_SHOW_TRANSACTION_DETAILS_STMT,
509
  QUERY_NODE_SHOW_VTABLES_STMT,
510
  QUERY_NODE_SHOW_BNODES_STMT,
511
  QUERY_NODE_SHOW_MOUNTS_STMT,
512
  QUERY_NODE_SHOW_SSMIGRATES_STMT,
513
  QUERY_NODE_SHOW_SCANS_STMT,
514
  QUERY_NODE_SHOW_SCAN_DETAILS_STMT,
515
  QUERY_NODE_SHOW_RSMAS_STMT,
516
  QUERY_NODE_SHOW_RETENTIONS_STMT,
517
  QUERY_NODE_SHOW_RETENTION_DETAILS_STMT,
518
  QUERY_NODE_SHOW_INSTANCES_STMT,
519
  QUERY_NODE_SHOW_ENCRYPT_ALGORITHMS_STMT,
520

521
  // logic plan node
522
  QUERY_NODE_LOGIC_PLAN_SCAN = 1000,
523
  QUERY_NODE_LOGIC_PLAN_JOIN,
524
  QUERY_NODE_LOGIC_PLAN_AGG,
525
  QUERY_NODE_LOGIC_PLAN_PROJECT,
526
  QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY,
527
  QUERY_NODE_LOGIC_PLAN_EXCHANGE,
528
  QUERY_NODE_LOGIC_PLAN_MERGE,
529
  QUERY_NODE_LOGIC_PLAN_WINDOW,
530
  QUERY_NODE_LOGIC_PLAN_FILL,
531
  QUERY_NODE_LOGIC_PLAN_SORT,
532
  QUERY_NODE_LOGIC_PLAN_PARTITION,
533
  QUERY_NODE_LOGIC_PLAN_INDEF_ROWS_FUNC,
534
  QUERY_NODE_LOGIC_PLAN_INTERP_FUNC,
535
  QUERY_NODE_LOGIC_SUBPLAN,
536
  QUERY_NODE_LOGIC_PLAN,
537
  QUERY_NODE_LOGIC_PLAN_GROUP_CACHE,
538
  QUERY_NODE_LOGIC_PLAN_DYN_QUERY_CTRL,
539
  QUERY_NODE_LOGIC_PLAN_FORECAST_FUNC,
540
  QUERY_NODE_LOGIC_PLAN_VIRTUAL_TABLE_SCAN,
541
  QUERY_NODE_LOGIC_PLAN_ANALYSIS_FUNC,
542

543
  // physical plan node
544
  QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN = 1100,
545
  QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN,
546
  QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN,  // INACTIVE
547
  QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN,
548
  QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN,
549
  QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN,
550
  QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN,
551
  QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN,
552
  QUERY_NODE_PHYSICAL_PLAN_PROJECT,
553
  QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN,
554
  QUERY_NODE_PHYSICAL_PLAN_HASH_AGG,
555
  QUERY_NODE_PHYSICAL_PLAN_EXCHANGE,
556
  QUERY_NODE_PHYSICAL_PLAN_MERGE,
557
  QUERY_NODE_PHYSICAL_PLAN_SORT,
558
  QUERY_NODE_PHYSICAL_PLAN_GROUP_SORT,
559
  QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL,
560
  QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL,  // INACTIVE
561
  QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL,
562
  QUERY_NODE_PHYSICAL_PLAN_UNUSED_1,
563
  QUERY_NODE_PHYSICAL_PLAN_UNUSED_2,
564
  QUERY_NODE_PHYSICAL_PLAN_UNUSED_3,
565
  QUERY_NODE_PHYSICAL_PLAN_FILL,
566
  QUERY_NODE_PHYSICAL_PLAN_UNUSED_4,
567
  QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION,
568
  QUERY_NODE_PHYSICAL_PLAN_UNUSED_5,
569
  QUERY_NODE_PHYSICAL_PLAN_UNUSED_6,
570
  QUERY_NODE_PHYSICAL_PLAN_UNUSED_7,
571
  QUERY_NODE_PHYSICAL_PLAN_MERGE_STATE,
572
  QUERY_NODE_PHYSICAL_PLAN_UNUSED_8,
573
  QUERY_NODE_PHYSICAL_PLAN_PARTITION,
574
  QUERY_NODE_PHYSICAL_PLAN_UNUSED_9,
575
  QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC,
576
  QUERY_NODE_PHYSICAL_PLAN_INTERP_FUNC,
577
  QUERY_NODE_PHYSICAL_PLAN_DISPATCH,
578
  QUERY_NODE_PHYSICAL_PLAN_INSERT,
579
  QUERY_NODE_PHYSICAL_PLAN_QUERY_INSERT,
580
  QUERY_NODE_PHYSICAL_PLAN_DELETE,
581
  QUERY_NODE_PHYSICAL_SUBPLAN,
582
  QUERY_NODE_PHYSICAL_PLAN,
583
  QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN,
584
  QUERY_NODE_PHYSICAL_PLAN_MERGE_EVENT,
585
  QUERY_NODE_PHYSICAL_PLAN_UNUSED_10,
586
  QUERY_NODE_PHYSICAL_PLAN_HASH_JOIN,
587
  QUERY_NODE_PHYSICAL_PLAN_GROUP_CACHE,
588
  QUERY_NODE_PHYSICAL_PLAN_DYN_QUERY_CTRL,
589
  QUERY_NODE_PHYSICAL_PLAN_MERGE_COUNT,
590
  QUERY_NODE_PHYSICAL_PLAN_UNUSED_11,
591
  QUERY_NODE_PHYSICAL_PLAN_UNUSED_12,
592
  QUERY_NODE_PHYSICAL_PLAN_UNUSED_13,
593
  QUERY_NODE_PHYSICAL_PLAN_MERGE_ANOMALY,
594
  QUERY_NODE_PHYSICAL_PLAN_UNUSED_14,
595
  QUERY_NODE_PHYSICAL_PLAN_FORECAST_FUNC,
596
  QUERY_NODE_PHYSICAL_PLAN_UNUSED_15,
597
  QUERY_NODE_PHYSICAL_PLAN_UNUSED_16,
598
  QUERY_NODE_PHYSICAL_PLAN_UNUSED_17,
599
  QUERY_NODE_PHYSICAL_PLAN_UNUSED_18,
600
  QUERY_NODE_PHYSICAL_PLAN_UNUSED_19,
601
  QUERY_NODE_PHYSICAL_PLAN_UNUSED_20,
602
  QUERY_NODE_PHYSICAL_PLAN_UNUSED_21,
603
  QUERY_NODE_PHYSICAL_PLAN_UNUSED_22,
604
  QUERY_NODE_PHYSICAL_PLAN_UNUSED_23,
605
  QUERY_NODE_PHYSICAL_PLAN_UNUSED_24,
606
  QUERY_NODE_PHYSICAL_PLAN_VIRTUAL_TABLE_SCAN,
607
  QUERY_NODE_PHYSICAL_PLAN_EXTERNAL_WINDOW,
608
  QUERY_NODE_PHYSICAL_PLAN_HASH_EXTERNAL,
609
  QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_EXTERNAL,
610
  QUERY_NODE_PHYSICAL_PLAN_STREAM_INSERT,
611
  QUERY_NODE_PHYSICAL_PLAN_ANALYSIS_FUNC,
612
} ENodeType;
613

614
typedef struct {
615
  int32_t     vgId;
616
  uint8_t     option;         // 0x0 REQ_OPT_TBNAME, 0x01 REQ_OPT_TBUID
617
  uint8_t     autoCreateCtb;  // 0x0 not auto create, 0x01 auto create
618
  const char* dbFName;
619
  const char* tbName;
620
} SBuildTableInput;
621

622
typedef struct {
623
  char    db[TSDB_DB_FNAME_LEN];
624
  int64_t dbId;
625
  int32_t vgVersion;
626
  int32_t numOfTable;  // unit is TSDB_TABLE_NUM_UNIT
627
  int64_t stateTs;
628
} SBuildUseDBInput;
629

630
typedef struct SField {
631
  char    name[TSDB_COL_NAME_LEN];
632
  uint8_t type;
633
  int8_t  flags;
634
  int32_t bytes;
635
} SField;
636

637
typedef struct SFieldWithOptions {
638
  char     name[TSDB_COL_NAME_LEN];
639
  uint8_t  type;
640
  int8_t   flags;
641
  int32_t  bytes;
642
  uint32_t compress;
643
  STypeMod typeMod;
644
} SFieldWithOptions;
645

646
typedef struct SRetention {
647
  int64_t freq;
648
  int64_t keep;
649
  int8_t  freqUnit;
650
  int8_t  keepUnit;
651
} SRetention;
652

653
#define RETENTION_VALID(l, r) ((((l) == 0 && (r)->freq >= 0) || ((r)->freq > 0)) && ((r)->keep > 0))
654

655
#pragma pack(push, 1)
656
// null-terminated string instead of char array to avoid too many memory consumption in case of more than 1M tableMeta
657
typedef struct SEp {
658
  char     fqdn[TSDB_FQDN_LEN];
659
  uint16_t port;
660
} SEp;
661

662
typedef struct {
663
  int32_t contLen;
664
  int32_t vgId;
665
} SMsgHead;
666

667
// Submit message for one table
668
typedef struct SSubmitBlk {
669
  int64_t uid;        // table unique id
670
  int64_t suid;       // stable id
671
  int32_t sversion;   // data schema version
672
  int32_t dataLen;    // data part length, not including the SSubmitBlk head
673
  int32_t schemaLen;  // schema length, if length is 0, no schema exists
674
  int32_t numOfRows;  // total number of rows in current submit block
675
  char    data[];
676
} SSubmitBlk;
677

678
// Submit message for this TSDB
679
typedef struct {
680
  SMsgHead header;
681
  int64_t  version;
682
  int32_t  length;
683
  int32_t  numOfBlocks;
684
  char     blocks[];
685
} SSubmitReq;
686

687
typedef struct {
688
  int32_t totalLen;
689
  int32_t len;
690
  STSRow* row;
691
} SSubmitBlkIter;
692

693
typedef struct {
694
  int32_t totalLen;
695
  int32_t len;
696
  // head of SSubmitBlk
697
  int64_t uid;        // table unique id
698
  int64_t suid;       // stable id
699
  int32_t sversion;   // data schema version
700
  int32_t dataLen;    // data part length, not including the SSubmitBlk head
701
  int32_t schemaLen;  // schema length, if length is 0, no schema exists
702
  int32_t numOfRows;  // total number of rows in current submit block
703
  // head of SSubmitBlk
704
  int32_t     numOfBlocks;
705
  const void* pMsg;
706
} SSubmitMsgIter;
707

708
int32_t tInitSubmitMsgIter(const SSubmitReq* pMsg, SSubmitMsgIter* pIter);
709
int32_t tGetSubmitMsgNext(SSubmitMsgIter* pIter, SSubmitBlk** pPBlock);
710
int32_t tInitSubmitBlkIter(SSubmitMsgIter* pMsgIter, SSubmitBlk* pBlock, SSubmitBlkIter* pIter);
711
STSRow* tGetSubmitBlkNext(SSubmitBlkIter* pIter);
712
// for debug
713
int32_t tPrintFixedSchemaSubmitReq(SSubmitReq* pReq, STSchema* pSchema);
714

715
typedef struct {
716
  bool     hasRef;
717
  col_id_t id;
718
  char     refDbName[TSDB_DB_NAME_LEN];
719
  char     refTableName[TSDB_TABLE_NAME_LEN];
720
  char     refColName[TSDB_COL_NAME_LEN];
721
} SColRef;
722

723
typedef struct {
724
  int32_t  nCols;
725
  int32_t  version;
726
  SColRef* pColRef;
727
} SColRefWrapper;
728

729
int32_t tEncodeSColRefWrapper(SEncoder *pCoder, const SColRefWrapper *pWrapper);
730
int32_t tDecodeSColRefWrapperEx(SDecoder *pDecoder, SColRefWrapper *pWrapper, bool decoderMalloc);
731
typedef struct {
732
  int32_t vgId;
733
  SColRef colRef;
734
} SColRefEx;
735

736
typedef struct {
737
  int16_t colId;
738
  char    refDbName[TSDB_DB_NAME_LEN];
739
  char    refTableName[TSDB_TABLE_NAME_LEN];
740
  char    refColName[TSDB_COL_NAME_LEN];
741
} SRefColInfo;
742

743
typedef struct SVCTableRefCols {
744
  uint64_t     uid;
745
  int32_t      numOfSrcTbls;
746
  int32_t      numOfColRefs;
747
  SRefColInfo* refCols;
748
} SVCTableRefCols;
749

750
typedef struct SVCTableMergeInfo {
751
  uint64_t uid;
752
  int32_t  numOfSrcTbls;
753
} SVCTableMergeInfo;
754

755
typedef struct {
756
  int32_t    nCols;
757
  SColRefEx* pColRefEx;
758
} SColRefExWrapper;
759

760
struct SSchema {
761
  int8_t   type;
762
  int8_t   flags;
763
  col_id_t colId;
764
  int32_t  bytes;
765
  char     name[TSDB_COL_NAME_LEN];
766
};
767
struct SSchemaExt {
768
  col_id_t colId;
769
  uint32_t compress;
770
  STypeMod typeMod;
771
};
772

773
struct SSchemaRsma {
774
  int64_t    interval[2];
775
  int32_t    nFuncs;
776
  int8_t     tbType;
777
  tb_uid_t   tbUid;
778
  func_id_t* funcIds;
779
  char       tbName[TSDB_TABLE_NAME_LEN];
780
};
781

782
struct SSchema2 {
783
  int8_t   type;
784
  int8_t   flags;
785
  col_id_t colId;
786
  int32_t  bytes;
787
  char     name[TSDB_COL_NAME_LEN];
788
  uint32_t compress;
789
};
790

791
typedef struct {
792
  char        tbName[TSDB_TABLE_NAME_LEN];
793
  char        stbName[TSDB_TABLE_NAME_LEN];
794
  char        dbFName[TSDB_DB_FNAME_LEN];
795
  int64_t     dbId;
796
  int32_t     numOfTags;
797
  int32_t     numOfColumns;
798
  int8_t      precision;
799
  int8_t      tableType;
800
  int32_t     sversion;
801
  int32_t     tversion;
802
  int32_t     rversion;
803
  uint64_t    suid;
804
  uint64_t    tuid;
805
  int32_t     vgId;
806
  int8_t      sysInfo;
807
  SSchema*    pSchemas;
808
  SSchemaExt* pSchemaExt;
809
  int8_t      virtualStb;
810
  int32_t     numOfColRefs;
811
  SColRef*    pColRefs;
812
} STableMetaRsp;
813

814
typedef struct {
815
  int32_t        code;
816
  int64_t        uid;
817
  char*          tblFName;
818
  int32_t        numOfRows;
819
  int32_t        affectedRows;
820
  int64_t        sver;
821
  STableMetaRsp* pMeta;
822
} SSubmitBlkRsp;
823

824
typedef struct {
825
  int32_t numOfRows;
826
  int32_t affectedRows;
827
  int32_t nBlocks;
828
  union {
829
    SArray*        pArray;
830
    SSubmitBlkRsp* pBlocks;
831
  };
832
} SSubmitRsp;
833

834
// int32_t tEncodeSSubmitRsp(SEncoder* pEncoder, const SSubmitRsp* pRsp);
835
// int32_t tDecodeSSubmitRsp(SDecoder* pDecoder, SSubmitRsp* pRsp);
836
// void    tFreeSSubmitBlkRsp(void* param);
837
void tFreeSSubmitRsp(SSubmitRsp* pRsp);
838

839
#define COL_SMA_ON       ((int8_t)0x1)
840
#define COL_IDX_ON       ((int8_t)0x2)
841
#define COL_IS_KEY       ((int8_t)0x4)
842
#define COL_SET_NULL     ((int8_t)0x10)
843
#define COL_SET_VAL      ((int8_t)0x20)
844
#define COL_IS_SYSINFO   ((int8_t)0x40)
845
#define COL_HAS_TYPE_MOD ((int8_t)0x80)
846
#define COL_REF_BY_STM   ((int8_t)0x08)
847

848
#define COL_IS_SET(FLG)  (((FLG) & (COL_SET_VAL | COL_SET_NULL)) != 0)
849
#define COL_CLR_SET(FLG) ((FLG) &= (~(COL_SET_VAL | COL_SET_NULL)))
850

851
#define IS_BSMA_ON(s)  (((s)->flags & 0x01) == COL_SMA_ON)
852
#define IS_IDX_ON(s)   (((s)->flags & 0x02) == COL_IDX_ON)
853
#define IS_SET_NULL(s) (((s)->flags & COL_SET_NULL) == COL_SET_NULL)
854

855
#define SSCHMEA_SET_IDX_ON(s) \
856
  do {                        \
857
    (s)->flags |= COL_IDX_ON; \
858
  } while (0)
859

860
#define SSCHMEA_SET_IDX_OFF(s)   \
861
  do {                           \
862
    (s)->flags &= (~COL_IDX_ON); \
863
  } while (0)
864

865
#define SSCHEMA_SET_TYPE_MOD(s)     \
866
  do {                              \
867
    (s)->flags |= COL_HAS_TYPE_MOD; \
868
  } while (0)
869

870
#define HAS_TYPE_MOD(s) (((s)->flags & COL_HAS_TYPE_MOD))
871

872
#define SSCHMEA_TYPE(s)  ((s)->type)
873
#define SSCHMEA_FLAGS(s) ((s)->flags)
874
#define SSCHMEA_COLID(s) ((s)->colId)
875
#define SSCHMEA_BYTES(s) ((s)->bytes)
876
#define SSCHMEA_NAME(s)  ((s)->name)
877

878
typedef struct {
879
  bool    tsEnableMonitor;
880
  int32_t tsMonitorInterval;
881
  int32_t tsSlowLogThreshold;
882
  int32_t tsSlowLogMaxLen;
883
  int32_t tsSlowLogScope;
884
  int32_t tsSlowLogThresholdTest;  // Obsolete
885
  char    tsSlowLogExceptDb[TSDB_DB_NAME_LEN];
886
} SMonitorParas;
887

888
typedef struct {
889
  STypeMod typeMod;
890
} SExtSchema;
891

892
bool hasExtSchema(const SExtSchema* pExtSchema);
893

894
typedef struct {
895
  int32_t      nCols;
896
  int32_t      version;
897
  SSchema*     pSchema;
898
  SSchemaRsma* pRsma;
899
} SSchemaWrapper;
900

901
typedef struct {
902
  col_id_t id;
903
  uint32_t alg;
904
} SColCmpr;
905

906
typedef struct {
907
  int32_t   nCols;
908
  int32_t   version;
909
  SColCmpr* pColCmpr;
910
} SColCmprWrapper;
911

912
static FORCE_INLINE int32_t tInitDefaultSColRefWrapperByCols(SColRefWrapper* pRef, int32_t nCols) {
913
  if (pRef->pColRef) {
375,537✔
914
    return TSDB_CODE_INVALID_PARA;
×
915
  }
916
  pRef->pColRef = (SColRef*)taosMemoryCalloc(nCols, sizeof(SColRef));
375,537✔
917
  if (pRef->pColRef == NULL) {
375,537✔
918
    return terrno;
×
919
  }
920
  pRef->nCols = nCols;
375,537✔
921
  for (int32_t i = 0; i < nCols; i++) {
4,643,226✔
922
    pRef->pColRef[i].hasRef = false;
4,267,689✔
923
    pRef->pColRef[i].id = (col_id_t)(i + 1);
4,267,689✔
924
  }
925
  return 0;
375,537✔
926
}
927

928
static FORCE_INLINE SColCmprWrapper* tCloneSColCmprWrapper(const SColCmprWrapper* pSrcWrapper) {
929
  if (pSrcWrapper->pColCmpr == NULL || pSrcWrapper->nCols == 0) {
930
    terrno = TSDB_CODE_INVALID_PARA;
931
    return NULL;
932
  }
933

934
  SColCmprWrapper* pDstWrapper = (SColCmprWrapper*)taosMemoryMalloc(sizeof(SColCmprWrapper));
935
  if (pDstWrapper == NULL) {
936
    return NULL;
937
  }
938
  pDstWrapper->nCols = pSrcWrapper->nCols;
939
  pDstWrapper->version = pSrcWrapper->version;
940

941
  int32_t size = sizeof(SColCmpr) * pDstWrapper->nCols;
942
  pDstWrapper->pColCmpr = (SColCmpr*)taosMemoryCalloc(1, size);
943
  if (pDstWrapper->pColCmpr == NULL) {
944
    taosMemoryFree(pDstWrapper);
945
    return NULL;
946
  }
947
  (void)memcpy(pDstWrapper->pColCmpr, pSrcWrapper->pColCmpr, size);
948

949
  return pDstWrapper;
950
}
951

952
static FORCE_INLINE int32_t tInitDefaultSColCmprWrapperByCols(SColCmprWrapper* pCmpr, int32_t nCols) {
953
  if (!(!pCmpr->pColCmpr)) {
2,175,312✔
954
    return TSDB_CODE_INVALID_PARA;
×
955
  }
956
  pCmpr->pColCmpr = (SColCmpr*)taosMemoryCalloc(nCols, sizeof(SColCmpr));
2,175,312✔
957
  if (pCmpr->pColCmpr == NULL) {
2,175,312✔
958
    return terrno;
×
959
  }
960
  pCmpr->nCols = nCols;
2,175,312✔
961
  return 0;
2,175,312✔
962
}
963

964
static FORCE_INLINE int32_t tInitDefaultSColCmprWrapper(SColCmprWrapper* pCmpr, SSchemaWrapper* pSchema) {
965
  pCmpr->nCols = pSchema->nCols;
966
  if (!(!pCmpr->pColCmpr)) {
967
    return TSDB_CODE_INVALID_PARA;
968
  }
969
  pCmpr->pColCmpr = (SColCmpr*)taosMemoryCalloc(pCmpr->nCols, sizeof(SColCmpr));
970
  if (pCmpr->pColCmpr == NULL) {
971
    return terrno;
972
  }
973
  for (int32_t i = 0; i < pCmpr->nCols; i++) {
974
    SColCmpr* pColCmpr = &pCmpr->pColCmpr[i];
975
    SSchema*  pColSchema = &pSchema->pSchema[i];
976
    pColCmpr->id = pColSchema->colId;
977
    pColCmpr->alg = 0;
978
  }
979
  return 0;
980
}
981

982
static FORCE_INLINE void tDeleteSColCmprWrapper(SColCmprWrapper* pWrapper) {
983
  if (pWrapper == NULL) return;
984

985
  taosMemoryFreeClear(pWrapper->pColCmpr);
986
  taosMemoryFreeClear(pWrapper);
987
}
988
static FORCE_INLINE SSchemaWrapper* tCloneSSchemaWrapper(const SSchemaWrapper* pSchemaWrapper) {
989
  if (pSchemaWrapper->pSchema == NULL) return NULL;
325,826,681✔
990

991
  SSchemaWrapper* pSW = (SSchemaWrapper*)taosMemoryCalloc(1, sizeof(SSchemaWrapper));
325,809,553✔
992
  if (pSW == NULL) {
325,721,462✔
993
    return NULL;
×
994
  }
995
  pSW->nCols = pSchemaWrapper->nCols;
325,721,462✔
996
  pSW->version = pSchemaWrapper->version;
325,738,330✔
997
  pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema));
325,714,063✔
998
  if (pSW->pSchema == NULL) {
325,629,021✔
999
    taosMemoryFree(pSW);
×
1000
    return NULL;
×
1001
  }
1002

1003
  (void)memcpy(pSW->pSchema, pSchemaWrapper->pSchema, pSW->nCols * sizeof(SSchema));
325,660,051✔
1004
  return pSW;
325,843,739✔
1005
}
1006

1007
static FORCE_INLINE void tDeleteSchemaWrapper(SSchemaWrapper* pSchemaWrapper) {
107,262,051✔
1008
  if (pSchemaWrapper) {
886,353,472✔
1009
    taosMemoryFree(pSchemaWrapper->pSchema);
495,404,482✔
1010
    if(pSchemaWrapper->pRsma) {
495,346,077✔
1011
      taosMemoryFreeClear(pSchemaWrapper->pRsma->funcIds);
27,792✔
1012
      taosMemoryFreeClear(pSchemaWrapper->pRsma);
27,792✔
1013
    }
1014
    taosMemoryFree(pSchemaWrapper);
495,352,611✔
1015
  }
1016
}
871,974,333✔
1017

1018
static FORCE_INLINE void tDestroySchemaWrapper(SSchemaWrapper* pSchemaWrapper) {
1019
  if (pSchemaWrapper) {
1020
    taosMemoryFreeClear(pSchemaWrapper->pSchema);
1021
    if(pSchemaWrapper->pRsma) {
1022
      taosMemoryFreeClear(pSchemaWrapper->pRsma->funcIds);
1023
      taosMemoryFreeClear(pSchemaWrapper->pRsma);
1024
    }
1025
  }
1026
}
1027

1028
static FORCE_INLINE void tDeleteSSchemaWrapperForHash(void* pSchemaWrapper) {
1,384,343✔
1029
  if (pSchemaWrapper != NULL && *(SSchemaWrapper**)pSchemaWrapper != NULL) {
1,384,343✔
1030
    tDeleteSchemaWrapper(*(SSchemaWrapper**)pSchemaWrapper);
1,384,343✔
1031
  }
1032
}
1,383,074✔
1033

1034
static FORCE_INLINE int32_t taosEncodeSSchema(void** buf, const SSchema* pSchema) {
1035
  int32_t tlen = 0;
1,400,384✔
1036
  tlen += taosEncodeFixedI8(buf, pSchema->type);
1,400,456✔
1037
  tlen += taosEncodeFixedI8(buf, pSchema->flags);
1,400,384✔
1038
  tlen += taosEncodeFixedI32(buf, pSchema->bytes);
1,400,384✔
1039
  tlen += taosEncodeFixedI16(buf, pSchema->colId);
1,400,384✔
1040
  tlen += taosEncodeString(buf, pSchema->name);
1,400,384✔
1041
  return tlen;
1,400,384✔
1042
}
1043

1044
static FORCE_INLINE void* taosDecodeSSchema(const void* buf, SSchema* pSchema) {
1045
  buf = taosDecodeFixedI8(buf, &pSchema->type);
597,327✔
1046
  buf = taosDecodeFixedI8(buf, &pSchema->flags);
597,309✔
1047
  buf = taosDecodeFixedI32(buf, &pSchema->bytes);
597,309✔
1048
  buf = taosDecodeFixedI16(buf, &pSchema->colId);
597,309✔
1049
  buf = taosDecodeStringTo(buf, pSchema->name);
597,309✔
1050
  return (void*)buf;
597,309✔
1051
}
1052

1053
static FORCE_INLINE int32_t tEncodeSSchema(SEncoder* pEncoder, const SSchema* pSchema) {
1054
  TAOS_CHECK_RETURN(tEncodeI8(pEncoder, pSchema->type));
2,147,483,647✔
1055
  TAOS_CHECK_RETURN(tEncodeI8(pEncoder, pSchema->flags));
2,147,483,647✔
1056
  TAOS_CHECK_RETURN(tEncodeI32v(pEncoder, pSchema->bytes));
2,147,483,647✔
1057
  TAOS_CHECK_RETURN(tEncodeI16v(pEncoder, pSchema->colId));
2,147,483,647✔
1058
  TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pSchema->name));
2,147,483,647✔
1059
  return 0;
2,147,483,647✔
1060
}
1061

1062
static FORCE_INLINE int32_t tDecodeSSchema(SDecoder* pDecoder, SSchema* pSchema) {
1063
  TAOS_CHECK_RETURN(tDecodeI8(pDecoder, &pSchema->type));
2,147,483,647✔
1064
  TAOS_CHECK_RETURN(tDecodeI8(pDecoder, &pSchema->flags));
2,147,483,647✔
1065
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pSchema->bytes));
2,147,483,647✔
1066
  TAOS_CHECK_RETURN(tDecodeI16v(pDecoder, &pSchema->colId));
2,147,483,647✔
1067
  TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, pSchema->name));
2,147,483,647✔
1068
  return 0;
2,147,483,647✔
1069
}
1070

1071
static FORCE_INLINE int32_t tEncodeSSchemaExt(SEncoder* pEncoder, const SSchemaExt* pSchemaExt) {
1072
  TAOS_CHECK_RETURN(tEncodeI16v(pEncoder, pSchemaExt->colId));
2,147,483,647✔
1073
  TAOS_CHECK_RETURN(tEncodeU32(pEncoder, pSchemaExt->compress));
2,147,483,647✔
1074
  TAOS_CHECK_RETURN(tEncodeI32(pEncoder, pSchemaExt->typeMod));
2,147,483,647✔
1075
  return 0;
2,147,483,647✔
1076
}
1077

1078
static FORCE_INLINE int32_t tDecodeSSchemaExt(SDecoder* pDecoder, SSchemaExt* pSchemaExt) {
1079
  TAOS_CHECK_RETURN(tDecodeI16v(pDecoder, &pSchemaExt->colId));
2,147,483,647✔
1080
  TAOS_CHECK_RETURN(tDecodeU32(pDecoder, &pSchemaExt->compress));
2,147,483,647✔
1081
  TAOS_CHECK_RETURN(tDecodeI32(pDecoder, &pSchemaExt->typeMod));
2,147,483,647✔
1082
  return 0;
2,147,483,647✔
1083
}
1084

1085
static FORCE_INLINE int32_t tEncodeSColRef(SEncoder* pEncoder, const SColRef* pColRef) {
1086
  TAOS_CHECK_RETURN(tEncodeI8(pEncoder, pColRef->hasRef));
23,731,760✔
1087
  TAOS_CHECK_RETURN(tEncodeI16(pEncoder, pColRef->id));
23,731,760✔
1088
  if (pColRef->hasRef) {
11,865,880✔
1089
    TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pColRef->refDbName));
13,196,840✔
1090
    TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pColRef->refTableName));
13,196,840✔
1091
    TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pColRef->refColName));
13,196,840✔
1092
  }
1093
  return 0;
11,865,880✔
1094
}
1095

1096
static FORCE_INLINE int32_t tDecodeSColRef(SDecoder* pDecoder, SColRef* pColRef) {
1097
  TAOS_CHECK_RETURN(tDecodeI8(pDecoder, (int8_t*)&pColRef->hasRef));
14,352,230✔
1098
  TAOS_CHECK_RETURN(tDecodeI16(pDecoder, &pColRef->id));
14,352,230✔
1099
  if (pColRef->hasRef) {
7,176,115✔
1100
    TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, pColRef->refDbName));
4,135,599✔
1101
    TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, pColRef->refTableName));
4,135,599✔
1102
    TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, pColRef->refColName));
4,135,599✔
1103
  }
1104

1105
  return 0;
7,176,115✔
1106
}
1107

1108
static FORCE_INLINE int32_t taosEncodeSSchemaWrapper(void** buf, const SSchemaWrapper* pSW) {
1109
  int32_t tlen = 0;
180,398✔
1110
  tlen += taosEncodeVariantI32(buf, pSW->nCols);
180,398✔
1111
  tlen += taosEncodeVariantI32(buf, pSW->version);
180,398✔
1112
  for (int32_t i = 0; i < pSW->nCols; i++) {
1,580,782✔
1113
    tlen += taosEncodeSSchema(buf, &pSW->pSchema[i]);
2,800,768✔
1114
  }
1115
  return tlen;
180,398✔
1116
}
1117

1118
static FORCE_INLINE void* taosDecodeSSchemaWrapper(const void* buf, SSchemaWrapper* pSW) {
1119
  buf = taosDecodeVariantI32(buf, &pSW->nCols);
75,209✔
1120
  buf = taosDecodeVariantI32(buf, &pSW->version);
75,209✔
1121
  if (pSW->nCols > 0) {
75,209✔
1122
    pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema));
75,209✔
1123
    if (pSW->pSchema == NULL) {
75,209✔
1124
      return NULL;
×
1125
    }
1126

1127
    for (int32_t i = 0; i < pSW->nCols; i++) {
672,518✔
1128
      buf = taosDecodeSSchema(buf, &pSW->pSchema[i]);
1,194,618✔
1129
    }
1130
  } else {
UNCOV
1131
    pSW->pSchema = NULL;
×
1132
  }
1133
  return (void*)buf;
75,209✔
1134
}
1135

1136
static FORCE_INLINE int32_t tEncodeSSchemaWrapper(SEncoder* pEncoder, const SSchemaWrapper* pSW) {
1137
  if (pSW == NULL) {
282,684,574✔
1138
    return TSDB_CODE_INVALID_PARA;
×
1139
  }
1140
  TAOS_CHECK_RETURN(tEncodeI32v(pEncoder, pSW->nCols));
565,315,676✔
1141
  TAOS_CHECK_RETURN(tEncodeI32v(pEncoder, pSW->version));
565,214,822✔
1142
  for (int32_t i = 0; i < pSW->nCols; i++) {
2,147,483,647✔
1143
    TAOS_CHECK_RETURN(tEncodeSSchema(pEncoder, &pSW->pSchema[i]));
2,147,483,647✔
1144
  }
1145
  return 0;
282,748,515✔
1146
}
1147

1148
static FORCE_INLINE int32_t tDecodeSSchemaWrapper(SDecoder* pDecoder, SSchemaWrapper* pSW) {
1149
  if (pSW == NULL) {
81,045,660✔
1150
    return TSDB_CODE_INVALID_PARA;
×
1151
  }
1152
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pSW->nCols));
162,071,627✔
1153
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pSW->version));
162,054,834✔
1154

1155
  pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema));
81,028,867✔
1156
  if (pSW->pSchema == NULL) {
80,989,267✔
1157
    TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
×
1158
  }
1159
  for (int32_t i = 0; i < pSW->nCols; i++) {
740,591,313✔
1160
    TAOS_CHECK_RETURN(tDecodeSSchema(pDecoder, &pSW->pSchema[i]));
1,319,021,764✔
1161
  }
1162

1163
  return 0;
81,062,474✔
1164
}
1165

1166
static FORCE_INLINE int32_t tDecodeSSchemaWrapperEx(SDecoder* pDecoder, SSchemaWrapper* pSW) {
1167
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pSW->nCols));
2,147,483,647✔
1168
  TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pSW->version));
2,147,483,647✔
1169

1170
  pSW->pSchema = (SSchema*)tDecoderMalloc(pDecoder, pSW->nCols * sizeof(SSchema));
2,147,483,647✔
1171
  if (pSW->pSchema == NULL) {
1,438,047,408✔
1172
    TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
×
1173
  }
1174
  for (int32_t i = 0; i < pSW->nCols; i++) {
2,147,483,647✔
1175
    TAOS_CHECK_RETURN(tDecodeSSchema(pDecoder, &pSW->pSchema[i]));
2,147,483,647✔
1176
  }
1177

1178
  return 0;
1,438,340,981✔
1179
}
1180

1181
typedef struct {
1182
  char     name[TSDB_TABLE_FNAME_LEN];
1183
  int8_t   igExists;
1184
  int8_t   source;  // TD_REQ_FROM_TAOX-taosX or TD_REQ_FROM_APP-taosClient
1185
  int8_t   reserved[6];
1186
  tb_uid_t suid;
1187
  int64_t  delay1;
1188
  int64_t  delay2;
1189
  int64_t  watermark1;
1190
  int64_t  watermark2;
1191
  int32_t  ttl;
1192
  int32_t  colVer;
1193
  int32_t  tagVer;
1194
  int32_t  numOfColumns;
1195
  int32_t  numOfTags;
1196
  int32_t  numOfFuncs;
1197
  int32_t  commentLen;
1198
  int32_t  ast1Len;
1199
  int32_t  ast2Len;
1200
  SArray*  pColumns;  // array of SFieldWithOptions
1201
  SArray*  pTags;     // array of SField
1202
  SArray*  pFuncs;
1203
  char*    pComment;
1204
  char*    pAst1;
1205
  char*    pAst2;
1206
  int64_t  deleteMark1;
1207
  int64_t  deleteMark2;
1208
  int32_t  sqlLen;
1209
  char*    sql;
1210
  int64_t  keep;
1211
  int8_t   virtualStb;
1212
} SMCreateStbReq;
1213

1214
int32_t tSerializeSMCreateStbReq(void* buf, int32_t bufLen, SMCreateStbReq* pReq);
1215
int32_t tDeserializeSMCreateStbReq(void* buf, int32_t bufLen, SMCreateStbReq* pReq);
1216
void    tFreeSMCreateStbReq(SMCreateStbReq* pReq);
1217

1218
typedef struct {
1219
  STableMetaRsp* pMeta;
1220
} SMCreateStbRsp;
1221

1222
int32_t tEncodeSMCreateStbRsp(SEncoder* pEncoder, const SMCreateStbRsp* pRsp);
1223
int32_t tDecodeSMCreateStbRsp(SDecoder* pDecoder, SMCreateStbRsp* pRsp);
1224
void    tFreeSMCreateStbRsp(SMCreateStbRsp* pRsp);
1225

1226
typedef struct {
1227
  char     name[TSDB_TABLE_FNAME_LEN];
1228
  int8_t   igNotExists;
1229
  int8_t   source;  // TD_REQ_FROM_TAOX-taosX or TD_REQ_FROM_APP-taosClient
1230
  int8_t   reserved[6];
1231
  tb_uid_t suid;
1232
  int32_t  sqlLen;
1233
  char*    sql;
1234
} SMDropStbReq;
1235

1236
int32_t tSerializeSMDropStbReq(void* buf, int32_t bufLen, SMDropStbReq* pReq);
1237
int32_t tDeserializeSMDropStbReq(void* buf, int32_t bufLen, SMDropStbReq* pReq);
1238
void    tFreeSMDropStbReq(SMDropStbReq* pReq);
1239

1240
typedef struct {
1241
  char    name[TSDB_TABLE_FNAME_LEN];
1242
  int8_t  alterType;
1243
  int32_t numOfFields;
1244
  SArray* pFields;
1245
  int32_t ttl;
1246
  int32_t commentLen;
1247
  char*   comment;
1248
  int32_t sqlLen;
1249
  char*   sql;
1250
  int64_t keep;
1251
  SArray* pTypeMods;
1252
} SMAlterStbReq;
1253

1254
int32_t tSerializeSMAlterStbReq(void* buf, int32_t bufLen, SMAlterStbReq* pReq);
1255
int32_t tDeserializeSMAlterStbReq(void* buf, int32_t bufLen, SMAlterStbReq* pReq);
1256
void    tFreeSMAltertbReq(SMAlterStbReq* pReq);
1257

1258
typedef struct SEpSet {
1259
  int8_t inUse;
1260
  int8_t numOfEps;
1261
  SEp    eps[TSDB_MAX_REPLICA];
1262
} SEpSet;
1263

1264
int32_t tEncodeSEpSet(SEncoder* pEncoder, const SEpSet* pEp);
1265
int32_t tDecodeSEpSet(SDecoder* pDecoder, SEpSet* pEp);
1266
int32_t taosEncodeSEpSet(void** buf, const SEpSet* pEp);
1267
void*   taosDecodeSEpSet(const void* buf, SEpSet* pEp);
1268

1269
int32_t tSerializeSEpSet(void* buf, int32_t bufLen, const SEpSet* pEpset);
1270
int32_t tDeserializeSEpSet(void* buf, int32_t buflen, SEpSet* pEpset);
1271

1272
typedef struct {
1273
  int8_t  connType;
1274
  int32_t pid;
1275
  char    app[TSDB_APP_NAME_LEN];
1276
  char    db[TSDB_DB_NAME_LEN];
1277
  char    user[TSDB_USER_LEN];
1278
  char    passwd[TSDB_PASSWORD_LEN];
1279
  int64_t startTime;
1280
  char    sVer[TSDB_VERSION_LEN];
1281
  int32_t totpCode;
1282
} SConnectReq;
1283

1284
int32_t tSerializeSConnectReq(void* buf, int32_t bufLen, SConnectReq* pReq);
1285
int32_t tDeserializeSConnectReq(void* buf, int32_t bufLen, SConnectReq* pReq);
1286

1287
typedef struct {
1288
  int64_t       clusterId;
1289
  int32_t       acctId;
1290
  uint32_t      connId;
1291
  int32_t       dnodeNum;
1292
  int8_t        superUser;
1293
  int8_t        sysInfo;
1294
  int8_t        connType;
1295
  SEpSet        epSet;
1296
  int32_t       svrTimestamp;
1297
  int32_t       passVer;
1298
  int32_t       authVer;
1299
  char          sVer[TSDB_VERSION_LEN];
1300
  char          sDetailVer[128];
1301
  int64_t       whiteListVer;
1302
  int64_t       timeWhiteListVer;
1303
  SMonitorParas monitorParas;
1304
  int8_t        enableAuditDelete;
1305
} SConnectRsp;
1306

1307
int32_t tSerializeSConnectRsp(void* buf, int32_t bufLen, SConnectRsp* pRsp);
1308
int32_t tDeserializeSConnectRsp(void* buf, int32_t bufLen, SConnectRsp* pRsp);
1309

1310
typedef struct {
1311
  char    user[TSDB_USER_LEN];
1312
  char    pass[TSDB_PASSWORD_LEN];
1313
  int32_t maxUsers;
1314
  int32_t maxDbs;
1315
  int32_t maxTimeSeries;
1316
  int32_t maxStreams;
1317
  int32_t accessState;  // Configured only by command
1318
  int64_t maxStorage;
1319
} SCreateAcctReq, SAlterAcctReq;
1320

1321
// int32_t tSerializeSCreateAcctReq(void* buf, int32_t bufLen, SCreateAcctReq* pReq);
1322
// int32_t tDeserializeSCreateAcctReq(void* buf, int32_t bufLen, SCreateAcctReq* pReq);
1323

1324
typedef struct {
1325
  char    user[TSDB_USER_LEN];
1326
  int32_t sqlLen;
1327
  char*   sql;
1328
} SDropUserReq, SDropAcctReq;
1329

1330
int32_t tSerializeSDropUserReq(void* buf, int32_t bufLen, SDropUserReq* pReq);
1331
int32_t tDeserializeSDropUserReq(void* buf, int32_t bufLen, SDropUserReq* pReq);
1332
void    tFreeSDropUserReq(SDropUserReq* pReq);
1333

1334
typedef struct {
1335
  char    algorithmId[TSDB_ENCRYPT_ALGR_NAME_LEN];
1336
  int32_t sqlLen;
1337
  char*   sql;
1338
} SDropEncryptAlgrReq;
1339

1340
int32_t tSerializeSDropEncryptAlgrReq(void* buf, int32_t bufLen, SDropEncryptAlgrReq* pReq);
1341
int32_t tDeserializeSDropEncryptAlgrReq(void* buf, int32_t bufLen, SDropEncryptAlgrReq* pReq);
1342
void    tFreeSDropEncryptAlgrReq(SDropEncryptAlgrReq* pReq);
1343

1344
typedef struct SIpV4Range {
1345
  uint32_t ip;
1346
  uint32_t mask;
1347
} SIpV4Range;
1348

1349
typedef struct SIpv6Range {
1350
  uint64_t addr[2];
1351
  uint32_t mask;
1352
} SIpV6Range;
1353

1354
typedef struct {
1355
  int8_t type;   // 0: IPv4, 1: IPv6
1356
  int8_t neg;    // only used in SIpWhiteListDual, if neg is 1, means this is a blacklist entry
1357
  union {
1358
    SIpV4Range ipV4;
1359
    SIpV6Range ipV6;
1360
  };
1361
} SIpRange;
1362

1363
typedef struct {
1364
  int32_t    num;
1365
  SIpV4Range pIpRange[];
1366
} SIpWhiteList;
1367

1368
typedef struct {
1369
  int32_t  num;
1370
  SIpRange pIpRanges[];
1371
} SIpWhiteListDual;
1372

1373
SIpWhiteListDual* cloneIpWhiteList(const SIpWhiteListDual* src);
1374
int32_t           cvtIpWhiteListToDual(SIpWhiteList* pWhiteList, SIpWhiteListDual** pWhiteListDual);
1375
int32_t           cvtIpWhiteListDualToV4(SIpWhiteListDual* pWhiteListDual, SIpWhiteList** pWhiteList);
1376
int32_t           createDefaultIp6Range(SIpRange* pRange);
1377
int32_t           createDefaultIp4Range(SIpRange* pRange);
1378

1379
// copyIpRange ensures that unused bytes are always zeroed, so that [pDst] can be used as a key in hash tables
1380
void copyIpRange(SIpRange* pDst, const SIpRange* pSrc);
1381

1382
// SDateTimeRange is used in client side during SQL statement parsing, client sends this structure
1383
// to server, and server will convert it to SDateTimeWhiteListItem for internal usage.
1384
typedef struct {
1385
  int16_t year;
1386
  int8_t month; // 1-12, when month is -1, it means day is week day and year is not used.
1387
  int8_t day;   // 1-31 or 0-6 (0 means Sunday), depends on the month value.
1388
  int8_t hour;
1389
  int8_t minute;
1390
  int8_t neg;   // this is a negative entry
1391
  int32_t duration; // duration in minute
1392
} SDateTimeRange;
1393

1394
bool isValidDateTimeRange(SDateTimeRange* pRange);
1395
int32_t tEncodeSDateTimeRange(SEncoder* pEncoder, const SDateTimeRange* pRange);
1396
int32_t tDecodeSDateTimeRange(SDecoder* pDecoder, SDateTimeRange* pRange);
1397

1398

1399
// SDateTimeWhiteListItem is used by server internally to represent datetime ranges. 
1400
typedef struct {
1401
  bool absolute;    // true: absolute datetime range; false: weekly recurring datetime range
1402
  bool neg;         // this is a negative entry
1403
  int32_t duration; // duration in seconds
1404
  int64_t start;    // absolute timestamp in seconds or weekly offset in seconds
1405
} SDateTimeWhiteListItem;
1406

1407
void DateTimeRangeToWhiteListItem(SDateTimeWhiteListItem* dst, const SDateTimeRange* src);
1408
bool isDateTimeWhiteListItemExpired(const SDateTimeWhiteListItem* item);
1409

1410
typedef struct {
1411
  int32_t num;
1412
  SDateTimeWhiteListItem ranges[];
1413
} SDateTimeWhiteList;
1414

1415
SDateTimeWhiteList* cloneDateTimeWhiteList(const SDateTimeWhiteList* src);
1416
bool isTimeInDateTimeWhiteList(const SDateTimeWhiteList *wl, int64_t tm);
1417

1418

1419
typedef struct {
1420
  int8_t createType;
1421
  int8_t superUser;  // denote if it is a super user or not
1422
  int8_t ignoreExisting;
1423

1424
  char   user[TSDB_USER_LEN];
1425
  char   pass[TSDB_USER_PASSWORD_LONGLEN];
1426
  char   totpseed[TSDB_USER_TOTPSEED_MAX_LEN + 1];
1427

1428
  int8_t sysInfo;
1429
  int8_t createDb;
1430
  int8_t isImport;
1431
  int8_t changepass;
1432
  int8_t enable;
1433

1434
  int8_t negIpRanges;
1435
  int8_t negTimeRanges;
1436

1437
  int32_t sessionPerUser;
1438
  int32_t connectTime;
1439
  int32_t connectIdleTime;
1440
  int32_t callPerSession;
1441
  int32_t vnodePerCall;
1442
  int32_t failedLoginAttempts;
1443
  int32_t passwordLifeTime;
1444
  int32_t passwordReuseTime;
1445
  int32_t passwordReuseMax;
1446
  int32_t passwordLockTime;
1447
  int32_t passwordGraceTime;
1448
  int32_t inactiveAccountTime;
1449
  int32_t allowTokenNum;
1450

1451
  int32_t         numIpRanges;
1452
  SIpRange*       pIpDualRanges;
1453
  int32_t         numTimeRanges;
1454
  SDateTimeRange* pTimeRanges;
1455

1456
  int32_t sqlLen;
1457
  char*   sql;
1458
} SCreateUserReq;
1459

1460
int32_t tSerializeSCreateUserReq(void* buf, int32_t bufLen, SCreateUserReq* pReq);
1461
int32_t tDeserializeSCreateUserReq(void* buf, int32_t bufLen, SCreateUserReq* pReq);
1462
void    tFreeSCreateUserReq(SCreateUserReq* pReq);
1463

1464
typedef struct {
1465
  char    algorithmId[TSDB_ENCRYPT_ALGR_NAME_LEN];
1466
  char    name[TSDB_ENCRYPT_ALGR_NAME_LEN];
1467
  char    desc[TSDB_ENCRYPT_ALGR_DESC_LEN];
1468
  char    type[TSDB_ENCRYPT_ALGR_TYPE_LEN];
1469
  char    osslAlgrName[TSDB_ENCRYPT_ALGR_NAME_LEN];
1470
  int32_t sqlLen;
1471
  char*   sql;
1472
} SCreateEncryptAlgrReq;
1473

1474
int32_t tSerializeSCreateEncryptAlgrReq(void* buf, int32_t bufLen, SCreateEncryptAlgrReq* pReq);
1475
int32_t tDeserializeSCreateEncryptAlgrReq(void* buf, int32_t bufLen, SCreateEncryptAlgrReq* pReq);
1476
void    tFreeSCreateEncryptAlgrReq(SCreateEncryptAlgrReq* pReq);
1477

1478
typedef struct {
1479
  int32_t dnodeId;
1480
  int64_t analVer;
1481
} SRetrieveAnalyticsAlgoReq;
1482

1483
typedef struct {
1484
  int64_t   ver;
1485
  SHashObj* hash;  // algoname:algotype -> SAnalUrl
1486
} SRetrieveAnalyticAlgoRsp;
1487

1488
int32_t tSerializeRetrieveAnalyticAlgoReq(void* buf, int32_t bufLen, SRetrieveAnalyticsAlgoReq* pReq);
1489
int32_t tDeserializeRetrieveAnalyticAlgoReq(void* buf, int32_t bufLen, SRetrieveAnalyticsAlgoReq* pReq);
1490
int32_t tSerializeRetrieveAnalyticAlgoRsp(void* buf, int32_t bufLen, SRetrieveAnalyticAlgoRsp* pRsp);
1491
int32_t tDeserializeRetrieveAnalyticAlgoRsp(void* buf, int32_t bufLen, SRetrieveAnalyticAlgoRsp* pRsp);
1492
void    tFreeRetrieveAnalyticAlgoRsp(SRetrieveAnalyticAlgoRsp* pRsp);
1493

1494
typedef struct {
1495
  int8_t alterType;
1496

1497
  int8_t isView;
1498
  
1499
  int8_t hasPassword;
1500
  int8_t hasTotpseed;
1501
  int8_t hasEnable;
1502
  int8_t hasSysinfo;
1503
  int8_t hasCreatedb;
1504
  int8_t hasChangepass;
1505
  int8_t hasSessionPerUser;
1506
  int8_t hasConnectTime;
1507
  int8_t hasConnectIdleTime;
1508
  int8_t hasCallPerSession;
1509
  int8_t hasVnodePerCall;
1510
  int8_t hasFailedLoginAttempts;
1511
  int8_t hasPasswordLifeTime;
1512
  int8_t hasPasswordReuseTime;
1513
  int8_t hasPasswordReuseMax;
1514
  int8_t hasPasswordLockTime;
1515
  int8_t hasPasswordGraceTime;
1516
  int8_t hasInactiveAccountTime;
1517
  int8_t hasAllowTokenNum;
1518

1519
  int8_t enable;
1520
  int8_t sysinfo;
1521
  int8_t createdb;
1522
  int8_t changepass;
1523

1524
  char   user[TSDB_USER_LEN];
1525
  char   pass[TSDB_USER_PASSWORD_LONGLEN];
1526
  char   totpseed[TSDB_USER_TOTPSEED_MAX_LEN + 1];
1527
  int32_t sessionPerUser;
1528
  int32_t connectTime;
1529
  int32_t connectIdleTime;
1530
  int32_t callPerSession;
1531
  int32_t vnodePerCall;
1532
  int32_t failedLoginAttempts;
1533
  int32_t passwordLifeTime;
1534
  int32_t passwordReuseTime;
1535
  int32_t passwordReuseMax;
1536
  int32_t passwordLockTime;
1537
  int32_t passwordGraceTime;
1538
  int32_t inactiveAccountTime;
1539
  int32_t allowTokenNum;
1540

1541
  int32_t         numIpRanges;
1542
  int32_t         numTimeRanges;
1543
  int32_t         numDropIpRanges;
1544
  int32_t         numDropTimeRanges;
1545
  SIpRange*       pIpRanges;
1546
  SDateTimeRange* pTimeRanges;
1547
  SIpRange*       pDropIpRanges;
1548
  SDateTimeRange* pDropTimeRanges;
1549

1550
  char        objname[TSDB_DB_FNAME_LEN];  // db or topic
1551
  char        tabName[TSDB_TABLE_NAME_LEN];
1552
  char*       tagCond;
1553
  int32_t     tagCondLen;
1554
  int32_t     sqlLen;
1555
  char*       sql;
1556
  int64_t     privileges;
1557
} SAlterUserReq;
1558

1559
int32_t tSerializeSAlterUserReq(void* buf, int32_t bufLen, SAlterUserReq* pReq);
1560
int32_t tDeserializeSAlterUserReq(void* buf, int32_t bufLen, SAlterUserReq* pReq);
1561
void    tFreeSAlterUserReq(SAlterUserReq* pReq);
1562

1563
typedef struct {
1564
  char user[TSDB_USER_LEN];
1565
} SGetUserAuthReq;
1566

1567
int32_t tSerializeSGetUserAuthReq(void* buf, int32_t bufLen, SGetUserAuthReq* pReq);
1568
int32_t tDeserializeSGetUserAuthReq(void* buf, int32_t bufLen, SGetUserAuthReq* pReq);
1569

1570
typedef struct {
1571
  char      user[TSDB_USER_LEN];
1572
  int32_t   version;
1573
  int32_t   passVer;
1574
  int8_t    superAuth;
1575
  int8_t    sysInfo;
1576
  int8_t    enable;
1577
  int8_t    dropped;
1578
  SHashObj* createdDbs;
1579
  SHashObj* readDbs;
1580
  SHashObj* writeDbs;
1581
  SHashObj* readTbs;
1582
  SHashObj* writeTbs;
1583
  SHashObj* alterTbs;
1584
  SHashObj* readViews;
1585
  SHashObj* writeViews;
1586
  SHashObj* alterViews;
1587
  SHashObj* useDbs;
1588
  int64_t   whiteListVer;
1589
  int64_t   timeWhiteListVer;
1590
} SGetUserAuthRsp;
1591

1592
int32_t tSerializeSGetUserAuthRsp(void* buf, int32_t bufLen, SGetUserAuthRsp* pRsp);
1593
int32_t tDeserializeSGetUserAuthRsp(void* buf, int32_t bufLen, SGetUserAuthRsp* pRsp);
1594
void    tFreeSGetUserAuthRsp(SGetUserAuthRsp* pRsp);
1595

1596
int32_t tSerializeIpRange(SEncoder* encoder, SIpRange* pRange);
1597
int32_t tDeserializeIpRange(SDecoder* decoder, SIpRange* pRange, bool supportNeg);
1598
typedef struct {
1599
  int64_t ver;
1600
  char    user[TSDB_USER_LEN];
1601
  int32_t numOfRange;
1602
  union {
1603
    SIpV4Range* pIpRanges;
1604
    SIpRange*   pIpDualRanges;
1605
  };
1606
} SUpdateUserIpWhite;
1607

1608
typedef struct {
1609
  int64_t             ver;
1610
  int                 numOfUser;
1611
  SUpdateUserIpWhite* pUserIpWhite;
1612
} SUpdateIpWhite;
1613

1614
int32_t tSerializeSUpdateIpWhite(void* buf, int32_t bufLen, SUpdateIpWhite* pReq);
1615
int32_t tDeserializeSUpdateIpWhite(void* buf, int32_t bufLen, SUpdateIpWhite* pReq);
1616
void    tFreeSUpdateIpWhiteReq(SUpdateIpWhite* pReq);
1617
int32_t cloneSUpdateIpWhiteReq(SUpdateIpWhite* pReq, SUpdateIpWhite** pUpdate);
1618

1619
int32_t tSerializeSUpdateIpWhiteDual(void* buf, int32_t bufLen, SUpdateIpWhite* pReq);
1620
int32_t tDeserializeSUpdateIpWhiteDual(void* buf, int32_t bufLen, SUpdateIpWhite* pReq);
1621
void    tFreeSUpdateIpWhiteDualReq(SUpdateIpWhite* pReq);
1622

1623

1624
// SRetrieveWhiteListReq is used to retrieve both ip and datetime whitelist, but the
1625
// corresponding response struct is different.
1626
typedef struct {
1627
  int64_t ver;
1628
} SRetrieveWhiteListReq;
1629

1630
int32_t tSerializeRetrieveWhiteListReq(void* buf, int32_t bufLen, SRetrieveWhiteListReq* pReq);
1631
int32_t tDeserializeRetrieveWhiteListReq(void* buf, int32_t bufLen, SRetrieveWhiteListReq* pReq);
1632

1633

1634
// SGetUserWhiteListReq is used to get both ip and datetime whitelist, but the
1635
// corresponding response struct is different.
1636
typedef struct {
1637
  char user[TSDB_USER_LEN];
1638
} SGetUserWhiteListReq;
1639

1640
int32_t tSerializeSGetUserWhiteListReq(void* buf, int32_t bufLen, SGetUserWhiteListReq* pReq);
1641
int32_t tDeserializeSGetUserWhiteListReq(void* buf, int32_t bufLen, SGetUserWhiteListReq* pReq);
1642

1643
typedef struct {
1644
  char    user[TSDB_USER_LEN];
1645
  int32_t numWhiteLists;
1646
  union {
1647
    SIpV4Range* pWhiteLists;
1648
    SIpRange*   pWhiteListsDual;
1649
  };
1650
} SGetUserIpWhiteListRsp;
1651

1652
int32_t tIpStrToUint(const SIpAddr* addr, SIpRange* range);
1653
int32_t tIpUintToStr(const SIpRange* range, SIpAddr* addr);
1654
int32_t tIpRangeSetMask(SIpRange* range, int32_t mask);
1655
void    tIpRangeSetDefaultMask(SIpRange* range);
1656

1657
int32_t tSerializeSGetUserIpWhiteListRsp(void* buf, int32_t bufLen, SGetUserIpWhiteListRsp* pRsp);
1658
int32_t tDeserializeSGetUserIpWhiteListRsp(void* buf, int32_t bufLen, SGetUserIpWhiteListRsp* pRsp);
1659
void    tFreeSGetUserIpWhiteListRsp(SGetUserIpWhiteListRsp* pRsp);
1660

1661
int32_t tSerializeSGetUserIpWhiteListDualRsp(void* buf, int32_t bufLen, SGetUserIpWhiteListRsp* pRsp);
1662
int32_t tDeserializeSGetUserIpWhiteListDualRsp(void* buf, int32_t bufLen, SGetUserIpWhiteListRsp* pRsp);
1663
void    tFreeSGetUserIpWhiteListDualRsp(SGetUserIpWhiteListRsp* pRsp);
1664

1665
typedef struct {
1666
  int64_t ver;
1667
  char    user[TSDB_USER_LEN];
1668
  int32_t numWhiteLists;
1669
  SDateTimeWhiteListItem* pWhiteLists;
1670
} SUserDateTimeWhiteList;
1671

1672

1673
int32_t tSerializeSUserDateTimeWhiteList(void* buf, int32_t bufLen, SUserDateTimeWhiteList* pRsp);
1674
int32_t tDeserializeSUserDateTimeWhiteList(void* buf, int32_t bufLen, SUserDateTimeWhiteList* pRsp);
1675
void    tFreeSUserDateTimeWhiteList(SUserDateTimeWhiteList* pRsp);
1676

1677
typedef struct {
1678
  int64_t             ver;
1679
  int                 numOfUser;
1680
  SUserDateTimeWhiteList *pUsers;
1681
} SRetrieveDateTimeWhiteListRsp;
1682

1683
int32_t tSerializeSRetrieveDateTimeWhiteListRsp(void* buf, int32_t bufLen, SRetrieveDateTimeWhiteListRsp* pRsp);
1684
int32_t tDeserializeSRetrieveDateTimeWhiteListRsp(void* buf, int32_t bufLen, SRetrieveDateTimeWhiteListRsp* pRsp);
1685
void    tFreeSRetrieveDateTimeWhiteListRsp(SRetrieveDateTimeWhiteListRsp* pRsp);
1686

1687
/*
1688
 * for client side struct, only column id, type, bytes are necessary
1689
 * But for data in vnode side, we need all the following information.
1690
 */
1691
typedef struct {
1692
  union {
1693
    col_id_t colId;
1694
    int16_t  slotId;
1695
  };
1696

1697
  uint8_t precision;
1698
  uint8_t scale;
1699
  int32_t bytes;
1700
  int8_t  type;
1701
  uint8_t pk;
1702
  bool    noData;
1703
} SColumnInfo;
1704

1705
typedef struct STimeWindow {
1706
  TSKEY skey;
1707
  TSKEY ekey;
1708
} STimeWindow;
1709

1710
typedef struct SQueryHint {
1711
  bool batchScan;
1712
} SQueryHint;
1713

1714
typedef struct {
1715
  int32_t tsOffset;       // offset value in current msg body, NOTE: ts list is compressed
1716
  int32_t tsLen;          // total length of ts comp block
1717
  int32_t tsNumOfBlocks;  // ts comp block numbers
1718
  int32_t tsOrder;        // ts comp block order
1719
} STsBufInfo;
1720

1721
typedef struct {
1722
  void*       timezone;
1723
  char        intervalUnit;
1724
  char        slidingUnit;
1725
  char        offsetUnit;
1726
  int8_t      precision;
1727
  int64_t     interval;
1728
  int64_t     sliding;
1729
  int64_t     offset;
1730
  STimeWindow timeRange;
1731
} SInterval;
1732

1733
typedef struct STbVerInfo {
1734
  char    tbFName[TSDB_TABLE_FNAME_LEN];
1735
  int32_t sversion;
1736
  int32_t tversion;
1737
  int32_t rversion;  // virtual table's column ref's version
1738
} STbVerInfo;
1739

1740
typedef struct {
1741
  int32_t code;
1742
  int64_t affectedRows;
1743
  SArray* tbVerInfo;  // STbVerInfo
1744
} SQueryTableRsp;
1745

1746
int32_t tSerializeSQueryTableRsp(void* buf, int32_t bufLen, SQueryTableRsp* pRsp);
1747

1748
int32_t tDeserializeSQueryTableRsp(void* buf, int32_t bufLen, SQueryTableRsp* pRsp);
1749

1750
typedef struct {
1751
  SMsgHead header;
1752
  char     dbFName[TSDB_DB_FNAME_LEN];
1753
  char     tbName[TSDB_TABLE_NAME_LEN];
1754
} STableCfgReq;
1755

1756
typedef struct {
1757
  char        tbName[TSDB_TABLE_NAME_LEN];
1758
  char        stbName[TSDB_TABLE_NAME_LEN];
1759
  char        dbFName[TSDB_DB_FNAME_LEN];
1760
  int32_t     numOfTags;
1761
  int32_t     numOfColumns;
1762
  int8_t      tableType;
1763
  int64_t     delay1;
1764
  int64_t     delay2;
1765
  int64_t     watermark1;
1766
  int64_t     watermark2;
1767
  int32_t     ttl;
1768
  int32_t     keep;
1769
  SArray*     pFuncs;
1770
  int32_t     commentLen;
1771
  char*       pComment;
1772
  SSchema*    pSchemas;
1773
  int32_t     tagsLen;
1774
  char*       pTags;
1775
  SSchemaExt* pSchemaExt;
1776
  int8_t      virtualStb;
1777
  SColRef*    pColRefs;
1778
} STableCfg;
1779

1780
typedef STableCfg STableCfgRsp;
1781

1782
int32_t tSerializeSTableCfgReq(void* buf, int32_t bufLen, STableCfgReq* pReq);
1783
int32_t tDeserializeSTableCfgReq(void* buf, int32_t bufLen, STableCfgReq* pReq);
1784

1785
int32_t tSerializeSTableCfgRsp(void* buf, int32_t bufLen, STableCfgRsp* pRsp);
1786
int32_t tDeserializeSTableCfgRsp(void* buf, int32_t bufLen, STableCfgRsp* pRsp);
1787
void    tFreeSTableCfgRsp(STableCfgRsp* pRsp);
1788

1789
typedef struct {
1790
  SMsgHead header;
1791
  tb_uid_t suid;
1792
} SVSubTablesReq;
1793

1794
int32_t tSerializeSVSubTablesReq(void* buf, int32_t bufLen, SVSubTablesReq* pReq);
1795
int32_t tDeserializeSVSubTablesReq(void* buf, int32_t bufLen, SVSubTablesReq* pReq);
1796

1797
typedef struct {
1798
  int32_t vgId;
1799
  SArray* pTables;  // SArray<SVCTableRefCols*>
1800
} SVSubTablesRsp;
1801

1802
int32_t tSerializeSVSubTablesRsp(void* buf, int32_t bufLen, SVSubTablesRsp* pRsp);
1803
int32_t tDeserializeSVSubTablesRsp(void* buf, int32_t bufLen, SVSubTablesRsp* pRsp);
1804
void    tDestroySVSubTablesRsp(void* rsp);
1805

1806
typedef struct {
1807
  SMsgHead header;
1808
  tb_uid_t suid;
1809
} SVStbRefDbsReq;
1810

1811
int32_t tSerializeSVStbRefDbsReq(void* buf, int32_t bufLen, SVStbRefDbsReq* pReq);
1812
int32_t tDeserializeSVStbRefDbsReq(void* buf, int32_t bufLen, SVStbRefDbsReq* pReq);
1813

1814
typedef struct {
1815
  int32_t vgId;
1816
  SArray* pDbs;  // SArray<char* (db name)>
1817
} SVStbRefDbsRsp;
1818

1819
int32_t tSerializeSVStbRefDbsRsp(void* buf, int32_t bufLen, SVStbRefDbsRsp* pRsp);
1820
int32_t tDeserializeSVStbRefDbsRsp(void* buf, int32_t bufLen, SVStbRefDbsRsp* pRsp);
1821
void    tDestroySVStbRefDbsRsp(void* rsp);
1822

1823
typedef struct {
1824
  char    db[TSDB_DB_FNAME_LEN];
1825
  int32_t numOfVgroups;
1826
  int32_t numOfStables;  // single_stable
1827
  int32_t buffer;        // MB
1828
  int32_t pageSize;
1829
  int32_t pages;
1830
  int32_t cacheLastSize;
1831
  int32_t daysPerFile;
1832
  int32_t daysToKeep0;
1833
  int32_t daysToKeep1;
1834
  int32_t daysToKeep2;
1835
  int32_t keepTimeOffset;
1836
  int32_t minRows;
1837
  int32_t maxRows;
1838
  int32_t walFsyncPeriod;
1839
  int8_t  walLevel;
1840
  int8_t  precision;  // time resolution
1841
  int8_t  compression;
1842
  int8_t  replications;
1843
  int8_t  strict;
1844
  int8_t  cacheLast;
1845
  int8_t  schemaless;
1846
  int8_t  ignoreExist;
1847
  int32_t numOfRetensions;
1848
  SArray* pRetensions;  // SRetention
1849
  int32_t walRetentionPeriod;
1850
  int64_t walRetentionSize;
1851
  int32_t walRollPeriod;
1852
  int64_t walSegmentSize;
1853
  int32_t sstTrigger;
1854
  int16_t hashPrefix;
1855
  int16_t hashSuffix;
1856
  int32_t ssChunkSize;
1857
  int32_t ssKeepLocal;
1858
  int8_t  ssCompact;
1859
  int32_t tsdbPageSize;
1860
  int32_t sqlLen;
1861
  char*   sql;
1862
  int8_t  withArbitrator;
1863
  int8_t  encryptAlgorithm;
1864
  char    dnodeListStr[TSDB_DNODE_LIST_LEN];
1865
  // 1. add auto-compact parameters
1866
  int32_t compactInterval;    // minutes
1867
  int32_t compactStartTime;   // minutes
1868
  int32_t compactEndTime;     // minutes
1869
  int8_t  compactTimeOffset;  // hour
1870
  char    encryptAlgrName[TSDB_ENCRYPT_ALGR_NAME_LEN];
1871
} SCreateDbReq;
1872

1873
int32_t tSerializeSCreateDbReq(void* buf, int32_t bufLen, SCreateDbReq* pReq);
1874
int32_t tDeserializeSCreateDbReq(void* buf, int32_t bufLen, SCreateDbReq* pReq);
1875
void    tFreeSCreateDbReq(SCreateDbReq* pReq);
1876

1877
typedef struct {
1878
  char    db[TSDB_DB_FNAME_LEN];
1879
  int32_t buffer;
1880
  int32_t pageSize;
1881
  int32_t pages;
1882
  int32_t cacheLastSize;
1883
  int32_t daysPerFile;
1884
  int32_t daysToKeep0;
1885
  int32_t daysToKeep1;
1886
  int32_t daysToKeep2;
1887
  int32_t keepTimeOffset;
1888
  int32_t walFsyncPeriod;
1889
  int8_t  walLevel;
1890
  int8_t  strict;
1891
  int8_t  cacheLast;
1892
  int8_t  replications;
1893
  int32_t sstTrigger;
1894
  int32_t minRows;
1895
  int32_t walRetentionPeriod;
1896
  int32_t walRetentionSize;
1897
  int32_t ssKeepLocal;
1898
  int8_t  ssCompact;
1899
  int32_t sqlLen;
1900
  char*   sql;
1901
  int8_t  withArbitrator;
1902
  // 1. add auto-compact parameters
1903
  int32_t compactInterval;
1904
  int32_t compactStartTime;
1905
  int32_t compactEndTime;
1906
  int8_t  compactTimeOffset;
1907
  char    encryptAlgrName[TSDB_ENCRYPT_ALGR_NAME_LEN];
1908
} SAlterDbReq;
1909

1910
int32_t tSerializeSAlterDbReq(void* buf, int32_t bufLen, SAlterDbReq* pReq);
1911
int32_t tDeserializeSAlterDbReq(void* buf, int32_t bufLen, SAlterDbReq* pReq);
1912
void    tFreeSAlterDbReq(SAlterDbReq* pReq);
1913

1914
typedef struct {
1915
  char    db[TSDB_DB_FNAME_LEN];
1916
  int8_t  ignoreNotExists;
1917
  int8_t  force;
1918
  int32_t sqlLen;
1919
  char*   sql;
1920
} SDropDbReq;
1921

1922
int32_t tSerializeSDropDbReq(void* buf, int32_t bufLen, SDropDbReq* pReq);
1923
int32_t tDeserializeSDropDbReq(void* buf, int32_t bufLen, SDropDbReq* pReq);
1924
void    tFreeSDropDbReq(SDropDbReq* pReq);
1925

1926
typedef struct {
1927
  char    db[TSDB_DB_FNAME_LEN];
1928
  int64_t uid;
1929
} SDropDbRsp;
1930

1931
int32_t tSerializeSDropDbRsp(void* buf, int32_t bufLen, SDropDbRsp* pRsp);
1932
int32_t tDeserializeSDropDbRsp(void* buf, int32_t bufLen, SDropDbRsp* pRsp);
1933

1934
typedef struct {
1935
  char    name[TSDB_MOUNT_NAME_LEN];
1936
  int64_t uid;
1937
} SDropMountRsp;
1938

1939
int32_t tSerializeSDropMountRsp(void* buf, int32_t bufLen, SDropMountRsp* pRsp);
1940
int32_t tDeserializeSDropMountRsp(void* buf, int32_t bufLen, SDropMountRsp* pRsp);
1941

1942
typedef struct {
1943
  char    db[TSDB_DB_FNAME_LEN];
1944
  int64_t dbId;
1945
  int32_t vgVersion;
1946
  int32_t numOfTable;  // unit is TSDB_TABLE_NUM_UNIT
1947
  int64_t stateTs;     // ms
1948
} SUseDbReq;
1949

1950
int32_t tSerializeSUseDbReq(void* buf, int32_t bufLen, SUseDbReq* pReq);
1951
int32_t tDeserializeSUseDbReq(void* buf, int32_t bufLen, SUseDbReq* pReq);
1952

1953
typedef struct {
1954
  char    db[TSDB_DB_FNAME_LEN];
1955
  int64_t uid;
1956
  int32_t vgVersion;
1957
  int32_t vgNum;
1958
  int16_t hashPrefix;
1959
  int16_t hashSuffix;
1960
  int8_t  hashMethod;
1961
  union {
1962
    uint8_t flags;
1963
    struct {
1964
      uint8_t isMount : 1;  // TS-5868
1965
      uint8_t padding : 7;
1966
    };
1967
  };
1968
  SArray* pVgroupInfos;  // Array of SVgroupInfo
1969
  int32_t errCode;
1970
  int64_t stateTs;  // ms
1971
} SUseDbRsp;
1972

1973
int32_t tSerializeSUseDbRsp(void* buf, int32_t bufLen, const SUseDbRsp* pRsp);
1974
int32_t tDeserializeSUseDbRsp(void* buf, int32_t bufLen, SUseDbRsp* pRsp);
1975
int32_t tSerializeSUseDbRspImp(SEncoder* pEncoder, const SUseDbRsp* pRsp);
1976
int32_t tDeserializeSUseDbRspImp(SDecoder* pDecoder, SUseDbRsp* pRsp);
1977
void    tFreeSUsedbRsp(SUseDbRsp* pRsp);
1978

1979
typedef struct {
1980
  char db[TSDB_DB_FNAME_LEN];
1981
} SDbCfgReq;
1982

1983
int32_t tSerializeSDbCfgReq(void* buf, int32_t bufLen, SDbCfgReq* pReq);
1984
int32_t tDeserializeSDbCfgReq(void* buf, int32_t bufLen, SDbCfgReq* pReq);
1985

1986
typedef struct {
1987
  char db[TSDB_DB_FNAME_LEN];
1988
} SSsMigrateDbReq;
1989

1990
int32_t tSerializeSSsMigrateDbReq(void* buf, int32_t bufLen, SSsMigrateDbReq* pReq);
1991
int32_t tDeserializeSSsMigrateDbReq(void* buf, int32_t bufLen, SSsMigrateDbReq* pReq);
1992

1993
typedef struct {
1994
  int32_t ssMigrateId;
1995
  bool    bAccepted;
1996
} SSsMigrateDbRsp;
1997

1998
int32_t tSerializeSSsMigrateDbRsp(void* buf, int32_t bufLen, SSsMigrateDbRsp* pRsp);
1999
int32_t tDeserializeSSsMigrateDbRsp(void* buf, int32_t bufLen, SSsMigrateDbRsp* pRsp);
2000

2001

2002
// Request and response for TDMT_VND_LIST_SSMIGRATE_FILESETS
2003
typedef struct {
2004
  int32_t ssMigrateId;
2005
} SListSsMigrateFileSetsReq;
2006

2007
int32_t tSerializeSListSsMigrateFileSetsReq(void* buf, int32_t bufLen, SListSsMigrateFileSetsReq* pReq);
2008
int32_t tDeserializeSListSsMigrateFileSetsReq(void* buf, int32_t bufLen, SListSsMigrateFileSetsReq* pReq);
2009

2010
typedef struct {
2011
  int32_t ssMigrateId;
2012
  int32_t vgId;   // vgroup id
2013
  SArray* pFileSets; // SArray<int32_t>
2014
} SListSsMigrateFileSetsRsp;
2015

2016
int32_t tSerializeSListSsMigrateFileSetsRsp(void* buf, int32_t bufLen, SListSsMigrateFileSetsRsp* pRsp);
2017
int32_t tDeserializeSListSsMigrateFileSetsRsp(void* buf, int32_t bufLen, SListSsMigrateFileSetsRsp* pRsp);
2018
void tFreeSListSsMigrateFileSetsRsp(SListSsMigrateFileSetsRsp* pRsp);
2019

2020

2021
// Request and response for TDMT_VND_SSMIGRATE_FILESET
2022
typedef struct {
2023
  int32_t ssMigrateId;
2024
  int32_t nodeId; // node id of the leader vnode, filled by vnode
2025
  int32_t fid;
2026
  int64_t startTimeSec;
2027
} SSsMigrateFileSetReq;
2028

2029
int32_t tSerializeSSsMigrateFileSetReq(void* buf, int32_t bufLen, SSsMigrateFileSetReq* pReq);
2030
int32_t tDeserializeSSsMigrateFileSetReq(void* buf, int32_t bufLen, SSsMigrateFileSetReq* pReq);
2031

2032
typedef struct {
2033
  int32_t ssMigrateId;
2034
  int32_t nodeId; // node id of the leader vnode
2035
  int32_t vgId;
2036
  int32_t fid;
2037
} SSsMigrateFileSetRsp;
2038

2039
int32_t tSerializeSSsMigrateFileSetRsp(void* buf, int32_t bufLen, SSsMigrateFileSetRsp* pRsp);
2040
int32_t tDeserializeSSsMigrateFileSetRsp(void* buf, int32_t bufLen, SSsMigrateFileSetRsp* pRsp);
2041

2042

2043
#define SSMIGRATE_FILESET_STATE_IN_PROGRESS  0
2044
#define SSMIGRATE_FILESET_STATE_SUCCEEDED    1
2045
#define SSMIGRATE_FILESET_STATE_COMPACT      2
2046
#define SSMIGRATE_FILESET_STATE_SKIPPED      3
2047
#define SSMIGRATE_FILESET_STATE_FAILED       4
2048

2049
// Request and response for TDMT_VND_QUERY_SSMIGRATE_PROGRESS and TDMT_VND_FOLLOWER_SSMIGRATE
2050
// Note this struct is reused as both request and response in TDMT_VND_QUERY_SSMIGRATE_PROGRESS,
2051
// while as a request, the 'state' field is not used.
2052
// This struct is also used in TDMT_VND_FOLLOWER_SSMIGRATE as request, which don't need a response.
2053
typedef struct {
2054
  int32_t ssMigrateId; // ss migrate id
2055
  int32_t nodeId;      // node id of the leader vnode
2056
  int32_t vgId;        // vgroup id
2057
  int32_t fid;         // file set id
2058
  int32_t state;       // SSMIGRATE_FILESET_STATE_*
2059
} SSsMigrateProgress;
2060

2061
int tSerializeSSsMigrateProgress(void* buf, int32_t bufLen, SSsMigrateProgress* pProgress);
2062
int tDeserializeSSsMigrateProgress(void* buf, int32_t bufLen, SSsMigrateProgress* pProgress);
2063

2064

2065
// Request for TDMT_MND_KILL_SSMIGRATE
2066
typedef struct {
2067
  int32_t ssMigrateId;
2068
  int32_t sqlLen;
2069
  char*   sql;
2070
} SKillSsMigrateReq;
2071

2072
int32_t tSerializeSKillSsMigrateReq(void* buf, int32_t bufLen, SKillSsMigrateReq* pReq);
2073
int32_t tDeserializeSKillSsMigrateReq(void* buf, int32_t bufLen, SKillSsMigrateReq* pReq);
2074
void    tFreeSKillSsMigrateReq(SKillSsMigrateReq* pReq);
2075

2076
// Request for TDMT_VND_KILL_SSMIGRATE
2077
typedef struct {
2078
  int32_t ssMigrateId;
2079
} SVnodeKillSsMigrateReq;
2080

2081
int32_t tSerializeSVnodeKillSsMigrateReq(void* buf, int32_t bufLen, SVnodeKillSsMigrateReq* pReq);
2082
int32_t tDeserializeSVnodeKillSsMigrateReq(void* buf, int32_t bufLen, SVnodeKillSsMigrateReq* pReq);
2083

2084

2085
typedef struct {
2086
  int32_t vgId;
2087
  int64_t keepVersion;
2088
} SMndSetVgroupKeepVersionReq;
2089

2090
int32_t tSerializeSMndSetVgroupKeepVersionReq(void* buf, int32_t bufLen, SMndSetVgroupKeepVersionReq* pReq);
2091
int32_t tDeserializeSMndSetVgroupKeepVersionReq(void* buf, int32_t bufLen, SMndSetVgroupKeepVersionReq* pReq);
2092

2093
typedef struct {
2094
  int32_t timestampSec;
2095
  int32_t ttlDropMaxCount;
2096
  int32_t nUids;
2097
  SArray* pTbUids;
2098
} SVDropTtlTableReq;
2099

2100
int32_t tSerializeSVDropTtlTableReq(void* buf, int32_t bufLen, SVDropTtlTableReq* pReq);
2101
int32_t tDeserializeSVDropTtlTableReq(void* buf, int32_t bufLen, SVDropTtlTableReq* pReq);
2102

2103
typedef struct {
2104
  char    db[TSDB_DB_FNAME_LEN];
2105
  int64_t dbId;
2106
  int32_t cfgVersion;
2107
  int32_t numOfVgroups;
2108
  int32_t numOfStables;
2109
  int32_t buffer;
2110
  int32_t cacheSize;
2111
  int32_t pageSize;
2112
  int32_t pages;
2113
  int32_t daysPerFile;
2114
  int32_t daysToKeep0;
2115
  int32_t daysToKeep1;
2116
  int32_t daysToKeep2;
2117
  int32_t keepTimeOffset;
2118
  int32_t minRows;
2119
  int32_t maxRows;
2120
  int32_t walFsyncPeriod;
2121
  int16_t hashPrefix;
2122
  int16_t hashSuffix;
2123
  int8_t  hashMethod;
2124
  int8_t  walLevel;
2125
  int8_t  precision;
2126
  int8_t  compression;
2127
  int8_t  replications;
2128
  int8_t  strict;
2129
  int8_t  cacheLast;
2130
  int8_t  encryptAlgr;
2131
  char    algorithmsId[TSDB_ENCRYPT_ALGR_NAME_LEN];
2132
  int32_t ssChunkSize;
2133
  int32_t ssKeepLocal;
2134
  int8_t  ssCompact;
2135
  union {
2136
    uint8_t flags;
2137
    struct {
2138
      uint8_t isMount : 1;  // TS-5868
2139
      uint8_t padding : 7;
2140
    };
2141
  };
2142
  int8_t  compactTimeOffset;
2143
  int32_t compactInterval;
2144
  int32_t compactStartTime;
2145
  int32_t compactEndTime;
2146
  int32_t tsdbPageSize;
2147
  int32_t walRetentionPeriod;
2148
  int32_t walRollPeriod;
2149
  int64_t walRetentionSize;
2150
  int64_t walSegmentSize;
2151
  int32_t numOfRetensions;
2152
  SArray* pRetensions;
2153
  int8_t  schemaless;
2154
  int16_t sstTrigger;
2155
  int8_t  withArbitrator;
2156
} SDbCfgRsp;
2157

2158
typedef SDbCfgRsp SDbCfgInfo;
2159

2160
int32_t tSerializeSDbCfgRspImpl(SEncoder* encoder, const SDbCfgRsp* pRsp);
2161
int32_t tSerializeSDbCfgRsp(void* buf, int32_t bufLen, const SDbCfgRsp* pRsp);
2162
int32_t tDeserializeSDbCfgRsp(void* buf, int32_t bufLen, SDbCfgRsp* pRsp);
2163
int32_t tDeserializeSDbCfgRspImpl(SDecoder* decoder, SDbCfgRsp* pRsp);
2164
void    tFreeSDbCfgRsp(SDbCfgRsp* pRsp);
2165

2166
typedef struct {
2167
  int32_t rowNum;
2168
} SQnodeListReq;
2169

2170
int32_t tSerializeSQnodeListReq(void* buf, int32_t bufLen, SQnodeListReq* pReq);
2171
int32_t tDeserializeSQnodeListReq(void* buf, int32_t bufLen, SQnodeListReq* pReq);
2172

2173
typedef struct {
2174
  int32_t rowNum;
2175
} SDnodeListReq;
2176

2177
int32_t tSerializeSDnodeListReq(void* buf, int32_t bufLen, SDnodeListReq* pReq);
2178

2179
typedef struct {
2180
  int32_t useless;  // useless
2181
} SServerVerReq;
2182

2183
int32_t tSerializeSServerVerReq(void* buf, int32_t bufLen, SServerVerReq* pReq);
2184
// int32_t tDeserializeSServerVerReq(void* buf, int32_t bufLen, SServerVerReq* pReq);
2185

2186
typedef struct {
2187
  char ver[TSDB_VERSION_LEN];
2188
} SServerVerRsp;
2189

2190
int32_t tSerializeSServerVerRsp(void* buf, int32_t bufLen, SServerVerRsp* pRsp);
2191
int32_t tDeserializeSServerVerRsp(void* buf, int32_t bufLen, SServerVerRsp* pRsp);
2192

2193
typedef struct SQueryNodeAddr {
2194
  int32_t nodeId;  // vgId or qnodeId
2195
  SEpSet  epSet;
2196
} SQueryNodeAddr;
2197

2198
typedef struct {
2199
  SQueryNodeAddr addr;
2200
  uint64_t       load;
2201
} SQueryNodeLoad;
2202

2203
typedef struct {
2204
  SArray* qnodeList;  // SArray<SQueryNodeLoad>
2205
} SQnodeListRsp;
2206

2207
int32_t tSerializeSQnodeListRsp(void* buf, int32_t bufLen, SQnodeListRsp* pRsp);
2208
int32_t tDeserializeSQnodeListRsp(void* buf, int32_t bufLen, SQnodeListRsp* pRsp);
2209
void    tFreeSQnodeListRsp(SQnodeListRsp* pRsp);
2210

2211
typedef struct SDNodeAddr {
2212
  int32_t nodeId;  // dnodeId
2213
  SEpSet  epSet;
2214
} SDNodeAddr;
2215

2216
typedef struct {
2217
  SArray* dnodeList;  // SArray<SDNodeAddr>
2218
} SDnodeListRsp;
2219

2220
int32_t tSerializeSDnodeListRsp(void* buf, int32_t bufLen, SDnodeListRsp* pRsp);
2221
int32_t tDeserializeSDnodeListRsp(void* buf, int32_t bufLen, SDnodeListRsp* pRsp);
2222
void    tFreeSDnodeListRsp(SDnodeListRsp* pRsp);
2223

2224
typedef struct {
2225
  SArray* pTsmas;  // SArray<STableTSMAInfo*>
2226
} STableTSMAInfoRsp;
2227

2228
typedef struct {
2229
  SUseDbRsp*         useDbRsp;
2230
  SDbCfgRsp*         cfgRsp;
2231
  STableTSMAInfoRsp* pTsmaRsp;
2232
  int32_t            dbTsmaVersion;
2233
  char               db[TSDB_DB_FNAME_LEN];
2234
  int64_t            dbId;
2235
} SDbHbRsp;
2236

2237
typedef struct {
2238
  SArray* pArray;  // Array of SDbHbRsp
2239
} SDbHbBatchRsp;
2240

2241
int32_t tSerializeSDbHbBatchRsp(void* buf, int32_t bufLen, SDbHbBatchRsp* pRsp);
2242
int32_t tDeserializeSDbHbBatchRsp(void* buf, int32_t bufLen, SDbHbBatchRsp* pRsp);
2243
void    tFreeSDbHbBatchRsp(SDbHbBatchRsp* pRsp);
2244

2245
typedef struct {
2246
  SArray* pArray;  // Array of SGetUserAuthRsp
2247
} SUserAuthBatchRsp;
2248

2249
int32_t tSerializeSUserAuthBatchRsp(void* buf, int32_t bufLen, SUserAuthBatchRsp* pRsp);
2250
int32_t tDeserializeSUserAuthBatchRsp(void* buf, int32_t bufLen, SUserAuthBatchRsp* pRsp);
2251
void    tFreeSUserAuthBatchRsp(SUserAuthBatchRsp* pRsp);
2252

2253
typedef struct {
2254
  char        db[TSDB_DB_FNAME_LEN];
2255
  STimeWindow timeRange;
2256
  int32_t     sqlLen;
2257
  char*       sql;
2258
  SArray*     vgroupIds;
2259
  int32_t     compactId;
2260
  int8_t      metaOnly;
2261
  int8_t      force;
2262
} SCompactDbReq;
2263

2264
int32_t tSerializeSCompactDbReq(void* buf, int32_t bufLen, SCompactDbReq* pReq);
2265
int32_t tDeserializeSCompactDbReq(void* buf, int32_t bufLen, SCompactDbReq* pReq);
2266
void    tFreeSCompactDbReq(SCompactDbReq* pReq);
2267

2268
typedef struct {
2269
  union {
2270
    int32_t compactId;
2271
    int32_t id;
2272
  };
2273
  int8_t bAccepted;
2274
} SCompactDbRsp;
2275

2276
int32_t tSerializeSCompactDbRsp(void* buf, int32_t bufLen, SCompactDbRsp* pRsp);
2277
int32_t tDeserializeSCompactDbRsp(void* buf, int32_t bufLen, SCompactDbRsp* pRsp);
2278

2279
typedef struct {
2280
  union {
2281
    int32_t compactId;
2282
    int32_t id;
2283
  };
2284
  int32_t sqlLen;
2285
  char*   sql;
2286
} SKillCompactReq;
2287

2288
int32_t tSerializeSKillCompactReq(void* buf, int32_t bufLen, SKillCompactReq* pReq);
2289
int32_t tDeserializeSKillCompactReq(void* buf, int32_t bufLen, SKillCompactReq* pReq);
2290
void    tFreeSKillCompactReq(SKillCompactReq* pReq);
2291

2292
typedef SCompactDbRsp   STrimDbRsp;         // reuse structs
2293
typedef SKillCompactReq SKillRetentionReq;  // reuse structs
2294

2295
typedef struct {
2296
  char    name[TSDB_FUNC_NAME_LEN];
2297
  int8_t  igExists;
2298
  int8_t  funcType;
2299
  int8_t  scriptType;
2300
  int8_t  outputType;
2301
  int32_t outputLen;
2302
  int32_t bufSize;
2303
  int32_t codeLen;
2304
  int64_t signature;
2305
  char*   pComment;
2306
  char*   pCode;
2307
  int8_t  orReplace;
2308
} SCreateFuncReq;
2309

2310
int32_t tSerializeSCreateFuncReq(void* buf, int32_t bufLen, SCreateFuncReq* pReq);
2311
int32_t tDeserializeSCreateFuncReq(void* buf, int32_t bufLen, SCreateFuncReq* pReq);
2312
void    tFreeSCreateFuncReq(SCreateFuncReq* pReq);
2313

2314
typedef struct {
2315
  char   name[TSDB_FUNC_NAME_LEN];
2316
  int8_t igNotExists;
2317
} SDropFuncReq;
2318

2319
int32_t tSerializeSDropFuncReq(void* buf, int32_t bufLen, SDropFuncReq* pReq);
2320
int32_t tDeserializeSDropFuncReq(void* buf, int32_t bufLen, SDropFuncReq* pReq);
2321

2322
typedef struct {
2323
  int32_t numOfFuncs;
2324
  bool    ignoreCodeComment;
2325
  SArray* pFuncNames;
2326
} SRetrieveFuncReq;
2327

2328
int32_t tSerializeSRetrieveFuncReq(void* buf, int32_t bufLen, SRetrieveFuncReq* pReq);
2329
int32_t tDeserializeSRetrieveFuncReq(void* buf, int32_t bufLen, SRetrieveFuncReq* pReq);
2330
void    tFreeSRetrieveFuncReq(SRetrieveFuncReq* pReq);
2331

2332
typedef struct {
2333
  char    name[TSDB_FUNC_NAME_LEN];
2334
  int8_t  funcType;
2335
  int8_t  scriptType;
2336
  int8_t  outputType;
2337
  int32_t outputLen;
2338
  int32_t bufSize;
2339
  int64_t signature;
2340
  int32_t commentSize;
2341
  int32_t codeSize;
2342
  char*   pComment;
2343
  char*   pCode;
2344
} SFuncInfo;
2345

2346
typedef struct {
2347
  int32_t funcVersion;
2348
  int64_t funcCreatedTime;
2349
} SFuncExtraInfo;
2350

2351
typedef struct {
2352
  int32_t numOfFuncs;
2353
  SArray* pFuncInfos;
2354
  SArray* pFuncExtraInfos;
2355
} SRetrieveFuncRsp;
2356

2357
int32_t tSerializeSRetrieveFuncRsp(void* buf, int32_t bufLen, SRetrieveFuncRsp* pRsp);
2358
int32_t tDeserializeSRetrieveFuncRsp(void* buf, int32_t bufLen, SRetrieveFuncRsp* pRsp);
2359
void    tFreeSFuncInfo(SFuncInfo* pInfo);
2360
void    tFreeSRetrieveFuncRsp(SRetrieveFuncRsp* pRsp);
2361

2362
typedef struct {
2363
  int32_t       statusInterval;
2364
  int64_t       checkTime;                  // 1970-01-01 00:00:00.000
2365
  char          timezone[TD_TIMEZONE_LEN];  // tsTimezone
2366
  char          locale[TD_LOCALE_LEN];      // tsLocale
2367
  char          charset[TD_LOCALE_LEN];     // tsCharset
2368
  int8_t        ttlChangeOnWrite;
2369
  int8_t        enableWhiteList;
2370
  int8_t        encryptionKeyStat;
2371
  uint32_t      encryptionKeyChksum;
2372
  SMonitorParas monitorParas;
2373
  int32_t       statusIntervalMs;
2374
} SClusterCfg;
2375

2376
typedef struct {
2377
  int32_t openVnodes;
2378
  int32_t dropVnodes;
2379
  int32_t totalVnodes;
2380
  int32_t masterNum;
2381
  int64_t numOfSelectReqs;
2382
  int64_t numOfInsertReqs;
2383
  int64_t numOfInsertSuccessReqs;
2384
  int64_t numOfBatchInsertReqs;
2385
  int64_t numOfBatchInsertSuccessReqs;
2386
  int64_t errors;
2387
} SVnodesStat;
2388

2389
typedef struct {
2390
  int32_t vgId;
2391
  int8_t  syncState;
2392
  int8_t  syncRestore;
2393
  int64_t syncTerm;
2394
  int64_t roleTimeMs;
2395
  int64_t startTimeMs;
2396
  int8_t  syncCanRead;
2397
  int64_t cacheUsage;
2398
  int64_t numOfTables;
2399
  int64_t numOfTimeSeries;
2400
  int64_t totalStorage;
2401
  int64_t compStorage;
2402
  int64_t pointsWritten;
2403
  int64_t numOfSelectReqs;
2404
  int64_t numOfInsertReqs;
2405
  int64_t numOfInsertSuccessReqs;
2406
  int64_t numOfBatchInsertReqs;
2407
  int64_t numOfBatchInsertSuccessReqs;
2408
  int32_t numOfCachedTables;
2409
  int32_t learnerProgress;  // use one reservered
2410
  int64_t syncAppliedIndex;
2411
  int64_t syncCommitIndex;
2412
  int64_t bufferSegmentUsed;
2413
  int64_t bufferSegmentSize;
2414
} SVnodeLoad;
2415

2416
typedef struct {
2417
  int64_t total_requests;
2418
  int64_t total_rows;
2419
  int64_t total_bytes;
2420
  double  write_size;
2421
  double  cache_hit_ratio;
2422
  int64_t rpc_queue_wait;
2423
  int64_t preprocess_time;
2424

2425
  int64_t memory_table_size;
2426
  int64_t commit_count;
2427
  int64_t merge_count;
2428
  double  commit_time;
2429
  double  merge_time;
2430
  int64_t block_commit_time;
2431
  int64_t memtable_wait_time;
2432
} SVnodeMetrics;
2433

2434
typedef struct {
2435
  int32_t     vgId;
2436
  int64_t     numOfTables;
2437
  int64_t     memSize;
2438
  int64_t     l1Size;
2439
  int64_t     l2Size;
2440
  int64_t     l3Size;
2441
  int64_t     cacheSize;
2442
  int64_t     walSize;
2443
  int64_t     metaSize;
2444
  int64_t     rawDataSize;
2445
  int64_t     ssSize;
2446
  const char* dbname;
2447
  int8_t      estimateRawData;
2448
} SDbSizeStatisInfo;
2449

2450
typedef struct {
2451
  int32_t vgId;
2452
  int64_t nTimeSeries;
2453
} SVnodeLoadLite;
2454

2455
typedef struct {
2456
  int8_t  syncState;
2457
  int64_t syncTerm;
2458
  int8_t  syncRestore;
2459
  int64_t roleTimeMs;
2460
} SMnodeLoad;
2461

2462
typedef struct {
2463
  int32_t dnodeId;
2464
  int64_t numOfProcessedQuery;
2465
  int64_t numOfProcessedCQuery;
2466
  int64_t numOfProcessedFetch;
2467
  int64_t numOfProcessedDrop;
2468
  int64_t numOfProcessedNotify;
2469
  int64_t numOfProcessedHb;
2470
  int64_t numOfProcessedDelete;
2471
  int64_t cacheDataSize;
2472
  int64_t numOfQueryInQueue;
2473
  int64_t numOfFetchInQueue;
2474
  int64_t timeInQueryQueue;
2475
  int64_t timeInFetchQueue;
2476
} SQnodeLoad;
2477

2478
typedef struct {
2479
  int32_t     sver;      // software version
2480
  int64_t     dnodeVer;  // dnode table version in sdb
2481
  int32_t     dnodeId;
2482
  int64_t     clusterId;
2483
  int64_t     rebootTime;
2484
  int64_t     updateTime;
2485
  float       numOfCores;
2486
  int32_t     numOfSupportVnodes;
2487
  int32_t     numOfDiskCfg;
2488
  int64_t     memTotal;
2489
  int64_t     memAvail;
2490
  char        dnodeEp[TSDB_EP_LEN];
2491
  char        machineId[TSDB_MACHINE_ID_LEN + 1];
2492
  SMnodeLoad  mload;
2493
  SQnodeLoad  qload;
2494
  SClusterCfg clusterCfg;
2495
  SArray*     pVloads;  // array of SVnodeLoad
2496
  int32_t     statusSeq;
2497
  int64_t     ipWhiteVer;
2498
  int64_t     timeWhiteVer;
2499
  int64_t     analVer;
2500
  int64_t     timestamp;
2501
} SStatusReq;
2502

2503
int32_t tSerializeSStatusReq(void* buf, int32_t bufLen, SStatusReq* pReq);
2504
int32_t tDeserializeSStatusReq(void* buf, int32_t bufLen, SStatusReq* pReq);
2505
void    tFreeSStatusReq(SStatusReq* pReq);
2506

2507
typedef struct {
2508
  int32_t forceReadConfig;
2509
  int32_t cver;
2510
  SArray* array;
2511
} SConfigReq;
2512

2513
int32_t tSerializeSConfigReq(void* buf, int32_t bufLen, SConfigReq* pReq);
2514
int32_t tDeserializeSConfigReq(void* buf, int32_t bufLen, SConfigReq* pReq);
2515
void    tFreeSConfigReq(SConfigReq* pReq);
2516

2517
typedef struct {
2518
  int32_t dnodeId;
2519
  char    machineId[TSDB_MACHINE_ID_LEN + 1];
2520
} SDnodeInfoReq;
2521

2522
int32_t tSerializeSDnodeInfoReq(void* buf, int32_t bufLen, SDnodeInfoReq* pReq);
2523
int32_t tDeserializeSDnodeInfoReq(void* buf, int32_t bufLen, SDnodeInfoReq* pReq);
2524

2525
typedef enum {
2526
  MONITOR_TYPE_COUNTER = 0,
2527
  MONITOR_TYPE_SLOW_LOG = 1,
2528
} MONITOR_TYPE;
2529

2530
typedef struct {
2531
  int32_t      contLen;
2532
  char*        pCont;
2533
  MONITOR_TYPE type;
2534
} SStatisReq;
2535

2536
int32_t tSerializeSStatisReq(void* buf, int32_t bufLen, SStatisReq* pReq);
2537
int32_t tDeserializeSStatisReq(void* buf, int32_t bufLen, SStatisReq* pReq);
2538
void    tFreeSStatisReq(SStatisReq* pReq);
2539

2540
typedef struct {
2541
  char    db[TSDB_DB_FNAME_LEN];
2542
  char    table[TSDB_TABLE_NAME_LEN];
2543
  char    operation[AUDIT_OPERATION_LEN];
2544
  int32_t sqlLen;
2545
  char*   pSql;
2546
} SAuditReq;
2547
int32_t tSerializeSAuditReq(void* buf, int32_t bufLen, SAuditReq* pReq);
2548
int32_t tDeserializeSAuditReq(void* buf, int32_t bufLen, SAuditReq* pReq);
2549
void    tFreeSAuditReq(SAuditReq* pReq);
2550

2551
typedef struct {
2552
  int32_t dnodeId;
2553
  int64_t clusterId;
2554
  SArray* pVloads;
2555
} SNotifyReq;
2556

2557
int32_t tSerializeSNotifyReq(void* buf, int32_t bufLen, SNotifyReq* pReq);
2558
int32_t tDeserializeSNotifyReq(void* buf, int32_t bufLen, SNotifyReq* pReq);
2559
void    tFreeSNotifyReq(SNotifyReq* pReq);
2560

2561
typedef struct {
2562
  int32_t dnodeId;
2563
  int64_t clusterId;
2564
} SDnodeCfg;
2565

2566
typedef struct {
2567
  int32_t id;
2568
  int8_t  isMnode;
2569
  SEp     ep;
2570
} SDnodeEp;
2571

2572
typedef struct {
2573
  int32_t id;
2574
  int8_t  isMnode;
2575
  int8_t  offlineReason;
2576
  SEp     ep;
2577
  char    active[TSDB_ACTIVE_KEY_LEN];
2578
  char    connActive[TSDB_CONN_ACTIVE_KEY_LEN];
2579
} SDnodeInfo;
2580

2581
typedef struct {
2582
  int64_t   dnodeVer;
2583
  SDnodeCfg dnodeCfg;
2584
  SArray*   pDnodeEps;  // Array of SDnodeEp
2585
  int32_t   statusSeq;
2586
  int64_t   ipWhiteVer;
2587
  int64_t   analVer;
2588
  int64_t   timeWhiteVer;
2589
} SStatusRsp;
2590

2591
int32_t tSerializeSStatusRsp(void* buf, int32_t bufLen, SStatusRsp* pRsp);
2592
int32_t tDeserializeSStatusRsp(void* buf, int32_t bufLen, SStatusRsp* pRsp);
2593
void    tFreeSStatusRsp(SStatusRsp* pRsp);
2594

2595
typedef struct {
2596
  int32_t forceReadConfig;
2597
  int32_t isConifgVerified;
2598
  int32_t isVersionVerified;
2599
  int32_t cver;
2600
  SArray* array;
2601
} SConfigRsp;
2602

2603
int32_t tSerializeSConfigRsp(void* buf, int32_t bufLen, SConfigRsp* pRsp);
2604
int32_t tDeserializeSConfigRsp(void* buf, int32_t bufLen, SConfigRsp* pRsp);
2605
void    tFreeSConfigRsp(SConfigRsp* pRsp);
2606

2607
typedef struct {
2608
  int32_t reserved;
2609
} SMTimerReq;
2610

2611
int32_t tSerializeSMTimerMsg(void* buf, int32_t bufLen, SMTimerReq* pReq);
2612
// int32_t tDeserializeSMTimerMsg(void* buf, int32_t bufLen, SMTimerReq* pReq);
2613

2614
typedef struct SOrphanTask {
2615
  int64_t streamId;
2616
  int32_t taskId;
2617
  int32_t nodeId;
2618
} SOrphanTask;
2619

2620
typedef struct SMStreamDropOrphanMsg {
2621
  SArray* pList;  // SArray<SOrphanTask>
2622
} SMStreamDropOrphanMsg;
2623

2624
int32_t tSerializeDropOrphanTaskMsg(void* buf, int32_t bufLen, SMStreamDropOrphanMsg* pMsg);
2625
int32_t tDeserializeDropOrphanTaskMsg(void* buf, int32_t bufLen, SMStreamDropOrphanMsg* pMsg);
2626
void    tDestroyDropOrphanTaskMsg(SMStreamDropOrphanMsg* pMsg);
2627

2628
typedef struct {
2629
  int32_t  id;
2630
  uint16_t port;                 // node sync Port
2631
  char     fqdn[TSDB_FQDN_LEN];  // node FQDN
2632
} SReplica;
2633

2634
typedef struct {
2635
  int32_t  vgId;
2636
  char     db[TSDB_DB_FNAME_LEN];
2637
  int64_t  dbUid;
2638
  int32_t  vgVersion;
2639
  int32_t  numOfStables;
2640
  int32_t  buffer;
2641
  int32_t  pageSize;
2642
  int32_t  pages;
2643
  int32_t  cacheLastSize;
2644
  int32_t  daysPerFile;
2645
  int32_t  daysToKeep0;
2646
  int32_t  daysToKeep1;
2647
  int32_t  daysToKeep2;
2648
  int32_t  keepTimeOffset;
2649
  int32_t  minRows;
2650
  int32_t  maxRows;
2651
  int32_t  walFsyncPeriod;
2652
  uint32_t hashBegin;
2653
  uint32_t hashEnd;
2654
  int8_t   hashMethod;
2655
  int8_t   walLevel;
2656
  int8_t   precision;
2657
  int8_t   compression;
2658
  int8_t   strict;
2659
  int8_t   cacheLast;
2660
  int8_t   isTsma;
2661
  int8_t   replica;
2662
  int8_t   selfIndex;
2663
  SReplica replicas[TSDB_MAX_REPLICA];
2664
  int32_t  numOfRetensions;
2665
  SArray*  pRetensions;  // SRetention
2666
  void*    pTsma;
2667
  int32_t  walRetentionPeriod;
2668
  int64_t  walRetentionSize;
2669
  int32_t  walRollPeriod;
2670
  int64_t  walSegmentSize;
2671
  int16_t  sstTrigger;
2672
  int16_t  hashPrefix;
2673
  int16_t  hashSuffix;
2674
  int32_t  tsdbPageSize;
2675
  int32_t  ssChunkSize;
2676
  int32_t  ssKeepLocal;
2677
  int8_t   ssCompact;
2678
  int64_t  reserved[6];
2679
  int8_t   learnerReplica;
2680
  int8_t   learnerSelfIndex;
2681
  SReplica learnerReplicas[TSDB_MAX_LEARNER_REPLICA];
2682
  int32_t  changeVersion;
2683
  int8_t   encryptAlgorithm;
2684
  char     encryptAlgrName[TSDB_ENCRYPT_ALGR_NAME_LEN];
2685
} SCreateVnodeReq;
2686

2687
int32_t tSerializeSCreateVnodeReq(void* buf, int32_t bufLen, SCreateVnodeReq* pReq);
2688
int32_t tDeserializeSCreateVnodeReq(void* buf, int32_t bufLen, SCreateVnodeReq* pReq);
2689
int32_t tFreeSCreateVnodeReq(SCreateVnodeReq* pReq);
2690

2691
typedef struct {
2692
  union {
2693
    int32_t compactId;
2694
    int32_t id;
2695
  };
2696
  int32_t vgId;
2697
  int32_t dnodeId;
2698
} SQueryCompactProgressReq;
2699

2700
int32_t tSerializeSQueryCompactProgressReq(void* buf, int32_t bufLen, SQueryCompactProgressReq* pReq);
2701
int32_t tDeserializeSQueryCompactProgressReq(void* buf, int32_t bufLen, SQueryCompactProgressReq* pReq);
2702

2703
typedef struct {
2704
  union {
2705
    int32_t compactId;
2706
    int32_t id;
2707
  };
2708
  int32_t vgId;
2709
  int32_t dnodeId;
2710
  int32_t numberFileset;
2711
  int32_t finished;
2712
  int32_t progress;
2713
  int64_t remainingTime;
2714
} SQueryCompactProgressRsp;
2715

2716
int32_t tSerializeSQueryCompactProgressRsp(void* buf, int32_t bufLen, SQueryCompactProgressRsp* pReq);
2717
int32_t tDeserializeSQueryCompactProgressRsp(void* buf, int32_t bufLen, SQueryCompactProgressRsp* pReq);
2718

2719
typedef SQueryCompactProgressReq SQueryRetentionProgressReq;
2720
typedef SQueryCompactProgressRsp SQueryRetentionProgressRsp;
2721

2722
typedef struct {
2723
  int32_t vgId;
2724
  int32_t dnodeId;
2725
  int64_t dbUid;
2726
  char    db[TSDB_DB_FNAME_LEN];
2727
  int64_t reserved[8];
2728
} SDropVnodeReq;
2729

2730
int32_t tSerializeSDropVnodeReq(void* buf, int32_t bufLen, SDropVnodeReq* pReq);
2731
int32_t tDeserializeSDropVnodeReq(void* buf, int32_t bufLen, SDropVnodeReq* pReq);
2732

2733
typedef struct {
2734
  char    colName[TSDB_COL_NAME_LEN];
2735
  char    stb[TSDB_TABLE_FNAME_LEN];
2736
  int64_t stbUid;
2737
  int64_t dbUid;
2738
  int64_t reserved[8];
2739
} SDropIndexReq;
2740

2741
int32_t tSerializeSDropIdxReq(void* buf, int32_t bufLen, SDropIndexReq* pReq);
2742
int32_t tDeserializeSDropIdxReq(void* buf, int32_t bufLen, SDropIndexReq* pReq);
2743

2744
typedef struct {
2745
  int64_t dbUid;
2746
  char    db[TSDB_DB_FNAME_LEN];
2747
  union {
2748
    int64_t compactStartTime;
2749
    int64_t startTime;
2750
  };
2751

2752
  STimeWindow tw;
2753
  union {
2754
    int32_t compactId;
2755
    int32_t id;
2756
  };
2757
  int8_t metaOnly;
2758
  union {
2759
    uint16_t flags;
2760
    struct {
2761
      uint16_t optrType : 3;     // ETsdbOpType
2762
      uint16_t triggerType : 1;  // ETriggerType 0 manual, 1 auto
2763
      uint16_t reserved : 12;
2764
    };
2765
  };
2766
  int8_t force;  // force compact
2767
} SCompactVnodeReq;
2768

2769
int32_t tSerializeSCompactVnodeReq(void* buf, int32_t bufLen, SCompactVnodeReq* pReq);
2770
int32_t tDeserializeSCompactVnodeReq(void* buf, int32_t bufLen, SCompactVnodeReq* pReq);
2771

2772
typedef struct {
2773
  union {
2774
    int32_t compactId;
2775
    int32_t taskId;
2776
  };
2777
  int32_t vgId;
2778
  int32_t dnodeId;
2779
} SVKillCompactReq;
2780

2781
int32_t tSerializeSVKillCompactReq(void* buf, int32_t bufLen, SVKillCompactReq* pReq);
2782
int32_t tDeserializeSVKillCompactReq(void* buf, int32_t bufLen, SVKillCompactReq* pReq);
2783

2784
typedef SVKillCompactReq SVKillRetentionReq;
2785

2786
typedef struct {
2787
  char        db[TSDB_DB_FNAME_LEN];
2788
  int32_t     maxSpeed;
2789
  int32_t     sqlLen;
2790
  char*       sql;
2791
  SArray*     vgroupIds;
2792
  STimeWindow tw;  // unit is second
2793
  union {
2794
    uint32_t flags;
2795
    struct {
2796
      uint32_t optrType : 3;     // ETsdbOpType
2797
      uint32_t triggerType : 1;  // ETriggerType 0 manual, 1 auto
2798
      uint32_t reserved : 28;
2799
    };
2800
  };
2801
} STrimDbReq;
2802

2803
int32_t tSerializeSTrimDbReq(void* buf, int32_t bufLen, STrimDbReq* pReq);
2804
int32_t tDeserializeSTrimDbReq(void* buf, int32_t bufLen, STrimDbReq* pReq);
2805
void    tFreeSTrimDbReq(STrimDbReq* pReq);
2806

2807
typedef SCompactVnodeReq SVTrimDbReq;  // reuse SCompactVnodeReq, add task monitor since 3.3.8.0
2808

2809
int32_t tSerializeSVTrimDbReq(void* buf, int32_t bufLen, SVTrimDbReq* pReq);
2810
int32_t tDeserializeSVTrimDbReq(void* buf, int32_t bufLen, SVTrimDbReq* pReq);
2811

2812
typedef struct {
2813
  int32_t vgVersion;
2814
  int32_t buffer;
2815
  int32_t pageSize;
2816
  int32_t pages;
2817
  int32_t cacheLastSize;
2818
  int32_t daysPerFile;
2819
  int32_t daysToKeep0;
2820
  int32_t daysToKeep1;
2821
  int32_t daysToKeep2;
2822
  int32_t keepTimeOffset;
2823
  int32_t walFsyncPeriod;
2824
  int8_t  walLevel;
2825
  int8_t  strict;
2826
  int8_t  cacheLast;
2827
  int64_t reserved[7];
2828
  // 1st modification
2829
  int16_t sttTrigger;
2830
  int32_t minRows;
2831
  // 2nd modification
2832
  int32_t walRetentionPeriod;
2833
  int32_t walRetentionSize;
2834
  int32_t ssKeepLocal;
2835
  int8_t  ssCompact;
2836
} SAlterVnodeConfigReq;
2837

2838
int32_t tSerializeSAlterVnodeConfigReq(void* buf, int32_t bufLen, SAlterVnodeConfigReq* pReq);
2839
int32_t tDeserializeSAlterVnodeConfigReq(void* buf, int32_t bufLen, SAlterVnodeConfigReq* pReq);
2840

2841
typedef struct {
2842
  int32_t  vgId;
2843
  int8_t   strict;
2844
  int8_t   selfIndex;
2845
  int8_t   replica;
2846
  SReplica replicas[TSDB_MAX_REPLICA];
2847
  int64_t  reserved[8];
2848
  int8_t   learnerSelfIndex;
2849
  int8_t   learnerReplica;
2850
  SReplica learnerReplicas[TSDB_MAX_LEARNER_REPLICA];
2851
  int32_t  changeVersion;
2852
  int32_t  electBaseLine;
2853
} SAlterVnodeReplicaReq, SAlterVnodeTypeReq, SCheckLearnCatchupReq, SAlterVnodeElectBaselineReq;
2854

2855
int32_t tSerializeSAlterVnodeReplicaReq(void* buf, int32_t bufLen, SAlterVnodeReplicaReq* pReq);
2856
int32_t tDeserializeSAlterVnodeReplicaReq(void* buf, int32_t bufLen, SAlterVnodeReplicaReq* pReq);
2857

2858
typedef struct {
2859
  int32_t vgId;
2860
  int8_t  disable;
2861
} SDisableVnodeWriteReq;
2862

2863
int32_t tSerializeSDisableVnodeWriteReq(void* buf, int32_t bufLen, SDisableVnodeWriteReq* pReq);
2864
int32_t tDeserializeSDisableVnodeWriteReq(void* buf, int32_t bufLen, SDisableVnodeWriteReq* pReq);
2865

2866
typedef struct {
2867
  int32_t  srcVgId;
2868
  int32_t  dstVgId;
2869
  uint32_t hashBegin;
2870
  uint32_t hashEnd;
2871
  int32_t  changeVersion;
2872
  int32_t  reserved;
2873
} SAlterVnodeHashRangeReq;
2874

2875
int32_t tSerializeSAlterVnodeHashRangeReq(void* buf, int32_t bufLen, SAlterVnodeHashRangeReq* pReq);
2876
int32_t tDeserializeSAlterVnodeHashRangeReq(void* buf, int32_t bufLen, SAlterVnodeHashRangeReq* pReq);
2877

2878
#define REQ_OPT_TBNAME 0x0
2879
#define REQ_OPT_TBUID  0x01
2880
typedef struct {
2881
  SMsgHead header;
2882
  char     dbFName[TSDB_DB_FNAME_LEN];
2883
  char     tbName[TSDB_TABLE_NAME_LEN];
2884
  uint8_t  option;
2885
  uint8_t  autoCreateCtb;
2886
} STableInfoReq;
2887

2888
int32_t tSerializeSTableInfoReq(void* buf, int32_t bufLen, STableInfoReq* pReq);
2889
int32_t tDeserializeSTableInfoReq(void* buf, int32_t bufLen, STableInfoReq* pReq);
2890

2891
typedef struct {
2892
  int8_t  metaClone;  // create local clone of the cached table meta
2893
  int32_t numOfVgroups;
2894
  int32_t numOfTables;
2895
  int32_t numOfUdfs;
2896
  char    tableNames[];
2897
} SMultiTableInfoReq;
2898

2899
// todo refactor
2900
typedef struct SVgroupInfo {
2901
  int32_t  vgId;
2902
  uint32_t hashBegin;
2903
  uint32_t hashEnd;
2904
  SEpSet   epSet;
2905
  union {
2906
    int32_t numOfTable;  // unit is TSDB_TABLE_NUM_UNIT
2907
    int32_t taskId;      // used in stream
2908
  };
2909
} SVgroupInfo;
2910

2911
typedef struct {
2912
  int32_t     numOfVgroups;
2913
  SVgroupInfo vgroups[];
2914
} SVgroupsInfo;
2915

2916
typedef struct {
2917
  STableMetaRsp* pMeta;
2918
} SMAlterStbRsp;
2919

2920
int32_t tEncodeSMAlterStbRsp(SEncoder* pEncoder, const SMAlterStbRsp* pRsp);
2921
int32_t tDecodeSMAlterStbRsp(SDecoder* pDecoder, SMAlterStbRsp* pRsp);
2922
void    tFreeSMAlterStbRsp(SMAlterStbRsp* pRsp);
2923

2924
int32_t tSerializeSTableMetaRsp(void* buf, int32_t bufLen, STableMetaRsp* pRsp);
2925
int32_t tDeserializeSTableMetaRsp(void* buf, int32_t bufLen, STableMetaRsp* pRsp);
2926
void    tFreeSTableMetaRsp(void* pRsp);
2927
void    tFreeSTableIndexRsp(void* info);
2928

2929
typedef struct {
2930
  SArray* pMetaRsp;   // Array of STableMetaRsp
2931
  SArray* pIndexRsp;  // Array of STableIndexRsp;
2932
} SSTbHbRsp;
2933

2934
int32_t tSerializeSSTbHbRsp(void* buf, int32_t bufLen, SSTbHbRsp* pRsp);
2935
int32_t tDeserializeSSTbHbRsp(void* buf, int32_t bufLen, SSTbHbRsp* pRsp);
2936
void    tFreeSSTbHbRsp(SSTbHbRsp* pRsp);
2937

2938
typedef struct {
2939
  SArray* pViewRsp;  // Array of SViewMetaRsp*;
2940
} SViewHbRsp;
2941

2942
int32_t tSerializeSViewHbRsp(void* buf, int32_t bufLen, SViewHbRsp* pRsp);
2943
int32_t tDeserializeSViewHbRsp(void* buf, int32_t bufLen, SViewHbRsp* pRsp);
2944
void    tFreeSViewHbRsp(SViewHbRsp* pRsp);
2945

2946
typedef struct {
2947
  int32_t numOfTables;
2948
  int32_t numOfVgroup;
2949
  int32_t numOfUdf;
2950
  int32_t contLen;
2951
  int8_t  compressed;  // denote if compressed or not
2952
  int32_t rawLen;      // size before compress
2953
  uint8_t metaClone;   // make meta clone after retrieve meta from mnode
2954
  char    meta[];
2955
} SMultiTableMeta;
2956

2957
typedef struct {
2958
  int32_t dataLen;
2959
  char    name[TSDB_TABLE_FNAME_LEN];
2960
  char*   data;
2961
} STagData;
2962

2963
typedef struct {
2964
  int32_t  opType;
2965
  uint32_t valLen;
2966
  char*    val;
2967
} SShowVariablesReq;
2968

2969
int32_t tSerializeSShowVariablesReq(void* buf, int32_t bufLen, SShowVariablesReq* pReq);
2970
int32_t tDeserializeSShowVariablesReq(void* buf, int32_t bufLen, SShowVariablesReq* pReq);
2971
void    tFreeSShowVariablesReq(SShowVariablesReq* pReq);
2972

2973
typedef struct {
2974
  char name[TSDB_CONFIG_OPTION_LEN + 1];
2975
  char value[TSDB_CONFIG_PATH_LEN + 1];
2976
  char scope[TSDB_CONFIG_SCOPE_LEN + 1];
2977
  char category[TSDB_CONFIG_CATEGORY_LEN + 1];
2978
  char info[TSDB_CONFIG_INFO_LEN + 1];
2979
} SVariablesInfo;
2980

2981
typedef struct {
2982
  SArray* variables;  // SArray<SVariablesInfo>
2983
} SShowVariablesRsp;
2984

2985
int32_t tSerializeSShowVariablesRsp(void* buf, int32_t bufLen, SShowVariablesRsp* pReq);
2986
int32_t tDeserializeSShowVariablesRsp(void* buf, int32_t bufLen, SShowVariablesRsp* pReq);
2987

2988
void tFreeSShowVariablesRsp(SShowVariablesRsp* pRsp);
2989

2990
/*
2991
 * sql: show tables like '%a_%'
2992
 * payload is the query condition, e.g., '%a_%'
2993
 * payloadLen is the length of payload
2994
 */
2995
typedef struct {
2996
  int32_t type;
2997
  char    db[TSDB_DB_FNAME_LEN];
2998
  int32_t payloadLen;
2999
  char*   payload;
3000
} SShowReq;
3001

3002
int32_t tSerializeSShowReq(void* buf, int32_t bufLen, SShowReq* pReq);
3003
// int32_t tDeserializeSShowReq(void* buf, int32_t bufLen, SShowReq* pReq);
3004
void tFreeSShowReq(SShowReq* pReq);
3005

3006
typedef struct {
3007
  int64_t       showId;
3008
  STableMetaRsp tableMeta;
3009
} SShowRsp, SVShowTablesRsp;
3010

3011
// int32_t tSerializeSShowRsp(void* buf, int32_t bufLen, SShowRsp* pRsp);
3012
// int32_t tDeserializeSShowRsp(void* buf, int32_t bufLen, SShowRsp* pRsp);
3013
// void    tFreeSShowRsp(SShowRsp* pRsp);
3014

3015
typedef struct {
3016
  char    db[TSDB_DB_FNAME_LEN];
3017
  char    tb[TSDB_TABLE_NAME_LEN];
3018
  char    user[TSDB_USER_LEN];
3019
  char    filterTb[TSDB_TABLE_NAME_LEN];  // for ins_columns
3020
  int64_t showId;
3021
  int64_t compactId;  // for compact
3022
  bool    withFull;   // for show users full
3023
} SRetrieveTableReq;
3024

3025
typedef struct SSysTableSchema {
3026
  int8_t   type;
3027
  col_id_t colId;
3028
  int32_t  bytes;
3029
} SSysTableSchema;
3030

3031
int32_t tSerializeSRetrieveTableReq(void* buf, int32_t bufLen, SRetrieveTableReq* pReq);
3032
int32_t tDeserializeSRetrieveTableReq(void* buf, int32_t bufLen, SRetrieveTableReq* pReq);
3033

3034
#define RETRIEVE_TABLE_RSP_VERSION         0
3035
#define RETRIEVE_TABLE_RSP_TMQ_VERSION     1
3036
#define RETRIEVE_TABLE_RSP_TMQ_RAW_VERSION 2
3037

3038
typedef struct {
3039
  int64_t useconds;
3040
  int8_t  completed;  // all results are returned to client
3041
  int8_t  precision;
3042
  int8_t  compressed;
3043
  int8_t  streamBlockType;
3044
  int32_t payloadLen;
3045
  int32_t compLen;
3046
  int32_t numOfBlocks;
3047
  int64_t numOfRows;  // from int32_t change to int64_t
3048
  int64_t numOfCols;
3049
  int64_t skey;
3050
  int64_t ekey;
3051
  int64_t version;                         // for stream
3052
  TSKEY   watermark;                       // for stream
3053
  char    parTbName[TSDB_TABLE_NAME_LEN];  // for stream
3054
  char    data[];
3055
} SRetrieveTableRsp;
3056

3057
#define PAYLOAD_PREFIX_LEN ((sizeof(int32_t)) << 1)
3058

3059
#define SET_PAYLOAD_LEN(_p, _compLen, _fullLen) \
3060
  do {                                          \
3061
    ((int32_t*)(_p))[0] = (_compLen);           \
3062
    ((int32_t*)(_p))[1] = (_fullLen);           \
3063
  } while (0);
3064

3065
typedef struct {
3066
  int64_t version;
3067
  int64_t numOfRows;
3068
  int8_t  compressed;
3069
  int8_t  precision;
3070
  char    data[];
3071
} SRetrieveTableRspForTmq;
3072

3073
typedef struct {
3074
  int64_t handle;
3075
  int64_t useconds;
3076
  int8_t  completed;  // all results are returned to client
3077
  int8_t  precision;
3078
  int8_t  compressed;
3079
  int32_t compLen;
3080
  int32_t numOfRows;
3081
  int32_t fullLen;
3082
  char    data[];
3083
} SRetrieveMetaTableRsp;
3084

3085
typedef struct SExplainExecInfo {
3086
  double   startupCost;
3087
  double   totalCost;
3088
  uint64_t numOfRows;
3089
  uint32_t verboseLen;
3090
  void*    verboseInfo;
3091
} SExplainExecInfo;
3092

3093
typedef struct {
3094
  int32_t           numOfPlans;
3095
  SExplainExecInfo* subplanInfo;
3096
} SExplainRsp;
3097

3098
typedef struct {
3099
  SExplainRsp rsp;
3100
  uint64_t    qId;
3101
  uint64_t    cId;
3102
  uint64_t    tId;
3103
  int64_t     rId;
3104
  int32_t     eId;
3105
} SExplainLocalRsp;
3106

3107
typedef struct STableScanAnalyzeInfo {
3108
  uint64_t totalRows;
3109
  uint64_t totalCheckedRows;
3110
  uint32_t totalBlocks;
3111
  uint32_t loadBlocks;
3112
  uint32_t loadBlockStatis;
3113
  uint32_t skipBlocks;
3114
  uint32_t filterOutBlocks;
3115
  double   elapsedTime;
3116
  double   filterTime;
3117
} STableScanAnalyzeInfo;
3118

3119
int32_t tSerializeSExplainRsp(void* buf, int32_t bufLen, SExplainRsp* pRsp);
3120
int32_t tDeserializeSExplainRsp(void* buf, int32_t bufLen, SExplainRsp* pRsp);
3121
void    tFreeSExplainRsp(SExplainRsp* pRsp);
3122

3123
typedef struct {
3124
  char    config[TSDB_DNODE_CONFIG_LEN];
3125
  char    value[TSDB_CLUSTER_VALUE_LEN];
3126
  int32_t sqlLen;
3127
  char*   sql;
3128
} SMCfgClusterReq;
3129

3130
int32_t tSerializeSMCfgClusterReq(void* buf, int32_t bufLen, SMCfgClusterReq* pReq);
3131
int32_t tDeserializeSMCfgClusterReq(void* buf, int32_t bufLen, SMCfgClusterReq* pReq);
3132
void    tFreeSMCfgClusterReq(SMCfgClusterReq* pReq);
3133

3134
typedef struct {
3135
  char    fqdn[TSDB_FQDN_LEN];  // end point, hostname:port
3136
  int32_t port;
3137
  int32_t sqlLen;
3138
  char*   sql;
3139
} SCreateDnodeReq;
3140

3141
int32_t tSerializeSCreateDnodeReq(void* buf, int32_t bufLen, SCreateDnodeReq* pReq);
3142
int32_t tDeserializeSCreateDnodeReq(void* buf, int32_t bufLen, SCreateDnodeReq* pReq);
3143
void    tFreeSCreateDnodeReq(SCreateDnodeReq* pReq);
3144

3145
typedef struct {
3146
  int32_t dnodeId;
3147
  char    fqdn[TSDB_FQDN_LEN];
3148
  int32_t port;
3149
  int8_t  force;
3150
  int8_t  unsafe;
3151
  int32_t sqlLen;
3152
  char*   sql;
3153
} SDropDnodeReq;
3154

3155
int32_t tSerializeSDropDnodeReq(void* buf, int32_t bufLen, SDropDnodeReq* pReq);
3156
int32_t tDeserializeSDropDnodeReq(void* buf, int32_t bufLen, SDropDnodeReq* pReq);
3157
void    tFreeSDropDnodeReq(SDropDnodeReq* pReq);
3158

3159
enum {
3160
  RESTORE_TYPE__ALL = 1,
3161
  RESTORE_TYPE__MNODE,
3162
  RESTORE_TYPE__VNODE,
3163
  RESTORE_TYPE__QNODE,
3164
};
3165

3166
typedef struct {
3167
  int32_t dnodeId;
3168
  int8_t  restoreType;
3169
  int32_t sqlLen;
3170
  char*   sql;
3171
} SRestoreDnodeReq;
3172

3173
int32_t tSerializeSRestoreDnodeReq(void* buf, int32_t bufLen, SRestoreDnodeReq* pReq);
3174
int32_t tDeserializeSRestoreDnodeReq(void* buf, int32_t bufLen, SRestoreDnodeReq* pReq);
3175
void    tFreeSRestoreDnodeReq(SRestoreDnodeReq* pReq);
3176

3177
typedef struct {
3178
  int32_t dnodeId;
3179
  char    config[TSDB_DNODE_CONFIG_LEN];
3180
  char    value[TSDB_DNODE_VALUE_LEN];
3181
  int32_t sqlLen;
3182
  char*   sql;
3183
} SMCfgDnodeReq;
3184

3185
int32_t tSerializeSMCfgDnodeReq(void* buf, int32_t bufLen, SMCfgDnodeReq* pReq);
3186
int32_t tDeserializeSMCfgDnodeReq(void* buf, int32_t bufLen, SMCfgDnodeReq* pReq);
3187
void    tFreeSMCfgDnodeReq(SMCfgDnodeReq* pReq);
3188

3189
typedef struct {
3190
  char    config[TSDB_DNODE_CONFIG_LEN];
3191
  char    value[TSDB_DNODE_VALUE_LEN];
3192
  int32_t version;
3193
} SDCfgDnodeReq;
3194

3195
int32_t tSerializeSDCfgDnodeReq(void* buf, int32_t bufLen, SDCfgDnodeReq* pReq);
3196
int32_t tDeserializeSDCfgDnodeReq(void* buf, int32_t bufLen, SDCfgDnodeReq* pReq);
3197

3198
typedef struct {
3199
  int32_t dnodeId;
3200
  int32_t sqlLen;
3201
  char*   sql;
3202
} SMCreateMnodeReq, SMDropMnodeReq, SDDropMnodeReq, SMCreateQnodeReq, SMDropQnodeReq, SDCreateQnodeReq, SDDropQnodeReq,
3203
    SMCreateSnodeReq, SMDropSnodeReq,     SDDropSnodeReq;
3204

3205

3206
int32_t tSerializeSCreateDropMQSNodeReq(void* buf, int32_t bufLen, SMCreateQnodeReq* pReq);
3207
int32_t tDeserializeSCreateDropMQSNodeReq(void* buf, int32_t bufLen, SMCreateQnodeReq* pReq);
3208

3209

3210
typedef struct {
3211
  int32_t nodeId;
3212
  SEpSet  epSet;
3213
} SNodeEpSet;
3214

3215

3216
typedef struct {
3217
  int32_t    snodeId;
3218
  SNodeEpSet leaders[2];
3219
  SNodeEpSet replica;
3220
  int32_t    sqlLen;
3221
  char*      sql;
3222
} SDCreateSnodeReq;
3223

3224
int32_t tSerializeSDCreateSNodeReq(void *buf, int32_t bufLen, SDCreateSnodeReq *pReq);
3225
int32_t tDeserializeSDCreateSNodeReq(void *buf, int32_t bufLen, SDCreateSnodeReq *pReq);
3226
void tFreeSDCreateSnodeReq(SDCreateSnodeReq *pReq);
3227

3228

3229
void    tFreeSMCreateQnodeReq(SMCreateQnodeReq* pReq);
3230
void    tFreeSDDropQnodeReq(SDDropQnodeReq* pReq);
3231
typedef struct {
3232
  int8_t   replica;
3233
  SReplica replicas[TSDB_MAX_REPLICA];
3234
  int8_t   learnerReplica;
3235
  SReplica learnerReplicas[TSDB_MAX_LEARNER_REPLICA];
3236
  int64_t  lastIndex;
3237
} SDCreateMnodeReq, SDAlterMnodeReq, SDAlterMnodeTypeReq;
3238

3239
int32_t tSerializeSDCreateMnodeReq(void* buf, int32_t bufLen, SDCreateMnodeReq* pReq);
3240
int32_t tDeserializeSDCreateMnodeReq(void* buf, int32_t bufLen, SDCreateMnodeReq* pReq);
3241

3242
typedef struct {
3243
  int32_t urlLen;
3244
  int32_t sqlLen;
3245
  char*   url;
3246
  char*   sql;
3247
} SMCreateAnodeReq;
3248

3249
int32_t tSerializeSMCreateAnodeReq(void* buf, int32_t bufLen, SMCreateAnodeReq* pReq);
3250
int32_t tDeserializeSMCreateAnodeReq(void* buf, int32_t bufLen, SMCreateAnodeReq* pReq);
3251
void    tFreeSMCreateAnodeReq(SMCreateAnodeReq* pReq);
3252

3253
typedef struct {
3254
  int32_t anodeId;
3255
  int32_t sqlLen;
3256
  char*   sql;
3257
} SMDropAnodeReq, SMUpdateAnodeReq;
3258

3259
int32_t tSerializeSMDropAnodeReq(void* buf, int32_t bufLen, SMDropAnodeReq* pReq);
3260
int32_t tDeserializeSMDropAnodeReq(void* buf, int32_t bufLen, SMDropAnodeReq* pReq);
3261
void    tFreeSMDropAnodeReq(SMDropAnodeReq* pReq);
3262
int32_t tSerializeSMUpdateAnodeReq(void* buf, int32_t bufLen, SMUpdateAnodeReq* pReq);
3263
int32_t tDeserializeSMUpdateAnodeReq(void* buf, int32_t bufLen, SMUpdateAnodeReq* pReq);
3264
void    tFreeSMUpdateAnodeReq(SMUpdateAnodeReq* pReq);
3265

3266
typedef struct {
3267
  int32_t dnodeId;
3268
  int32_t bnodeProto;
3269
  int32_t sqlLen;
3270
  char*   sql;
3271
} SMCreateBnodeReq, SDCreateBnodeReq;
3272

3273
int32_t tSerializeSMCreateBnodeReq(void* buf, int32_t bufLen, SMCreateBnodeReq* pReq);
3274
int32_t tDeserializeSMCreateBnodeReq(void* buf, int32_t bufLen, SMCreateBnodeReq* pReq);
3275
void    tFreeSMCreateBnodeReq(SMCreateBnodeReq* pReq);
3276

3277
typedef struct {
3278
  int32_t dnodeId;
3279
  int32_t sqlLen;
3280
  char*   sql;
3281
} SMDropBnodeReq, SDDropBnodeReq;
3282

3283
int32_t tSerializeSMDropBnodeReq(void* buf, int32_t bufLen, SMDropBnodeReq* pReq);
3284
int32_t tDeserializeSMDropBnodeReq(void* buf, int32_t bufLen, SMDropBnodeReq* pReq);
3285
void    tFreeSMDropBnodeReq(SMDropBnodeReq* pReq);
3286

3287
typedef struct {
3288
  int32_t vgId;
3289
  int32_t hbSeq;
3290
} SVArbHbReqMember;
3291

3292
typedef struct {
3293
  int32_t dnodeId;
3294
  char*   arbToken;
3295
  int64_t arbTerm;
3296
  SArray* hbMembers;  // SVArbHbReqMember
3297
} SVArbHeartBeatReq;
3298

3299
int32_t tSerializeSVArbHeartBeatReq(void* buf, int32_t bufLen, SVArbHeartBeatReq* pReq);
3300
int32_t tDeserializeSVArbHeartBeatReq(void* buf, int32_t bufLen, SVArbHeartBeatReq* pReq);
3301
void    tFreeSVArbHeartBeatReq(SVArbHeartBeatReq* pReq);
3302

3303
typedef struct {
3304
  int32_t vgId;
3305
  char    memberToken[TSDB_ARB_TOKEN_SIZE];
3306
  int32_t hbSeq;
3307
} SVArbHbRspMember;
3308

3309
typedef struct {
3310
  char    arbToken[TSDB_ARB_TOKEN_SIZE];
3311
  int32_t dnodeId;
3312
  SArray* hbMembers;  // SVArbHbRspMember
3313
} SVArbHeartBeatRsp;
3314

3315
int32_t tSerializeSVArbHeartBeatRsp(void* buf, int32_t bufLen, SVArbHeartBeatRsp* pRsp);
3316
int32_t tDeserializeSVArbHeartBeatRsp(void* buf, int32_t bufLen, SVArbHeartBeatRsp* pRsp);
3317
void    tFreeSVArbHeartBeatRsp(SVArbHeartBeatRsp* pRsp);
3318

3319
typedef struct {
3320
  char*   arbToken;
3321
  int64_t arbTerm;
3322
  char*   member0Token;
3323
  char*   member1Token;
3324
} SVArbCheckSyncReq;
3325

3326
int32_t tSerializeSVArbCheckSyncReq(void* buf, int32_t bufLen, SVArbCheckSyncReq* pReq);
3327
int32_t tDeserializeSVArbCheckSyncReq(void* buf, int32_t bufLen, SVArbCheckSyncReq* pReq);
3328
void    tFreeSVArbCheckSyncReq(SVArbCheckSyncReq* pRsp);
3329

3330
typedef struct {
3331
  char*   arbToken;
3332
  char*   member0Token;
3333
  char*   member1Token;
3334
  int32_t vgId;
3335
  int32_t errCode;
3336
} SVArbCheckSyncRsp;
3337

3338
int32_t tSerializeSVArbCheckSyncRsp(void* buf, int32_t bufLen, SVArbCheckSyncRsp* pRsp);
3339
int32_t tDeserializeSVArbCheckSyncRsp(void* buf, int32_t bufLen, SVArbCheckSyncRsp* pRsp);
3340
void    tFreeSVArbCheckSyncRsp(SVArbCheckSyncRsp* pRsp);
3341

3342
typedef struct {
3343
  char*   arbToken;
3344
  int64_t arbTerm;
3345
  char*   memberToken;
3346
  int8_t  force;
3347
} SVArbSetAssignedLeaderReq;
3348

3349
int32_t tSerializeSVArbSetAssignedLeaderReq(void* buf, int32_t bufLen, SVArbSetAssignedLeaderReq* pReq);
3350
int32_t tDeserializeSVArbSetAssignedLeaderReq(void* buf, int32_t bufLen, SVArbSetAssignedLeaderReq* pReq);
3351
void    tFreeSVArbSetAssignedLeaderReq(SVArbSetAssignedLeaderReq* pReq);
3352

3353
typedef struct {
3354
  char*   arbToken;
3355
  char*   memberToken;
3356
  int32_t vgId;
3357
} SVArbSetAssignedLeaderRsp;
3358

3359
int32_t tSerializeSVArbSetAssignedLeaderRsp(void* buf, int32_t bufLen, SVArbSetAssignedLeaderRsp* pRsp);
3360
int32_t tDeserializeSVArbSetAssignedLeaderRsp(void* buf, int32_t bufLen, SVArbSetAssignedLeaderRsp* pRsp);
3361
void    tFreeSVArbSetAssignedLeaderRsp(SVArbSetAssignedLeaderRsp* pRsp);
3362

3363
typedef struct {
3364
  int32_t dnodeId;
3365
  char*   token;
3366
} SMArbUpdateGroupMember;
3367

3368
typedef struct {
3369
  int32_t dnodeId;
3370
  char*   token;
3371
  int8_t  acked;
3372
} SMArbUpdateGroupAssigned;
3373

3374
typedef struct {
3375
  int32_t                  vgId;
3376
  int64_t                  dbUid;
3377
  SMArbUpdateGroupMember   members[2];
3378
  int8_t                   isSync;
3379
  int8_t                   assignedAcked;
3380
  SMArbUpdateGroupAssigned assignedLeader;
3381
  int64_t                  version;
3382
  int32_t                  code;
3383
  int64_t                  updateTimeMs;
3384
} SMArbUpdateGroup;
3385

3386
typedef struct {
3387
  SArray* updateArray;  // SMArbUpdateGroup
3388
} SMArbUpdateGroupBatchReq;
3389

3390
int32_t tSerializeSMArbUpdateGroupBatchReq(void* buf, int32_t bufLen, SMArbUpdateGroupBatchReq* pReq);
3391
int32_t tDeserializeSMArbUpdateGroupBatchReq(void* buf, int32_t bufLen, SMArbUpdateGroupBatchReq* pReq);
3392
void    tFreeSMArbUpdateGroupBatchReq(SMArbUpdateGroupBatchReq* pReq);
3393

3394
typedef struct {
3395
  char queryStrId[TSDB_QUERY_ID_LEN];
3396
} SKillQueryReq;
3397

3398
int32_t tSerializeSKillQueryReq(void* buf, int32_t bufLen, SKillQueryReq* pReq);
3399
int32_t tDeserializeSKillQueryReq(void* buf, int32_t bufLen, SKillQueryReq* pReq);
3400

3401
typedef struct {
3402
  uint32_t connId;
3403
} SKillConnReq;
3404

3405
int32_t tSerializeSKillConnReq(void* buf, int32_t bufLen, SKillConnReq* pReq);
3406
int32_t tDeserializeSKillConnReq(void* buf, int32_t bufLen, SKillConnReq* pReq);
3407

3408
typedef struct {
3409
  int32_t transId;
3410
} SKillTransReq;
3411

3412
int32_t tSerializeSKillTransReq(void* buf, int32_t bufLen, SKillTransReq* pReq);
3413
int32_t tDeserializeSKillTransReq(void* buf, int32_t bufLen, SKillTransReq* pReq);
3414

3415
typedef struct {
3416
  int32_t useless;  // useless
3417
  int32_t sqlLen;
3418
  char*   sql;
3419
} SBalanceVgroupReq;
3420

3421
int32_t tSerializeSBalanceVgroupReq(void* buf, int32_t bufLen, SBalanceVgroupReq* pReq);
3422
int32_t tDeserializeSBalanceVgroupReq(void* buf, int32_t bufLen, SBalanceVgroupReq* pReq);
3423
void    tFreeSBalanceVgroupReq(SBalanceVgroupReq* pReq);
3424

3425
typedef struct {
3426
  int32_t useless;  // useless
3427
  int32_t sqlLen;
3428
  char*   sql;
3429
} SAssignLeaderReq;
3430

3431
int32_t tSerializeSAssignLeaderReq(void* buf, int32_t bufLen, SAssignLeaderReq* pReq);
3432
int32_t tDeserializeSAssignLeaderReq(void* buf, int32_t bufLen, SAssignLeaderReq* pReq);
3433
void    tFreeSAssignLeaderReq(SAssignLeaderReq* pReq);
3434
typedef struct {
3435
  int32_t vgId1;
3436
  int32_t vgId2;
3437
} SMergeVgroupReq;
3438

3439
int32_t tSerializeSMergeVgroupReq(void* buf, int32_t bufLen, SMergeVgroupReq* pReq);
3440
int32_t tDeserializeSMergeVgroupReq(void* buf, int32_t bufLen, SMergeVgroupReq* pReq);
3441

3442
typedef struct {
3443
  int32_t vgId;
3444
  int32_t dnodeId1;
3445
  int32_t dnodeId2;
3446
  int32_t dnodeId3;
3447
  int32_t sqlLen;
3448
  char*   sql;
3449
} SRedistributeVgroupReq;
3450

3451
int32_t tSerializeSRedistributeVgroupReq(void* buf, int32_t bufLen, SRedistributeVgroupReq* pReq);
3452
int32_t tDeserializeSRedistributeVgroupReq(void* buf, int32_t bufLen, SRedistributeVgroupReq* pReq);
3453
void    tFreeSRedistributeVgroupReq(SRedistributeVgroupReq* pReq);
3454

3455
typedef struct {
3456
  int32_t reserved;
3457
  int32_t vgId;
3458
  int32_t sqlLen;
3459
  char*   sql;
3460
  char    db[TSDB_DB_FNAME_LEN];
3461
} SBalanceVgroupLeaderReq;
3462

3463
int32_t tSerializeSBalanceVgroupLeaderReq(void* buf, int32_t bufLen, SBalanceVgroupLeaderReq* pReq);
3464
int32_t tDeserializeSBalanceVgroupLeaderReq(void* buf, int32_t bufLen, SBalanceVgroupLeaderReq* pReq);
3465
void    tFreeSBalanceVgroupLeaderReq(SBalanceVgroupLeaderReq* pReq);
3466

3467
typedef struct {
3468
  int32_t vgId;
3469
} SForceBecomeFollowerReq;
3470

3471
int32_t tSerializeSForceBecomeFollowerReq(void* buf, int32_t bufLen, SForceBecomeFollowerReq* pReq);
3472
// int32_t tDeserializeSForceBecomeFollowerReq(void* buf, int32_t bufLen, SForceBecomeFollowerReq* pReq);
3473

3474
typedef struct {
3475
  int32_t vgId;
3476
  bool    force;
3477
} SSplitVgroupReq;
3478

3479
int32_t tSerializeSSplitVgroupReq(void* buf, int32_t bufLen, SSplitVgroupReq* pReq);
3480
int32_t tDeserializeSSplitVgroupReq(void* buf, int32_t bufLen, SSplitVgroupReq* pReq);
3481

3482
typedef struct {
3483
  char user[TSDB_USER_LEN];
3484
  char spi;
3485
  char encrypt;
3486
  char secret[TSDB_PASSWORD_LEN];
3487
  char ckey[TSDB_PASSWORD_LEN];
3488
} SAuthReq, SAuthRsp;
3489

3490
// int32_t tSerializeSAuthReq(void* buf, int32_t bufLen, SAuthReq* pReq);
3491
// int32_t tDeserializeSAuthReq(void* buf, int32_t bufLen, SAuthReq* pReq);
3492

3493
typedef struct {
3494
  int32_t statusCode;
3495
  char    details[1024];
3496
} SServerStatusRsp;
3497

3498
int32_t tSerializeSServerStatusRsp(void* buf, int32_t bufLen, SServerStatusRsp* pRsp);
3499
int32_t tDeserializeSServerStatusRsp(void* buf, int32_t bufLen, SServerStatusRsp* pRsp);
3500

3501
/**
3502
 * The layout of the query message payload is as following:
3503
 * +--------------------+---------------------------------+
3504
 * |Sql statement       | Physical plan                   |
3505
 * |(denoted by sqlLen) |(In JSON, denoted by contentLen) |
3506
 * +--------------------+---------------------------------+
3507
 */
3508
typedef struct SSubQueryMsg {
3509
  SMsgHead header;
3510
  uint64_t sId;
3511
  uint64_t queryId;
3512
  uint64_t clientId;
3513
  uint64_t taskId;
3514
  int64_t  refId;
3515
  int32_t  execId;
3516
  int32_t  msgMask;
3517
  int8_t   taskType;
3518
  int8_t   explain;
3519
  int8_t   needFetch;
3520
  int8_t   compress;
3521
  uint32_t sqlLen;
3522
  char*    sql;
3523
  uint32_t msgLen;
3524
  char*    msg;
3525
} SSubQueryMsg;
3526

3527
int32_t tSerializeSSubQueryMsg(void* buf, int32_t bufLen, SSubQueryMsg* pReq);
3528
int32_t tDeserializeSSubQueryMsg(void* buf, int32_t bufLen, SSubQueryMsg* pReq);
3529
void    tFreeSSubQueryMsg(SSubQueryMsg* pReq);
3530

3531
typedef struct {
3532
  SMsgHead header;
3533
  uint64_t sId;
3534
  uint64_t queryId;
3535
  uint64_t taskId;
3536
} SSinkDataReq;
3537

3538
typedef struct {
3539
  SMsgHead header;
3540
  uint64_t sId;
3541
  uint64_t queryId;
3542
  uint64_t clientId;
3543
  uint64_t taskId;
3544
  int32_t  execId;
3545
} SQueryContinueReq;
3546

3547
typedef struct {
3548
  SMsgHead header;
3549
  uint64_t sId;
3550
  uint64_t queryId;
3551
  uint64_t taskId;
3552
} SResReadyReq;
3553

3554
typedef struct {
3555
  int32_t code;
3556
  char    tbFName[TSDB_TABLE_FNAME_LEN];
3557
  int32_t sversion;
3558
  int32_t tversion;
3559
} SResReadyRsp;
3560

3561
typedef struct SOperatorParam {
3562
  int32_t opType;
3563
  int32_t downstreamIdx;
3564
  void*   value;
3565
  SArray* pChildren;  // SArray<SOperatorParam*>
3566
  bool    reUse;
3567
} SOperatorParam;
3568

3569
typedef struct SColIdNameKV {
3570
  col_id_t colId;
3571
  char     colName[TSDB_COL_NAME_LEN];
3572
} SColIdNameKV;
3573

3574
typedef struct SColIdPair {
3575
  col_id_t vtbColId;
3576
  col_id_t orgColId;
3577
} SColIdPair;
3578

3579
typedef struct SColIdSlotIdPair {
3580
  int32_t  vtbSlotId;
3581
  col_id_t orgColId;
3582
} SColIdSlotIdPair;
3583

3584
typedef struct SOrgTbInfo {
3585
  int32_t vgId;
3586
  char    tbName[TSDB_TABLE_FNAME_LEN];
3587
  SArray* colMap;  // SArray<SColIdNameKV>
3588
} SOrgTbInfo;
3589

3590
typedef struct STableScanOperatorParam {
3591
  bool        tableSeq;
3592
  bool        isNewParam;
3593
  SArray*     pUidList;
3594
  SOrgTbInfo* pOrgTbInfo;
3595
  STimeWindow window;
3596
} STableScanOperatorParam;
3597

3598
typedef struct STagScanOperatorParam {
3599
  tb_uid_t       vcUid;
3600
} STagScanOperatorParam;
3601

3602
typedef struct SVTableScanOperatorParam {
3603
  uint64_t        uid;
3604
  STimeWindow     window;
3605
  SOperatorParam* pTagScanOp;
3606
  SArray*         pOpParamArray;  // SArray<SOperatorParam>
3607
} SVTableScanOperatorParam;
3608

3609
typedef struct SMergeOperatorParam {
3610
  int32_t         winNum;
3611
} SMergeOperatorParam;
3612

3613
typedef struct SExternalWindowOperatorParam {
3614
  SArray*         ExtWins;  // SArray<SExtWinTimeWindow>
3615
} SExternalWindowOperatorParam;
3616

3617
typedef struct SDynQueryCtrlOperatorParam {
3618
  STimeWindow    window;
3619
} SDynQueryCtrlOperatorParam;
3620

3621
struct SStreamRuntimeFuncInfo;
3622
typedef struct {
3623
  SMsgHead                       header;
3624
  uint64_t                       sId;
3625
  uint64_t                       queryId;
3626
  uint64_t                       clientId;
3627
  uint64_t                       taskId;
3628
  int32_t                        execId;
3629
  SOperatorParam*                pOpParam;
3630

3631
  // used for new-stream
3632
  struct SStreamRuntimeFuncInfo* pStRtFuncInfo;
3633
  bool                           reset;
3634
  bool                           dynTbname;
3635
  // used for new-stream
3636
} SResFetchReq;
3637

3638
int32_t tSerializeSResFetchReq(void* buf, int32_t bufLen, SResFetchReq* pReq, bool needStreamPesudoFuncVals);
3639
int32_t tDeserializeSResFetchReq(void* buf, int32_t bufLen, SResFetchReq* pReq);
3640
void    tDestroySResFetchReq(SResFetchReq* pReq);
3641
typedef struct {
3642
  SMsgHead header;
3643
  uint64_t clientId;
3644
} SSchTasksStatusReq;
3645

3646
typedef struct {
3647
  uint64_t queryId;
3648
  uint64_t clientId;
3649
  uint64_t taskId;
3650
  int64_t  refId;
3651
  int32_t  execId;
3652
  int8_t   status;
3653
} STaskStatus;
3654

3655
typedef struct {
3656
  int64_t refId;
3657
  SArray* taskStatus;  // SArray<STaskStatus>
3658
} SSchedulerStatusRsp;
3659

3660
typedef struct {
3661
  uint64_t queryId;
3662
  uint64_t taskId;
3663
  int8_t   action;
3664
} STaskAction;
3665

3666
typedef struct SQueryNodeEpId {
3667
  int32_t nodeId;  // vgId or qnodeId
3668
  SEp     ep;
3669
} SQueryNodeEpId;
3670

3671
typedef struct {
3672
  SMsgHead       header;
3673
  uint64_t       clientId;
3674
  SQueryNodeEpId epId;
3675
  SArray*        taskAction;  // SArray<STaskAction>
3676
} SSchedulerHbReq;
3677

3678
int32_t tSerializeSSchedulerHbReq(void* buf, int32_t bufLen, SSchedulerHbReq* pReq);
3679
int32_t tDeserializeSSchedulerHbReq(void* buf, int32_t bufLen, SSchedulerHbReq* pReq);
3680
void    tFreeSSchedulerHbReq(SSchedulerHbReq* pReq);
3681

3682
typedef struct {
3683
  SQueryNodeEpId epId;
3684
  SArray*        taskStatus;  // SArray<STaskStatus>
3685
} SSchedulerHbRsp;
3686

3687
int32_t tSerializeSSchedulerHbRsp(void* buf, int32_t bufLen, SSchedulerHbRsp* pRsp);
3688
int32_t tDeserializeSSchedulerHbRsp(void* buf, int32_t bufLen, SSchedulerHbRsp* pRsp);
3689
void    tFreeSSchedulerHbRsp(SSchedulerHbRsp* pRsp);
3690

3691
typedef struct {
3692
  SMsgHead header;
3693
  uint64_t sId;
3694
  uint64_t queryId;
3695
  uint64_t clientId;
3696
  uint64_t taskId;
3697
  int64_t  refId;
3698
  int32_t  execId;
3699
} STaskCancelReq;
3700

3701
typedef struct {
3702
  int32_t code;
3703
} STaskCancelRsp;
3704

3705
typedef struct {
3706
  SMsgHead header;
3707
  uint64_t sId;
3708
  uint64_t queryId;
3709
  uint64_t clientId;
3710
  uint64_t taskId;
3711
  int64_t  refId;
3712
  int32_t  execId;
3713
} STaskDropReq;
3714

3715
int32_t tSerializeSTaskDropReq(void* buf, int32_t bufLen, STaskDropReq* pReq);
3716
int32_t tDeserializeSTaskDropReq(void* buf, int32_t bufLen, STaskDropReq* pReq);
3717

3718
typedef enum {
3719
  TASK_NOTIFY_FINISHED = 1,
3720
} ETaskNotifyType;
3721

3722
typedef struct {
3723
  SMsgHead        header;
3724
  uint64_t        sId;
3725
  uint64_t        queryId;
3726
  uint64_t        clientId;
3727
  uint64_t        taskId;
3728
  int64_t         refId;
3729
  int32_t         execId;
3730
  ETaskNotifyType type;
3731
} STaskNotifyReq;
3732

3733
int32_t tSerializeSTaskNotifyReq(void* buf, int32_t bufLen, STaskNotifyReq* pReq);
3734
int32_t tDeserializeSTaskNotifyReq(void* buf, int32_t bufLen, STaskNotifyReq* pReq);
3735

3736
int32_t tSerializeSQueryTableRsp(void* buf, int32_t bufLen, SQueryTableRsp* pRsp);
3737
int32_t tDeserializeSQueryTableRsp(void* buf, int32_t bufLen, SQueryTableRsp* pRsp);
3738

3739
typedef struct {
3740
  int32_t code;
3741
} STaskDropRsp;
3742

3743
#define STREAM_TRIGGER_AT_ONCE                 1
3744
#define STREAM_TRIGGER_WINDOW_CLOSE            2
3745
#define STREAM_TRIGGER_MAX_DELAY               3
3746
#define STREAM_TRIGGER_FORCE_WINDOW_CLOSE      4
3747
#define STREAM_TRIGGER_CONTINUOUS_WINDOW_CLOSE 5
3748

3749
#define STREAM_DEFAULT_IGNORE_EXPIRED 1
3750
#define STREAM_FILL_HISTORY_ON        1
3751
#define STREAM_FILL_HISTORY_OFF       0
3752
#define STREAM_DEFAULT_FILL_HISTORY   STREAM_FILL_HISTORY_OFF
3753
#define STREAM_DEFAULT_IGNORE_UPDATE  1
3754
#define STREAM_CREATE_STABLE_TRUE     1
3755
#define STREAM_CREATE_STABLE_FALSE    0
3756

3757
typedef struct SVgroupVer {
3758
  int32_t vgId;
3759
  int64_t ver;
3760
} SVgroupVer;
3761

3762
typedef struct STaskNotifyEventStat {
3763
  int64_t notifyEventAddTimes;     // call times of add function
3764
  int64_t notifyEventAddElems;     // elements added by add function
3765
  double  notifyEventAddCostSec;   // time cost of add function
3766
  int64_t notifyEventPushTimes;    // call times of push function
3767
  int64_t notifyEventPushElems;    // elements pushed by push function
3768
  double  notifyEventPushCostSec;  // time cost of push function
3769
  int64_t notifyEventPackTimes;    // call times of pack function
3770
  int64_t notifyEventPackElems;    // elements packed by pack function
3771
  double  notifyEventPackCostSec;  // time cost of pack function
3772
  int64_t notifyEventSendTimes;    // call times of send function
3773
  int64_t notifyEventSendElems;    // elements sent by send function
3774
  double  notifyEventSendCostSec;  // time cost of send function
3775
  int64_t notifyEventHoldElems;    // elements hold due to watermark
3776
} STaskNotifyEventStat;
3777

3778
enum {
3779
  TOPIC_SUB_TYPE__DB = 1,
3780
  TOPIC_SUB_TYPE__TABLE,
3781
  TOPIC_SUB_TYPE__COLUMN,
3782
};
3783

3784
#define DEFAULT_MAX_POLL_INTERVAL  300000
3785
#define DEFAULT_SESSION_TIMEOUT    12000
3786
#define DEFAULT_MAX_POLL_WAIT_TIME 1000
3787
#define DEFAULT_MIN_POLL_ROWS      4096
3788

3789
typedef struct {
3790
  char   name[TSDB_TOPIC_FNAME_LEN];  // accout.topic
3791
  int8_t igExists;
3792
  int8_t subType;
3793
  int8_t withMeta;
3794
  char*  sql;
3795
  char   subDbName[TSDB_DB_FNAME_LEN];
3796
  char*  ast;
3797
  char   subStbName[TSDB_TABLE_FNAME_LEN];
3798
  int8_t reload;
3799
} SCMCreateTopicReq;
3800

3801
int32_t tSerializeSCMCreateTopicReq(void* buf, int32_t bufLen, const SCMCreateTopicReq* pReq);
3802
int32_t tDeserializeSCMCreateTopicReq(void* buf, int32_t bufLen, SCMCreateTopicReq* pReq);
3803
void    tFreeSCMCreateTopicReq(SCMCreateTopicReq* pReq);
3804

3805
typedef struct {
3806
  int64_t consumerId;
3807
} SMqConsumerRecoverMsg, SMqConsumerClearMsg;
3808

3809
typedef struct {
3810
  int64_t consumerId;
3811
  char    cgroup[TSDB_CGROUP_LEN];
3812
  char    clientId[TSDB_CLIENT_ID_LEN];
3813
  char    user[TSDB_USER_LEN];
3814
  char    fqdn[TSDB_FQDN_LEN];
3815
  SArray* topicNames;  // SArray<char**>
3816

3817
  int8_t  withTbName;
3818
  int8_t  autoCommit;
3819
  int32_t autoCommitInterval;
3820
  int8_t  resetOffsetCfg;
3821
  int8_t  enableReplay;
3822
  int8_t  enableBatchMeta;
3823
  int32_t sessionTimeoutMs;
3824
  int32_t maxPollIntervalMs;
3825
} SCMSubscribeReq;
3826

3827
static FORCE_INLINE int32_t tSerializeSCMSubscribeReq(void** buf, const SCMSubscribeReq* pReq) {
3828
  int32_t tlen = 0;
316,984✔
3829
  tlen += taosEncodeFixedI64(buf, pReq->consumerId);
316,984✔
3830
  tlen += taosEncodeString(buf, pReq->cgroup);
316,984✔
3831
  tlen += taosEncodeString(buf, pReq->clientId);
316,984✔
3832

3833
  int32_t topicNum = taosArrayGetSize(pReq->topicNames);
316,984✔
3834
  tlen += taosEncodeFixedI32(buf, topicNum);
316,984✔
3835

3836
  for (int32_t i = 0; i < topicNum; i++) {
438,030✔
3837
    tlen += taosEncodeString(buf, (char*)taosArrayGetP(pReq->topicNames, i));
242,092✔
3838
  }
3839

3840
  tlen += taosEncodeFixedI8(buf, pReq->withTbName);
316,984✔
3841
  tlen += taosEncodeFixedI8(buf, pReq->autoCommit);
316,984✔
3842
  tlen += taosEncodeFixedI32(buf, pReq->autoCommitInterval);
316,984✔
3843
  tlen += taosEncodeFixedI8(buf, pReq->resetOffsetCfg);
316,984✔
3844
  tlen += taosEncodeFixedI8(buf, pReq->enableReplay);
316,984✔
3845
  tlen += taosEncodeFixedI8(buf, pReq->enableBatchMeta);
316,984✔
3846
  tlen += taosEncodeFixedI32(buf, pReq->sessionTimeoutMs);
316,984✔
3847
  tlen += taosEncodeFixedI32(buf, pReq->maxPollIntervalMs);
316,984✔
3848
  tlen += taosEncodeString(buf, pReq->user);
316,984✔
3849
  tlen += taosEncodeString(buf, pReq->fqdn);
316,984✔
3850

3851
  return tlen;
316,984✔
3852
}
3853

3854
static FORCE_INLINE int32_t tDeserializeSCMSubscribeReq(void* buf, SCMSubscribeReq* pReq, int32_t len) {
3855
  void* start = buf;
131,678✔
3856
  buf = taosDecodeFixedI64(buf, &pReq->consumerId);
131,678✔
3857
  buf = taosDecodeStringTo(buf, pReq->cgroup);
131,678✔
3858
  buf = taosDecodeStringTo(buf, pReq->clientId);
131,678✔
3859

3860
  int32_t topicNum = 0;
131,678✔
3861
  buf = taosDecodeFixedI32(buf, &topicNum);
131,678✔
3862

3863
  pReq->topicNames = taosArrayInit(topicNum, sizeof(void*));
131,678✔
3864
  if (pReq->topicNames == NULL) {
131,678✔
3865
    return terrno;
×
3866
  }
3867
  for (int32_t i = 0; i < topicNum; i++) {
186,526✔
3868
    char* name = NULL;
54,848✔
3869
    buf = taosDecodeString(buf, &name);
54,848✔
3870
    if (taosArrayPush(pReq->topicNames, &name) == NULL) {
109,696✔
3871
      return terrno;
×
3872
    }
3873
  }
3874

3875
  buf = taosDecodeFixedI8(buf, &pReq->withTbName);
131,678✔
3876
  buf = taosDecodeFixedI8(buf, &pReq->autoCommit);
131,678✔
3877
  buf = taosDecodeFixedI32(buf, &pReq->autoCommitInterval);
131,678✔
3878
  buf = taosDecodeFixedI8(buf, &pReq->resetOffsetCfg);
131,678✔
3879
  buf = taosDecodeFixedI8(buf, &pReq->enableReplay);
131,678✔
3880
  buf = taosDecodeFixedI8(buf, &pReq->enableBatchMeta);
131,678✔
3881
  if ((char*)buf - (char*)start < len) {
131,678✔
3882
    buf = taosDecodeFixedI32(buf, &pReq->sessionTimeoutMs);
131,678✔
3883
    buf = taosDecodeFixedI32(buf, &pReq->maxPollIntervalMs);
131,678✔
3884
    buf = taosDecodeStringTo(buf, pReq->user);
131,678✔
3885
    buf = taosDecodeStringTo(buf, pReq->fqdn);
263,356✔
3886
  } else {
3887
    pReq->sessionTimeoutMs = DEFAULT_SESSION_TIMEOUT;
×
3888
    pReq->maxPollIntervalMs = DEFAULT_MAX_POLL_INTERVAL;
×
3889
  }
3890

3891
  return 0;
131,678✔
3892
}
3893

3894
typedef struct {
3895
  char    key[TSDB_SUBSCRIBE_KEY_LEN];
3896
  SArray* removedConsumers;  // SArray<int64_t>
3897
  SArray* newConsumers;      // SArray<int64_t>
3898
} SMqRebInfo;
3899

3900
static FORCE_INLINE SMqRebInfo* tNewSMqRebSubscribe(const char* key) {
3901
  SMqRebInfo* pRebInfo = (SMqRebInfo*)taosMemoryCalloc(1, sizeof(SMqRebInfo));
99,959✔
3902
  if (pRebInfo == NULL) {
99,959✔
3903
    return NULL;
×
3904
  }
3905
  tstrncpy(pRebInfo->key, key, TSDB_SUBSCRIBE_KEY_LEN);
99,959✔
3906
  pRebInfo->removedConsumers = taosArrayInit(0, sizeof(int64_t));
99,959✔
3907
  if (pRebInfo->removedConsumers == NULL) {
99,959✔
3908
    goto _err;
×
3909
  }
3910
  pRebInfo->newConsumers = taosArrayInit(0, sizeof(int64_t));
99,959✔
3911
  if (pRebInfo->newConsumers == NULL) {
99,959✔
3912
    goto _err;
×
3913
  }
3914
  return pRebInfo;
99,959✔
3915
_err:
×
3916
  taosArrayDestroy(pRebInfo->removedConsumers);
×
3917
  taosArrayDestroy(pRebInfo->newConsumers);
×
3918
  taosMemoryFreeClear(pRebInfo);
×
3919
  return NULL;
×
3920
}
3921

3922
typedef struct {
3923
  int64_t streamId;
3924
  int64_t checkpointId;
3925
  char    streamName[TSDB_STREAM_FNAME_LEN];
3926
} SMStreamDoCheckpointMsg;
3927

3928
typedef struct {
3929
  int64_t status;
3930
} SMVSubscribeRsp;
3931

3932
typedef struct {
3933
  char    name[TSDB_TOPIC_FNAME_LEN];
3934
  int8_t  igNotExists;
3935
  int32_t sqlLen;
3936
  char*   sql;
3937
  int8_t  force;
3938
} SMDropTopicReq;
3939

3940
int32_t tSerializeSMDropTopicReq(void* buf, int32_t bufLen, SMDropTopicReq* pReq);
3941
int32_t tDeserializeSMDropTopicReq(void* buf, int32_t bufLen, SMDropTopicReq* pReq);
3942
void    tFreeSMDropTopicReq(SMDropTopicReq* pReq);
3943

3944
typedef struct {
3945
  char    name[TSDB_TOPIC_FNAME_LEN];
3946
  int8_t  igNotExists;
3947
  int32_t sqlLen;
3948
  char*   sql;
3949
} SMReloadTopicReq;
3950

3951
int32_t tSerializeSMReloadTopicReq(void* buf, int32_t bufLen, SMReloadTopicReq* pReq);
3952
int32_t tDeserializeSMReloadTopicReq(void* buf, int32_t bufLen, SMReloadTopicReq* pReq);
3953
void    tFreeSMReloadTopicReq(SMReloadTopicReq* pReq);
3954

3955
typedef struct {
3956
  char   topic[TSDB_TOPIC_FNAME_LEN];
3957
  char   cgroup[TSDB_CGROUP_LEN];
3958
  int8_t igNotExists;
3959
  int8_t force;
3960
} SMDropCgroupReq;
3961

3962
int32_t tSerializeSMDropCgroupReq(void* buf, int32_t bufLen, SMDropCgroupReq* pReq);
3963
int32_t tDeserializeSMDropCgroupReq(void* buf, int32_t bufLen, SMDropCgroupReq* pReq);
3964

3965
typedef struct {
3966
  int8_t reserved;
3967
} SMDropCgroupRsp;
3968

3969
typedef struct {
3970
  char    name[TSDB_TABLE_FNAME_LEN];
3971
  int8_t  alterType;
3972
  SSchema schema;
3973
} SAlterTopicReq;
3974

3975
typedef struct {
3976
  SMsgHead head;
3977
  char     name[TSDB_TABLE_FNAME_LEN];
3978
  int64_t  tuid;
3979
  int32_t  sverson;
3980
  int32_t  execLen;
3981
  char*    executor;
3982
  int32_t  sqlLen;
3983
  char*    sql;
3984
} SDCreateTopicReq;
3985

3986
typedef struct {
3987
  SMsgHead head;
3988
  char     name[TSDB_TABLE_FNAME_LEN];
3989
  int64_t  tuid;
3990
} SDDropTopicReq;
3991

3992
typedef struct {
3993
  char*      name;
3994
  int64_t    uid;
3995
  int64_t    interval[2];
3996
  int8_t     intervalUnit;
3997
  int16_t    nFuncs;
3998
  col_id_t*  funcColIds;  // column ids specified by user
3999
  func_id_t* funcIds;     // function ids specified by user
4000
} SRSmaParam;
4001

4002
int32_t tEncodeSRSmaParam(SEncoder* pCoder, const SRSmaParam* pRSmaParam);
4003
int32_t tDecodeSRSmaParam(SDecoder* pCoder, SRSmaParam* pRSmaParam);
4004

4005
// TDMT_VND_CREATE_STB ==============
4006
typedef struct SVCreateStbReq {
4007
  char*           name;
4008
  tb_uid_t        suid;
4009
  int8_t          rollup;
4010
  SSchemaWrapper  schemaRow;
4011
  SSchemaWrapper  schemaTag;
4012
  SRSmaParam      rsmaParam;
4013
  int32_t         alterOriDataLen;
4014
  void*           alterOriData;
4015
  int8_t          source;
4016
  int8_t          colCmpred;
4017
  SColCmprWrapper colCmpr;
4018
  int64_t         keep;
4019
  SExtSchema*     pExtSchemas;
4020
  int8_t          virtualStb;
4021
} SVCreateStbReq;
4022

4023
int tEncodeSVCreateStbReq(SEncoder* pCoder, const SVCreateStbReq* pReq);
4024
int tDecodeSVCreateStbReq(SDecoder* pCoder, SVCreateStbReq* pReq);
4025

4026
// TDMT_VND_DROP_STB ==============
4027
typedef struct SVDropStbReq {
4028
  char*    name;
4029
  tb_uid_t suid;
4030
} SVDropStbReq;
4031

4032
int32_t tEncodeSVDropStbReq(SEncoder* pCoder, const SVDropStbReq* pReq);
4033
int32_t tDecodeSVDropStbReq(SDecoder* pCoder, SVDropStbReq* pReq);
4034

4035
// TDMT_VND_CREATE_TABLE ==============
4036
#define TD_CREATE_IF_NOT_EXISTS       0x1
4037
#define TD_CREATE_NORMAL_TB_IN_STREAM 0x2
4038
#define TD_CREATE_SUB_TB_IN_STREAM    0x4
4039
typedef struct SVCreateTbReq {
4040
  int32_t  flags;
4041
  char*    name;
4042
  tb_uid_t uid;
4043
  int64_t  btime;
4044
  int32_t  ttl;
4045
  int32_t  commentLen;
4046
  char*    comment;
4047
  int8_t   type;
4048
  union {
4049
    struct {
4050
      char*    stbName;  // super table name
4051
      uint8_t  tagNum;
4052
      tb_uid_t suid;
4053
      SArray*  tagName;
4054
      uint8_t* pTag;
4055
    } ctb;
4056
    struct {
4057
      SSchemaWrapper schemaRow;
4058
    } ntb;
4059
  };
4060
  int32_t         sqlLen;
4061
  char*           sql;
4062
  SColCmprWrapper colCmpr;
4063
  SExtSchema*     pExtSchemas;
4064
  SColRefWrapper  colRef;  // col reference for virtual table
4065
} SVCreateTbReq;
4066

4067
int  tEncodeSVCreateTbReq(SEncoder* pCoder, const SVCreateTbReq* pReq);
4068
int  tDecodeSVCreateTbReq(SDecoder* pCoder, SVCreateTbReq* pReq);
4069
void tDestroySVCreateTbReq(SVCreateTbReq* pReq, int32_t flags);
4070
void tDestroySVSubmitCreateTbReq(SVCreateTbReq *pReq, int32_t flags);
4071

4072
static FORCE_INLINE void tdDestroySVCreateTbReq(SVCreateTbReq* req) {
4073
  if (NULL == req) {
2,147,483,647✔
4074
    return;
2,092,572,420✔
4075
  }
4076

4077
  taosMemoryFreeClear(req->sql);
56,872,083✔
4078
  taosMemoryFreeClear(req->name);
56,872,508✔
4079
  taosMemoryFreeClear(req->comment);
56,865,365✔
4080
  if (req->type == TSDB_CHILD_TABLE || req->type == TSDB_VIRTUAL_CHILD_TABLE) {
56,865,707✔
4081
    taosMemoryFreeClear(req->ctb.pTag);
54,428,593✔
4082
    taosMemoryFreeClear(req->ctb.stbName);
54,424,943✔
4083
    taosArrayDestroy(req->ctb.tagName);
54,421,943✔
4084
    req->ctb.tagName = NULL;
54,410,328✔
4085
  } else if (req->type == TSDB_NORMAL_TABLE || req->type == TSDB_VIRTUAL_NORMAL_TABLE) {
2,441,727✔
4086
    taosMemoryFreeClear(req->ntb.schemaRow.pSchema);
2,441,727✔
4087
  }
4088
  taosMemoryFreeClear(req->colCmpr.pColCmpr);
56,858,140✔
4089
  taosMemoryFreeClear(req->pExtSchemas);
56,871,108✔
4090
  taosMemoryFreeClear(req->colRef.pColRef);
56,869,221✔
4091
}
4092

4093
typedef struct {
4094
  int32_t nReqs;
4095
  union {
4096
    SVCreateTbReq* pReqs;
4097
    SArray*        pArray;
4098
  };
4099
  int8_t source;  // TD_REQ_FROM_TAOX-taosX or TD_REQ_FROM_APP-taosClient
4100
} SVCreateTbBatchReq;
4101

4102
int  tEncodeSVCreateTbBatchReq(SEncoder* pCoder, const SVCreateTbBatchReq* pReq);
4103
int  tDecodeSVCreateTbBatchReq(SDecoder* pCoder, SVCreateTbBatchReq* pReq);
4104
void tDeleteSVCreateTbBatchReq(SVCreateTbBatchReq* pReq);
4105

4106
typedef struct {
4107
  int32_t        code;
4108
  STableMetaRsp* pMeta;
4109
} SVCreateTbRsp, SVUpdateTbRsp;
4110

4111
int  tEncodeSVCreateTbRsp(SEncoder* pCoder, const SVCreateTbRsp* pRsp);
4112
int  tDecodeSVCreateTbRsp(SDecoder* pCoder, SVCreateTbRsp* pRsp);
4113
void tFreeSVCreateTbRsp(void* param);
4114

4115
int32_t tSerializeSVCreateTbReq(void** buf, SVCreateTbReq* pReq);
4116
void*   tDeserializeSVCreateTbReq(void* buf, SVCreateTbReq* pReq);
4117

4118
typedef struct {
4119
  int32_t nRsps;
4120
  union {
4121
    SVCreateTbRsp* pRsps;
4122
    SArray*        pArray;
4123
  };
4124
} SVCreateTbBatchRsp;
4125

4126
int tEncodeSVCreateTbBatchRsp(SEncoder* pCoder, const SVCreateTbBatchRsp* pRsp);
4127
int tDecodeSVCreateTbBatchRsp(SDecoder* pCoder, SVCreateTbBatchRsp* pRsp);
4128

4129
// int32_t tSerializeSVCreateTbBatchRsp(void* buf, int32_t bufLen, SVCreateTbBatchRsp* pRsp);
4130
// int32_t tDeserializeSVCreateTbBatchRsp(void* buf, int32_t bufLen, SVCreateTbBatchRsp* pRsp);
4131

4132
// TDMT_VND_DROP_TABLE =================
4133
typedef struct {
4134
  char*    name;
4135
  uint64_t suid;  // for tmq in wal format
4136
  int64_t  uid;
4137
  int8_t   igNotExists;
4138
  int8_t   isVirtual;
4139
} SVDropTbReq;
4140

4141
typedef struct {
4142
  int32_t code;
4143
} SVDropTbRsp;
4144

4145
typedef struct {
4146
  int32_t nReqs;
4147
  union {
4148
    SVDropTbReq* pReqs;
4149
    SArray*      pArray;
4150
  };
4151
} SVDropTbBatchReq;
4152

4153
int32_t tEncodeSVDropTbBatchReq(SEncoder* pCoder, const SVDropTbBatchReq* pReq);
4154
int32_t tDecodeSVDropTbBatchReq(SDecoder* pCoder, SVDropTbBatchReq* pReq);
4155

4156
typedef struct {
4157
  int32_t nRsps;
4158
  union {
4159
    SVDropTbRsp* pRsps;
4160
    SArray*      pArray;
4161
  };
4162
} SVDropTbBatchRsp;
4163

4164
int32_t tEncodeSVDropTbBatchRsp(SEncoder* pCoder, const SVDropTbBatchRsp* pRsp);
4165
int32_t tDecodeSVDropTbBatchRsp(SDecoder* pCoder, SVDropTbBatchRsp* pRsp);
4166

4167
// TDMT_VND_ALTER_TABLE =====================
4168
typedef struct SMultiTagUpateVal {
4169
  char*    tagName;
4170
  int32_t  colId;
4171
  int8_t   tagType;
4172
  int8_t   tagFree;
4173
  uint32_t nTagVal;
4174
  uint8_t* pTagVal;
4175
  int8_t   isNull;
4176
  SArray*  pTagArray;
4177
} SMultiTagUpateVal;
4178
typedef struct SVAlterTbReq {
4179
  char*   tbName;
4180
  int8_t  action;
4181
  char*   colName;
4182
  int32_t colId;
4183
  // TSDB_ALTER_TABLE_ADD_COLUMN
4184
  int8_t  type;
4185
  int8_t  flags;
4186
  int32_t bytes;
4187
  // TSDB_ALTER_TABLE_DROP_COLUMN
4188
  // TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES
4189
  int8_t   colModType;
4190
  int32_t  colModBytes;
4191
  char*    colNewName;  // TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME
4192
  char*    tagName;     // TSDB_ALTER_TABLE_UPDATE_TAG_VAL
4193
  int8_t   isNull;
4194
  int8_t   tagType;
4195
  int8_t   tagFree;
4196
  uint32_t nTagVal;
4197
  uint8_t* pTagVal;
4198
  SArray*  pTagArray;
4199
  // TSDB_ALTER_TABLE_UPDATE_OPTIONS
4200
  int8_t   updateTTL;
4201
  int32_t  newTTL;
4202
  int32_t  newCommentLen;
4203
  char*    newComment;
4204
  int64_t  ctimeMs;    // fill by vnode
4205
  int8_t   source;     // TD_REQ_FROM_TAOX-taosX or TD_REQ_FROM_APP-taosClient
4206
  uint32_t compress;   // TSDB_ALTER_TABLE_UPDATE_COLUMN_COMPRESS
4207
  SArray*  pMultiTag;  // TSDB_ALTER_TABLE_ADD_MULTI_TAGS
4208
  // for Add column
4209
  STypeMod typeMod;
4210
  // TSDB_ALTER_TABLE_ALTER_COLUMN_REF
4211
  char* refDbName;
4212
  char* refTbName;
4213
  char* refColName;
4214
  // TSDB_ALTER_TABLE_REMOVE_COLUMN_REF
4215
} SVAlterTbReq;
4216

4217
int32_t tEncodeSVAlterTbReq(SEncoder* pEncoder, const SVAlterTbReq* pReq);
4218
int32_t tDecodeSVAlterTbReq(SDecoder* pDecoder, SVAlterTbReq* pReq);
4219
int32_t tDecodeSVAlterTbReqSetCtime(SDecoder* pDecoder, SVAlterTbReq* pReq, int64_t ctimeMs);
4220
void    tfreeMultiTagUpateVal(void* pMultiTag);
4221

4222
typedef struct {
4223
  int32_t        code;
4224
  STableMetaRsp* pMeta;
4225
} SVAlterTbRsp;
4226

4227
int32_t tEncodeSVAlterTbRsp(SEncoder* pEncoder, const SVAlterTbRsp* pRsp);
4228
int32_t tDecodeSVAlterTbRsp(SDecoder* pDecoder, SVAlterTbRsp* pRsp);
4229
// ======================
4230

4231
typedef struct {
4232
  SMsgHead head;
4233
  int64_t  uid;
4234
  int32_t  tid;
4235
  int16_t  tversion;
4236
  int16_t  colId;
4237
  int8_t   type;
4238
  int16_t  bytes;
4239
  int32_t  tagValLen;
4240
  int16_t  numOfTags;
4241
  int32_t  schemaLen;
4242
  char     data[];
4243
} SUpdateTagValReq;
4244

4245
typedef struct {
4246
  SMsgHead head;
4247
} SUpdateTagValRsp;
4248

4249
typedef struct {
4250
  SMsgHead head;
4251
} SVShowTablesReq;
4252

4253
typedef struct {
4254
  SMsgHead head;
4255
  int32_t  id;
4256
} SVShowTablesFetchReq;
4257

4258
typedef struct {
4259
  int64_t useconds;
4260
  int8_t  completed;  // all results are returned to client
4261
  int8_t  precision;
4262
  int8_t  compressed;
4263
  int32_t compLen;
4264
  int32_t numOfRows;
4265
  char    data[];
4266
} SVShowTablesFetchRsp;
4267

4268
typedef struct {
4269
  int64_t consumerId;
4270
  int32_t epoch;
4271
  char    cgroup[TSDB_CGROUP_LEN];
4272
} SMqAskEpReq;
4273

4274
typedef struct {
4275
  int32_t key;
4276
  int32_t valueLen;
4277
  void*   value;
4278
} SKv;
4279

4280
typedef struct {
4281
  int64_t tscRid;
4282
  int8_t  connType;
4283
} SClientHbKey;
4284

4285
typedef struct {
4286
  int64_t tid;
4287
  char    status[TSDB_JOB_STATUS_LEN];
4288
} SQuerySubDesc;
4289

4290
typedef struct {
4291
  char     sql[TSDB_SHOW_SQL_LEN];
4292
  uint64_t queryId;
4293
  int64_t  useconds;
4294
  int64_t  stime;  // timestamp precision ms
4295
  int64_t  reqRid;
4296
  bool     stableQuery;
4297
  bool     isSubQuery;
4298
  char     fqdn[TSDB_FQDN_LEN];
4299
  int32_t  subPlanNum;
4300
  SArray*  subDesc;  // SArray<SQuerySubDesc>
4301
} SQueryDesc;
4302

4303
typedef struct {
4304
  uint32_t connId;
4305
  SArray*  queryDesc;  // SArray<SQueryDesc>
4306
} SQueryHbReqBasic;
4307

4308
typedef struct {
4309
  uint32_t connId;
4310
  uint64_t killRid;
4311
  int32_t  totalDnodes;
4312
  int32_t  onlineDnodes;
4313
  int8_t   killConnection;
4314
  int8_t   align[3];
4315
  SEpSet   epSet;
4316
  SArray*  pQnodeList;
4317
} SQueryHbRspBasic;
4318

4319
typedef struct SAppClusterSummary {
4320
  uint64_t numOfInsertsReq;
4321
  uint64_t numOfInsertRows;
4322
  uint64_t insertElapsedTime;
4323
  uint64_t insertBytes;  // submit to tsdb since launched.
4324

4325
  uint64_t fetchBytes;
4326
  uint64_t numOfQueryReq;
4327
  uint64_t queryElapsedTime;
4328
  uint64_t numOfSlowQueries;
4329
  uint64_t totalRequests;
4330
  uint64_t currentRequests;  // the number of SRequestObj
4331
} SAppClusterSummary;
4332

4333
typedef struct {
4334
  int64_t            appId;
4335
  int32_t            pid;
4336
  char               name[TSDB_APP_NAME_LEN];
4337
  int64_t            startTime;
4338
  SAppClusterSummary summary;
4339
} SAppHbReq;
4340

4341
typedef struct {
4342
  SClientHbKey      connKey;
4343
  int64_t           clusterId;
4344
  SAppHbReq         app;
4345
  SQueryHbReqBasic* query;
4346
  SHashObj*         info;  // hash<Skv.key, Skv>
4347
  char              userApp[TSDB_APP_NAME_LEN];
4348
  uint32_t          userIp;
4349
  SIpRange          userDualIp;
4350
  char              sVer[TSDB_VERSION_LEN];
4351
  char              cInfo[CONNECTOR_INFO_LEN];
4352
} SClientHbReq;
4353

4354
typedef struct {
4355
  int64_t reqId;
4356
  SArray* reqs;  // SArray<SClientHbReq>
4357
  int64_t ipWhiteListVer;
4358
} SClientHbBatchReq;
4359

4360
typedef struct {
4361
  SClientHbKey      connKey;
4362
  int32_t           status;
4363
  SQueryHbRspBasic* query;
4364
  SArray*           info;  // Array<Skv>
4365
} SClientHbRsp;
4366

4367
typedef struct {
4368
  int64_t       reqId;
4369
  int64_t       rspId;
4370
  int32_t       svrTimestamp;
4371
  SArray*       rsps;  // SArray<SClientHbRsp>
4372
  SMonitorParas monitorParas;
4373
  int8_t        enableAuditDelete;
4374
  int8_t        enableStrongPass;
4375
} SClientHbBatchRsp;
4376

4377
static FORCE_INLINE uint32_t hbKeyHashFunc(const char* key, uint32_t keyLen) { return taosIntHash_64(key, keyLen); }
56,604,525✔
4378

4379
static FORCE_INLINE void tFreeReqKvHash(SHashObj* info) {
4380
  void* pIter = taosHashIterate(info, NULL);
36,567,998✔
4381
  while (pIter != NULL) {
79,534,314✔
4382
    SKv* kv = (SKv*)pIter;
42,966,253✔
4383
    taosMemoryFreeClear(kv->value);
42,966,253✔
4384
    pIter = taosHashIterate(info, pIter);
42,966,234✔
4385
  }
4386
}
36,568,061✔
4387

4388
static FORCE_INLINE void tFreeClientHbQueryDesc(void* pDesc) {
20,637,659✔
4389
  SQueryDesc* desc = (SQueryDesc*)pDesc;
20,637,659✔
4390
  if (desc->subDesc) {
20,637,659✔
4391
    taosArrayDestroy(desc->subDesc);
17,879,565✔
4392
    desc->subDesc = NULL;
17,879,076✔
4393
  }
4394
}
20,638,042✔
4395

4396
static FORCE_INLINE void tFreeClientHbReq(void* pReq) {
44,836,747✔
4397
  SClientHbReq* req = (SClientHbReq*)pReq;
48,010,567✔
4398
  if (req->query) {
48,010,567✔
4399
    if (req->query->queryDesc) {
40,056,715✔
4400
      taosArrayDestroyEx(req->query->queryDesc, tFreeClientHbQueryDesc);
19,013,840✔
4401
    }
4402
    taosMemoryFreeClear(req->query);
40,056,715✔
4403
  }
4404

4405
  if (req->info) {
48,011,333✔
4406
    tFreeReqKvHash(req->info);
36,568,061✔
4407
    taosHashCleanup(req->info);
36,568,061✔
4408
    req->info = NULL;
36,568,045✔
4409
  }
4410
}
24,549,166✔
4411

4412
int32_t tSerializeSClientHbBatchReq(void* buf, int32_t bufLen, const SClientHbBatchReq* pReq);
4413
int32_t tDeserializeSClientHbBatchReq(void* buf, int32_t bufLen, SClientHbBatchReq* pReq);
4414

4415
static FORCE_INLINE void tFreeClientHbBatchReq(void* pReq) {
4416
  if (pReq == NULL) return;
19,426,264✔
4417
  SClientHbBatchReq* req = (SClientHbBatchReq*)pReq;
19,426,264✔
4418
  taosArrayDestroyEx(req->reqs, tFreeClientHbReq);
19,426,264✔
4419
  taosMemoryFree(pReq);
19,426,264✔
4420
}
4421

4422
static FORCE_INLINE void tFreeClientKv(void* pKv) {
15,781,926✔
4423
  SKv* kv = (SKv*)pKv;
15,781,926✔
4424
  if (kv) {
15,781,926✔
4425
    taosMemoryFreeClear(kv->value);
15,781,926✔
4426
  }
4427
}
15,782,143✔
4428

4429
static FORCE_INLINE void tFreeClientHbRsp(void* pRsp) {
44,644,944✔
4430
  SClientHbRsp* rsp = (SClientHbRsp*)pRsp;
44,644,944✔
4431
  if (rsp->query) {
44,644,944✔
4432
    taosArrayDestroy(rsp->query->pQnodeList);
39,892,137✔
4433
    taosMemoryFreeClear(rsp->query);
39,890,903✔
4434
  }
4435
  if (rsp->info) taosArrayDestroyEx(rsp->info, tFreeClientKv);
44,648,823✔
4436
}
23,272,198✔
4437

4438
static FORCE_INLINE void tFreeClientHbBatchRsp(void* pRsp) {
4439
  SClientHbBatchRsp* rsp = (SClientHbBatchRsp*)pRsp;
36,716,918✔
4440
  taosArrayDestroyEx(rsp->rsps, tFreeClientHbRsp);
36,716,918✔
4441
}
36,716,968✔
4442

4443
int32_t tSerializeSClientHbBatchRsp(void* buf, int32_t bufLen, const SClientHbBatchRsp* pBatchRsp);
4444
int32_t tDeserializeSClientHbBatchRsp(void* buf, int32_t bufLen, SClientHbBatchRsp* pBatchRsp);
4445
void    tFreeSClientHbBatchRsp(SClientHbBatchRsp* pBatchRsp);
4446

4447
static FORCE_INLINE int32_t tEncodeSKv(SEncoder* pEncoder, const SKv* pKv) {
4448
  TAOS_CHECK_RETURN(tEncodeI32(pEncoder, pKv->key));
115,818,126✔
4449
  TAOS_CHECK_RETURN(tEncodeI32(pEncoder, pKv->valueLen));
115,818,954✔
4450
  TAOS_CHECK_RETURN(tEncodeBinary(pEncoder, (uint8_t*)pKv->value, pKv->valueLen));
115,819,368✔
4451
  return 0;
57,909,794✔
4452
}
4453

4454
static FORCE_INLINE int32_t tDecodeSKv(SDecoder* pDecoder, SKv* pKv) {
4455
  TAOS_CHECK_RETURN(tDecodeI32(pDecoder, &pKv->key));
55,913,772✔
4456
  TAOS_CHECK_RETURN(tDecodeI32(pDecoder, &pKv->valueLen));
55,913,878✔
4457
  pKv->value = taosMemoryMalloc(pKv->valueLen + 1);
27,956,939✔
4458
  if (pKv->value == NULL) {
27,956,939✔
4459
    TAOS_CHECK_RETURN(TSDB_CODE_OUT_OF_MEMORY);
×
4460
  }
4461
  TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, (char*)pKv->value));
27,956,939✔
4462
  return 0;
27,956,939✔
4463
}
4464

4465
static FORCE_INLINE int32_t tEncodeSClientHbKey(SEncoder* pEncoder, const SClientHbKey* pKey) {
4466
  TAOS_CHECK_RETURN(tEncodeI64(pEncoder, pKey->tscRid));
173,721,071✔
4467
  TAOS_CHECK_RETURN(tEncodeI8(pEncoder, pKey->connType));
173,718,425✔
4468
  return 0;
86,858,029✔
4469
}
4470

4471
static FORCE_INLINE int32_t tDecodeSClientHbKey(SDecoder* pDecoder, SClientHbKey* pKey) {
4472
  TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &pKey->tscRid));
86,493,755✔
4473
  TAOS_CHECK_RETURN(tDecodeI8(pDecoder, &pKey->connType));
86,493,920✔
4474
  return 0;
43,247,395✔
4475
}
4476

4477
typedef struct {
4478
  int32_t vgId;
4479
  // TODO stas
4480
} SMqReportVgInfo;
4481

4482
static FORCE_INLINE int32_t taosEncodeSMqVgInfo(void** buf, const SMqReportVgInfo* pVgInfo) {
4483
  int32_t tlen = 0;
4484
  tlen += taosEncodeFixedI32(buf, pVgInfo->vgId);
4485
  return tlen;
4486
}
4487

4488
static FORCE_INLINE void* taosDecodeSMqVgInfo(void* buf, SMqReportVgInfo* pVgInfo) {
4489
  buf = taosDecodeFixedI32(buf, &pVgInfo->vgId);
4490
  return buf;
4491
}
4492

4493
typedef struct {
4494
  int32_t epoch;
4495
  int64_t topicUid;
4496
  char    name[TSDB_TOPIC_FNAME_LEN];
4497
  SArray* pVgInfo;  // SArray<SMqHbVgInfo>
4498
} SMqTopicInfo;
4499

4500
static FORCE_INLINE int32_t taosEncodeSMqTopicInfoMsg(void** buf, const SMqTopicInfo* pTopicInfo) {
4501
  int32_t tlen = 0;
4502
  tlen += taosEncodeFixedI32(buf, pTopicInfo->epoch);
4503
  tlen += taosEncodeFixedI64(buf, pTopicInfo->topicUid);
4504
  tlen += taosEncodeString(buf, pTopicInfo->name);
4505
  int32_t sz = taosArrayGetSize(pTopicInfo->pVgInfo);
4506
  tlen += taosEncodeFixedI32(buf, sz);
4507
  for (int32_t i = 0; i < sz; i++) {
4508
    SMqReportVgInfo* pVgInfo = (SMqReportVgInfo*)taosArrayGet(pTopicInfo->pVgInfo, i);
4509
    tlen += taosEncodeSMqVgInfo(buf, pVgInfo);
4510
  }
4511
  return tlen;
4512
}
4513

4514
static FORCE_INLINE void* taosDecodeSMqTopicInfoMsg(void* buf, SMqTopicInfo* pTopicInfo) {
4515
  buf = taosDecodeFixedI32(buf, &pTopicInfo->epoch);
4516
  buf = taosDecodeFixedI64(buf, &pTopicInfo->topicUid);
4517
  buf = taosDecodeStringTo(buf, pTopicInfo->name);
4518
  int32_t sz;
4519
  buf = taosDecodeFixedI32(buf, &sz);
4520
  if ((pTopicInfo->pVgInfo = taosArrayInit(sz, sizeof(SMqReportVgInfo))) == NULL) {
4521
    return NULL;
4522
  }
4523
  for (int32_t i = 0; i < sz; i++) {
4524
    SMqReportVgInfo vgInfo;
4525
    buf = taosDecodeSMqVgInfo(buf, &vgInfo);
4526
    if (taosArrayPush(pTopicInfo->pVgInfo, &vgInfo) == NULL) {
4527
      return NULL;
4528
    }
4529
  }
4530
  return buf;
4531
}
4532

4533
typedef struct {
4534
  int32_t status;  // ask hb endpoint
4535
  int32_t epoch;
4536
  int64_t consumerId;
4537
  SArray* pTopics;  // SArray<SMqHbTopicInfo>
4538
} SMqReportReq;
4539

4540
static FORCE_INLINE int32_t taosEncodeSMqReportMsg(void** buf, const SMqReportReq* pMsg) {
4541
  int32_t tlen = 0;
4542
  tlen += taosEncodeFixedI32(buf, pMsg->status);
4543
  tlen += taosEncodeFixedI32(buf, pMsg->epoch);
4544
  tlen += taosEncodeFixedI64(buf, pMsg->consumerId);
4545
  int32_t sz = taosArrayGetSize(pMsg->pTopics);
4546
  tlen += taosEncodeFixedI32(buf, sz);
4547
  for (int32_t i = 0; i < sz; i++) {
4548
    SMqTopicInfo* topicInfo = (SMqTopicInfo*)taosArrayGet(pMsg->pTopics, i);
4549
    tlen += taosEncodeSMqTopicInfoMsg(buf, topicInfo);
4550
  }
4551
  return tlen;
4552
}
4553

4554
static FORCE_INLINE void* taosDecodeSMqReportMsg(void* buf, SMqReportReq* pMsg) {
4555
  buf = taosDecodeFixedI32(buf, &pMsg->status);
4556
  buf = taosDecodeFixedI32(buf, &pMsg->epoch);
4557
  buf = taosDecodeFixedI64(buf, &pMsg->consumerId);
4558
  int32_t sz;
4559
  buf = taosDecodeFixedI32(buf, &sz);
4560
  if ((pMsg->pTopics = taosArrayInit(sz, sizeof(SMqTopicInfo))) == NULL) {
4561
    return NULL;
4562
  }
4563
  for (int32_t i = 0; i < sz; i++) {
4564
    SMqTopicInfo topicInfo;
4565
    buf = taosDecodeSMqTopicInfoMsg(buf, &topicInfo);
4566
    if (taosArrayPush(pMsg->pTopics, &topicInfo) == NULL) {
4567
      return NULL;
4568
    }
4569
  }
4570
  return buf;
4571
}
4572

4573
typedef struct {
4574
  SMsgHead head;
4575
  int64_t  leftForVer;
4576
  int32_t  vgId;
4577
  int64_t  consumerId;
4578
  char     subKey[TSDB_SUBSCRIBE_KEY_LEN];
4579
} SMqVDeleteReq;
4580

4581
typedef struct {
4582
  int8_t reserved;
4583
} SMqVDeleteRsp;
4584

4585
typedef struct {
4586
  char*   name;
4587
  int8_t  igNotExists;
4588
} SMDropStreamReq;
4589

4590
typedef struct {
4591
  int8_t reserved;
4592
} SMDropStreamRsp;
4593

4594
typedef struct {
4595
  SMsgHead head;
4596
  int64_t  resetRelHalt;  // reset related stream task halt status
4597
  int64_t  streamId;
4598
  int32_t  taskId;
4599
} SVDropStreamTaskReq;
4600

4601
typedef struct {
4602
  int8_t reserved;
4603
} SVDropStreamTaskRsp;
4604

4605
int32_t tSerializeSMDropStreamReq(void* buf, int32_t bufLen, const SMDropStreamReq* pReq);
4606
int32_t tDeserializeSMDropStreamReq(void* buf, int32_t bufLen, SMDropStreamReq* pReq);
4607
void    tFreeMDropStreamReq(SMDropStreamReq* pReq);
4608

4609
typedef struct {
4610
  char*  name;
4611
  int8_t igNotExists;
4612
} SMPauseStreamReq;
4613

4614
int32_t tSerializeSMPauseStreamReq(void* buf, int32_t bufLen, const SMPauseStreamReq* pReq);
4615
int32_t tDeserializeSMPauseStreamReq(void* buf, int32_t bufLen, SMPauseStreamReq* pReq);
4616
void    tFreeMPauseStreamReq(SMPauseStreamReq *pReq);
4617

4618
typedef struct {
4619
  char*  name;
4620
  int8_t igNotExists;
4621
  int8_t igUntreated;
4622
} SMResumeStreamReq;
4623

4624
int32_t tSerializeSMResumeStreamReq(void* buf, int32_t bufLen, const SMResumeStreamReq* pReq);
4625
int32_t tDeserializeSMResumeStreamReq(void* buf, int32_t bufLen, SMResumeStreamReq* pReq);
4626
void    tFreeMResumeStreamReq(SMResumeStreamReq *pReq);
4627

4628
typedef struct {
4629
  char*       name;
4630
  int8_t      calcAll;
4631
  STimeWindow timeRange;
4632
} SMRecalcStreamReq;
4633

4634
int32_t tSerializeSMRecalcStreamReq(void* buf, int32_t bufLen, const SMRecalcStreamReq* pReq);
4635
int32_t tDeserializeSMRecalcStreamReq(void* buf, int32_t bufLen, SMRecalcStreamReq* pReq);
4636
void    tFreeMRecalcStreamReq(SMRecalcStreamReq *pReq);
4637

4638
typedef struct SVndSetKeepVersionReq {
4639
  int64_t keepVersion;
4640
} SVndSetKeepVersionReq;
4641

4642
int32_t tSerializeSVndSetKeepVersionReq(void* buf, int32_t bufLen, SVndSetKeepVersionReq* pReq);
4643
int32_t tDeserializeSVndSetKeepVersionReq(void* buf, int32_t bufLen, SVndSetKeepVersionReq* pReq);
4644

4645
typedef struct SVUpdateCheckpointInfoReq {
4646
  SMsgHead head;
4647
  int64_t  streamId;
4648
  int32_t  taskId;
4649
  int64_t  checkpointId;
4650
  int64_t  checkpointVer;
4651
  int64_t  checkpointTs;
4652
  int32_t  transId;
4653
  int64_t  hStreamId;  // add encode/decode
4654
  int64_t  hTaskId;
4655
  int8_t   dropRelHTask;
4656
} SVUpdateCheckpointInfoReq;
4657

4658
typedef struct {
4659
  int64_t leftForVer;
4660
  int32_t vgId;
4661
  int64_t oldConsumerId;
4662
  int64_t newConsumerId;
4663
  char    subKey[TSDB_SUBSCRIBE_KEY_LEN];
4664
  int8_t  subType;
4665
  int8_t  withMeta;
4666
  char*   qmsg;  // SubPlanToString
4667
  SSchemaWrapper schema;
4668
  int64_t suid;
4669
} SMqRebVgReq;
4670

4671
int32_t tEncodeSMqRebVgReq(SEncoder* pCoder, const SMqRebVgReq* pReq);
4672
int32_t tDecodeSMqRebVgReq(SDecoder* pCoder, SMqRebVgReq* pReq);
4673

4674
// tqOffset
4675
enum {
4676
  TMQ_OFFSET__RESET_NONE = -3,
4677
  TMQ_OFFSET__RESET_EARLIEST = -2,
4678
  TMQ_OFFSET__RESET_LATEST = -1,
4679
  TMQ_OFFSET__LOG = 1,
4680
  TMQ_OFFSET__SNAPSHOT_DATA = 2,
4681
  TMQ_OFFSET__SNAPSHOT_META = 3,
4682
};
4683

4684
enum {
4685
  WITH_DATA = 0,
4686
  WITH_META = 1,
4687
  ONLY_META = 2,
4688
};
4689

4690
#define TQ_OFFSET_VERSION 1
4691

4692
typedef struct {
4693
  int8_t type;
4694
  union {
4695
    // snapshot
4696
    struct {
4697
      int64_t uid;
4698
      int64_t ts;
4699
      SValue  primaryKey;
4700
    };
4701
    // log
4702
    struct {
4703
      int64_t version;
4704
    };
4705
  };
4706
} STqOffsetVal;
4707

4708
static FORCE_INLINE void tqOffsetResetToData(STqOffsetVal* pOffsetVal, int64_t uid, int64_t ts, SValue primaryKey) {
4709
  pOffsetVal->type = TMQ_OFFSET__SNAPSHOT_DATA;
1,737,122✔
4710
  pOffsetVal->uid = uid;
1,736,171✔
4711
  pOffsetVal->ts = ts;
1,737,006✔
4712
  if (IS_VAR_DATA_TYPE(pOffsetVal->primaryKey.type)) {
1,736,858✔
4713
    taosMemoryFree(pOffsetVal->primaryKey.pData);
68✔
4714
  }
4715
  pOffsetVal->primaryKey = primaryKey;
1,735,411✔
4716
}
1,736,442✔
4717

4718
static FORCE_INLINE void tqOffsetResetToMeta(STqOffsetVal* pOffsetVal, int64_t uid) {
4719
  pOffsetVal->type = TMQ_OFFSET__SNAPSHOT_META;
6,708✔
4720
  pOffsetVal->uid = uid;
6,708✔
4721
}
6,708✔
4722

4723
static FORCE_INLINE void tqOffsetResetToLog(STqOffsetVal* pOffsetVal, int64_t ver) {
4724
  pOffsetVal->type = TMQ_OFFSET__LOG;
49,109,384✔
4725
  pOffsetVal->version = ver;
49,110,515✔
4726
}
49,107,641✔
4727

4728
int32_t tEncodeSTqOffsetVal(SEncoder* pEncoder, const STqOffsetVal* pOffsetVal);
4729
int32_t tDecodeSTqOffsetVal(SDecoder* pDecoder, STqOffsetVal* pOffsetVal);
4730
void    tFormatOffset(char* buf, int32_t maxLen, const STqOffsetVal* pVal);
4731
bool    tOffsetEqual(const STqOffsetVal* pLeft, const STqOffsetVal* pRight);
4732
void    tOffsetCopy(STqOffsetVal* pLeft, const STqOffsetVal* pRight);
4733
void    tOffsetDestroy(void* pVal);
4734

4735
typedef struct {
4736
  STqOffsetVal val;
4737
  char         subKey[TSDB_SUBSCRIBE_KEY_LEN];
4738
} STqOffset;
4739

4740
int32_t tEncodeSTqOffset(SEncoder* pEncoder, const STqOffset* pOffset);
4741
int32_t tDecodeSTqOffset(SDecoder* pDecoder, STqOffset* pOffset);
4742
void    tDeleteSTqOffset(void* val);
4743

4744
typedef struct SMqVgOffset {
4745
  int64_t   consumerId;
4746
  STqOffset offset;
4747
} SMqVgOffset;
4748

4749
int32_t tEncodeMqVgOffset(SEncoder* pEncoder, const SMqVgOffset* pOffset);
4750
int32_t tDecodeMqVgOffset(SDecoder* pDecoder, SMqVgOffset* pOffset);
4751

4752
typedef struct {
4753
  char    name[TSDB_TABLE_FNAME_LEN];
4754
  char    stb[TSDB_TABLE_FNAME_LEN];
4755
  int8_t  igExists;
4756
  int8_t  intervalUnit;
4757
  int8_t  slidingUnit;
4758
  int8_t  timezone;  // int8_t is not enough, timezone is unit of second
4759
  int32_t dstVgId;   // for stream
4760
  int64_t interval;
4761
  int64_t offset;
4762
  int64_t sliding;
4763
  int64_t maxDelay;
4764
  int64_t watermark;
4765
  int32_t exprLen;        // strlen + 1
4766
  int32_t tagsFilterLen;  // strlen + 1
4767
  int32_t sqlLen;         // strlen + 1
4768
  int32_t astLen;         // strlen + 1
4769
  char*   expr;
4770
  char*   tagsFilter;
4771
  char*   sql;
4772
  char*   ast;
4773
  int64_t deleteMark;
4774
  int64_t lastTs;
4775
  int64_t normSourceTbUid;  // the Uid of source tb if its a normal table, otherwise 0
4776
  SArray* pVgroupVerList;
4777
  int8_t  recursiveTsma;
4778
  char    baseTsmaName[TSDB_TABLE_FNAME_LEN];  // base tsma name for recursively created tsma
4779
  char*   createStreamReq;
4780
  int32_t streamReqLen;
4781
  char*   dropStreamReq;
4782
  int32_t dropStreamReqLen;
4783
  int64_t uid;
4784
} SMCreateSmaReq;
4785

4786
int32_t tSerializeSMCreateSmaReq(void* buf, int32_t bufLen, SMCreateSmaReq* pReq);
4787
int32_t tDeserializeSMCreateSmaReq(void* buf, int32_t bufLen, SMCreateSmaReq* pReq);
4788
void    tFreeSMCreateSmaReq(SMCreateSmaReq* pReq);
4789

4790
typedef struct {
4791
  char   name[TSDB_TABLE_FNAME_LEN];
4792
  int8_t igNotExists;
4793
  char*   dropStreamReq;
4794
  int32_t dropStreamReqLen;
4795
} SMDropSmaReq;
4796

4797
int32_t tSerializeSMDropSmaReq(void* buf, int32_t bufLen, SMDropSmaReq* pReq);
4798
int32_t tDeserializeSMDropSmaReq(void* buf, int32_t bufLen, SMDropSmaReq* pReq);
4799
void tFreeSMDropSmaReq(SMDropSmaReq *pReq);
4800

4801
typedef struct {
4802
  char name[TSDB_TABLE_NAME_LEN];
4803
  union {
4804
    char tbFName[TSDB_TABLE_FNAME_LEN];  // used by mnode
4805
    char tbName[TSDB_TABLE_NAME_LEN];    // used by vnode
4806
  };
4807
  int8_t tbType;  // ETableType: 1 stable, 3 normal table
4808
  union {
4809
    int8_t igExists;   // used by mnode
4810
    int8_t alterType;  // used by vnode
4811
  };
4812
  int8_t     intervalUnit;
4813
  int16_t    nFuncs;       // number of functions specified by user
4814
  col_id_t*  funcColIds;   // column ids specified by user
4815
  func_id_t* funcIds;      // function ids specified by user
4816
  int64_t    interval[2];  // 0 unspecified, > 0 valid interval
4817
  int64_t    tbUid;
4818
  int64_t    uid;     // rsma uid
4819
  int32_t    sqlLen;  // strlen + 1
4820
  char*      sql;
4821
} SMCreateRsmaReq;
4822

4823
int32_t tSerializeSMCreateRsmaReq(void* buf, int32_t bufLen, SMCreateRsmaReq* pReq);
4824
int32_t tDeserializeSMCreateRsmaReq(void* buf, int32_t bufLen, SMCreateRsmaReq* pReq);
4825
void    tFreeSMCreateRsmaReq(SMCreateRsmaReq* pReq);
4826

4827
typedef SMCreateRsmaReq SVCreateRsmaReq;
4828

4829
int32_t tSerializeSVCreateRsmaReq(void* buf, int32_t bufLen, SVCreateRsmaReq* pReq);
4830
int32_t tDeserializeSVCreateRsmaReq(void* buf, int32_t bufLen, SVCreateRsmaReq* pReq);
4831
void    tFreeSVCreateRsmaReq(SVCreateRsmaReq* pReq);
4832

4833
typedef SMCreateRsmaReq SVAlterRsmaReq;
4834

4835
int32_t tSerializeSVAlterRsmaReq(void* buf, int32_t bufLen, SVAlterRsmaReq* pReq);
4836
int32_t tDeserializeSVAlterRsmaReq(void* buf, int32_t bufLen, SVAlterRsmaReq* pReq);
4837
void    tFreeSVAlterRsmaReq(SVAlterRsmaReq* pReq);
4838

4839
typedef struct {
4840
  char       name[TSDB_TABLE_NAME_LEN];
4841
  int8_t     alterType;
4842
  int8_t     tbType;  // ETableType: 1 stable, 3 normal table
4843
  int8_t     igNotExists;
4844
  int16_t    nFuncs;      // number of functions specified by user
4845
  col_id_t*  funcColIds;  // column ids specified by user
4846
  func_id_t* funcIds;     // function ids specified by user
4847
  int32_t    sqlLen;      // strlen + 1
4848
  char*      sql;
4849
} SMAlterRsmaReq;
4850

4851
int32_t tSerializeSMAlterRsmaReq(void* buf, int32_t bufLen, SMAlterRsmaReq* pReq);
4852
int32_t tDeserializeSMAlterRsmaReq(void* buf, int32_t bufLen, SMAlterRsmaReq* pReq);
4853
void    tFreeSMAlterRsmaReq(SMAlterRsmaReq* pReq);
4854

4855
typedef struct {
4856
  int64_t    id;
4857
  char       name[TSDB_TABLE_NAME_LEN];
4858
  char       tbFName[TSDB_TABLE_FNAME_LEN];
4859
  int32_t    code;
4860
  int32_t    version;
4861
  int8_t     tbType;
4862
  int8_t     intervalUnit;
4863
  col_id_t   nFuncs;
4864
  col_id_t   nColNames;
4865
  int64_t    interval[2];
4866
  col_id_t*  funcColIds;
4867
  func_id_t* funcIds;
4868
  SArray*    colNames;
4869
} SRsmaInfoRsp;
4870

4871
int32_t tSerializeRsmaInfoRsp(void* buf, int32_t bufLen, SRsmaInfoRsp* pReq);
4872
int32_t tDeserializeRsmaInfoRsp(void* buf, int32_t bufLen, SRsmaInfoRsp* pReq);
4873
void    tFreeRsmaInfoRsp(SRsmaInfoRsp* pReq, bool deep);
4874

4875
typedef struct {
4876
  char   name[TSDB_TABLE_FNAME_LEN];
4877
  int8_t igNotExists;
4878
} SMDropRsmaReq;
4879

4880
int32_t tSerializeSMDropRsmaReq(void* buf, int32_t bufLen, SMDropRsmaReq* pReq);
4881
int32_t tDeserializeSMDropRsmaReq(void* buf, int32_t bufLen, SMDropRsmaReq* pReq);
4882

4883
typedef struct {
4884
  char    name[TSDB_TABLE_NAME_LEN];
4885
  char    tbName[TSDB_TABLE_NAME_LEN];
4886
  int64_t uid;
4887
  int64_t tbUid;
4888
  int8_t  tbType;
4889
} SVDropRsmaReq;
4890

4891
int32_t tSerializeSVDropRsmaReq(void* buf, int32_t bufLen, SVDropRsmaReq* pReq);
4892
int32_t tDeserializeSVDropRsmaReq(void* buf, int32_t bufLen, SVDropRsmaReq* pReq);
4893

4894
typedef struct {
4895
  char   dbFName[TSDB_DB_FNAME_LEN];
4896
  char   stbName[TSDB_TABLE_NAME_LEN];
4897
  char   colName[TSDB_COL_NAME_LEN];
4898
  char   idxName[TSDB_INDEX_FNAME_LEN];
4899
  int8_t idxType;
4900
} SCreateTagIndexReq;
4901

4902
int32_t tSerializeSCreateTagIdxReq(void* buf, int32_t bufLen, SCreateTagIndexReq* pReq);
4903
int32_t tDeserializeSCreateTagIdxReq(void* buf, int32_t bufLen, SCreateTagIndexReq* pReq);
4904

4905
typedef SMDropSmaReq SDropTagIndexReq;
4906

4907
// int32_t tSerializeSDropTagIdxReq(void* buf, int32_t bufLen, SDropTagIndexReq* pReq);
4908
int32_t tDeserializeSDropTagIdxReq(void* buf, int32_t bufLen, SDropTagIndexReq* pReq);
4909

4910
typedef struct {
4911
  int8_t         version;       // for compatibility(default 0)
4912
  int8_t         intervalUnit;  // MACRO: TIME_UNIT_XXX
4913
  int8_t         slidingUnit;   // MACRO: TIME_UNIT_XXX
4914
  int8_t         timezoneInt;   // sma data expired if timezone changes.
4915
  int32_t        dstVgId;
4916
  char           indexName[TSDB_INDEX_NAME_LEN];
4917
  int32_t        exprLen;
4918
  int32_t        tagsFilterLen;
4919
  int64_t        indexUid;
4920
  tb_uid_t       tableUid;  // super/child/common table uid
4921
  tb_uid_t       dstTbUid;  // for dstVgroup
4922
  int64_t        interval;
4923
  int64_t        offset;  // use unit by precision of DB
4924
  int64_t        sliding;
4925
  char*          dstTbName;  // for dstVgroup
4926
  char*          expr;       // sma expression
4927
  char*          tagsFilter;
4928
  SSchemaWrapper schemaRow;  // for dstVgroup
4929
  SSchemaWrapper schemaTag;  // for dstVgroup
4930
} STSma;                     // Time-range-wise SMA
4931

4932
typedef STSma SVCreateTSmaReq;
4933

4934
typedef struct {
4935
  int8_t  type;  // 0 status report, 1 update data
4936
  int64_t indexUid;
4937
  int64_t skey;  // start TS key of interval/sliding window
4938
} STSmaMsg;
4939

4940
typedef struct {
4941
  int64_t indexUid;
4942
  char    indexName[TSDB_INDEX_NAME_LEN];
4943
} SVDropTSmaReq;
4944

4945
typedef struct {
4946
  int tmp;  // TODO: to avoid compile error
4947
} SVCreateTSmaRsp, SVDropTSmaRsp;
4948

4949
#if 0
4950
int32_t tSerializeSVCreateTSmaReq(void** buf, SVCreateTSmaReq* pReq);
4951
void*   tDeserializeSVCreateTSmaReq(void* buf, SVCreateTSmaReq* pReq);
4952
int32_t tSerializeSVDropTSmaReq(void** buf, SVDropTSmaReq* pReq);
4953
void*   tDeserializeSVDropTSmaReq(void* buf, SVDropTSmaReq* pReq);
4954
#endif
4955

4956
int32_t tEncodeSVCreateTSmaReq(SEncoder* pCoder, const SVCreateTSmaReq* pReq);
4957
int32_t tDecodeSVCreateTSmaReq(SDecoder* pCoder, SVCreateTSmaReq* pReq);
4958
int32_t tEncodeSVDropTSmaReq(SEncoder* pCoder, const SVDropTSmaReq* pReq);
4959
// int32_t tDecodeSVDropTSmaReq(SDecoder* pCoder, SVDropTSmaReq* pReq);
4960

4961
typedef struct {
4962
  int32_t number;
4963
  STSma*  tSma;
4964
} STSmaWrapper;
4965

4966
static FORCE_INLINE void tDestroyTSma(STSma* pSma) {
4967
  if (pSma) {
×
4968
    taosMemoryFreeClear(pSma->dstTbName);
×
4969
    taosMemoryFreeClear(pSma->expr);
×
4970
    taosMemoryFreeClear(pSma->tagsFilter);
×
4971
  }
4972
}
×
4973

4974
static FORCE_INLINE void tDestroyTSmaWrapper(STSmaWrapper* pSW, bool deepCopy) {
4975
  if (pSW) {
×
4976
    if (pSW->tSma) {
×
4977
      if (deepCopy) {
×
4978
        for (uint32_t i = 0; i < pSW->number; ++i) {
×
4979
          tDestroyTSma(pSW->tSma + i);
×
4980
        }
4981
      }
4982
      taosMemoryFreeClear(pSW->tSma);
×
4983
    }
4984
  }
4985
}
×
4986

4987
static FORCE_INLINE void* tFreeTSmaWrapper(STSmaWrapper* pSW, bool deepCopy) {
4988
  tDestroyTSmaWrapper(pSW, deepCopy);
×
4989
  taosMemoryFreeClear(pSW);
×
4990
  return NULL;
×
4991
}
4992

4993
int32_t tEncodeSVCreateTSmaReq(SEncoder* pCoder, const SVCreateTSmaReq* pReq);
4994
int32_t tDecodeSVCreateTSmaReq(SDecoder* pCoder, SVCreateTSmaReq* pReq);
4995

4996
int32_t tEncodeTSma(SEncoder* pCoder, const STSma* pSma);
4997
int32_t tDecodeTSma(SDecoder* pCoder, STSma* pSma, bool deepCopy);
4998

4999
static int32_t tEncodeTSmaWrapper(SEncoder* pEncoder, const STSmaWrapper* pReq) {
×
5000
  TAOS_CHECK_RETURN(tEncodeI32(pEncoder, pReq->number));
×
5001
  for (int32_t i = 0; i < pReq->number; ++i) {
×
5002
    TAOS_CHECK_RETURN(tEncodeTSma(pEncoder, pReq->tSma + i));
×
5003
  }
5004
  return 0;
×
5005
}
5006

5007
static int32_t tDecodeTSmaWrapper(SDecoder* pDecoder, STSmaWrapper* pReq, bool deepCopy) {
×
5008
  TAOS_CHECK_RETURN(tDecodeI32(pDecoder, &pReq->number));
×
5009
  for (int32_t i = 0; i < pReq->number; ++i) {
×
5010
    TAOS_CHECK_RETURN(tDecodeTSma(pDecoder, pReq->tSma + i, deepCopy));
×
5011
  }
5012
  return 0;
×
5013
}
5014

5015
typedef struct {
5016
  int idx;
5017
} SMCreateFullTextReq;
5018

5019
int32_t tSerializeSMCreateFullTextReq(void* buf, int32_t bufLen, SMCreateFullTextReq* pReq);
5020
int32_t tDeserializeSMCreateFullTextReq(void* buf, int32_t bufLen, SMCreateFullTextReq* pReq);
5021
void    tFreeSMCreateFullTextReq(SMCreateFullTextReq* pReq);
5022

5023
typedef struct {
5024
  char   name[TSDB_TABLE_FNAME_LEN];
5025
  int8_t igNotExists;
5026
} SMDropFullTextReq;
5027

5028
// int32_t tSerializeSMDropFullTextReq(void* buf, int32_t bufLen, SMDropFullTextReq* pReq);
5029
// int32_t tDeserializeSMDropFullTextReq(void* buf, int32_t bufLen, SMDropFullTextReq* pReq);
5030

5031
typedef struct {
5032
  char indexFName[TSDB_INDEX_FNAME_LEN];
5033
} SUserIndexReq;
5034

5035
int32_t tSerializeSUserIndexReq(void* buf, int32_t bufLen, SUserIndexReq* pReq);
5036
int32_t tDeserializeSUserIndexReq(void* buf, int32_t bufLen, SUserIndexReq* pReq);
5037

5038
typedef struct {
5039
  char dbFName[TSDB_DB_FNAME_LEN];
5040
  char tblFName[TSDB_TABLE_FNAME_LEN];
5041
  char colName[TSDB_COL_NAME_LEN];
5042
  char indexType[TSDB_INDEX_TYPE_LEN];
5043
  char indexExts[TSDB_INDEX_EXTS_LEN];
5044
} SUserIndexRsp;
5045

5046
int32_t tSerializeSUserIndexRsp(void* buf, int32_t bufLen, const SUserIndexRsp* pRsp);
5047
int32_t tDeserializeSUserIndexRsp(void* buf, int32_t bufLen, SUserIndexRsp* pRsp);
5048

5049
typedef struct {
5050
  char tbFName[TSDB_TABLE_FNAME_LEN];
5051
} STableIndexReq;
5052

5053
int32_t tSerializeSTableIndexReq(void* buf, int32_t bufLen, STableIndexReq* pReq);
5054
int32_t tDeserializeSTableIndexReq(void* buf, int32_t bufLen, STableIndexReq* pReq);
5055

5056
typedef struct {
5057
  int8_t  intervalUnit;
5058
  int8_t  slidingUnit;
5059
  int64_t interval;
5060
  int64_t offset;
5061
  int64_t sliding;
5062
  int64_t dstTbUid;
5063
  int32_t dstVgId;
5064
  SEpSet  epSet;
5065
  char*   expr;
5066
} STableIndexInfo;
5067

5068
typedef struct {
5069
  char     tbName[TSDB_TABLE_NAME_LEN];
5070
  char     dbFName[TSDB_DB_FNAME_LEN];
5071
  uint64_t suid;
5072
  int32_t  version;
5073
  int32_t  indexSize;
5074
  SArray*  pIndex;  // STableIndexInfo
5075
} STableIndexRsp;
5076

5077
int32_t tSerializeSTableIndexRsp(void* buf, int32_t bufLen, const STableIndexRsp* pRsp);
5078
int32_t tDeserializeSTableIndexRsp(void* buf, int32_t bufLen, STableIndexRsp* pRsp);
5079
void    tFreeSerializeSTableIndexRsp(STableIndexRsp* pRsp);
5080

5081
void tFreeSTableIndexInfo(void* pInfo);
5082

5083
typedef struct {
5084
  int8_t  mqMsgType;
5085
  int32_t code;
5086
  int32_t epoch;
5087
  int64_t consumerId;
5088
  int64_t walsver;
5089
  int64_t walever;
5090
} SMqRspHead;
5091

5092
typedef struct {
5093
  SMsgHead     head;
5094
  char         subKey[TSDB_SUBSCRIBE_KEY_LEN];
5095
  int8_t       withTbName;
5096
  int8_t       useSnapshot;
5097
  int32_t      epoch;
5098
  uint64_t     reqId;
5099
  int64_t      consumerId;
5100
  int64_t      timeout;
5101
  STqOffsetVal reqOffset;
5102
  int8_t       enableReplay;
5103
  int8_t       sourceExcluded;
5104
  int8_t       rawData;
5105
  int32_t      minPollRows;
5106
  int8_t       enableBatchMeta;
5107
  SHashObj*    uidHash;  // to find if uid is duplicated
5108
} SMqPollReq;
5109

5110
int32_t tSerializeSMqPollReq(void* buf, int32_t bufLen, SMqPollReq* pReq);
5111
int32_t tDeserializeSMqPollReq(void* buf, int32_t bufLen, SMqPollReq* pReq);
5112
void    tDestroySMqPollReq(SMqPollReq* pReq);
5113

5114
typedef struct {
5115
  int32_t vgId;
5116
  int64_t offset;
5117
  SEpSet  epSet;
5118
} SMqSubVgEp;
5119

5120
static FORCE_INLINE int32_t tEncodeSMqSubVgEp(void** buf, const SMqSubVgEp* pVgEp) {
5121
  int32_t tlen = 0;
447,896✔
5122
  tlen += taosEncodeFixedI32(buf, pVgEp->vgId);
447,896✔
5123
  tlen += taosEncodeFixedI64(buf, pVgEp->offset);
447,896✔
5124
  tlen += taosEncodeSEpSet(buf, &pVgEp->epSet);
447,896✔
5125
  return tlen;
447,896✔
5126
}
5127

5128
static FORCE_INLINE void* tDecodeSMqSubVgEp(void* buf, SMqSubVgEp* pVgEp) {
5129
  buf = taosDecodeFixedI32(buf, &pVgEp->vgId);
247,464✔
5130
  buf = taosDecodeFixedI64(buf, &pVgEp->offset);
247,464✔
5131
  buf = taosDecodeSEpSet(buf, &pVgEp->epSet);
247,464✔
5132
  return buf;
247,464✔
5133
}
5134

5135
typedef struct {
5136
  char           topic[TSDB_TOPIC_FNAME_LEN];
5137
  char           db[TSDB_DB_FNAME_LEN];
5138
  SArray*        vgs;  // SArray<SMqSubVgEp>
5139
} SMqSubTopicEp;
5140

5141
int32_t tEncodeMqSubTopicEp(void** buf, const SMqSubTopicEp* pTopicEp);
5142
void*   tDecodeMqSubTopicEp(void* buf, SMqSubTopicEp* pTopicEp);
5143
void    tDeleteMqSubTopicEp(SMqSubTopicEp* pSubTopicEp);
5144

5145
typedef struct {
5146
  SMqRspHead   head;
5147
  STqOffsetVal rspOffset;
5148
  int16_t      resMsgType;
5149
  int32_t      metaRspLen;
5150
  void*        metaRsp;
5151
} SMqMetaRsp;
5152

5153
int32_t tEncodeMqMetaRsp(SEncoder* pEncoder, const SMqMetaRsp* pRsp);
5154
int32_t tDecodeMqMetaRsp(SDecoder* pDecoder, SMqMetaRsp* pRsp);
5155
void    tDeleteMqMetaRsp(SMqMetaRsp* pRsp);
5156

5157
#define MQ_DATA_RSP_VERSION 100
5158

5159
typedef struct {
5160
  SMqRspHead   head;
5161
  STqOffsetVal rspOffset;
5162
  STqOffsetVal reqOffset;
5163
  int32_t      blockNum;
5164
  int8_t       withTbName;
5165
  // int8_t       withSchema;
5166
  SArray*      blockDataLen;
5167
  SArray*      blockData;
5168
  SArray*      blockTbName;
5169
  SArray*      blockSchema;
5170

5171
  union {
5172
    struct {
5173
      int64_t sleepTime;
5174
    };
5175
    struct {
5176
      int32_t createTableNum;
5177
      SArray* createTableLen;
5178
      SArray* createTableReq;
5179
    };
5180
    struct {
5181
      int32_t len;
5182
      void*   rawData;
5183
    };
5184
  };
5185
  void* data;                  // for free in client, only effected if type is data or metadata. raw data not effected
5186
  bool  blockDataElementFree;  // if true, free blockDataElement in blockData,(true in server, false in client)
5187
} SMqDataRsp;
5188

5189
int32_t tEncodeMqDataRsp(SEncoder* pEncoder, const SMqDataRsp* pObj);
5190
int32_t tDecodeMqDataRsp(SDecoder* pDecoder, SMqDataRsp* pRsp);
5191
int32_t tDecodeMqRawDataRsp(SDecoder* pDecoder, SMqDataRsp* pRsp);
5192
void    tDeleteMqDataRsp(SMqDataRsp* pRsp);
5193
void    tDeleteMqRawDataRsp(SMqDataRsp* pRsp);
5194

5195
int32_t tEncodeSTaosxRsp(SEncoder* pEncoder, const SMqDataRsp* pRsp);
5196
int32_t tDecodeSTaosxRsp(SDecoder* pDecoder, SMqDataRsp* pRsp);
5197
void    tDeleteSTaosxRsp(SMqDataRsp* pRsp);
5198

5199
typedef struct SMqBatchMetaRsp {
5200
  SMqRspHead   head;  // not serialize
5201
  STqOffsetVal rspOffset;
5202
  SArray*      batchMetaLen;
5203
  SArray*      batchMetaReq;
5204
  void*        pMetaBuff;    // not serialize
5205
  uint32_t     metaBuffLen;  // not serialize
5206
} SMqBatchMetaRsp;
5207

5208
int32_t tEncodeMqBatchMetaRsp(SEncoder* pEncoder, const SMqBatchMetaRsp* pRsp);
5209
int32_t tDecodeMqBatchMetaRsp(SDecoder* pDecoder, SMqBatchMetaRsp* pRsp);
5210
int32_t tSemiDecodeMqBatchMetaRsp(SDecoder* pDecoder, SMqBatchMetaRsp* pRsp);
5211
void    tDeleteMqBatchMetaRsp(SMqBatchMetaRsp* pRsp);
5212

5213
typedef struct {
5214
  SMqRspHead head;
5215
  char       cgroup[TSDB_CGROUP_LEN];
5216
  SArray*    topics;  // SArray<SMqSubTopicEp>
5217
} SMqAskEpRsp;
5218

5219
static FORCE_INLINE int32_t tEncodeSMqAskEpRsp(void** buf, const SMqAskEpRsp* pRsp) {
5220
  int32_t tlen = 0;
1,272,556✔
5221
  // tlen += taosEncodeString(buf, pRsp->cgroup);
5222
  int32_t sz = taosArrayGetSize(pRsp->topics);
1,272,556✔
5223
  tlen += taosEncodeFixedI32(buf, sz);
1,272,450✔
5224
  for (int32_t i = 0; i < sz; i++) {
1,461,506✔
5225
    SMqSubTopicEp* pVgEp = (SMqSubTopicEp*)taosArrayGet(pRsp->topics, i);
189,056✔
5226
    tlen += tEncodeMqSubTopicEp(buf, pVgEp);
189,056✔
5227
  }
5228
  return tlen;
1,272,450✔
5229
}
5230

5231
static FORCE_INLINE void* tDecodeSMqAskEpRsp(void* buf, SMqAskEpRsp* pRsp) {
5232
  // buf = taosDecodeStringTo(buf, pRsp->cgroup);
5233
  int32_t sz;
607,779✔
5234
  buf = taosDecodeFixedI32(buf, &sz);
653,740✔
5235
  pRsp->topics = taosArrayInit(sz, sizeof(SMqSubTopicEp));
653,740✔
5236
  if (pRsp->topics == NULL) {
653,740✔
5237
    return NULL;
×
5238
  }
5239
  for (int32_t i = 0; i < sz; i++) {
776,574✔
5240
    SMqSubTopicEp topicEp;
106,104✔
5241
    buf = tDecodeMqSubTopicEp(buf, &topicEp);
122,834✔
5242
    if (buf == NULL) {
122,834✔
5243
      return NULL;
×
5244
    }
5245
    if ((taosArrayPush(pRsp->topics, &topicEp) == NULL)) {
245,668✔
5246
      return NULL;
×
5247
    }
5248
  }
5249
  return buf;
653,740✔
5250
}
5251

5252
static FORCE_INLINE void tDeleteSMqAskEpRsp(SMqAskEpRsp* pRsp) {
5253
  taosArrayDestroyEx(pRsp->topics, (FDelete)tDeleteMqSubTopicEp);
1,587,363✔
5254
}
1,587,257✔
5255

5256
typedef struct {
5257
  int32_t      vgId;
5258
  STqOffsetVal offset;
5259
  int64_t      rows;
5260
  int64_t      ever;
5261
} OffsetRows;
5262

5263
typedef struct {
5264
  char    topicName[TSDB_TOPIC_FNAME_LEN];
5265
  SArray* offsetRows;
5266
} TopicOffsetRows;
5267

5268
typedef struct {
5269
  int64_t consumerId;
5270
  int32_t epoch;
5271
  SArray* topics;
5272
  int8_t  pollFlag;
5273
} SMqHbReq;
5274

5275
typedef struct {
5276
  char   topic[TSDB_TOPIC_FNAME_LEN];
5277
  int8_t noPrivilege;
5278
} STopicPrivilege;
5279

5280
typedef struct {
5281
  SArray* topicPrivileges;  // SArray<STopicPrivilege>
5282
  int32_t debugFlag;
5283
} SMqHbRsp;
5284

5285
typedef struct {
5286
  SMsgHead head;
5287
  int64_t  consumerId;
5288
  char     subKey[TSDB_SUBSCRIBE_KEY_LEN];
5289
} SMqSeekReq;
5290

5291
#define TD_AUTO_CREATE_TABLE 0x1
5292
typedef struct {
5293
  int64_t       suid;
5294
  int64_t       uid;
5295
  int32_t       sver;
5296
  uint32_t      nData;
5297
  uint8_t*      pData;
5298
  SVCreateTbReq cTbReq;
5299
} SVSubmitBlk;
5300

5301
typedef struct {
5302
  SMsgHead header;
5303
  uint64_t sId;
5304
  uint64_t queryId;
5305
  uint64_t clientId;
5306
  uint64_t taskId;
5307
  uint32_t sqlLen;
5308
  uint32_t phyLen;
5309
  char*    sql;
5310
  char*    msg;
5311
  int8_t   source;
5312
} SVDeleteReq;
5313

5314
int32_t tSerializeSVDeleteReq(void* buf, int32_t bufLen, SVDeleteReq* pReq);
5315
int32_t tDeserializeSVDeleteReq(void* buf, int32_t bufLen, SVDeleteReq* pReq);
5316

5317
typedef struct {
5318
  int64_t affectedRows;
5319
} SVDeleteRsp;
5320

5321
int32_t tEncodeSVDeleteRsp(SEncoder* pCoder, const SVDeleteRsp* pReq);
5322
int32_t tDecodeSVDeleteRsp(SDecoder* pCoder, SVDeleteRsp* pReq);
5323

5324
typedef struct SDeleteRes {
5325
  uint64_t suid;
5326
  SArray*  uidList;
5327
  int64_t  skey;
5328
  int64_t  ekey;
5329
  int64_t  affectedRows;
5330
  char     tableFName[TSDB_TABLE_NAME_LEN];
5331
  char     tsColName[TSDB_COL_NAME_LEN];
5332
  int64_t  ctimeMs;  // fill by vnode
5333
  int8_t   source;
5334
} SDeleteRes;
5335

5336
int32_t tEncodeDeleteRes(SEncoder* pCoder, const SDeleteRes* pRes);
5337
int32_t tDecodeDeleteRes(SDecoder* pCoder, SDeleteRes* pRes);
5338

5339
typedef struct {
5340
  // int64_t uid;
5341
  char    tbname[TSDB_TABLE_NAME_LEN];
5342
  int64_t startTs;
5343
  int64_t endTs;
5344
} SSingleDeleteReq;
5345

5346
int32_t tEncodeSSingleDeleteReq(SEncoder* pCoder, const SSingleDeleteReq* pReq);
5347
int32_t tDecodeSSingleDeleteReq(SDecoder* pCoder, SSingleDeleteReq* pReq);
5348

5349
typedef struct {
5350
  int64_t suid;
5351
  SArray* deleteReqs;  // SArray<SSingleDeleteReq>
5352
  int64_t ctimeMs;     // fill by vnode
5353
  int8_t  level;       // 0 tsdb(default), 1 rsma1 , 2 rsma2
5354
} SBatchDeleteReq;
5355

5356
int32_t tEncodeSBatchDeleteReq(SEncoder* pCoder, const SBatchDeleteReq* pReq);
5357
int32_t tDecodeSBatchDeleteReq(SDecoder* pCoder, SBatchDeleteReq* pReq);
5358
int32_t tDecodeSBatchDeleteReqSetCtime(SDecoder* pDecoder, SBatchDeleteReq* pReq, int64_t ctimeMs);
5359

5360
typedef struct {
5361
  int32_t msgIdx;
5362
  int32_t msgType;
5363
  int32_t msgLen;
5364
  void*   msg;
5365
} SBatchMsg;
5366

5367
typedef struct {
5368
  SMsgHead header;
5369
  SArray*  pMsgs;  // SArray<SBatchMsg>
5370
} SBatchReq;
5371

5372
typedef struct {
5373
  int32_t reqType;
5374
  int32_t msgIdx;
5375
  int32_t msgLen;
5376
  int32_t rspCode;
5377
  void*   msg;
5378
} SBatchRspMsg;
5379

5380
typedef struct {
5381
  SArray* pRsps;  // SArray<SBatchRspMsg>
5382
} SBatchRsp;
5383

5384
int32_t                  tSerializeSBatchReq(void* buf, int32_t bufLen, SBatchReq* pReq);
5385
int32_t                  tDeserializeSBatchReq(void* buf, int32_t bufLen, SBatchReq* pReq);
5386
static FORCE_INLINE void tFreeSBatchReqMsg(void* msg) {
92,949,494✔
5387
  if (NULL == msg) {
92,949,494✔
5388
    return;
×
5389
  }
5390
  SBatchMsg* pMsg = (SBatchMsg*)msg;
92,949,494✔
5391
  taosMemoryFree(pMsg->msg);
92,949,494✔
5392
}
5393

5394
int32_t tSerializeSBatchRsp(void* buf, int32_t bufLen, SBatchRsp* pRsp);
5395
int32_t tDeserializeSBatchRsp(void* buf, int32_t bufLen, SBatchRsp* pRsp);
5396

5397
static FORCE_INLINE void tFreeSBatchRspMsg(void* p) {
129,847,572✔
5398
  if (NULL == p) {
129,847,572✔
5399
    return;
×
5400
  }
5401

5402
  SBatchRspMsg* pRsp = (SBatchRspMsg*)p;
129,847,572✔
5403
  taosMemoryFree(pRsp->msg);
129,847,572✔
5404
}
5405

5406
int32_t tSerializeSMqAskEpReq(void* buf, int32_t bufLen, SMqAskEpReq* pReq);
5407
int32_t tDeserializeSMqAskEpReq(void* buf, int32_t bufLen, SMqAskEpReq* pReq);
5408
int32_t tSerializeSMqHbReq(void* buf, int32_t bufLen, SMqHbReq* pReq);
5409
int32_t tDeserializeSMqHbReq(void* buf, int32_t bufLen, SMqHbReq* pReq);
5410
void    tDestroySMqHbReq(SMqHbReq* pReq);
5411

5412
int32_t tSerializeSMqHbRsp(void* buf, int32_t bufLen, SMqHbRsp* pRsp);
5413
int32_t tDeserializeSMqHbRsp(void* buf, int32_t bufLen, SMqHbRsp* pRsp);
5414
void    tDestroySMqHbRsp(SMqHbRsp* pRsp);
5415

5416
int32_t tSerializeSMqSeekReq(void* buf, int32_t bufLen, SMqSeekReq* pReq);
5417
int32_t tDeserializeSMqSeekReq(void* buf, int32_t bufLen, SMqSeekReq* pReq);
5418

5419
#define TD_REQ_FROM_APP               0x0
5420
#define SUBMIT_REQ_AUTO_CREATE_TABLE  0x1
5421
#define SUBMIT_REQ_COLUMN_DATA_FORMAT 0x2
5422
#define SUBMIT_REQ_FROM_FILE          0x4
5423
#define TD_REQ_FROM_TAOX              0x8
5424
#define TD_REQ_FROM_SML               0x10
5425
#define SUBMIT_REQUEST_VERSION        (2)
5426
#define SUBMIT_REQ_WITH_BLOB          0x10
5427
#define SUBMIT_REQ_SCHEMA_RES         0x20
5428
#define SUBMIT_REQ_ONLY_CREATE_TABLE  0x40
5429

5430
#define TD_REQ_FROM_TAOX_OLD 0x1  // for compatibility
5431

5432
typedef struct {
5433
  int32_t        flags;
5434
  SVCreateTbReq* pCreateTbReq;
5435
  int64_t        suid;
5436
  int64_t        uid;
5437
  int32_t        sver;
5438
  union {
5439
    SArray* aRowP;
5440
    SArray* aCol;
5441
  };
5442
  int64_t    ctimeMs;
5443
  SBlobSet*  pBlobSet;
5444
} SSubmitTbData;
5445

5446
typedef struct {
5447
  SArray* aSubmitTbData;  // SArray<SSubmitTbData>
5448
  SArray* aSubmitBlobData;
5449
  bool    raw;
5450
} SSubmitReq2;
5451

5452
typedef struct {
5453
  SMsgHead header;
5454
  int64_t  version;
5455
  char     data[];  // SSubmitReq2
5456
} SSubmitReq2Msg;
5457

5458
int32_t transformRawSSubmitTbData(void* data, int64_t suid, int64_t uid, int32_t sver);
5459
int32_t tEncodeSubmitReq(SEncoder* pCoder, const SSubmitReq2* pReq);
5460
int32_t tDecodeSubmitReq(SDecoder* pCoder, SSubmitReq2* pReq, SArray* rawList);
5461
void    tDestroySubmitTbData(SSubmitTbData* pTbData, int32_t flag);
5462
void    tDestroySubmitReq(SSubmitReq2* pReq, int32_t flag);
5463

5464
typedef struct {
5465
  int32_t affectedRows;
5466
  SArray* aCreateTbRsp;  // SArray<SVCreateTbRsp>
5467
} SSubmitRsp2;
5468

5469
int32_t tEncodeSSubmitRsp2(SEncoder* pCoder, const SSubmitRsp2* pRsp);
5470
int32_t tDecodeSSubmitRsp2(SDecoder* pCoder, SSubmitRsp2* pRsp);
5471
void    tDestroySSubmitRsp2(SSubmitRsp2* pRsp, int32_t flag);
5472

5473
#define TSDB_MSG_FLG_ENCODE 0x1
5474
#define TSDB_MSG_FLG_DECODE 0x2
5475
#define TSDB_MSG_FLG_CMPT   0x3
5476

5477
typedef struct {
5478
  union {
5479
    struct {
5480
      void*   msgStr;
5481
      int32_t msgLen;
5482
      int64_t ver;
5483
    };
5484
    void* pDataBlock;
5485
  };
5486
} SPackedData;
5487

5488
typedef struct {
5489
  char     fullname[TSDB_VIEW_FNAME_LEN];
5490
  char     name[TSDB_VIEW_NAME_LEN];
5491
  char     dbFName[TSDB_DB_FNAME_LEN];
5492
  char*    querySql;
5493
  char*    sql;
5494
  int8_t   orReplace;
5495
  int8_t   precision;
5496
  int32_t  numOfCols;
5497
  SSchema* pSchema;
5498
} SCMCreateViewReq;
5499

5500
int32_t tSerializeSCMCreateViewReq(void* buf, int32_t bufLen, const SCMCreateViewReq* pReq);
5501
int32_t tDeserializeSCMCreateViewReq(void* buf, int32_t bufLen, SCMCreateViewReq* pReq);
5502
void    tFreeSCMCreateViewReq(SCMCreateViewReq* pReq);
5503

5504
typedef struct {
5505
  char   fullname[TSDB_VIEW_FNAME_LEN];
5506
  char   name[TSDB_VIEW_NAME_LEN];
5507
  char   dbFName[TSDB_DB_FNAME_LEN];
5508
  char*  sql;
5509
  int8_t igNotExists;
5510
} SCMDropViewReq;
5511

5512
int32_t tSerializeSCMDropViewReq(void* buf, int32_t bufLen, const SCMDropViewReq* pReq);
5513
int32_t tDeserializeSCMDropViewReq(void* buf, int32_t bufLen, SCMDropViewReq* pReq);
5514
void    tFreeSCMDropViewReq(SCMDropViewReq* pReq);
5515

5516
typedef struct {
5517
  char fullname[TSDB_VIEW_FNAME_LEN];
5518
} SViewMetaReq;
5519
int32_t tSerializeSViewMetaReq(void* buf, int32_t bufLen, const SViewMetaReq* pReq);
5520
int32_t tDeserializeSViewMetaReq(void* buf, int32_t bufLen, SViewMetaReq* pReq);
5521

5522
typedef struct {
5523
  char     name[TSDB_VIEW_NAME_LEN];
5524
  char     dbFName[TSDB_DB_FNAME_LEN];
5525
  char*    user;
5526
  uint64_t dbId;
5527
  uint64_t viewId;
5528
  char*    querySql;
5529
  int8_t   precision;
5530
  int8_t   type;
5531
  int32_t  version;
5532
  int32_t  numOfCols;
5533
  SSchema* pSchema;
5534
} SViewMetaRsp;
5535
int32_t tSerializeSViewMetaRsp(void* buf, int32_t bufLen, const SViewMetaRsp* pRsp);
5536
int32_t tDeserializeSViewMetaRsp(void* buf, int32_t bufLen, SViewMetaRsp* pRsp);
5537
void    tFreeSViewMetaRsp(SViewMetaRsp* pRsp);
5538
typedef struct {
5539
  char name[TSDB_TABLE_FNAME_LEN];  // table name or tsma name
5540
  bool fetchingWithTsmaName;        // if we are fetching with tsma name
5541
} STableTSMAInfoReq;
5542

5543
int32_t tSerializeTableTSMAInfoReq(void* buf, int32_t bufLen, const STableTSMAInfoReq* pReq);
5544
int32_t tDeserializeTableTSMAInfoReq(void* buf, int32_t bufLen, STableTSMAInfoReq* pReq);
5545

5546
typedef struct {
5547
  char name[TSDB_TABLE_NAME_LEN];  // rsmaName
5548
  union {
5549
    uint8_t flags;
5550
    struct {
5551
      uint8_t withColName : 1;
5552
      uint8_t reserved : 7;
5553
    };
5554
  };
5555

5556
} SRsmaInfoReq;
5557

5558
int32_t tSerializeRsmaInfoReq(void* buf, int32_t bufLen, const SRsmaInfoReq* pReq);
5559
int32_t tDeserializeRsmaInfoReq(void* buf, int32_t bufLen, SRsmaInfoReq* pReq);
5560

5561
typedef struct {
5562
  int32_t  funcId;
5563
  col_id_t colId;
5564
} STableTSMAFuncInfo;
5565

5566
typedef struct {
5567
  char     name[TSDB_TABLE_NAME_LEN];
5568
  uint64_t tsmaId;
5569
  char     targetTb[TSDB_TABLE_NAME_LEN];
5570
  char     targetDbFName[TSDB_DB_FNAME_LEN];
5571
  char     tb[TSDB_TABLE_NAME_LEN];
5572
  char     dbFName[TSDB_DB_FNAME_LEN];
5573
  uint64_t suid;
5574
  uint64_t destTbUid;
5575
  uint64_t dbId;
5576
  int32_t  version;
5577
  int64_t  interval;
5578
  int8_t   unit;
5579
  SArray*  pFuncs;     // SArray<STableTSMAFuncInfo>
5580
  SArray*  pTags;      // SArray<SSchema>
5581
  SArray*  pUsedCols;  // SArray<SSchema>
5582
  char*    ast;
5583

5584
  int64_t streamUid;
5585
  int64_t reqTs;
5586
  int64_t rspTs;
5587
  int64_t delayDuration;  // ms
5588
  bool    fillHistoryFinished;
5589

5590
  void*   streamAddr;  // for stream task, the address of the stream task
5591
} STableTSMAInfo;
5592

5593
int32_t tSerializeTableTSMAInfoRsp(void* buf, int32_t bufLen, const STableTSMAInfoRsp* pRsp);
5594
int32_t tDeserializeTableTSMAInfoRsp(void* buf, int32_t bufLen, STableTSMAInfoRsp* pRsp);
5595
int32_t tCloneTbTSMAInfo(STableTSMAInfo* pInfo, STableTSMAInfo** pRes);
5596
void    tFreeTableTSMAInfo(void* p);
5597
void    tFreeAndClearTableTSMAInfo(void* p);
5598
void    tFreeTableTSMAInfoRsp(STableTSMAInfoRsp* pRsp);
5599

5600
#define STSMAHbRsp            STableTSMAInfoRsp
5601
#define tSerializeTSMAHbRsp   tSerializeTableTSMAInfoRsp
5602
#define tDeserializeTSMAHbRsp tDeserializeTableTSMAInfoRsp
5603
#define tFreeTSMAHbRsp        tFreeTableTSMAInfoRsp
5604

5605
typedef struct SDropCtbWithTsmaSingleVgReq {
5606
  SVgroupInfo vgInfo;
5607
  SArray*     pTbs;  // SVDropTbReq
5608
} SMDropTbReqsOnSingleVg;
5609

5610
int32_t tEncodeSMDropTbReqOnSingleVg(SEncoder* pEncoder, const SMDropTbReqsOnSingleVg* pReq);
5611
int32_t tDecodeSMDropTbReqOnSingleVg(SDecoder* pDecoder, SMDropTbReqsOnSingleVg* pReq);
5612
void    tFreeSMDropTbReqOnSingleVg(void* p);
5613

5614
typedef struct SDropTbsReq {
5615
  SArray* pVgReqs;  // SMDropTbReqsOnSingleVg
5616
} SMDropTbsReq;
5617

5618
int32_t tSerializeSMDropTbsReq(void* buf, int32_t bufLen, const SMDropTbsReq* pReq);
5619
int32_t tDeserializeSMDropTbsReq(void* buf, int32_t bufLen, SMDropTbsReq* pReq);
5620
void    tFreeSMDropTbsReq(void*);
5621

5622
typedef struct SVFetchTtlExpiredTbsRsp {
5623
  SArray* pExpiredTbs;  // SVDropTbReq
5624
  int32_t vgId;
5625
} SVFetchTtlExpiredTbsRsp;
5626

5627
int32_t tEncodeVFetchTtlExpiredTbsRsp(SEncoder* pCoder, const SVFetchTtlExpiredTbsRsp* pRsp);
5628
int32_t tDecodeVFetchTtlExpiredTbsRsp(SDecoder* pCoder, SVFetchTtlExpiredTbsRsp* pRsp);
5629

5630
void tFreeFetchTtlExpiredTbsRsp(void* p);
5631

5632
void setDefaultOptionsForField(SFieldWithOptions* field);
5633
void setFieldWithOptions(SFieldWithOptions* fieldWithOptions, SField* field);
5634

5635
int32_t tSerializeSVSubTablesRspImpl(SEncoder* pEncoder, SVSubTablesRsp *pRsp);
5636
int32_t tDeserializeSVSubTablesRspImpl(SDecoder* pDecoder, SVSubTablesRsp *pRsp);
5637

5638
typedef struct {
5639
  char    id[TSDB_INSTANCE_ID_LEN];
5640
  char    type[TSDB_INSTANCE_TYPE_LEN];
5641
  char    desc[TSDB_INSTANCE_DESC_LEN];
5642
  int32_t expire;
5643
} SInstanceRegisterReq;
5644

5645
int32_t tSerializeSInstanceRegisterReq(void* buf, int32_t bufLen, SInstanceRegisterReq* pReq);
5646
int32_t tDeserializeSInstanceRegisterReq(void* buf, int32_t bufLen, SInstanceRegisterReq* pReq);
5647

5648
typedef struct {
5649
  char filter_type[TSDB_INSTANCE_TYPE_LEN];
5650
} SInstanceListReq;
5651

5652
typedef struct {
5653
  int32_t count;
5654
  char**  ids;  // Array of instance IDs
5655
} SInstanceListRsp;
5656

5657
int32_t tSerializeSInstanceListReq(void* buf, int32_t bufLen, SInstanceListReq* pReq);
5658
int32_t tDeserializeSInstanceListReq(void* buf, int32_t bufLen, SInstanceListReq* pReq);
5659
int32_t tSerializeSInstanceListRsp(void* buf, int32_t bufLen, SInstanceListRsp* pRsp);
5660
int32_t tDeserializeSInstanceListRsp(void* buf, int32_t bufLen, SInstanceListRsp* pRsp);
5661

5662
#ifdef USE_MOUNT
5663
typedef struct {
5664
  char     mountName[TSDB_MOUNT_NAME_LEN];
5665
  int8_t   ignoreExist;
5666
  int16_t  nMounts;
5667
  int32_t* dnodeIds;
5668
  char**   mountPaths;
5669
  int32_t  sqlLen;
5670
  char*    sql;
5671
} SCreateMountReq;
5672

5673
int32_t tSerializeSCreateMountReq(void* buf, int32_t bufLen, SCreateMountReq* pReq);
5674
int32_t tDeserializeSCreateMountReq(void* buf, int32_t bufLen, SCreateMountReq* pReq);
5675
void    tFreeSCreateMountReq(SCreateMountReq* pReq);
5676

5677
typedef struct {
5678
  char    mountName[TSDB_MOUNT_NAME_LEN];
5679
  int8_t  ignoreNotExists;
5680
  int32_t sqlLen;
5681
  char*   sql;
5682
} SDropMountReq;
5683

5684
int32_t tSerializeSDropMountReq(void* buf, int32_t bufLen, SDropMountReq* pReq);
5685
int32_t tDeserializeSDropMountReq(void* buf, int32_t bufLen, SDropMountReq* pReq);
5686
void    tFreeSDropMountReq(SDropMountReq* pReq);
5687

5688
typedef struct {
5689
  char     mountName[TSDB_MOUNT_NAME_LEN];
5690
  char     mountPath[TSDB_MOUNT_PATH_LEN];
5691
  int64_t  mountUid;
5692
  int32_t  dnodeId;
5693
  uint32_t valLen;
5694
  int8_t   ignoreExist;
5695
  void*    pVal;
5696
} SRetrieveMountPathReq;
5697

5698
int32_t tSerializeSRetrieveMountPathReq(void* buf, int32_t bufLen, SRetrieveMountPathReq* pReq);
5699
int32_t tDeserializeSRetrieveMountPathReq(void* buf, int32_t bufLen, SRetrieveMountPathReq* pReq);
5700

5701
typedef struct {
5702
  // path
5703
  int32_t diskPrimary;
5704
  // vgInfo
5705
  int32_t  vgId;
5706
  int32_t  cacheLastSize;
5707
  int32_t  szPage;
5708
  int32_t  szCache;
5709
  uint64_t szBuf;
5710
  int8_t   cacheLast;
5711
  int8_t   standby;
5712
  int8_t   hashMethod;
5713
  uint32_t hashBegin;
5714
  uint32_t hashEnd;
5715
  int16_t  hashPrefix;
5716
  int16_t  hashSuffix;
5717
  int16_t  sttTrigger;
5718
  // syncInfo
5719
  int32_t replications;
5720
  // tsdbInfo
5721
  int8_t  precision;
5722
  int8_t  compression;
5723
  int8_t  slLevel;
5724
  int32_t daysPerFile;
5725
  int32_t keep0;
5726
  int32_t keep1;
5727
  int32_t keep2;
5728
  int32_t keepTimeOffset;
5729
  int32_t minRows;
5730
  int32_t maxRows;
5731
  int32_t tsdbPageSize;
5732
  int32_t ssChunkSize;
5733
  int32_t ssKeepLocal;
5734
  int8_t  ssCompact;
5735
  // walInfo
5736
  int32_t walFsyncPeriod;      // millisecond
5737
  int32_t walRetentionPeriod;  // secs
5738
  int32_t walRollPeriod;       // secs
5739
  int64_t walRetentionSize;
5740
  int64_t walSegSize;
5741
  int32_t walLevel;
5742
  // encryptInfo
5743
  int32_t encryptAlgorithm;
5744
  // SVState
5745
  int64_t committed;
5746
  int64_t commitID;
5747
  int64_t commitTerm;
5748
  // stats
5749
  int64_t numOfSTables;
5750
  int64_t numOfCTables;
5751
  int64_t numOfNTables;
5752
  // dbInfo
5753
  uint64_t dbId;
5754
} SMountVgInfo;
5755

5756
typedef struct {
5757
  SMCreateStbReq req;
5758
  SArray*        pColExts;  // element: column id
5759
  SArray*        pTagExts;  // element: tag id
5760
} SMountStbInfo;
5761

5762
int32_t tSerializeSMountStbInfo(void* buf, int32_t bufLen, int32_t* pFLen, SMountStbInfo* pInfo);
5763
int32_t tDeserializeSMountStbInfo(void* buf, int32_t bufLen, int32_t flen, SMountStbInfo* pInfo);
5764

5765
typedef struct {
5766
  char     dbName[TSDB_DB_FNAME_LEN];
5767
  uint64_t dbId;
5768
  SArray*  pVgs;      // SMountVgInfo
5769
  SArray*  pStbs;     // 0 serialized binary of SMountStbInfo, 1 SMountStbInfo
5770
} SMountDbInfo;
5771

5772
typedef struct {
5773
  // common fields
5774
  char     mountName[TSDB_MOUNT_NAME_LEN];
5775
  char     mountPath[TSDB_MOUNT_PATH_LEN];
5776
  int8_t   ignoreExist;
5777
  int64_t  mountUid;
5778
  int64_t  clusterId;
5779
  int32_t  dnodeId;
5780
  uint32_t valLen;
5781
  void*    pVal;
5782

5783
  // response fields
5784
  SArray* pDbs;  // SMountDbInfo
5785

5786
  // memory fields, no serialized
5787
  SArray*   pDisks[TFS_MAX_TIERS];
5788
  TdFilePtr pFile;
5789
} SMountInfo;
5790

5791
int32_t tSerializeSMountInfo(void* buf, int32_t bufLen, SMountInfo* pReq);
5792
int32_t tDeserializeSMountInfo(SDecoder* decoder, SMountInfo* pReq, bool extractStb);
5793
void    tFreeMountInfo(SMountInfo* pReq, bool stbExtracted);
5794

5795
typedef struct {
5796
  SCreateVnodeReq createReq;
5797
  char            mountPath[TSDB_MOUNT_FPATH_LEN];
5798
  char            mountName[TSDB_MOUNT_NAME_LEN];
5799
  int64_t         mountId;
5800
  int32_t         diskPrimary;
5801
  int32_t         mountVgId;
5802
  int64_t         committed;
5803
  int64_t         commitID;
5804
  int64_t         commitTerm;
5805
  int64_t         numOfSTables;
5806
  int64_t         numOfCTables;
5807
  int64_t         numOfNTables;
5808
} SMountVnodeReq;
5809

5810
int32_t tSerializeSMountVnodeReq(void *buf, int32_t *cBufLen, int32_t *tBufLen, SMountVnodeReq *pReq);
5811
int32_t tDeserializeSMountVnodeReq(void* buf, int32_t bufLen, SMountVnodeReq* pReq);
5812
int32_t tFreeSMountVnodeReq(SMountVnodeReq* pReq);
5813

5814
#endif  // USE_MOUNT
5815

5816
#pragma pack(pop)
5817

5818
typedef struct {
5819
  char        db[TSDB_DB_FNAME_LEN];
5820
  STimeWindow timeRange;
5821
  int32_t     sqlLen;
5822
  char*       sql;
5823
  SArray*     vgroupIds;
5824
} SScanDbReq;
5825

5826
int32_t tSerializeSScanDbReq(void* buf, int32_t bufLen, SScanDbReq* pReq);
5827
int32_t tDeserializeSScanDbReq(void* buf, int32_t bufLen, SScanDbReq* pReq);
5828
void    tFreeSScanDbReq(SScanDbReq* pReq);
5829

5830
typedef struct {
5831
  int32_t scanId;
5832
  int8_t  bAccepted;
5833
} SScanDbRsp;
5834

5835
int32_t tSerializeSScanDbRsp(void* buf, int32_t bufLen, SScanDbRsp* pRsp);
5836
int32_t tDeserializeSScanDbRsp(void* buf, int32_t bufLen, SScanDbRsp* pRsp);
5837

5838
typedef struct {
5839
  int32_t scanId;
5840
  int32_t sqlLen;
5841
  char*   sql;
5842
} SKillScanReq;
5843

5844
int32_t tSerializeSKillScanReq(void* buf, int32_t bufLen, SKillScanReq* pReq);
5845
int32_t tDeserializeSKillScanReq(void* buf, int32_t bufLen, SKillScanReq* pReq);
5846
void    tFreeSKillScanReq(SKillScanReq* pReq);
5847

5848
typedef struct {
5849
  int32_t scanId;
5850
  int32_t vgId;
5851
  int32_t dnodeId;
5852
} SVKillScanReq;
5853

5854
int32_t tSerializeSVKillScanReq(void* buf, int32_t bufLen, SVKillScanReq* pReq);
5855
int32_t tDeserializeSVKillScanReq(void* buf, int32_t bufLen, SVKillScanReq* pReq);
5856

5857
typedef struct {
5858
  int32_t scanId;
5859
  int32_t vgId;
5860
  int32_t dnodeId;
5861
  int32_t numberFileset;
5862
  int32_t finished;
5863
  int32_t progress;
5864
  int64_t remainingTime;
5865
} SQueryScanProgressRsp;
5866

5867
int32_t tSerializeSQueryScanProgressRsp(void* buf, int32_t bufLen, SQueryScanProgressRsp* pReq);
5868
int32_t tDeserializeSQueryScanProgressRsp(void* buf, int32_t bufLen, SQueryScanProgressRsp* pReq);
5869

5870
typedef struct {
5871
  int32_t scanId;
5872
  int32_t vgId;
5873
  int32_t dnodeId;
5874
} SQueryScanProgressReq;
5875

5876
int32_t tSerializeSQueryScanProgressReq(void* buf, int32_t bufLen, SQueryScanProgressReq* pReq);
5877
int32_t tDeserializeSQueryScanProgressReq(void* buf, int32_t bufLen, SQueryScanProgressReq* pReq);
5878

5879
typedef struct {
5880
  int64_t     dbUid;
5881
  char        db[TSDB_DB_FNAME_LEN];
5882
  int64_t     scanStartTime;
5883
  STimeWindow tw;
5884
  int32_t     scanId;
5885
} SScanVnodeReq;
5886

5887
int32_t tSerializeSScanVnodeReq(void* buf, int32_t bufLen, SScanVnodeReq* pReq);
5888
int32_t tDeserializeSScanVnodeReq(void* buf, int32_t bufLen, SScanVnodeReq* pReq);
5889

5890
#ifdef __cplusplus
5891
}
5892
#endif
5893

5894
#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