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

taosdata / TDengine / #4513

17 Jul 2025 02:02AM UTC coverage: 31.359% (-31.1%) from 62.446%
#4513

push

travis-ci

web-flow
Merge pull request #31914 from taosdata/fix/3.0/compare-ans-failed

fix:Convert line endings from LF to CRLF for ans file

68541 of 301034 branches covered (22.77%)

Branch coverage included in aggregate %.

117356 of 291771 relevant lines covered (40.22%)

602262.98 hits per line

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

48.67
/source/libs/executor/src/executorInt.c
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
#include "filter.h"
17
#include "function.h"
18
#include "functionMgt.h"
19
#include "os.h"
20
#include "querynodes.h"
21
#include "tfill.h"
22
#include "tname.h"
23

24
#include "tdatablock.h"
25
#include "tmsg.h"
26
#include "ttime.h"
27

28
#include "executorInt.h"
29
#include "index.h"
30
#include "operator.h"
31
#include "query.h"
32
#include "querytask.h"
33
#include "storageapi.h"
34
#include "tcompare.h"
35
#include "thash.h"
36
#include "ttypes.h"
37

38
#define SET_REVERSE_SCAN_FLAG(runtime)    ((runtime)->scanFlag = REVERSE_SCAN)
39
#define GET_FORWARD_DIRECTION_FACTOR(ord) (((ord) == TSDB_ORDER_ASC) ? QUERY_ASC_FORWARD_STEP : QUERY_DESC_FORWARD_STEP)
40

41
#if 0
42
static UNUSED_FUNC void *u_malloc (size_t __size) {
43
  uint32_t v = taosRand();
44

45
  if (v % 1000 <= 0) {
46
    return NULL;
47
  } else {
48
    return taosMemoryMalloc(__size);
49
  }
50
}
51

52
static UNUSED_FUNC void* u_calloc(size_t num, size_t __size) {
53
  uint32_t v = taosRand();
54
  if (v % 1000 <= 0) {
55
    return NULL;
56
  } else {
57
    return taosMemoryCalloc(num, __size);
58
  }
59
}
60

61
static UNUSED_FUNC void* u_realloc(void* p, size_t __size) {
62
  uint32_t v = taosRand();
63
  if (v % 5 <= 1) {
64
    return NULL;
65
  } else {
66
    return taosMemoryRealloc(p, __size);
67
  }
68
}
69

70
#define calloc  u_calloc
71
#define malloc  u_malloc
72
#define realloc u_realloc
73
#endif
74

75
static int32_t setBlockSMAInfo(SqlFunctionCtx* pCtx, SExprInfo* pExpr, SSDataBlock* pBlock);
76

77
static int32_t initCtxOutputBuffer(SqlFunctionCtx* pCtx, int32_t size);
78
static void    doApplyScalarCalculation(SOperatorInfo* pOperator, SSDataBlock* pBlock, int32_t order, int32_t scanFlag);
79

80
static int32_t doSetInputDataBlock(SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t order, int32_t scanFlag,
81
                                   bool createDummyCol);
82
static void    doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprSupp* pSup, SDiskbasedBuf* pBuf,
83
                                  SGroupResInfo* pGroupResInfo, int32_t threshold, bool ignoreGroup,
84
                                  int64_t minWindowSize);
85

86
SResultRow* getNewResultRow(SDiskbasedBuf* pResultBuf, int32_t* currentPageId, int32_t interBufSize) {
5,074✔
87
  SFilePage* pData = NULL;
5,074✔
88

89
  // in the first scan, new space needed for results
90
  int32_t pageId = -1;
5,074✔
91
  if (*currentPageId == -1) {
5,074✔
92
    pData = getNewBufPage(pResultBuf, &pageId);
3,062✔
93
    if (pData == NULL) {
3,062!
94
      qError("failed to get buffer, code:%s", tstrerror(terrno));
×
95
      return NULL;
×
96
    }
97
    pData->num = sizeof(SFilePage);
3,062✔
98
  } else {
99
    pData = getBufPage(pResultBuf, *currentPageId);
2,012✔
100
    if (pData == NULL) {
2,012!
101
      qError("failed to get buffer, code:%s", tstrerror(terrno));
×
102
      return NULL;
×
103
    }
104

105
    pageId = *currentPageId;
2,012✔
106

107
    if (pData->num + interBufSize > getBufPageSize(pResultBuf)) {
2,012!
108
      // release current page first, and prepare the next one
109
      releaseBufPage(pResultBuf, pData);
×
110

111
      pData = getNewBufPage(pResultBuf, &pageId);
×
112
      if (pData == NULL) {
×
113
        qError("failed to get buffer, code:%s", tstrerror(terrno));
×
114
        return NULL;
×
115
      }
116
      pData->num = sizeof(SFilePage);
×
117
    }
118
  }
119

120
  setBufPageDirty(pData, true);
5,074✔
121

122
  // set the number of rows in current disk page
123
  SResultRow* pResultRow = (SResultRow*)((char*)pData + pData->num);
5,073✔
124

125
  memset((char*)pResultRow, 0, interBufSize);
5,073✔
126
  pResultRow->pageId = pageId;
5,073✔
127
  pResultRow->offset = (int32_t)pData->num;
5,073✔
128

129
  *currentPageId = pageId;
5,073✔
130
  pData->num += interBufSize;
5,073✔
131
  return pResultRow;
5,073✔
132
}
133

134
/**
135
 * the struct of key in hash table
136
 * +----------+---------------+
137
 * | group id |   key data    |
138
 * | 8 bytes  | actual length |
139
 * +----------+---------------+
140
 */
141
SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pResultRowInfo, char* pData,
6,571✔
142
                                   int32_t bytes, bool masterscan, uint64_t groupId, SExecTaskInfo* pTaskInfo,
143
                                   bool isIntervalQuery, SAggSupporter* pSup, bool keepGroup) {
144
  SET_RES_WINDOW_KEY(pSup->keyBuf, pData, bytes, groupId);
6,571✔
145
  if (!keepGroup) {
6,571✔
146
    *(uint64_t*)pSup->keyBuf = calcGroupId(pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes));
2,280✔
147
  }
148

149
  SResultRowPosition* p1 =
150
      (SResultRowPosition*)tSimpleHashGet(pSup->pResultRowHashTable, pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes));
6,571✔
151

152
  SResultRow* pResult = NULL;
6,571✔
153

154
  // in case of repeat scan/reverse scan, no new time window added.
155
  if (isIntervalQuery) {
6,571✔
156
    if (p1 != NULL) {  // the *p1 may be NULL in case of sliding+offset exists.
342✔
157
      pResult = getResultRowByPos(pResultBuf, p1, true);
40✔
158
      if (pResult == NULL) {
40!
159
        pTaskInfo->code = terrno;
×
160
        return NULL;
×
161
      }
162

163
      if (pResult->pageId != p1->pageId || pResult->offset != p1->offset) {
40!
164
        terrno = TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
×
165
        pTaskInfo->code = terrno;
×
166
        return NULL;
×
167
      }
168
    }
169
  } else {
170
    // In case of group by column query, the required SResultRow object must be existInCurrentResusltRowInfo in the
171
    // pResultRowInfo object.
172
    if (p1 != NULL) {
6,229✔
173
      // todo
174
      pResult = getResultRowByPos(pResultBuf, p1, true);
1,456✔
175
      if (NULL == pResult) {
1,456!
176
        pTaskInfo->code = terrno;
×
177
        return NULL;
×
178
      }
179

180
      if (pResult->pageId != p1->pageId || pResult->offset != p1->offset) {
1,456!
181
        terrno = TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
×
182
        pTaskInfo->code = terrno;
×
183
        return NULL;
×
184
      }
185
    }
186
  }
187

188
  // 1. close current opened time window
189
  if (pResultRowInfo->cur.pageId != -1 && ((pResult == NULL) || (pResult->pageId != pResultRowInfo->cur.pageId))) {
6,571!
190
    SResultRowPosition pos = pResultRowInfo->cur;
2,012✔
191
    SFilePage*         pPage = getBufPage(pResultBuf, pos.pageId);
2,012✔
192
    if (pPage == NULL) {
2,012!
193
      qError("failed to get buffer, code:%s, %s", tstrerror(terrno), GET_TASKID(pTaskInfo));
×
194
      pTaskInfo->code = terrno;
×
195
      return NULL;
×
196
    }
197
    releaseBufPage(pResultBuf, pPage);
2,012✔
198
  }
199

200
  // allocate a new buffer page
201
  if (pResult == NULL) {
6,571✔
202
    pResult = getNewResultRow(pResultBuf, &pSup->currentPageId, pSup->resultRowSize);
5,074✔
203
    if (pResult == NULL) {
5,075!
204
      pTaskInfo->code = terrno;
×
205
      return NULL;
×
206
    }
207

208
    // add a new result set for a new group
209
    SResultRowPosition pos = {.pageId = pResult->pageId, .offset = pResult->offset};
5,075✔
210
    int32_t code = tSimpleHashPut(pSup->pResultRowHashTable, pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes), &pos,
5,075✔
211
                                  sizeof(SResultRowPosition));
212
    if (code != TSDB_CODE_SUCCESS) {
5,075✔
213
      qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
1!
214
      pTaskInfo->code = code;
×
215
      return NULL;
×
216
    }
217
  }
218

219
  // 2. set the new time window to be the new active time window
220
  pResultRowInfo->cur = (SResultRowPosition){.pageId = pResult->pageId, .offset = pResult->offset};
6,571✔
221

222
  // too many time window in query
223
  if (pTaskInfo->execModel == OPTR_EXEC_MODEL_BATCH &&
13,137!
224
      tSimpleHashGetSize(pSup->pResultRowHashTable) > MAX_INTERVAL_TIME_WINDOW) {
6,566✔
225
    pTaskInfo->code = TSDB_CODE_QRY_TOO_MANY_TIMEWINDOW;
×
226
    return NULL;
×
227
  }
228

229
  return pResult;
6,571✔
230
}
231

232
//  query_range_start, query_range_end, window_duration, window_start, window_end
233
int32_t initExecTimeWindowInfo(SColumnInfoData* pColData, STimeWindow* pQueryWindow) {
137✔
234
  pColData->info.type = TSDB_DATA_TYPE_TIMESTAMP;
137✔
235
  pColData->info.bytes = sizeof(int64_t);
137✔
236

237
  int32_t code = colInfoDataEnsureCapacity(pColData, 5, false);
137✔
238
  if (code != TSDB_CODE_SUCCESS) {
137!
239
    return code;
×
240
  }
241
  colDataSetInt64(pColData, 0, &pQueryWindow->skey);
137✔
242
  colDataSetInt64(pColData, 1, &pQueryWindow->ekey);
137✔
243

244
  int64_t interval = 0;
137✔
245
  colDataSetInt64(pColData, 2, &interval);  // this value may be variable in case of 'n' and 'y'.
246
  colDataSetInt64(pColData, 3, &pQueryWindow->skey);
137✔
247
  colDataSetInt64(pColData, 4, &pQueryWindow->ekey);
137✔
248
  return TSDB_CODE_SUCCESS;
137✔
249
}
250

251
static int32_t doSetInputDataBlockInfo(SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t order, int32_t scanFlag) {
×
252
  int32_t         code = TSDB_CODE_SUCCESS;
×
253
  int32_t         lino = 0;
×
254
  SqlFunctionCtx* pCtx = pExprSup->pCtx;
×
255
  for (int32_t i = 0; i < pExprSup->numOfExprs; ++i) {
×
256
    pCtx[i].order = order;
×
257
    pCtx[i].input.numOfRows = pBlock->info.rows;
×
258
    code = setBlockSMAInfo(&pCtx[i], &pExprSup->pExprInfo[i], pBlock);
×
259
    QUERY_CHECK_CODE(code, lino, _end);
×
260
    pCtx[i].pSrcBlock = pBlock;
×
261
    pCtx[i].scanFlag = scanFlag;
×
262
  }
263

264
_end:
×
265
  if (code != TSDB_CODE_SUCCESS) {
×
266
    qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
×
267
  }
268
  return code;
×
269
}
270

271
int32_t setInputDataBlock(SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t order, int32_t scanFlag,
5,397✔
272
                          bool createDummyCol) {
273
  if (pBlock->pBlockAgg != NULL) {
5,397!
274
    return doSetInputDataBlockInfo(pExprSup, pBlock, order, scanFlag);
×
275
  } else {
276
    return doSetInputDataBlock(pExprSup, pBlock, order, scanFlag, createDummyCol);
5,397✔
277
  }
278
}
279

280
static int32_t doCreateConstantValColumnInfo(SInputColumnInfoData* pInput, SFunctParam* pFuncParam, int32_t paramIndex,
×
281
                                             int32_t numOfRows) {
282
  int32_t          code = TSDB_CODE_SUCCESS;
×
283
  int32_t          lino = 0;
×
284
  SColumnInfoData* pColInfo = NULL;
×
285
  if (pInput->pData[paramIndex] == NULL) {
×
286
    pColInfo = taosMemoryCalloc(1, sizeof(SColumnInfoData));
×
287
    QUERY_CHECK_NULL(pColInfo, code, lino, _end, terrno);
×
288

289
    // Set the correct column info (data type and bytes)
290
    pColInfo->info.type = pFuncParam->param.nType;
×
291
    pColInfo->info.bytes = pFuncParam->param.nLen;
×
292

293
    pInput->pData[paramIndex] = pColInfo;
×
294
  } else {
295
    pColInfo = pInput->pData[paramIndex];
×
296
  }
297

298
  code = colInfoDataEnsureCapacity(pColInfo, numOfRows, false);
×
299
  QUERY_CHECK_CODE(code, lino, _end);
×
300

301
  int8_t type = pFuncParam->param.nType;
×
302
  if (type == TSDB_DATA_TYPE_BIGINT || type == TSDB_DATA_TYPE_UBIGINT) {
×
303
    int64_t v = pFuncParam->param.i;
×
304
    for (int32_t i = 0; i < numOfRows; ++i) {
×
305
      colDataSetInt64(pColInfo, i, &v);
×
306
    }
307
  } else if (type == TSDB_DATA_TYPE_DOUBLE) {
×
308
    double v = pFuncParam->param.d;
×
309
    for (int32_t i = 0; i < numOfRows; ++i) {
×
310
      colDataSetDouble(pColInfo, i, &v);
×
311
    }
312
  } else if (type == TSDB_DATA_TYPE_VARCHAR || type == TSDB_DATA_TYPE_GEOMETRY) {
×
313
    char* tmp = taosMemoryMalloc(pFuncParam->param.nLen + VARSTR_HEADER_SIZE);
×
314
    QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
×
315

316
    STR_WITH_SIZE_TO_VARSTR(tmp, pFuncParam->param.pz, pFuncParam->param.nLen);
×
317
    for (int32_t i = 0; i < numOfRows; ++i) {
×
318
      code = colDataSetVal(pColInfo, i, tmp, false);
×
319
      QUERY_CHECK_CODE(code, lino, _end);
×
320
    }
321
    taosMemoryFree(tmp);
×
322
  }
323

324
_end:
×
325
  if (code != TSDB_CODE_SUCCESS) {
×
326
    qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
×
327
  }
328
  return code;
×
329
}
330

331
static int32_t doSetInputDataBlock(SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t order, int32_t scanFlag,
5,397✔
332
                                   bool createDummyCol) {
333
  int32_t         code = TSDB_CODE_SUCCESS;
5,397✔
334
  int32_t         lino = 0;
5,397✔
335
  SqlFunctionCtx* pCtx = pExprSup->pCtx;
5,397✔
336

337
  for (int32_t i = 0; i < pExprSup->numOfExprs; ++i) {
15,194✔
338
    pCtx[i].order = order;
9,797✔
339
    pCtx[i].input.numOfRows = pBlock->info.rows;
9,797✔
340

341
    pCtx[i].pSrcBlock = pBlock;
9,797✔
342
    pCtx[i].scanFlag = scanFlag;
9,797✔
343

344
    SInputColumnInfoData* pInput = &pCtx[i].input;
9,797✔
345
    pInput->uid = pBlock->info.id.uid;
9,797✔
346
    pInput->colDataSMAIsSet = false;
9,797✔
347

348
    SExprInfo* pOneExpr = &pExprSup->pExprInfo[i];
9,797✔
349
    bool       hasPk = pOneExpr->pExpr->nodeType == QUERY_NODE_FUNCTION && pOneExpr->pExpr->_function.pFunctNode->hasPk;
9,797!
350
    pCtx[i].hasPrimaryKey = hasPk;
9,797✔
351

352
    int16_t tsParamIdx = (!hasPk) ? pOneExpr->base.numOfParams - 1 : pOneExpr->base.numOfParams - 2;
9,797!
353
    int16_t pkParamIdx = pOneExpr->base.numOfParams - 1;
9,797✔
354

355
    for (int32_t j = 0; j < pOneExpr->base.numOfParams; ++j) {
20,059✔
356
      SFunctParam* pFuncParam = &pOneExpr->base.pParam[j];
10,262✔
357
      if (pFuncParam->type == FUNC_PARAM_TYPE_COLUMN) {
10,262✔
358
        int32_t slotId = pFuncParam->pCol->slotId;
10,048✔
359
        pInput->pData[j] = taosArrayGet(pBlock->pDataBlock, slotId);
10,048✔
360
        pInput->totalRows = pBlock->info.rows;
10,048✔
361
        pInput->numOfRows = pBlock->info.rows;
10,048✔
362
        pInput->startRowIndex = 0;
10,048✔
363
        pInput->blankFill = pBlock->info.blankFill;
10,048✔
364

365
        // NOTE: the last parameter is the primary timestamp column
366
        // todo: refactor this
367

368
        if (fmIsImplicitTsFunc(pCtx[i].functionId) && (j == tsParamIdx)) {
10,048✔
369
          pInput->pPTS = pInput->pData[j];  // in case of merge function, this is not always the ts column data.
390✔
370
        }
371
        if (hasPk && (j == pkParamIdx)) {
10,048!
372
          pInput->pPrimaryKey = pInput->pData[j];
×
373
        }
374
        QUERY_CHECK_CONDITION((pInput->pData[j] != NULL), code, lino, _end, TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR);
10,048!
375
      } else if (pFuncParam->type == FUNC_PARAM_TYPE_VALUE) {
214✔
376
        // todo avoid case: top(k, 12), 12 is the value parameter.
377
        // sum(11), 11 is also the value parameter.
378
        if (createDummyCol && pOneExpr->base.numOfParams == 1) {
118!
379
          pInput->totalRows = pBlock->info.rows;
×
380
          pInput->numOfRows = pBlock->info.rows;
×
381
          pInput->startRowIndex = 0;
×
382
          pInput->blankFill = pBlock->info.blankFill;
×
383

384
          code = doCreateConstantValColumnInfo(pInput, pFuncParam, j, pBlock->info.rows);
×
385
          QUERY_CHECK_CODE(code, lino, _end);
×
386
        }
387
      }
388
    }
389
  }
390

391
_end:
5,397✔
392
  if (code != TSDB_CODE_SUCCESS) {
5,397!
393
    qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
×
394
  }
395
  return code;
5,397✔
396
}
397

398
bool functionNeedToExecute(SqlFunctionCtx* pCtx) {
5,191✔
399
  struct SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
5,191✔
400

401
  // in case of timestamp column, always generated results.
402
  int32_t functionId = pCtx->functionId;
5,191✔
403
  if (functionId == -1) {
5,191✔
404
    return false;
2,288✔
405
  }
406

407
  if (pCtx->scanFlag == PRE_SCAN) {
2,903!
408
    return fmIsRepeatScanFunc(pCtx->functionId);
×
409
  }
410

411
  if (isRowEntryCompleted(pResInfo)) {
2,903!
412
    return false;
×
413
  }
414

415
  return true;
2,903✔
416
}
417

418
static int32_t doCreateConstantValColumnSMAInfo(SInputColumnInfoData* pInput, SFunctParam* pFuncParam, int32_t type,
×
419
                                                int32_t paramIndex, int32_t numOfRows) {
420
  if (pInput->pData[paramIndex] == NULL) {
×
421
    pInput->pData[paramIndex] = taosMemoryCalloc(1, sizeof(SColumnInfoData));
×
422
    if (pInput->pData[paramIndex] == NULL) {
×
423
      return terrno;
×
424
    }
425

426
    // Set the correct column info (data type and bytes)
427
    pInput->pData[paramIndex]->info.type = type;
×
428
    pInput->pData[paramIndex]->info.bytes = tDataTypes[type].bytes;
×
429
  }
430

431
  SColumnDataAgg* da = NULL;
×
432
  if (pInput->pColumnDataAgg[paramIndex] == NULL) {
×
433
    da = taosMemoryCalloc(1, sizeof(SColumnDataAgg));
×
434
    if (!da) {
×
435
      return terrno;
×
436
    }
437
    pInput->pColumnDataAgg[paramIndex] = da;
×
438
  } else {
439
    da = pInput->pColumnDataAgg[paramIndex];
×
440
  }
441

442
  if (type == TSDB_DATA_TYPE_BIGINT) {
×
443
    int64_t v = pFuncParam->param.i;
×
444
    *da = (SColumnDataAgg){.numOfNull = 0, .min = v, .max = v, .sum = v * numOfRows};
×
445
  } else if (type == TSDB_DATA_TYPE_DOUBLE) {
×
446
    double v = pFuncParam->param.d;
×
447
    *da = (SColumnDataAgg){.numOfNull = 0};
×
448

449
    *(double*)&da->min = v;
×
450
    *(double*)&da->max = v;
×
451
    *(double*)&da->sum = v * numOfRows;
×
452
  } else if (type == TSDB_DATA_TYPE_BOOL) {  // todo validate this data type
×
453
    bool v = pFuncParam->param.i;
×
454

455
    *da = (SColumnDataAgg){.numOfNull = 0};
×
456
    *(bool*)&da->min = 0;
×
457
    *(bool*)&da->max = v;
×
458
    *(bool*)&da->sum = v * numOfRows;
×
459
  } else if (type == TSDB_DATA_TYPE_TIMESTAMP) {
×
460
    // do nothing
461
  } else {
462
    qError("invalid constant type for sma info");
×
463
  }
464

465
  return TSDB_CODE_SUCCESS;
×
466
}
467

468
int32_t setBlockSMAInfo(SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, SSDataBlock* pBlock) {
×
469
  int32_t code = TSDB_CODE_SUCCESS;
×
470
  int32_t lino = 0;
×
471
  int32_t numOfRows = pBlock->info.rows;
×
472

473
  SInputColumnInfoData* pInput = &pCtx->input;
×
474
  pInput->numOfRows = numOfRows;
×
475
  pInput->totalRows = numOfRows;
×
476

477
  if (pBlock->pBlockAgg != NULL) {
×
478
    pInput->colDataSMAIsSet = true;
×
479

480
    for (int32_t j = 0; j < pExprInfo->base.numOfParams; ++j) {
×
481
      SFunctParam* pFuncParam = &pExprInfo->base.pParam[j];
×
482

483
      if (pFuncParam->type == FUNC_PARAM_TYPE_COLUMN) {
×
484
        int32_t slotId = pFuncParam->pCol->slotId;
×
485
        pInput->pColumnDataAgg[j] = &pBlock->pBlockAgg[slotId];
×
486
        if (pInput->pColumnDataAgg[j]->colId == -1) {
×
487
          pInput->colDataSMAIsSet = false;
×
488
        }
489

490
        // Here we set the column info data since the data type for each column data is required, but
491
        // the data in the corresponding SColumnInfoData will not be used.
492
        pInput->pData[j] = taosArrayGet(pBlock->pDataBlock, slotId);
×
493
      } else if (pFuncParam->type == FUNC_PARAM_TYPE_VALUE) {
×
494
        code = doCreateConstantValColumnSMAInfo(pInput, pFuncParam, pFuncParam->param.nType, j, pBlock->info.rows);
×
495
        QUERY_CHECK_CODE(code, lino, _end);
×
496
      }
497
    }
498
  } else {
499
    pInput->colDataSMAIsSet = false;
×
500
  }
501

502
_end:
×
503
  if (code != TSDB_CODE_SUCCESS) {
×
504
    qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
×
505
  }
506
  return code;
×
507
}
508

509
/////////////////////////////////////////////////////////////////////////////////////////////
510
STimeWindow getAlignQueryTimeWindow(const SInterval* pInterval, int64_t key) {
40✔
511
  STimeWindow win = {0};
40✔
512
  win.skey = taosTimeTruncate(key, pInterval);
40✔
513

514
  /*
515
   * if the realSkey > INT64_MAX - pInterval->interval, the query duration between
516
   * realSkey and realEkey must be less than one interval.Therefore, no need to adjust the query ranges.
517
   */
518
  win.ekey = taosTimeGetIntervalEnd(win.skey, pInterval);
40✔
519
  if (win.ekey < win.skey) {
40!
520
    win.ekey = INT64_MAX;
×
521
  }
522

523
  return win;
40✔
524
}
525

526
int32_t setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numOfOutput,
4,141✔
527
                            int32_t* rowEntryInfoOffset) {
528
  bool init = false;
4,141✔
529
  for (int32_t i = 0; i < numOfOutput; ++i) {
9,280✔
530
    pCtx[i].resultInfo = getResultEntryInfo(pResult, i, rowEntryInfoOffset);
5,139✔
531
    if (init) {
5,139✔
532
      continue;
4✔
533
    }
534

535
    struct SResultRowEntryInfo* pResInfo = pCtx[i].resultInfo;
5,135✔
536
    
537
    if (isRowEntryCompleted(pResInfo) && isRowEntryInitialized(pResInfo)) {
5,135!
538
      continue;
×
539
    }
540

541
    if (pCtx[i].isPseudoFunc) {
5,135✔
542
      continue;
28✔
543
    }
544

545
    if (!pResInfo->initialized) {
5,107✔
546
      if (pCtx[i].functionId != -1) {
3,611✔
547
        int32_t code = pCtx[i].fpSet.init(&pCtx[i], pResInfo);
2,779✔
548
        if (code != TSDB_CODE_SUCCESS && fmIsUserDefinedFunc(pCtx[i].functionId)) {
2,779!
549
          pResInfo->initialized = false;
×
550
          qError("failed to initialize udf, funcId:%d error:%s", pCtx[i].functionId, tstrerror(code));
×
551
          return TSDB_CODE_UDF_FUNC_EXEC_FAILURE;
×
552
        } else if (code != TSDB_CODE_SUCCESS) {
2,779!
553
          qError("failed to initialize function context, funcId:%d error:%s", pCtx[i].functionId, tstrerror(code));
×
554
          return code;
×
555
        }
556
      } else {
557
        pResInfo->initialized = true;
832✔
558
      }
559
    } else {
560
      init = true;
1,496✔
561
    }
562
  }
563
  return TSDB_CODE_SUCCESS;
4,141✔
564
}
565

566
void clearResultRowInitFlag(SqlFunctionCtx* pCtx, int32_t numOfOutput) {
×
567
  for (int32_t i = 0; i < numOfOutput; ++i) {
×
568
    SResultRowEntryInfo* pResInfo = pCtx[i].resultInfo;
×
569
    if (pResInfo == NULL) {
×
570
      continue;
×
571
    }
572

573
    pResInfo->initialized = false;
×
574
    pResInfo->numOfRes = 0;
×
575
    pResInfo->isNullRes = 0;
×
576
    pResInfo->complete = false;
×
577
  }
578
}
×
579

580
int32_t doFilter(SSDataBlock* pBlock, SFilterInfo* pFilterInfo, SColMatchInfo* pColMatchInfo) {
20,470✔
581
  int32_t code = TSDB_CODE_SUCCESS;
20,470✔
582
  int32_t lino = 0;
20,470✔
583
  if (pFilterInfo == NULL || pBlock->info.rows == 0) {
20,470✔
584
    return TSDB_CODE_SUCCESS;
17,955✔
585
  }
586

587
  SFilterColumnParam param1 = {.numOfCols = taosArrayGetSize(pBlock->pDataBlock), .pDataBlock = pBlock->pDataBlock};
2,515✔
588
  SColumnInfoData*   p = NULL;
2,515✔
589

590
  code = filterSetDataFromSlotId(pFilterInfo, &param1);
2,515✔
591
  QUERY_CHECK_CODE(code, lino, _err);
2,515!
592

593
  int32_t status = 0;
2,515✔
594
  code =
595
      filterExecute(pFilterInfo, pBlock, &p, NULL, param1.numOfCols, &status);
2,515✔
596
  QUERY_CHECK_CODE(code, lino, _err);
2,515!
597

598
  code = extractQualifiedTupleByFilterResult(pBlock, p, status);
2,515✔
599
  QUERY_CHECK_CODE(code, lino, _err);
2,516!
600

601
  if (pColMatchInfo != NULL) {
2,516✔
602
    size_t size = taosArrayGetSize(pColMatchInfo->pList);
572✔
603
    for (int32_t i = 0; i < size; ++i) {
572!
604
      SColMatchItem* pInfo = taosArrayGet(pColMatchInfo->pList, i);
572✔
605
      QUERY_CHECK_NULL(pInfo, code, lino, _err, terrno);
572!
606
      if (pInfo->colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
572!
607
        SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, pInfo->dstSlotId);
572✔
608
        QUERY_CHECK_NULL(pColData, code, lino, _err, terrno);
572!
609
        if (pColData->info.type == TSDB_DATA_TYPE_TIMESTAMP) {
572!
610
          code = blockDataUpdateTsWindow(pBlock, pInfo->dstSlotId);
572✔
611
          QUERY_CHECK_CODE(code, lino, _err);
572!
612
          break;
572✔
613
        }
614
      }
615
    }
616
  }
617
  code = blockDataCheck(pBlock);
2,516✔
618
  QUERY_CHECK_CODE(code, lino, _err);
2,516!
619
_err:
2,516✔
620
  if (code != TSDB_CODE_SUCCESS) {
2,516!
621
    qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
×
622
  }
623
  colDataDestroy(p);
2,516✔
624
  taosMemoryFree(p);
2,516!
625
  return code;
2,516✔
626
}
627

628
int32_t extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoData* p, int32_t status) {
2,720✔
629
  int32_t code = TSDB_CODE_SUCCESS;
2,720✔
630
  int8_t* pIndicator = (int8_t*)p->pData;
2,720✔
631
  if (status == FILTER_RESULT_ALL_QUALIFIED) {
2,720✔
632
    // here nothing needs to be done
633
  } else if (status == FILTER_RESULT_NONE_QUALIFIED) {
1,580✔
634
    code = trimDataBlock(pBlock, pBlock->info.rows, NULL);
671✔
635
    pBlock->info.rows = 0;
671✔
636
  } else if (status == FILTER_RESULT_PARTIAL_QUALIFIED) {
909!
637
    code = trimDataBlock(pBlock, pBlock->info.rows, (bool*)pIndicator);
909✔
638
  } else {
639
    qError("unknown filter result type: %d", status);
×
640
  }
641
  return code;
2,720✔
642
}
643

644
void doUpdateNumOfRows(SqlFunctionCtx* pCtx, SResultRow* pRow, int32_t numOfExprs, const int32_t* rowEntryOffset) {
2,653✔
645
  bool returnNotNull = false;
2,653✔
646
  for (int32_t j = 0; j < numOfExprs; ++j) {
6,296✔
647
    SResultRowEntryInfo* pResInfo = getResultEntryInfo(pRow, j, rowEntryOffset);
3,643✔
648
    if (!isRowEntryInitialized(pResInfo)) {
3,643✔
649
      continue;
24✔
650
    } else {
651
    }
652

653
    if (pRow->numOfRows < pResInfo->numOfRes) {
3,619✔
654
      pRow->numOfRows = pResInfo->numOfRes;
2,645✔
655
    }
656

657
    if (pCtx[j].isNotNullFunc) {
3,619✔
658
      returnNotNull = true;
1,859✔
659
    }
660
  }
661
  // if all expr skips all blocks, e.g. all null inputs for max function, output one row in final result.
662
  //  except for first/last, which require not null output, output no rows
663
  if (pRow->numOfRows == 0 && !returnNotNull) {
2,653!
664
    pRow->numOfRows = 1;
×
665
  }
666
}
2,653✔
667

668
int32_t copyResultrowToDataBlock(SExprInfo* pExprInfo, int32_t numOfExprs, SResultRow* pRow, SqlFunctionCtx* pCtx,
2,633✔
669
                                 SSDataBlock* pBlock, const int32_t* rowEntryOffset, SExecTaskInfo* pTaskInfo) {
670
  int32_t code = TSDB_CODE_SUCCESS;
2,633✔
671
  int32_t lino = 0;
2,633✔
672
  for (int32_t j = 0; j < numOfExprs; ++j) {
6,256✔
673
    int32_t slotId = pExprInfo[j].base.resSchema.slotId;
3,623✔
674

675
    pCtx[j].resultInfo = getResultEntryInfo(pRow, j, rowEntryOffset);
3,623✔
676
    if (pCtx[j].fpSet.finalize) {
3,623✔
677
      if (strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_group_key") == 0 ||
2,767✔
678
          strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_group_const_value") == 0) {
1,901!
679
        // for groupkey along with functions that output multiple lines(e.g. Histogram)
680
        // need to match groupkey result for each output row of that function.
681
        if (pCtx[j].resultInfo->numOfRes != 0) {
866!
682
          pCtx[j].resultInfo->numOfRes = pRow->numOfRows;
866✔
683
        }
684
      }
685

686
      code = pCtx[j].fpSet.finalize(&pCtx[j], pBlock);
2,767✔
687
      if (TSDB_CODE_SUCCESS != code) {
2,767!
688
        qError("%s build result data block error, code %s", GET_TASKID(pTaskInfo), tstrerror(code));
×
689
        QUERY_CHECK_CODE(code, lino, _end);
×
690
      }
691
    } else if (strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_select_value") == 0) {
856!
692
      // do nothing
693
    } else {
694
      // expand the result into multiple rows. E.g., _wstart, top(k, 20)
695
      // the _wstart needs to copy to 20 following rows, since the results of top-k expands to 20 different rows.
696
      SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, slotId);
856✔
697
      QUERY_CHECK_NULL(pColInfoData, code, lino, _end, terrno);
856!
698
      char*            in = GET_ROWCELL_INTERBUF(pCtx[j].resultInfo);
856✔
699
      for (int32_t k = 0; k < pRow->numOfRows; ++k) {        
1,712✔
700
        code = colDataSetValOrCover(pColInfoData, pBlock->info.rows + k, in, pCtx[j].resultInfo->isNullRes);
856✔
701
        QUERY_CHECK_CODE(code, lino, _end);
856!
702
      }
703
    }
704
  }
705

706
_end:
2,633✔
707
  if (code != TSDB_CODE_SUCCESS) {
2,633!
708
    qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
×
709
  }
710
  return code;
2,633✔
711
}
712

713
// todo refactor. SResultRow has direct pointer in miainfo
714
void finalizeResultRows(SDiskbasedBuf* pBuf, SResultRowPosition* resultRowPosition, SExprSupp* pSup,
×
715
                        SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo) {
716
  SFilePage* page = getBufPage(pBuf, resultRowPosition->pageId);
×
717
  if (page == NULL) {
×
718
    qError("failed to get buffer, code:%s, %s", tstrerror(terrno), GET_TASKID(pTaskInfo));
×
719
    T_LONG_JMP(pTaskInfo->env, terrno);
×
720
  }
721

722
  SResultRow* pRow = (SResultRow*)((char*)page + resultRowPosition->offset);
×
723

724
  SqlFunctionCtx* pCtx = pSup->pCtx;
×
725
  SExprInfo*      pExprInfo = pSup->pExprInfo;
×
726
  const int32_t*  rowEntryOffset = pSup->rowEntryInfoOffset;
×
727

728
  doUpdateNumOfRows(pCtx, pRow, pSup->numOfExprs, rowEntryOffset);
×
729
  if (pRow->numOfRows == 0) {
×
730
    releaseBufPage(pBuf, page);
×
731
    return;
×
732
  }
733

734
  int32_t size = pBlock->info.capacity;
×
735
  while (pBlock->info.rows + pRow->numOfRows > size) {
×
736
    size = size * 1.25;
×
737
  }
738

739
  int32_t code = blockDataEnsureCapacity(pBlock, size);
×
740
  if (TAOS_FAILED(code)) {
×
741
    releaseBufPage(pBuf, page);
×
742
    qError("%s ensure result data capacity failed, code %s", GET_TASKID(pTaskInfo), tstrerror(code));
×
743
    T_LONG_JMP(pTaskInfo->env, code);
×
744
  }
745

746
  code = copyResultrowToDataBlock(pExprInfo, pSup->numOfExprs, pRow, pCtx, pBlock, rowEntryOffset, pTaskInfo);
×
747
  if (TAOS_FAILED(code)) {
×
748
    releaseBufPage(pBuf, page);
×
749
    qError("%s copy result row to datablock failed, code %s", GET_TASKID(pTaskInfo), tstrerror(code));
×
750
    T_LONG_JMP(pTaskInfo->env, code);
×
751
  }
752

753
  releaseBufPage(pBuf, page);
×
754
  pBlock->info.rows += pRow->numOfRows;
×
755
}
756

757
void doCopyToSDataBlockByHash(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprSupp* pSup, SDiskbasedBuf* pBuf,
141✔
758
                              SGroupResInfo* pGroupResInfo, SSHashObj* pHashmap, int32_t threshold, bool ignoreGroup) {
759
  int32_t         code = TSDB_CODE_SUCCESS;
141✔
760
  int32_t         lino = 0;
141✔
761
  SExprInfo*      pExprInfo = pSup->pExprInfo;
141✔
762
  int32_t         numOfExprs = pSup->numOfExprs;
141✔
763
  int32_t*        rowEntryOffset = pSup->rowEntryInfoOffset;
141✔
764
  SqlFunctionCtx* pCtx = pSup->pCtx;
141✔
765

766
  size_t  keyLen = 0;
141✔
767
  int32_t numOfRows = tSimpleHashGetSize(pHashmap);
141✔
768

769
  // begin from last iter
770
  void*   pData = pGroupResInfo->dataPos;
141✔
771
  int32_t iter = pGroupResInfo->iter;
141✔
772
  while ((pData = tSimpleHashIterate(pHashmap, pData, &iter)) != NULL) {
965✔
773
    void*               key = tSimpleHashGetKey(pData, &keyLen);
824✔
774
    SResultRowPosition* pos = pData;
824✔
775
    uint64_t            groupId = *(uint64_t*)key;
824✔
776

777
    SFilePage* page = getBufPage(pBuf, pos->pageId);
824✔
778
    if (page == NULL) {
824!
779
      qError("failed to get buffer, code:%s, %s", tstrerror(terrno), GET_TASKID(pTaskInfo));
×
780
      T_LONG_JMP(pTaskInfo->env, terrno);
×
781
    }
782

783
    SResultRow* pRow = (SResultRow*)((char*)page + pos->offset);
824✔
784

785
    doUpdateNumOfRows(pCtx, pRow, numOfExprs, rowEntryOffset);
824✔
786

787
    // no results, continue to check the next one
788
    if (pRow->numOfRows == 0) {
824!
789
      pGroupResInfo->index += 1;
×
790
      pGroupResInfo->iter = iter;
×
791
      pGroupResInfo->dataPos = pData;
×
792

793
      releaseBufPage(pBuf, page);
×
794
      continue;
×
795
    }
796

797
    if (!ignoreGroup) {
824!
798
      if (pBlock->info.id.groupId == 0) {
×
799
        pBlock->info.id.groupId = groupId;
×
800
      } else {
801
        // current value belongs to different group, it can't be packed into one datablock
802
        if (pBlock->info.id.groupId != groupId) {
×
803
          releaseBufPage(pBuf, page);
×
804
          break;
×
805
        }
806
      }
807
    }
808

809
    if (pBlock->info.rows + pRow->numOfRows > pBlock->info.capacity) {
824!
810
      uint32_t newSize = pBlock->info.rows + pRow->numOfRows + ((numOfRows - iter) > 1 ? 1 : 0);
×
811
      code = blockDataEnsureCapacity(pBlock, newSize);
×
812
      QUERY_CHECK_CODE(code, lino, _end);
×
813
      qDebug("datablock capacity not sufficient, expand to required:%d, current capacity:%d, %s", newSize,
×
814
             pBlock->info.capacity, GET_TASKID(pTaskInfo));
815
      // todo set the pOperator->resultInfo size
816
    }
817

818
    pGroupResInfo->index += 1;
824✔
819
    pGroupResInfo->iter = iter;
824✔
820
    pGroupResInfo->dataPos = pData;
824✔
821

822
    code = copyResultrowToDataBlock(pExprInfo, numOfExprs, pRow, pCtx, pBlock, rowEntryOffset, pTaskInfo);
824✔
823
    releaseBufPage(pBuf, page);
824✔
824
    QUERY_CHECK_CODE(code, lino, _end);
824!
825
    pBlock->info.rows += pRow->numOfRows;
824✔
826
    if (pBlock->info.rows >= threshold) {
824!
827
      break;
×
828
    }
829
  }
830

831
  qDebug("%s result generated, rows:%" PRId64 ", groupId:%" PRIu64, GET_TASKID(pTaskInfo), pBlock->info.rows,
141!
832
         pBlock->info.id.groupId);
833
  pBlock->info.dataLoad = 1;
141✔
834
  code = blockDataUpdateTsWindow(pBlock, 0);
141✔
835
  QUERY_CHECK_CODE(code, lino, _end);
141!
836

837
_end:
141✔
838
  if (code != TSDB_CODE_SUCCESS) {
141!
839
    qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
×
840
    T_LONG_JMP(pTaskInfo->env, code);
×
841
  }
842
}
141✔
843

844
void doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprSupp* pSup, SDiskbasedBuf* pBuf,
1,612✔
845
                        SGroupResInfo* pGroupResInfo, int32_t threshold, bool ignoreGroup, int64_t minWindowSize) {
846
  int32_t         code = TSDB_CODE_SUCCESS;
1,612✔
847
  int32_t         lino = 0;
1,612✔
848
  SExprInfo*      pExprInfo = pSup->pExprInfo;
1,612✔
849
  int32_t         numOfExprs = pSup->numOfExprs;
1,612✔
850
  int32_t*        rowEntryOffset = pSup->rowEntryInfoOffset;
1,612✔
851
  SqlFunctionCtx* pCtx = pSup->pCtx;
1,612✔
852

853
  int32_t numOfRows = getNumOfTotalRes(pGroupResInfo);
1,612✔
854

855
  for (int32_t i = pGroupResInfo->index; i < numOfRows; i += 1) {
3,433✔
856
    SResKeyPos* pPos = taosArrayGetP(pGroupResInfo->pRows, i);
1,829✔
857
    SFilePage*  page = getBufPage(pBuf, pPos->pos.pageId);
1,829✔
858
    if (page == NULL) {
1,829!
859
      qError("failed to get buffer, code:%s, %s", tstrerror(terrno), GET_TASKID(pTaskInfo));
×
860
      T_LONG_JMP(pTaskInfo->env, terrno);
×
861
    }
862

863
    SResultRow* pRow = (SResultRow*)((char*)page + pPos->pos.offset);
1,829✔
864

865
    doUpdateNumOfRows(pCtx, pRow, numOfExprs, rowEntryOffset);
1,829✔
866

867
    // no results, continue to check the next one
868
    if (pRow->numOfRows == 0) {
1,829!
869
      pGroupResInfo->index += 1;
×
870
      releaseBufPage(pBuf, page);
×
871
      continue;
×
872
    }
873
    // skip the window which is less than the windowMinSize
874
    if (pRow->win.ekey - pRow->win.skey < minWindowSize) {
1,829✔
875
      qDebug("skip small window, groupId: %" PRId64 ", windowSize: %" PRId64 ", minWindowSize: %" PRId64, pPos->groupId,
12!
876
             pRow->win.ekey - pRow->win.skey, minWindowSize);
877
      pGroupResInfo->index += 1;
12✔
878
      releaseBufPage(pBuf, page);
12✔
879
      continue;
12✔
880
    }
881

882
    if (!ignoreGroup) {
1,817✔
883
      if (pBlock->info.id.groupId == 0) {
129✔
884
        pBlock->info.id.groupId = pPos->groupId;
121✔
885
      } else {
886
        // current value belongs to different group, it can't be packed into one datablock
887
        if (pBlock->info.id.groupId != pPos->groupId) {
8!
888
          releaseBufPage(pBuf, page);
8✔
889
          break;
8✔
890
        }
891
      }
892
    }
893

894
    if (pBlock->info.rows + pRow->numOfRows > pBlock->info.capacity) {
1,809!
895
      uint32_t newSize = pBlock->info.rows + pRow->numOfRows + ((numOfRows - i) > 1 ? 1 : 0);
×
896
      code = blockDataEnsureCapacity(pBlock, newSize);
×
897
      QUERY_CHECK_CODE(code, lino, _end);
×
898
      qDebug("datablock capacity not sufficient, expand to required:%d, current capacity:%d, %s", newSize,
×
899
             pBlock->info.capacity, GET_TASKID(pTaskInfo));
900
      // todo set the pOperator->resultInfo size
901
    }
902

903
    pGroupResInfo->index += 1;
1,809✔
904
    code = copyResultrowToDataBlock(pExprInfo, numOfExprs, pRow, pCtx, pBlock, rowEntryOffset, pTaskInfo);
1,809✔
905
    releaseBufPage(pBuf, page);
1,809✔
906
    QUERY_CHECK_CODE(code, lino, _end);
1,809!
907

908
    pBlock->info.rows += pRow->numOfRows;
1,809✔
909
    if (pBlock->info.rows >= threshold) {
1,809!
910
      break;
×
911
    }
912
  }
913

914
  qDebug("%s result generated, rows:%" PRId64 ", groupId:%" PRIu64, GET_TASKID(pTaskInfo), pBlock->info.rows,
1,612!
915
         pBlock->info.id.groupId);
916
  pBlock->info.dataLoad = 1;
1,612✔
917
  code = blockDataUpdateTsWindow(pBlock, 0);
1,612✔
918
  QUERY_CHECK_CODE(code, lino, _end);
1,612!
919

920
_end:
1,612✔
921
  if (code != TSDB_CODE_SUCCESS) {
1,612!
922
    qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
×
923
    T_LONG_JMP(pTaskInfo->env, code);
×
924
  }
925
}
1,612✔
926

927
void doBuildResultDatablock(SOperatorInfo* pOperator, SOptrBasicInfo* pbInfo, SGroupResInfo* pGroupResInfo,
1,644✔
928
                            SDiskbasedBuf* pBuf) {
929
  SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
1,644✔
930
  SSDataBlock*   pBlock = pbInfo->pRes;
1,644✔
931

932
  // set output datablock version
933
  pBlock->info.version = pTaskInfo->version;
1,644✔
934

935
  blockDataCleanup(pBlock);
1,644✔
936
  if (!hasRemainResults(pGroupResInfo)) {
1,644✔
937
    return;
32✔
938
  }
939

940
  // clear the existed group id
941
  pBlock->info.id.groupId = 0;
1,612✔
942
  if (!pbInfo->mergeResultBlock) {
1,612✔
943
    doCopyToSDataBlock(pTaskInfo, pBlock, &pOperator->exprSupp, pBuf, pGroupResInfo, pOperator->resultInfo.threshold,
77✔
944
                       false, getMinWindowSize(pOperator));
945
  } else {
946
    while (hasRemainResults(pGroupResInfo)) {
3,070✔
947
      doCopyToSDataBlock(pTaskInfo, pBlock, &pOperator->exprSupp, pBuf, pGroupResInfo, pOperator->resultInfo.threshold,
1,535✔
948
                         true, getMinWindowSize(pOperator));
949
      if (pBlock->info.rows >= pOperator->resultInfo.threshold) {
1,535!
950
        break;
×
951
      }
952

953
      // clearing group id to continue to merge data that belong to different groups
954
      pBlock->info.id.groupId = 0;
1,535✔
955
    }
956

957
    // clear the group id info in SSDataBlock, since the client does not need it
958
    pBlock->info.id.groupId = 0;
1,535✔
959
  }
960
}
961

962
void destroyExprInfo(SExprInfo* pExpr, int32_t numOfExprs) {
10,173✔
963
  for (int32_t i = 0; i < numOfExprs; ++i) {
29,067✔
964
    SExprInfo* pExprInfo = &pExpr[i];
18,894✔
965
    for (int32_t j = 0; j < pExprInfo->base.numOfParams; ++j) {
37,093✔
966
      if (pExprInfo->base.pParam[j].type == FUNC_PARAM_TYPE_COLUMN) {
18,200✔
967
        taosMemoryFreeClear(pExprInfo->base.pParam[j].pCol);
17,636!
968
      } else if (pExprInfo->base.pParam[j].type == FUNC_PARAM_TYPE_VALUE) {
564✔
969
        taosVariantDestroy(&pExprInfo->base.pParam[j].param);
418✔
970
      }
971
    }
972

973
    taosMemoryFree(pExprInfo->base.pParam);
18,893!
974
    taosMemoryFree(pExprInfo->pExpr);
18,893!
975
  }
976
}
10,173✔
977

978
int32_t getBufferPgSize(int32_t rowSize, uint32_t* defaultPgsz, int64_t* defaultBufsz) {
5,200✔
979
  *defaultPgsz = 4096;
5,200✔
980
  uint32_t last = *defaultPgsz;
5,200✔
981
  while (*defaultPgsz < rowSize * 4) {
5,660✔
982
    *defaultPgsz <<= 1u;
460✔
983
    if (*defaultPgsz < last) {
460!
984
      return TSDB_CODE_INVALID_PARA;
×
985
    }
986
    last = *defaultPgsz;
460✔
987
  }
988

989
  // The default buffer for each operator in query is 10MB.
990
  // at least four pages need to be in buffer
991
  // TODO: make this variable to be configurable.
992
  *defaultBufsz = 4096 * 2560;
5,200✔
993
  if ((*defaultBufsz) <= (*defaultPgsz)) {
5,200!
994
    (*defaultBufsz) = (*defaultPgsz) * 4;
×
995
    if (*defaultBufsz < ((int64_t)(*defaultPgsz)) * 4) {
×
996
      return TSDB_CODE_INVALID_PARA;
×
997
    }
998
  }
999

1000
  return 0;
5,200✔
1001
}
1002

1003
void initResultSizeInfo(SResultInfo* pResultInfo, int32_t numOfRows) {
23,522✔
1004
  if (numOfRows == 0) {
23,522!
1005
    numOfRows = 4096;
×
1006
  }
1007

1008
  pResultInfo->capacity = numOfRows;
23,522✔
1009
  pResultInfo->threshold = numOfRows * 0.75;
23,522✔
1010

1011
  if (pResultInfo->threshold == 0) {
23,522!
1012
    pResultInfo->threshold = numOfRows;
×
1013
  }
1014
  pResultInfo->totalRows = 0;
23,522✔
1015
}
23,522✔
1016

1017
void initBasicInfo(SOptrBasicInfo* pInfo, SSDataBlock* pBlock) {
3,126✔
1018
  pInfo->pRes = pBlock;
3,126✔
1019
  initResultRowInfo(&pInfo->resultRowInfo);
3,126✔
1020
}
3,126✔
1021

1022
void destroySqlFunctionCtx(SqlFunctionCtx* pCtx, SExprInfo* pExpr, int32_t numOfOutput) {
60,148✔
1023
  if (pCtx == NULL) {
60,148✔
1024
    return;
51,174✔
1025
  }
1026

1027
  for (int32_t i = 0; i < numOfOutput; ++i) {
20,744✔
1028
    if (pExpr != NULL) {
11,769!
1029
      SExprInfo* pExprInfo = &pExpr[i];
11,769✔
1030
      for (int32_t j = 0; j < pExprInfo->base.numOfParams; ++j) {
22,844✔
1031
        if (pExprInfo->base.pParam[j].type == FUNC_PARAM_TYPE_VALUE) {
11,075✔
1032
          colDataDestroy(pCtx[i].input.pData[j]);
418✔
1033
          taosMemoryFree(pCtx[i].input.pData[j]);
418!
1034
          taosMemoryFree(pCtx[i].input.pColumnDataAgg[j]);
418!
1035
        }
1036
      }
1037
    }
1038
    for (int32_t j = 0; j < pCtx[i].numOfParams; ++j) {
22,844✔
1039
      taosVariantDestroy(&pCtx[i].param[j].param);
11,075✔
1040
    }
1041

1042
    taosMemoryFreeClear(pCtx[i].subsidiaries.pCtx);
11,769!
1043
    taosMemoryFreeClear(pCtx[i].subsidiaries.buf);
11,769!
1044
    taosMemoryFree(pCtx[i].input.pData);
11,769!
1045
    taosMemoryFree(pCtx[i].input.pColumnDataAgg);
11,768!
1046

1047
    if (pCtx[i].udfName != NULL) {
11,770!
1048
      taosMemoryFree(pCtx[i].udfName);
×
1049
    }
1050
  }
1051

1052
  taosMemoryFreeClear(pCtx);
8,975!
1053
  return;
8,973✔
1054
}
1055

1056
int32_t initExprSupp(SExprSupp* pSup, SExprInfo* pExprInfo, int32_t numOfExpr, SFunctionStateStore* pStore) {
4,290✔
1057
  pSup->pExprInfo = pExprInfo;
4,290✔
1058
  pSup->numOfExprs = numOfExpr;
4,290✔
1059
  if (pSup->pExprInfo != NULL) {
4,290✔
1060
    pSup->pCtx = createSqlFunctionCtx(pExprInfo, numOfExpr, &pSup->rowEntryInfoOffset, pStore);
3,733✔
1061
    if (pSup->pCtx == NULL) {
3,732!
1062
      return terrno;
×
1063
    }
1064
  }
1065

1066
  return TSDB_CODE_SUCCESS;
4,289✔
1067
}
1068

1069
void cleanupExprSupp(SExprSupp* pSupp) {
59,751✔
1070
  destroySqlFunctionCtx(pSupp->pCtx, pSupp->pExprInfo, pSupp->numOfExprs);
59,751✔
1071
  if (pSupp->pExprInfo != NULL) {
59,754✔
1072
    destroyExprInfo(pSupp->pExprInfo, pSupp->numOfExprs);
10,172✔
1073
    taosMemoryFreeClear(pSupp->pExprInfo);
10,173!
1074
  }
1075

1076
  if (pSupp->pFilterInfo != NULL) {
59,758✔
1077
    filterFreeInfo(pSupp->pFilterInfo);
800✔
1078
    pSupp->pFilterInfo = NULL;
800✔
1079
  }
1080

1081
  taosMemoryFree(pSupp->rowEntryInfoOffset);
59,758!
1082
  memset(pSupp, 0, sizeof(SExprSupp));
59,768✔
1083
}
59,768✔
1084

1085
void cleanupExprSuppWithoutFilter(SExprSupp* pSupp) {
393✔
1086
  destroySqlFunctionCtx(pSupp->pCtx, pSupp->pExprInfo, pSupp->numOfExprs);
393✔
1087
  if (pSupp->pExprInfo != NULL) {
393✔
1088
    destroyExprInfo(pSupp->pExprInfo, pSupp->numOfExprs);
2✔
1089
    taosMemoryFreeClear(pSupp->pExprInfo);
2!
1090
  }
1091

1092
  taosMemoryFreeClear(pSupp->rowEntryInfoOffset);
393!
1093
  pSupp->numOfExprs = 0;
393✔
1094
  pSupp->hasWindowOrGroup = false;
393✔
1095
  pSupp->pCtx = NULL;
393✔
1096
}
393✔
1097

1098
void cleanupBasicInfo(SOptrBasicInfo* pInfo) {
5,200✔
1099
  blockDataDestroy(pInfo->pRes);
5,200✔
1100
  pInfo->pRes = NULL;
5,200✔
1101
}
5,200✔
1102

1103
bool groupbyTbname(SNodeList* pGroupList) {
9,510✔
1104
  bool bytbname = false;
9,510✔
1105
  SNode*pNode = NULL;
9,510✔
1106
  FOREACH(pNode, pGroupList) {
9,512✔
1107
    if (pNode->type == QUERY_NODE_FUNCTION) {
146✔
1108
      bytbname = (strcmp(((struct SFunctionNode*)pNode)->functionName, "tbname") == 0);
144✔
1109
      break;
144✔
1110
    }
1111
  }
1112
  return bytbname;
9,510✔
1113
}
1114

1115
int32_t createDataSinkParam(SDataSinkNode* pNode, void** pParam, SExecTaskInfo* pTask, SReadHandle* readHandle) {
17,556✔
1116
  switch (pNode->type) {
17,556!
1117
    case QUERY_NODE_PHYSICAL_PLAN_QUERY_INSERT: {
×
1118
      SInserterParam* pInserterParam = taosMemoryCalloc(1, sizeof(SInserterParam));
×
1119
      if (NULL == pInserterParam) {
×
1120
        return terrno;
×
1121
      }
1122
      pInserterParam->readHandle = readHandle;
×
1123

1124
      *pParam = pInserterParam;
×
1125
      break;
×
1126
    }
1127
    case QUERY_NODE_PHYSICAL_PLAN_DELETE: {
×
1128
      SDeleterParam* pDeleterParam = taosMemoryCalloc(1, sizeof(SDeleterParam));
×
1129
      if (NULL == pDeleterParam) {
×
1130
        return terrno;
×
1131
      }
1132

1133
      SArray* pInfoList = NULL;
×
1134
      int32_t code = getTableListInfo(pTask, &pInfoList);
×
1135
      if (code != TSDB_CODE_SUCCESS || pInfoList == NULL) {
×
1136
        taosMemoryFree(pDeleterParam);
×
1137
        return code;
×
1138
      }
1139

1140
      STableListInfo* pTableListInfo = taosArrayGetP(pInfoList, 0);
×
1141
      taosArrayDestroy(pInfoList);
×
1142

1143
      pDeleterParam->suid = tableListGetSuid(pTableListInfo);
×
1144

1145
      // TODO extract uid list
1146
      int32_t numOfTables = 0;
×
1147
      code = tableListGetSize(pTableListInfo, &numOfTables);
×
1148
      if (code != TSDB_CODE_SUCCESS) {
×
1149
        qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
×
1150
        taosMemoryFree(pDeleterParam);
×
1151
        return code;
×
1152
      }
1153

1154
      pDeleterParam->pUidList = taosArrayInit(numOfTables, sizeof(uint64_t));
×
1155
      if (NULL == pDeleterParam->pUidList) {
×
1156
        taosMemoryFree(pDeleterParam);
×
1157
        return terrno;
×
1158
      }
1159

1160
      for (int32_t i = 0; i < numOfTables; ++i) {
×
1161
        STableKeyInfo* pTable = tableListGetInfo(pTableListInfo, i);
×
1162
        if (!pTable) {
×
1163
          taosArrayDestroy(pDeleterParam->pUidList);
×
1164
          taosMemoryFree(pDeleterParam);
×
1165
          return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
×
1166
        }
1167
        void*          tmp = taosArrayPush(pDeleterParam->pUidList, &pTable->uid);
×
1168
        if (!tmp) {
×
1169
          taosArrayDestroy(pDeleterParam->pUidList);
×
1170
          taosMemoryFree(pDeleterParam);
×
1171
          return terrno;
×
1172
        }
1173
      }
1174

1175
      *pParam = pDeleterParam;
×
1176
      break;
×
1177
    }
1178
    default:
17,556✔
1179
      break;
17,556✔
1180
  }
1181

1182
  return TSDB_CODE_SUCCESS;
17,556✔
1183
}
1184

1185
void streamOpReleaseState(SOperatorInfo* pOperator) {
×
1186
  SOperatorInfo* downstream = pOperator->pDownstream[0];
×
1187
  if (downstream->fpSet.releaseStreamStateFn) {
×
1188
    downstream->fpSet.releaseStreamStateFn(downstream);
×
1189
  }
1190
}
×
1191

1192
void streamOpReloadState(SOperatorInfo* pOperator) {
×
1193
  SOperatorInfo* downstream = pOperator->pDownstream[0];
×
1194
  if (downstream->fpSet.reloadStreamStateFn) {
×
1195
    downstream->fpSet.reloadStreamStateFn(downstream);
×
1196
  }
1197
}
×
1198

1199
void freeOperatorParamImpl(SOperatorParam* pParam, SOperatorParamType type) {
1,652✔
1200
  int32_t childrenNum = taosArrayGetSize(pParam->pChildren);
1,652✔
1201
  for (int32_t i = 0; i < childrenNum; ++i) {
1,652!
1202
    SOperatorParam* pChild = taosArrayGetP(pParam->pChildren, i);
×
1203
    freeOperatorParam(pChild, type);
×
1204
  }
1205

1206
  taosArrayDestroy(pParam->pChildren);
1,652✔
1207
  pParam->pChildren = NULL;
1,652✔
1208

1209
  taosMemoryFreeClear(pParam->value);
1,652!
1210

1211
  taosMemoryFree(pParam);
1,652!
1212
}
1,652✔
1213

1214
void freeExchangeGetBasicOperatorParam(void* pParam) {
342✔
1215
  SExchangeOperatorBasicParam* pBasic = (SExchangeOperatorBasicParam*)pParam;
342✔
1216
  taosArrayDestroy(pBasic->uidList);
342✔
1217
  if (pBasic->colMap) {
342!
1218
    taosArrayDestroy(pBasic->colMap->colMap);
×
1219
    taosMemoryFreeClear(pBasic->colMap);
×
1220
  }
1221
}
342✔
1222

1223
void freeExchangeGetOperatorParam(SOperatorParam* pParam) {
184✔
1224
  SExchangeOperatorParam* pExcParam = (SExchangeOperatorParam*)pParam->value;
184✔
1225
  if (pExcParam->multiParams) {
184!
1226
    SExchangeOperatorBatchParam* pExcBatch = (SExchangeOperatorBatchParam*)pParam->value;
184✔
1227
    tSimpleHashCleanup(pExcBatch->pBatchs);
184✔
1228
  } else {
1229
    freeExchangeGetBasicOperatorParam(&pExcParam->basic);
×
1230
  }
1231

1232
  freeOperatorParamImpl(pParam, OP_GET_PARAM);
184✔
1233
}
184✔
1234

1235
void freeExchangeNotifyOperatorParam(SOperatorParam* pParam) { freeOperatorParamImpl(pParam, OP_NOTIFY_PARAM); }
×
1236

1237
void freeGroupCacheGetOperatorParam(SOperatorParam* pParam) { freeOperatorParamImpl(pParam, OP_GET_PARAM); }
508✔
1238

1239
void freeGroupCacheNotifyOperatorParam(SOperatorParam* pParam) { freeOperatorParamImpl(pParam, OP_NOTIFY_PARAM); }
×
1240

1241
void freeMergeJoinGetOperatorParam(SOperatorParam* pParam) { freeOperatorParamImpl(pParam, OP_GET_PARAM); }
254✔
1242

1243
void freeMergeJoinNotifyOperatorParam(SOperatorParam* pParam) { freeOperatorParamImpl(pParam, OP_NOTIFY_PARAM); }
×
1244

1245
void freeTagScanGetOperatorParam(SOperatorParam* pParam) { freeOperatorParamImpl(pParam, OP_GET_PARAM); }
×
1246

1247
void freeTableScanGetOperatorParam(SOperatorParam* pParam) {
706✔
1248
  STableScanOperatorParam* pTableScanParam = (STableScanOperatorParam*)pParam->value;
706✔
1249
  taosArrayDestroy(pTableScanParam->pUidList);
706✔
1250
  if (pTableScanParam->pOrgTbInfo) {
706!
1251
    taosArrayDestroy(pTableScanParam->pOrgTbInfo->colMap);
×
1252
    taosMemoryFreeClear(pTableScanParam->pOrgTbInfo);
×
1253
  }
1254
  freeOperatorParamImpl(pParam, OP_GET_PARAM);
706✔
1255
}
706✔
1256

1257
void freeTableScanNotifyOperatorParam(SOperatorParam* pParam) { freeOperatorParamImpl(pParam, OP_NOTIFY_PARAM); }
×
1258

1259
void freeTagScanNotifyOperatorParam(SOperatorParam* pParam) { freeOperatorParamImpl(pParam, OP_NOTIFY_PARAM); }
×
1260

1261
void freeOpParamItem(void* pItem) {
×
1262
  SOperatorParam* pParam = *(SOperatorParam**)pItem;
×
1263
  pParam->reUse = false;
×
1264
  freeOperatorParam(pParam, OP_GET_PARAM);
×
1265
}
×
1266

1267
void freeVirtualTableScanGetOperatorParam(SOperatorParam* pParam) {
×
1268
  SVTableScanOperatorParam* pVTableScanParam = (SVTableScanOperatorParam*)pParam->value;
×
1269
  taosArrayDestroyEx(pVTableScanParam->pOpParamArray, freeOpParamItem);
×
1270
  freeOpParamItem(&pVTableScanParam->pTagScanOp);
×
1271
  freeOperatorParamImpl(pParam, OP_GET_PARAM);
×
1272
}
×
1273

1274
void freeVTableScanNotifyOperatorParam(SOperatorParam* pParam) { freeOperatorParamImpl(pParam, OP_NOTIFY_PARAM); }
×
1275

1276
void freeOperatorParam(SOperatorParam* pParam, SOperatorParamType type) {
33,531✔
1277
  if (NULL == pParam || pParam->reUse) {
33,531!
1278
    return;
31,879✔
1279
  }
1280

1281
  switch (pParam->opType) {
1,652!
1282
    case QUERY_NODE_PHYSICAL_PLAN_EXCHANGE:
184✔
1283
      type == OP_GET_PARAM ? freeExchangeGetOperatorParam(pParam) : freeExchangeNotifyOperatorParam(pParam);
184!
1284
      break;
184✔
1285
    case QUERY_NODE_PHYSICAL_PLAN_GROUP_CACHE:
508✔
1286
      type == OP_GET_PARAM ? freeGroupCacheGetOperatorParam(pParam) : freeGroupCacheNotifyOperatorParam(pParam);
508!
1287
      break;
508✔
1288
    case QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN:
254✔
1289
      type == OP_GET_PARAM ? freeMergeJoinGetOperatorParam(pParam) : freeMergeJoinNotifyOperatorParam(pParam);
254!
1290
      break;
254✔
1291
    case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN:
706✔
1292
      type == OP_GET_PARAM ? freeTableScanGetOperatorParam(pParam) : freeTableScanNotifyOperatorParam(pParam);
706!
1293
      break;
706✔
1294
    case QUERY_NODE_PHYSICAL_PLAN_VIRTUAL_TABLE_SCAN:
×
1295
      type == OP_GET_PARAM ? freeVirtualTableScanGetOperatorParam(pParam) : freeVTableScanNotifyOperatorParam(pParam);
×
1296
      break;
×
1297
    case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN:
×
1298
      type == OP_GET_PARAM ? freeTagScanGetOperatorParam(pParam) : freeTagScanNotifyOperatorParam(pParam);
×
1299
      break;
×
1300
    default:
×
1301
      qError("unsupported op %d param, type %d", pParam->opType, type);
×
1302
      break;
×
1303
  }
1304
}
1305

1306
void freeResetOperatorParams(struct SOperatorInfo* pOperator, SOperatorParamType type, bool allFree) {
86,426✔
1307
  SOperatorParam**  ppParam = NULL;
86,426✔
1308
  SOperatorParam*** pppDownstramParam = NULL;
86,426✔
1309
  switch (type) {
86,426!
1310
    case OP_GET_PARAM:
43,614✔
1311
      ppParam = &pOperator->pOperatorGetParam;
43,614✔
1312
      pppDownstramParam = &pOperator->pDownstreamGetParams;
43,614✔
1313
      break;
43,614✔
1314
    case OP_NOTIFY_PARAM:
42,812✔
1315
      ppParam = &pOperator->pOperatorNotifyParam;
42,812✔
1316
      pppDownstramParam = &pOperator->pDownstreamNotifyParams;
42,812✔
1317
      break;
42,812✔
1318
    default:
×
1319
      return;
×
1320
  }
1321

1322
  if (*ppParam) {
86,426✔
1323
    freeOperatorParam(*ppParam, type);
254✔
1324
    *ppParam = NULL;
254✔
1325
  }
1326

1327
  if (*pppDownstramParam) {
86,426✔
1328
    for (int32_t i = 0; i < pOperator->numOfDownstream; ++i) {
1,310✔
1329
      if ((*pppDownstramParam)[i]) {
508!
1330
        freeOperatorParam((*pppDownstramParam)[i], type);
×
1331
        (*pppDownstramParam)[i] = NULL;
×
1332
      }
1333
    }
1334
    if (allFree) {
802✔
1335
      taosMemoryFreeClear(*pppDownstramParam);
651!
1336
    }
1337
  }
1338
}
1339

1340
FORCE_INLINE int32_t getNextBlockFromDownstreamImpl(struct SOperatorInfo* pOperator, int32_t idx, bool clearParam,
25,806✔
1341
                                                    SSDataBlock** pResBlock) {
1342
  QRY_PARAM_CHECK(pResBlock);
25,806!
1343

1344
  int32_t code = 0;
25,806✔
1345
  if (pOperator->pDownstreamGetParams && pOperator->pDownstreamGetParams[idx]) {
25,806!
1346
    qDebug("DynOp: op %s start to get block from downstream %s", pOperator->name, pOperator->pDownstream[idx]->name);
918!
1347
    code = pOperator->pDownstream[idx]->fpSet.getNextExtFn(pOperator->pDownstream[idx],
918✔
1348
                                                           pOperator->pDownstreamGetParams[idx], pResBlock);
918✔
1349
    if (clearParam && (code == 0)) {
918!
1350
      freeOperatorParam(pOperator->pDownstreamGetParams[idx], OP_GET_PARAM);
×
1351
      pOperator->pDownstreamGetParams[idx] = NULL;
×
1352
    }
1353

1354
    if (code) {
918!
1355
      qError("failed to get next data block from upstream at %s, line:%d code:%s", __func__, __LINE__, tstrerror(code));
×
1356
    }
1357
    return code;
918✔
1358
  }
1359

1360
  code = pOperator->pDownstream[idx]->fpSet.getNextFn(pOperator->pDownstream[idx], pResBlock);
24,888✔
1361
  if (code) {
24,888!
1362
    qError("failed to get next data block from upstream at %s, %d code:%s", __func__, __LINE__, tstrerror(code));
×
1363
  }
1364
  return code;
24,888✔
1365
}
1366

1367
bool compareVal(const char* v, const SStateKeys* pKey) {
76✔
1368
  if (IS_VAR_DATA_TYPE(pKey->type)) {
76!
1369
    if (varDataLen(v) != varDataLen(pKey->pData)) {
×
1370
      return false;
×
1371
    } else {
1372
      return memcmp(varDataVal(v), varDataVal(pKey->pData), varDataLen(v)) == 0;
×
1373
    }
1374
  } else {
1375
    return memcmp(pKey->pData, v, pKey->bytes) == 0;
76✔
1376
  }
1377
}
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