Coverage Report

Created: 2026-05-23 07:09

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/tdengine/include/common/tcommon.h
Line
Count
Source
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_DEF_H_
17
#define _TD_COMMON_DEF_H_
18
19
#include "tarray.h"
20
#include "tmsg.h"
21
#include "tvariant.h"
22
23
#ifdef __cplusplus
24
extern "C" {
25
#endif
26
27
// clang-format off
28
#define IS_META_MSG(x) ( \
29
     x == TDMT_VND_CREATE_STB     \
30
  || x == TDMT_VND_ALTER_STB      \
31
  || x == TDMT_VND_DROP_STB       \
32
  || x == TDMT_VND_CREATE_TABLE   \
33
  || x == TDMT_VND_ALTER_TABLE    \
34
  || x == TDMT_VND_DROP_TABLE     \
35
  || x == TDMT_VND_DELETE         \
36
)
37
// clang-format on
38
39
typedef bool (*state_key_cmpr_fn)(void* pKey1, void* pKey2);
40
41
typedef struct STableKeyInfo {
42
  uint64_t uid;
43
  uint64_t groupId;
44
  uint64_t baseGId;
45
} STableKeyInfo;
46
47
typedef struct SWinKey {
48
  uint64_t groupId;
49
  TSKEY    ts;
50
  int32_t  numInGroup;
51
} SWinKey;
52
53
typedef struct SSessionKey {
54
  STimeWindow win;
55
  uint64_t    groupId;
56
} SSessionKey;
57
58
typedef int64_t COUNT_TYPE;
59
60
typedef struct SVersionRange {
61
  int64_t minVer;
62
  int64_t maxVer;
63
} SVersionRange;
64
65
0
static inline int winKeyCmprImpl(const void* pKey1, const void* pKey2) {
66
0
  SWinKey* pWin1 = (SWinKey*)pKey1;
67
0
  SWinKey* pWin2 = (SWinKey*)pKey2;
68
0
69
0
  if (pWin1->groupId > pWin2->groupId) {
70
0
    return 1;
71
0
  } else if (pWin1->groupId < pWin2->groupId) {
72
0
    return -1;
73
0
  }
74
0
75
0
  if (pWin1->ts > pWin2->ts) {
76
0
    return 1;
77
0
  } else if (pWin1->ts < pWin2->ts) {
78
0
    return -1;
79
0
  }
80
0
81
0
  return 0;
82
0
}
Unexecuted instantiation: sql-fuzzer.c:winKeyCmprImpl
Unexecuted instantiation: parser.c:winKeyCmprImpl
Unexecuted instantiation: parTranslater.c:winKeyCmprImpl
Unexecuted instantiation: parUtil.c:winKeyCmprImpl
Unexecuted instantiation: parAstParser.c:winKeyCmprImpl
Unexecuted instantiation: parAuthenticator.c:winKeyCmprImpl
Unexecuted instantiation: parCalcConst.c:winKeyCmprImpl
Unexecuted instantiation: parInsertSql.c:winKeyCmprImpl
Unexecuted instantiation: parInsertUtil.c:winKeyCmprImpl
Unexecuted instantiation: taos_lemon_sql.tab.c:winKeyCmprImpl
Unexecuted instantiation: parAstCreater.c:winKeyCmprImpl
Unexecuted instantiation: parInsertSml.c:winKeyCmprImpl
Unexecuted instantiation: planLogicCreater.c:winKeyCmprImpl
Unexecuted instantiation: planOptimizer.c:winKeyCmprImpl
Unexecuted instantiation: planPhysiCreater.c:winKeyCmprImpl
Unexecuted instantiation: planSpliter.c:winKeyCmprImpl
Unexecuted instantiation: planUtil.c:winKeyCmprImpl
Unexecuted instantiation: planValidator.c:winKeyCmprImpl
Unexecuted instantiation: catalog.c:winKeyCmprImpl
Unexecuted instantiation: ctgAsync.c:winKeyCmprImpl
Unexecuted instantiation: ctgCache.c:winKeyCmprImpl
Unexecuted instantiation: ctgDbg.c:winKeyCmprImpl
Unexecuted instantiation: ctgRemote.c:winKeyCmprImpl
Unexecuted instantiation: ctgRent.c:winKeyCmprImpl
Unexecuted instantiation: ctgUtil.c:winKeyCmprImpl
Unexecuted instantiation: functionMgt.c:winKeyCmprImpl
Unexecuted instantiation: tudf.c:winKeyCmprImpl
Unexecuted instantiation: builtins.c:winKeyCmprImpl
Unexecuted instantiation: builtinsimpl.c:winKeyCmprImpl
Unexecuted instantiation: thistogram.c:winKeyCmprImpl
Unexecuted instantiation: tpercentile.c:winKeyCmprImpl
Unexecuted instantiation: tavgfunction.c:winKeyCmprImpl
Unexecuted instantiation: tminmax.c:winKeyCmprImpl
Unexecuted instantiation: tminmaxavx.c:winKeyCmprImpl
Unexecuted instantiation: filter.c:winKeyCmprImpl
Unexecuted instantiation: scalar.c:winKeyCmprImpl
Unexecuted instantiation: sclfunc.c:winKeyCmprImpl
Unexecuted instantiation: sclvector.c:winKeyCmprImpl
Unexecuted instantiation: nodesCloneFuncs.c:winKeyCmprImpl
Unexecuted instantiation: nodesCodeFuncs.c:winKeyCmprImpl
Unexecuted instantiation: nodesEqualFuncs.c:winKeyCmprImpl
Unexecuted instantiation: nodesMsgFuncs.c:winKeyCmprImpl
Unexecuted instantiation: nodesUtilFuncs.c:winKeyCmprImpl
Unexecuted instantiation: geomFunc.c:winKeyCmprImpl
Unexecuted instantiation: tdigest.c:winKeyCmprImpl
Unexecuted instantiation: tlog.c:winKeyCmprImpl
Unexecuted instantiation: tdatablock.c:winKeyCmprImpl
Unexecuted instantiation: tdataformat.c:winKeyCmprImpl
Unexecuted instantiation: tmisce.c:winKeyCmprImpl
Unexecuted instantiation: tname.c:winKeyCmprImpl
Unexecuted instantiation: ttime.c:winKeyCmprImpl
Unexecuted instantiation: streamMsg.c:winKeyCmprImpl
83
84
0
static inline int winKeyCmpr(const void* pKey1, int kLen1, const void* pKey2, int kLen2) {
85
0
  return winKeyCmprImpl(pKey1, pKey2);
86
0
}
Unexecuted instantiation: sql-fuzzer.c:winKeyCmpr
Unexecuted instantiation: parser.c:winKeyCmpr
Unexecuted instantiation: parTranslater.c:winKeyCmpr
Unexecuted instantiation: parUtil.c:winKeyCmpr
Unexecuted instantiation: parAstParser.c:winKeyCmpr
Unexecuted instantiation: parAuthenticator.c:winKeyCmpr
Unexecuted instantiation: parCalcConst.c:winKeyCmpr
Unexecuted instantiation: parInsertSql.c:winKeyCmpr
Unexecuted instantiation: parInsertUtil.c:winKeyCmpr
Unexecuted instantiation: taos_lemon_sql.tab.c:winKeyCmpr
Unexecuted instantiation: parAstCreater.c:winKeyCmpr
Unexecuted instantiation: parInsertSml.c:winKeyCmpr
Unexecuted instantiation: planLogicCreater.c:winKeyCmpr
Unexecuted instantiation: planOptimizer.c:winKeyCmpr
Unexecuted instantiation: planPhysiCreater.c:winKeyCmpr
Unexecuted instantiation: planSpliter.c:winKeyCmpr
Unexecuted instantiation: planUtil.c:winKeyCmpr
Unexecuted instantiation: planValidator.c:winKeyCmpr
Unexecuted instantiation: catalog.c:winKeyCmpr
Unexecuted instantiation: ctgAsync.c:winKeyCmpr
Unexecuted instantiation: ctgCache.c:winKeyCmpr
Unexecuted instantiation: ctgDbg.c:winKeyCmpr
Unexecuted instantiation: ctgRemote.c:winKeyCmpr
Unexecuted instantiation: ctgRent.c:winKeyCmpr
Unexecuted instantiation: ctgUtil.c:winKeyCmpr
Unexecuted instantiation: functionMgt.c:winKeyCmpr
Unexecuted instantiation: tudf.c:winKeyCmpr
Unexecuted instantiation: builtins.c:winKeyCmpr
Unexecuted instantiation: builtinsimpl.c:winKeyCmpr
Unexecuted instantiation: thistogram.c:winKeyCmpr
Unexecuted instantiation: tpercentile.c:winKeyCmpr
Unexecuted instantiation: tavgfunction.c:winKeyCmpr
Unexecuted instantiation: tminmax.c:winKeyCmpr
Unexecuted instantiation: tminmaxavx.c:winKeyCmpr
Unexecuted instantiation: filter.c:winKeyCmpr
Unexecuted instantiation: scalar.c:winKeyCmpr
Unexecuted instantiation: sclfunc.c:winKeyCmpr
Unexecuted instantiation: sclvector.c:winKeyCmpr
Unexecuted instantiation: nodesCloneFuncs.c:winKeyCmpr
Unexecuted instantiation: nodesCodeFuncs.c:winKeyCmpr
Unexecuted instantiation: nodesEqualFuncs.c:winKeyCmpr
Unexecuted instantiation: nodesMsgFuncs.c:winKeyCmpr
Unexecuted instantiation: nodesUtilFuncs.c:winKeyCmpr
Unexecuted instantiation: geomFunc.c:winKeyCmpr
Unexecuted instantiation: tdigest.c:winKeyCmpr
Unexecuted instantiation: tlog.c:winKeyCmpr
Unexecuted instantiation: tdatablock.c:winKeyCmpr
Unexecuted instantiation: tdataformat.c:winKeyCmpr
Unexecuted instantiation: tmisce.c:winKeyCmpr
Unexecuted instantiation: tname.c:winKeyCmpr
Unexecuted instantiation: ttime.c:winKeyCmpr
Unexecuted instantiation: streamMsg.c:winKeyCmpr
87
88
typedef struct {
89
  uint64_t groupId;
90
  TSKEY    ts;
91
  int32_t  exprIdx;
92
} STupleKey;
93
94
0
static inline int STupleKeyCmpr(const void* pKey1, int kLen1, const void* pKey2, int kLen2) {
95
0
  STupleKey* pTuple1 = (STupleKey*)pKey1;
96
0
  STupleKey* pTuple2 = (STupleKey*)pKey2;
97
0
98
0
  if (pTuple1->groupId > pTuple2->groupId) {
99
0
    return 1;
100
0
  } else if (pTuple1->groupId < pTuple2->groupId) {
101
0
    return -1;
102
0
  }
103
0
104
0
  if (pTuple1->ts > pTuple2->ts) {
105
0
    return 1;
106
0
  } else if (pTuple1->ts < pTuple2->ts) {
107
0
    return -1;
108
0
  }
109
0
110
0
  if (pTuple1->exprIdx > pTuple2->exprIdx) {
111
0
    return 1;
112
0
  } else if (pTuple1->exprIdx < pTuple2->exprIdx) {
113
0
    return -1;
114
0
  }
115
0
116
0
  return 0;
117
0
}
Unexecuted instantiation: sql-fuzzer.c:STupleKeyCmpr
Unexecuted instantiation: parser.c:STupleKeyCmpr
Unexecuted instantiation: parTranslater.c:STupleKeyCmpr
Unexecuted instantiation: parUtil.c:STupleKeyCmpr
Unexecuted instantiation: parAstParser.c:STupleKeyCmpr
Unexecuted instantiation: parAuthenticator.c:STupleKeyCmpr
Unexecuted instantiation: parCalcConst.c:STupleKeyCmpr
Unexecuted instantiation: parInsertSql.c:STupleKeyCmpr
Unexecuted instantiation: parInsertUtil.c:STupleKeyCmpr
Unexecuted instantiation: taos_lemon_sql.tab.c:STupleKeyCmpr
Unexecuted instantiation: parAstCreater.c:STupleKeyCmpr
Unexecuted instantiation: parInsertSml.c:STupleKeyCmpr
Unexecuted instantiation: planLogicCreater.c:STupleKeyCmpr
Unexecuted instantiation: planOptimizer.c:STupleKeyCmpr
Unexecuted instantiation: planPhysiCreater.c:STupleKeyCmpr
Unexecuted instantiation: planSpliter.c:STupleKeyCmpr
Unexecuted instantiation: planUtil.c:STupleKeyCmpr
Unexecuted instantiation: planValidator.c:STupleKeyCmpr
Unexecuted instantiation: catalog.c:STupleKeyCmpr
Unexecuted instantiation: ctgAsync.c:STupleKeyCmpr
Unexecuted instantiation: ctgCache.c:STupleKeyCmpr
Unexecuted instantiation: ctgDbg.c:STupleKeyCmpr
Unexecuted instantiation: ctgRemote.c:STupleKeyCmpr
Unexecuted instantiation: ctgRent.c:STupleKeyCmpr
Unexecuted instantiation: ctgUtil.c:STupleKeyCmpr
Unexecuted instantiation: functionMgt.c:STupleKeyCmpr
Unexecuted instantiation: tudf.c:STupleKeyCmpr
Unexecuted instantiation: builtins.c:STupleKeyCmpr
Unexecuted instantiation: builtinsimpl.c:STupleKeyCmpr
Unexecuted instantiation: thistogram.c:STupleKeyCmpr
Unexecuted instantiation: tpercentile.c:STupleKeyCmpr
Unexecuted instantiation: tavgfunction.c:STupleKeyCmpr
Unexecuted instantiation: tminmax.c:STupleKeyCmpr
Unexecuted instantiation: tminmaxavx.c:STupleKeyCmpr
Unexecuted instantiation: filter.c:STupleKeyCmpr
Unexecuted instantiation: scalar.c:STupleKeyCmpr
Unexecuted instantiation: sclfunc.c:STupleKeyCmpr
Unexecuted instantiation: sclvector.c:STupleKeyCmpr
Unexecuted instantiation: nodesCloneFuncs.c:STupleKeyCmpr
Unexecuted instantiation: nodesCodeFuncs.c:STupleKeyCmpr
Unexecuted instantiation: nodesEqualFuncs.c:STupleKeyCmpr
Unexecuted instantiation: nodesMsgFuncs.c:STupleKeyCmpr
Unexecuted instantiation: nodesUtilFuncs.c:STupleKeyCmpr
Unexecuted instantiation: geomFunc.c:STupleKeyCmpr
Unexecuted instantiation: tdigest.c:STupleKeyCmpr
Unexecuted instantiation: tlog.c:STupleKeyCmpr
Unexecuted instantiation: tdatablock.c:STupleKeyCmpr
Unexecuted instantiation: tdataformat.c:STupleKeyCmpr
Unexecuted instantiation: tmisce.c:STupleKeyCmpr
Unexecuted instantiation: tname.c:STupleKeyCmpr
Unexecuted instantiation: ttime.c:STupleKeyCmpr
Unexecuted instantiation: streamMsg.c:STupleKeyCmpr
118
119
enum {
120
  TMQ_MSG_TYPE__POLL_DATA_RSP = 0,
121
  TMQ_MSG_TYPE__POLL_META_RSP,
122
  TMQ_MSG_TYPE__EP_RSP,
123
  TMQ_MSG_TYPE__POLL_DATA_META_RSP,
124
  TMQ_MSG_TYPE__WALINFO_RSP,
125
  TMQ_MSG_TYPE__POLL_BATCH_META_RSP,
126
  TMQ_MSG_TYPE__POLL_RAW_DATA_RSP,
127
};
128
129
static const char* const tmqMsgTypeStr[] = {
130
    "data", "meta", "ask ep", "meta data", "wal info", "batch meta", "raw data"
131
};
132
133
enum {
134
  STREAM_INPUT__DATA_SUBMIT = 1,
135
  STREAM_INPUT__DATA_BLOCK,
136
  STREAM_INPUT__MERGED_SUBMIT,
137
  STREAM_INPUT__RECALCULATE,
138
  STREAM_INPUT__DATA_RETRIEVE,
139
  STREAM_INPUT__GET_RES,
140
  STREAM_INPUT__CHECKPOINT,
141
  STREAM_INPUT__CHECKPOINT_TRIGGER,
142
  STREAM_INPUT__TRANS_STATE,
143
  STREAM_INPUT__REF_DATA_BLOCK,
144
  STREAM_INPUT__DESTROY,
145
};
146
147
#pragma pack(push, 1)
148
typedef struct SColumnDataAgg {
149
  int32_t colId;
150
  int16_t numOfNull;
151
  union {
152
    struct {
153
      int64_t sum;
154
      int64_t max;
155
      int64_t min;
156
    };
157
    struct {
158
      uint64_t decimal128Sum[2];
159
      uint64_t decimal128Max[2];
160
      uint64_t decimal128Min[2];
161
      uint8_t  overflow;
162
    };
163
  };
164
} SColumnDataAgg;
165
#pragma pack(pop)
166
167
0
#define DECIMAL_AGG_FLAG 0x80000000
168
169
#define COL_AGG_GET_SUM_PTR(pAggs, dataType) \
170
  (!IS_DECIMAL_TYPE(dataType) ? (void*)&pAggs->sum : (void*)pAggs->decimal128Sum)
171
172
#define COL_AGG_GET_MAX_PTR(pAggs, dataType) \
173
  (!IS_DECIMAL_TYPE(dataType) ? (void*)&pAggs->max : (void*)pAggs->decimal128Max)
174
175
#define COL_AGG_GET_MIN_PTR(pAggs, dataType) \
176
  (!IS_DECIMAL_TYPE(dataType) ? (void*)&pAggs->min : (void*)pAggs->decimal128Min)
177
178
typedef struct SBlockID {
179
  // The uid of table, from which current data block comes. And it is always 0, if current block is the
180
  // result of calculation.
181
  uint64_t uid;
182
183
  // Block id, acquired and assigned from executor, which created according to the hysical planner. Block id is used
184
  // to mark the stage of exec task.
185
  int64_t  blockId;
186
187
  // Generated by group/partition by [value|tags]. Created and assigned by table-scan operator, group-by operator,
188
  // and partition by operator.
189
  uint64_t groupId;
190
191
  // Base group id for stream group generated by trigger
192
  uint64_t baseGId;
193
} SBlockID;
194
195
typedef struct SPkInfo {
196
  int8_t  type;
197
  int32_t bytes;
198
  union {
199
    int64_t  val;
200
    uint8_t* pData;
201
  } skey;
202
  union {
203
    int64_t  val;
204
    uint8_t* pData;
205
  } ekey;
206
} SPkInfo;
207
208
typedef struct SDataBlockInfo {
209
  STimeWindow window;
210
  int32_t     rowSize;
211
  uint32_t    capacity;
212
  int64_t     rows;  // todo hide this attribute
213
  SBlockID    id;
214
  int16_t     hasVarCol;
215
  int16_t     dataLoad;  // denote if the data is loaded or not
216
  uint8_t     scanFlag;
217
  bool        blankFill;
218
  SValue      pks[2];
219
220
  // TODO: optimize and remove following
221
  int64_t     version;    // used for stream, and need serialization
222
  int32_t     childId;    // used for stream, do not serialize
223
  STimeWindow calWin;     // used for stream, do not serialize
224
  TSKEY       watermark;  // used for stream
225
226
  char parTbName[TSDB_TABLE_NAME_LEN];  // used for stream partition
227
} SDataBlockInfo;
228
229
typedef struct SSDataBlock {
230
  SColumnDataAgg* pBlockAgg;
231
  SArray*         pDataBlock;  // SArray<SColumnInfoData>
232
  SDataBlockInfo  info;
233
} SSDataBlock;
234
235
typedef struct SVarColAttr {
236
  int32_t* offset;    // start position for each entry in the list
237
  uint32_t length;    // used buffer size that contain the valid data
238
  uint32_t allocLen;  // allocated buffer size
239
} SVarColAttr;
240
241
// pBlockAgg->numOfNull == info.rows, all data are null
242
// pBlockAgg->numOfNull == 0, no data are null.
243
typedef struct SColumnInfoData {
244
  char* pData;  // the corresponding block data in memory
245
  union {
246
    char*       nullbitmap;  // bitmap, one bit for each item in the list
247
    SVarColAttr varmeta;
248
  };
249
  SColumnInfo info;        // column info
250
  bool        hasNull;     // if current column data has null value.
251
  bool        reassigned;  // if current column data is reassigned.
252
} SColumnInfoData;
253
254
typedef struct SQueryTableDataCond {
255
  uint64_t     suid;
256
  int32_t      order;  // desc|asc order to iterate the data block
257
  int32_t      numOfCols;
258
  SColumnInfo* colList;
259
  int32_t*     pSlotList;  // the column output destation slot, and it may be null
260
  int32_t      type;       // data block load type:
261
  bool         skipRollup;
262
  STimeWindow  twindows;
263
  STimeWindow  extTwindows[2];
264
  int64_t      startVersion;
265
  int64_t      endVersion;
266
  bool         notLoadData;  // response the actual data, not only the rows in the attribute of info.row of ssdatablock
267
  bool         cacheSttStatis;
268
} SQueryTableDataCond;
269
270
int32_t tEncodeDataBlock(void** buf, const SSDataBlock* pBlock);
271
void*   tDecodeDataBlock(const void* buf, SSDataBlock* pBlock);
272
273
void colDataDestroy(SColumnInfoData* pColData);
274
275
//======================================================================================================================
276
// the following structure shared by parser and executor
277
typedef struct SColumn {
278
  union {
279
    uint64_t uid;
280
    int64_t  dataBlockId;
281
  };
282
283
  int16_t colId;
284
  int16_t slotId;
285
286
  char    name[TSDB_COL_NAME_LEN];
287
  int16_t colType;  // column type: normal column, tag, or window column
288
  int16_t type;
289
  int32_t bytes;
290
  uint8_t precision;
291
  uint8_t scale;
292
} SColumn;
293
294
typedef struct STableBlockDistInfo {
295
  uint32_t rowSize;
296
  uint16_t numOfFiles;
297
  uint32_t numOfTables;
298
  uint32_t numOfBlocks;
299
  uint64_t totalSize;
300
  uint64_t totalRows;
301
  int32_t  maxRows;
302
  int32_t  minRows;
303
  int32_t  defMinRows;
304
  int32_t  defMaxRows;
305
  int32_t  firstSeekTimeUs;
306
  uint32_t numOfInmemRows;
307
  uint32_t numOfSttRows;
308
  uint32_t numOfVgroups;
309
  int32_t  blockRowsHisto[20];
310
} STableBlockDistInfo;
311
312
int32_t tSerializeBlockDistInfo(void* buf, int32_t bufLen, const STableBlockDistInfo* pInfo);
313
int32_t tDeserializeBlockDistInfo(void* buf, int32_t bufLen, STableBlockDistInfo* pInfo);
314
315
typedef struct SDBBlockUsageInfo {
316
  uint64_t dataInDiskSize;
317
  uint64_t walInDiskSize;
318
  uint64_t rawDataSize;
319
} SDBBlockUsageInfo;
320
321
int32_t tSerializeBlockDbUsage(void* buf, int32_t bufLen, const SDBBlockUsageInfo* pInfo);
322
int32_t tDeserializeBlockDbUsage(void* buf, int32_t bufLen, SDBBlockUsageInfo* pInfo);
323
324
enum {
325
  FUNC_PARAM_TYPE_VALUE = 0x1,
326
  FUNC_PARAM_TYPE_COLUMN = 0x2,
327
};
328
329
typedef struct SFunctParam {
330
  int32_t  type;
331
  SColumn* pCol;
332
  SVariant param;
333
} SFunctParam;
334
335
// the structure for sql function in select clause
336
typedef struct SResSchame {
337
  int8_t  type;
338
  int32_t slotId;
339
  int32_t bytes;
340
  int32_t precision;
341
  int32_t scale;
342
  char    name[TSDB_COL_NAME_LEN];
343
} SResSchema;
344
345
typedef struct SAggSupporter  SAggSupporter;
346
typedef struct SExprSupp      SExprSupp;
347
typedef struct SGroupResInfo  SGroupResInfo;
348
typedef struct SResultRow     SResultRow;
349
typedef struct SResultRowInfo SResultRowInfo;
350
typedef struct SExecTaskInfo  SExecTaskInfo;
351
typedef struct SRollupCtx {
352
  void*           pTsdb;     // STsdb*
353
  void*           pTargets;  // SNodeList*
354
  void*           pBuf;
355
  SExprSupp*      exprSup;
356
  SAggSupporter*  aggSup;
357
  SResultRow*     resultRow;
358
  SResultRowInfo* resultRowInfo;
359
  SGroupResInfo*  pGroupResInfo;
360
  SExecTaskInfo*  pTaskInfo;
361
  SSDataBlock*    pInputBlock;  // input data block for rollup
362
  SSDataBlock*    pResBlock;    // result data block for rollup
363
  SArray*         pColValArr;   // used the generate the aggregate row
364
  int32_t         rowSize;
365
  int32_t         maxBufRows;    // max buffer rows for aggregation
366
  int64_t         winTotalRows;  // number of total rows for current window
367
  int64_t         winStartTs;    // start timestamp of current window
368
} SRollupCtx;
369
370
typedef struct {
371
  const char* key;
372
  size_t      keyLen;
373
  uint8_t     type;
374
  union {
375
    const char* value;
376
    int64_t     i;
377
    uint64_t    u;
378
    double      d;
379
    float       f;
380
  };
381
  size_t length;
382
  bool   keyEscaped;
383
  bool   valueEscaped;
384
} SSmlKv;
385
386
0
#define QUERY_ASC_FORWARD_STEP  1
387
0
#define QUERY_DESC_FORWARD_STEP -1
388
389
0
#define GET_FORWARD_DIRECTION_FACTOR(ord) (((ord) != TSDB_ORDER_DESC) ? QUERY_ASC_FORWARD_STEP : QUERY_DESC_FORWARD_STEP)
390
391
#define SORT_QSORT_T              0x1
392
#define SORT_SPILLED_MERGE_SORT_T 0x2
393
typedef struct SSortExecInfo {
394
  int32_t sortMethod;
395
  int32_t sortBuffer;
396
  int32_t loops;       // loop count
397
  int32_t writeBytes;  // write io bytes
398
  int32_t readBytes;   // read io bytes
399
} SSortExecInfo;
400
401
typedef struct SExchangeExplainInfo {
402
  int8_t   mode;          // 0: concurrent, 1: sequential
403
  int32_t  numSources;
404
  double   avgFetchTimes;
405
  uint64_t maxFetchTimes;
406
  double   avgFetchRows;
407
  uint64_t maxFetchRows;
408
  double   avgFetchCost;  // us
409
  int64_t  maxFetchCost;  // us
410
} SExchangeExplainInfo;
411
412
typedef struct SNonSortExecInfo {
413
  int32_t blkNums;
414
} SNonSortExecInfo;
415
416
typedef struct STUidTagInfo {
417
  char*    name;
418
  uint64_t uid;
419
  void*    pTagVal;
420
} STUidTagInfo;
421
422
// stream special block column
423
424
#define START_TS_COLUMN_INDEX           0
425
#define END_TS_COLUMN_INDEX             1
426
#define UID_COLUMN_INDEX                2
427
#define GROUPID_COLUMN_INDEX            3
428
#define CALCULATE_START_TS_COLUMN_INDEX 4
429
#define CALCULATE_END_TS_COLUMN_INDEX   5
430
#define TABLE_NAME_COLUMN_INDEX         6
431
#define PRIMARY_KEY_COLUMN_INDEX        7
432
433
//steam get result block column
434
#define DATA_TS_COLUMN_INDEX            0
435
#define DATA_VERSION_COLUMN_INDEX       1
436
437
// stream create table block column
438
#define UD_TABLE_NAME_COLUMN_INDEX 0
439
#define UD_GROUPID_COLUMN_INDEX    1
440
#define UD_TAG_COLUMN_INDEX        2
441
442
// stream notify event block column
443
#define NOTIFY_EVENT_STR_COLUMN_INDEX 0
444
445
int32_t taosGenCrashJsonMsg(int signum, char** pMsg, int64_t clusterId, int64_t startTime);
446
447
#define SHOW_VAR_PRIV_SYSTEM   0x01
448
#define SHOW_VAR_PRIV_SECURITY 0x02
449
#define SHOW_VAR_PRIV_AUDIT    0x04
450
#define SHOW_VAR_PRIV_DEBUG    0x08
451
#define SHOW_VAR_PRIV_ALL (SHOW_VAR_PRIV_SYSTEM | SHOW_VAR_PRIV_SECURITY | SHOW_VAR_PRIV_AUDIT | SHOW_VAR_PRIV_DEBUG)
452
453
int32_t dumpConfToDataBlock(SSDataBlock* pBlock, int32_t startCol, char* likePattern, uint8_t showPrivMask);
454
455
0
#define TSMA_RES_STB_POSTFIX          "_tsma_res_stb_"
456
0
#define MD5_OUTPUT_LEN                32
457
0
#define TSMA_RES_STB_EXTRA_COLUMN_NUM 4  // 3 columns: _wstart, _wend, _wduration, 1 tag: tbname
458
459
0
static inline bool isTsmaResSTb(const char* stbName) {
460
0
  static bool showTsmaTables = true;
461
0
  if (showTsmaTables) return false;
462
0
  const char* pos = strstr(stbName, TSMA_RES_STB_POSTFIX);
463
0
  if (pos && strlen(stbName) == (pos - stbName) + strlen(TSMA_RES_STB_POSTFIX)) {
464
0
    return true;
465
0
  }
466
0
  return false;
467
0
}
Unexecuted instantiation: sql-fuzzer.c:isTsmaResSTb
Unexecuted instantiation: parser.c:isTsmaResSTb
Unexecuted instantiation: parTranslater.c:isTsmaResSTb
Unexecuted instantiation: parUtil.c:isTsmaResSTb
Unexecuted instantiation: parAstParser.c:isTsmaResSTb
Unexecuted instantiation: parAuthenticator.c:isTsmaResSTb
Unexecuted instantiation: parCalcConst.c:isTsmaResSTb
Unexecuted instantiation: parInsertSql.c:isTsmaResSTb
Unexecuted instantiation: parInsertUtil.c:isTsmaResSTb
Unexecuted instantiation: taos_lemon_sql.tab.c:isTsmaResSTb
Unexecuted instantiation: parAstCreater.c:isTsmaResSTb
Unexecuted instantiation: parInsertSml.c:isTsmaResSTb
Unexecuted instantiation: planLogicCreater.c:isTsmaResSTb
Unexecuted instantiation: planOptimizer.c:isTsmaResSTb
Unexecuted instantiation: planPhysiCreater.c:isTsmaResSTb
Unexecuted instantiation: planSpliter.c:isTsmaResSTb
Unexecuted instantiation: planUtil.c:isTsmaResSTb
Unexecuted instantiation: planValidator.c:isTsmaResSTb
Unexecuted instantiation: catalog.c:isTsmaResSTb
Unexecuted instantiation: ctgAsync.c:isTsmaResSTb
Unexecuted instantiation: ctgCache.c:isTsmaResSTb
Unexecuted instantiation: ctgDbg.c:isTsmaResSTb
Unexecuted instantiation: ctgRemote.c:isTsmaResSTb
Unexecuted instantiation: ctgRent.c:isTsmaResSTb
Unexecuted instantiation: ctgUtil.c:isTsmaResSTb
Unexecuted instantiation: functionMgt.c:isTsmaResSTb
Unexecuted instantiation: tudf.c:isTsmaResSTb
Unexecuted instantiation: builtins.c:isTsmaResSTb
Unexecuted instantiation: builtinsimpl.c:isTsmaResSTb
Unexecuted instantiation: thistogram.c:isTsmaResSTb
Unexecuted instantiation: tpercentile.c:isTsmaResSTb
Unexecuted instantiation: tavgfunction.c:isTsmaResSTb
Unexecuted instantiation: tminmax.c:isTsmaResSTb
Unexecuted instantiation: tminmaxavx.c:isTsmaResSTb
Unexecuted instantiation: filter.c:isTsmaResSTb
Unexecuted instantiation: scalar.c:isTsmaResSTb
Unexecuted instantiation: sclfunc.c:isTsmaResSTb
Unexecuted instantiation: sclvector.c:isTsmaResSTb
Unexecuted instantiation: nodesCloneFuncs.c:isTsmaResSTb
Unexecuted instantiation: nodesCodeFuncs.c:isTsmaResSTb
Unexecuted instantiation: nodesEqualFuncs.c:isTsmaResSTb
Unexecuted instantiation: nodesMsgFuncs.c:isTsmaResSTb
Unexecuted instantiation: nodesUtilFuncs.c:isTsmaResSTb
Unexecuted instantiation: geomFunc.c:isTsmaResSTb
Unexecuted instantiation: tdigest.c:isTsmaResSTb
Unexecuted instantiation: tlog.c:isTsmaResSTb
Unexecuted instantiation: tdatablock.c:isTsmaResSTb
Unexecuted instantiation: tdataformat.c:isTsmaResSTb
Unexecuted instantiation: tmisce.c:isTsmaResSTb
Unexecuted instantiation: tname.c:isTsmaResSTb
Unexecuted instantiation: ttime.c:isTsmaResSTb
Unexecuted instantiation: streamMsg.c:isTsmaResSTb
468
469
0
static inline STypeMod typeGetTypeModFromColInfo(const SColumnInfo* pCol) {
470
0
  return typeGetTypeMod(pCol->type, pCol->precision, pCol->scale, pCol->bytes);
471
0
}
Unexecuted instantiation: sql-fuzzer.c:typeGetTypeModFromColInfo
Unexecuted instantiation: parser.c:typeGetTypeModFromColInfo
Unexecuted instantiation: parTranslater.c:typeGetTypeModFromColInfo
Unexecuted instantiation: parUtil.c:typeGetTypeModFromColInfo
Unexecuted instantiation: parAstParser.c:typeGetTypeModFromColInfo
Unexecuted instantiation: parAuthenticator.c:typeGetTypeModFromColInfo
Unexecuted instantiation: parCalcConst.c:typeGetTypeModFromColInfo
Unexecuted instantiation: parInsertSql.c:typeGetTypeModFromColInfo
Unexecuted instantiation: parInsertUtil.c:typeGetTypeModFromColInfo
Unexecuted instantiation: taos_lemon_sql.tab.c:typeGetTypeModFromColInfo
Unexecuted instantiation: parAstCreater.c:typeGetTypeModFromColInfo
Unexecuted instantiation: parInsertSml.c:typeGetTypeModFromColInfo
Unexecuted instantiation: planLogicCreater.c:typeGetTypeModFromColInfo
Unexecuted instantiation: planOptimizer.c:typeGetTypeModFromColInfo
Unexecuted instantiation: planPhysiCreater.c:typeGetTypeModFromColInfo
Unexecuted instantiation: planSpliter.c:typeGetTypeModFromColInfo
Unexecuted instantiation: planUtil.c:typeGetTypeModFromColInfo
Unexecuted instantiation: planValidator.c:typeGetTypeModFromColInfo
Unexecuted instantiation: catalog.c:typeGetTypeModFromColInfo
Unexecuted instantiation: ctgAsync.c:typeGetTypeModFromColInfo
Unexecuted instantiation: ctgCache.c:typeGetTypeModFromColInfo
Unexecuted instantiation: ctgDbg.c:typeGetTypeModFromColInfo
Unexecuted instantiation: ctgRemote.c:typeGetTypeModFromColInfo
Unexecuted instantiation: ctgRent.c:typeGetTypeModFromColInfo
Unexecuted instantiation: ctgUtil.c:typeGetTypeModFromColInfo
Unexecuted instantiation: functionMgt.c:typeGetTypeModFromColInfo
Unexecuted instantiation: tudf.c:typeGetTypeModFromColInfo
Unexecuted instantiation: builtins.c:typeGetTypeModFromColInfo
Unexecuted instantiation: builtinsimpl.c:typeGetTypeModFromColInfo
Unexecuted instantiation: thistogram.c:typeGetTypeModFromColInfo
Unexecuted instantiation: tpercentile.c:typeGetTypeModFromColInfo
Unexecuted instantiation: tavgfunction.c:typeGetTypeModFromColInfo
Unexecuted instantiation: tminmax.c:typeGetTypeModFromColInfo
Unexecuted instantiation: tminmaxavx.c:typeGetTypeModFromColInfo
Unexecuted instantiation: filter.c:typeGetTypeModFromColInfo
Unexecuted instantiation: scalar.c:typeGetTypeModFromColInfo
Unexecuted instantiation: sclfunc.c:typeGetTypeModFromColInfo
Unexecuted instantiation: sclvector.c:typeGetTypeModFromColInfo
Unexecuted instantiation: nodesCloneFuncs.c:typeGetTypeModFromColInfo
Unexecuted instantiation: nodesCodeFuncs.c:typeGetTypeModFromColInfo
Unexecuted instantiation: nodesEqualFuncs.c:typeGetTypeModFromColInfo
Unexecuted instantiation: nodesMsgFuncs.c:typeGetTypeModFromColInfo
Unexecuted instantiation: nodesUtilFuncs.c:typeGetTypeModFromColInfo
Unexecuted instantiation: geomFunc.c:typeGetTypeModFromColInfo
Unexecuted instantiation: tdigest.c:typeGetTypeModFromColInfo
Unexecuted instantiation: tlog.c:typeGetTypeModFromColInfo
Unexecuted instantiation: tdatablock.c:typeGetTypeModFromColInfo
Unexecuted instantiation: tdataformat.c:typeGetTypeModFromColInfo
Unexecuted instantiation: tmisce.c:typeGetTypeModFromColInfo
Unexecuted instantiation: tname.c:typeGetTypeModFromColInfo
Unexecuted instantiation: ttime.c:typeGetTypeModFromColInfo
Unexecuted instantiation: streamMsg.c:typeGetTypeModFromColInfo
472
473
0
static inline STypeMod typeGetTypeModFromCol(const SColumn* pCol) {
474
0
  return typeGetTypeMod(pCol->type, pCol->precision, pCol->scale, pCol->bytes);
475
0
}
Unexecuted instantiation: sql-fuzzer.c:typeGetTypeModFromCol
Unexecuted instantiation: parser.c:typeGetTypeModFromCol
Unexecuted instantiation: parTranslater.c:typeGetTypeModFromCol
Unexecuted instantiation: parUtil.c:typeGetTypeModFromCol
Unexecuted instantiation: parAstParser.c:typeGetTypeModFromCol
Unexecuted instantiation: parAuthenticator.c:typeGetTypeModFromCol
Unexecuted instantiation: parCalcConst.c:typeGetTypeModFromCol
Unexecuted instantiation: parInsertSql.c:typeGetTypeModFromCol
Unexecuted instantiation: parInsertUtil.c:typeGetTypeModFromCol
Unexecuted instantiation: taos_lemon_sql.tab.c:typeGetTypeModFromCol
Unexecuted instantiation: parAstCreater.c:typeGetTypeModFromCol
Unexecuted instantiation: parInsertSml.c:typeGetTypeModFromCol
Unexecuted instantiation: planLogicCreater.c:typeGetTypeModFromCol
Unexecuted instantiation: planOptimizer.c:typeGetTypeModFromCol
Unexecuted instantiation: planPhysiCreater.c:typeGetTypeModFromCol
Unexecuted instantiation: planSpliter.c:typeGetTypeModFromCol
Unexecuted instantiation: planUtil.c:typeGetTypeModFromCol
Unexecuted instantiation: planValidator.c:typeGetTypeModFromCol
Unexecuted instantiation: catalog.c:typeGetTypeModFromCol
Unexecuted instantiation: ctgAsync.c:typeGetTypeModFromCol
Unexecuted instantiation: ctgCache.c:typeGetTypeModFromCol
Unexecuted instantiation: ctgDbg.c:typeGetTypeModFromCol
Unexecuted instantiation: ctgRemote.c:typeGetTypeModFromCol
Unexecuted instantiation: ctgRent.c:typeGetTypeModFromCol
Unexecuted instantiation: ctgUtil.c:typeGetTypeModFromCol
Unexecuted instantiation: functionMgt.c:typeGetTypeModFromCol
Unexecuted instantiation: tudf.c:typeGetTypeModFromCol
Unexecuted instantiation: builtins.c:typeGetTypeModFromCol
Unexecuted instantiation: builtinsimpl.c:typeGetTypeModFromCol
Unexecuted instantiation: thistogram.c:typeGetTypeModFromCol
Unexecuted instantiation: tpercentile.c:typeGetTypeModFromCol
Unexecuted instantiation: tavgfunction.c:typeGetTypeModFromCol
Unexecuted instantiation: tminmax.c:typeGetTypeModFromCol
Unexecuted instantiation: tminmaxavx.c:typeGetTypeModFromCol
Unexecuted instantiation: filter.c:typeGetTypeModFromCol
Unexecuted instantiation: scalar.c:typeGetTypeModFromCol
Unexecuted instantiation: sclfunc.c:typeGetTypeModFromCol
Unexecuted instantiation: sclvector.c:typeGetTypeModFromCol
Unexecuted instantiation: nodesCloneFuncs.c:typeGetTypeModFromCol
Unexecuted instantiation: nodesCodeFuncs.c:typeGetTypeModFromCol
Unexecuted instantiation: nodesEqualFuncs.c:typeGetTypeModFromCol
Unexecuted instantiation: nodesMsgFuncs.c:typeGetTypeModFromCol
Unexecuted instantiation: nodesUtilFuncs.c:typeGetTypeModFromCol
Unexecuted instantiation: geomFunc.c:typeGetTypeModFromCol
Unexecuted instantiation: tdigest.c:typeGetTypeModFromCol
Unexecuted instantiation: tlog.c:typeGetTypeModFromCol
Unexecuted instantiation: tdatablock.c:typeGetTypeModFromCol
Unexecuted instantiation: tdataformat.c:typeGetTypeModFromCol
Unexecuted instantiation: tmisce.c:typeGetTypeModFromCol
Unexecuted instantiation: tname.c:typeGetTypeModFromCol
Unexecuted instantiation: ttime.c:typeGetTypeModFromCol
Unexecuted instantiation: streamMsg.c:typeGetTypeModFromCol
476
477
/**
478
  @brief Calculate the absolute difference between two int64_t values,
479
         and return the result as uint64_t.
480
  @note This function utilizes the rule of unsigned integer arithmetic (always
481
  mod calculation) to avoid the overflow of the difference calculation and
482
  absolute calculation.
483
  For example, if a = INT64_MIN(-2^63) and b = 1, the difference b - a is
484
  1 - (-2^63), which is bigger than INT64_MAX(2^63 - 1) and overflow.
485
  But if we transfer them to unsigned integer: (uint64_t)a = 2^63,
486
  (uint64_t)b = 1. The result is 1 - 2^63 which will be calculated as
487
  1 - 2^63 + 2^64 = 2^64 - 2^63 + 1 = 2^63 + 1, which is not overflow and
488
  correct.
489
*/
490
0
static inline uint64_t safe_abs_diff_i64(int64_t a, int64_t b) {
491
0
  uint64_t ua = (uint64_t)a;
492
0
  uint64_t ub = (uint64_t)b;
493
0
  return a > b ? ua - ub : ub - ua;
494
0
}
Unexecuted instantiation: sql-fuzzer.c:safe_abs_diff_i64
Unexecuted instantiation: parser.c:safe_abs_diff_i64
Unexecuted instantiation: parTranslater.c:safe_abs_diff_i64
Unexecuted instantiation: parUtil.c:safe_abs_diff_i64
Unexecuted instantiation: parAstParser.c:safe_abs_diff_i64
Unexecuted instantiation: parAuthenticator.c:safe_abs_diff_i64
Unexecuted instantiation: parCalcConst.c:safe_abs_diff_i64
Unexecuted instantiation: parInsertSql.c:safe_abs_diff_i64
Unexecuted instantiation: parInsertUtil.c:safe_abs_diff_i64
Unexecuted instantiation: taos_lemon_sql.tab.c:safe_abs_diff_i64
Unexecuted instantiation: parAstCreater.c:safe_abs_diff_i64
Unexecuted instantiation: parInsertSml.c:safe_abs_diff_i64
Unexecuted instantiation: planLogicCreater.c:safe_abs_diff_i64
Unexecuted instantiation: planOptimizer.c:safe_abs_diff_i64
Unexecuted instantiation: planPhysiCreater.c:safe_abs_diff_i64
Unexecuted instantiation: planSpliter.c:safe_abs_diff_i64
Unexecuted instantiation: planUtil.c:safe_abs_diff_i64
Unexecuted instantiation: planValidator.c:safe_abs_diff_i64
Unexecuted instantiation: catalog.c:safe_abs_diff_i64
Unexecuted instantiation: ctgAsync.c:safe_abs_diff_i64
Unexecuted instantiation: ctgCache.c:safe_abs_diff_i64
Unexecuted instantiation: ctgDbg.c:safe_abs_diff_i64
Unexecuted instantiation: ctgRemote.c:safe_abs_diff_i64
Unexecuted instantiation: ctgRent.c:safe_abs_diff_i64
Unexecuted instantiation: ctgUtil.c:safe_abs_diff_i64
Unexecuted instantiation: functionMgt.c:safe_abs_diff_i64
Unexecuted instantiation: tudf.c:safe_abs_diff_i64
Unexecuted instantiation: builtins.c:safe_abs_diff_i64
Unexecuted instantiation: builtinsimpl.c:safe_abs_diff_i64
Unexecuted instantiation: thistogram.c:safe_abs_diff_i64
Unexecuted instantiation: tpercentile.c:safe_abs_diff_i64
Unexecuted instantiation: tavgfunction.c:safe_abs_diff_i64
Unexecuted instantiation: tminmax.c:safe_abs_diff_i64
Unexecuted instantiation: tminmaxavx.c:safe_abs_diff_i64
Unexecuted instantiation: filter.c:safe_abs_diff_i64
Unexecuted instantiation: scalar.c:safe_abs_diff_i64
Unexecuted instantiation: sclfunc.c:safe_abs_diff_i64
Unexecuted instantiation: sclvector.c:safe_abs_diff_i64
Unexecuted instantiation: nodesCloneFuncs.c:safe_abs_diff_i64
Unexecuted instantiation: nodesCodeFuncs.c:safe_abs_diff_i64
Unexecuted instantiation: nodesEqualFuncs.c:safe_abs_diff_i64
Unexecuted instantiation: nodesMsgFuncs.c:safe_abs_diff_i64
Unexecuted instantiation: nodesUtilFuncs.c:safe_abs_diff_i64
Unexecuted instantiation: geomFunc.c:safe_abs_diff_i64
Unexecuted instantiation: tdigest.c:safe_abs_diff_i64
Unexecuted instantiation: tlog.c:safe_abs_diff_i64
Unexecuted instantiation: tdatablock.c:safe_abs_diff_i64
Unexecuted instantiation: tdataformat.c:safe_abs_diff_i64
Unexecuted instantiation: tmisce.c:safe_abs_diff_i64
Unexecuted instantiation: tname.c:safe_abs_diff_i64
Unexecuted instantiation: ttime.c:safe_abs_diff_i64
Unexecuted instantiation: streamMsg.c:safe_abs_diff_i64
495
496
#ifdef __cplusplus
497
}
498
#endif
499
500
#endif /*_TD_COMMON_DEF_H_*/