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

taosdata / TDengine / #3593

24 Jan 2025 08:57AM UTC coverage: 63.239% (-0.3%) from 63.546%
#3593

push

travis-ci

web-flow
Merge pull request #29638 from taosdata/docs/TS-5846-3.0

enh: TDengine modify taosBenchmark new query rule cases and add doc

140619 of 285630 branches covered (49.23%)

Branch coverage included in aggregate %.

218877 of 282844 relevant lines covered (77.38%)

19647377.39 hits per line

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

0.0
/source/client/src/clientStmt2.c
1
#include "clientInt.h"
2
#include "clientLog.h"
3
#include "tdef.h"
4

5
#include "clientStmt.h"
6
#include "clientStmt2.h"
7
/*
8
char* gStmtStatusStr[] = {"unknown",     "init", "prepare", "settbname", "settags",
9
                          "fetchFields", "bind", "bindCol", "addBatch",  "exec"};
10
*/
11
static FORCE_INLINE int32_t stmtAllocQNodeFromBuf(STableBufInfo* pTblBuf, void** pBuf) {
12
  if (pTblBuf->buffOffset < pTblBuf->buffSize) {
×
13
    *pBuf = (char*)pTblBuf->pCurBuff + pTblBuf->buffOffset;
×
14
    pTblBuf->buffOffset += pTblBuf->buffUnit;
×
15
  } else if (pTblBuf->buffIdx < taosArrayGetSize(pTblBuf->pBufList)) {
×
16
    pTblBuf->pCurBuff = taosArrayGetP(pTblBuf->pBufList, pTblBuf->buffIdx++);
×
17
    if (NULL == pTblBuf->pCurBuff) {
×
18
      return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
×
19
    }
20
    *pBuf = pTblBuf->pCurBuff;
×
21
    pTblBuf->buffOffset = pTblBuf->buffUnit;
×
22
  } else {
23
    void* buff = taosMemoryMalloc(pTblBuf->buffSize);
×
24
    if (NULL == buff) {
×
25
      return terrno;
×
26
    }
27

28
    if (taosArrayPush(pTblBuf->pBufList, &buff) == NULL) {
×
29
      return terrno;
×
30
    }
31

32
    pTblBuf->buffIdx++;
×
33
    pTblBuf->pCurBuff = buff;
×
34
    *pBuf = buff;
×
35
    pTblBuf->buffOffset = pTblBuf->buffUnit;
×
36
  }
37

38
  return TSDB_CODE_SUCCESS;
×
39
}
40

41
static bool stmtDequeue(STscStmt2* pStmt, SStmtQNode** param) {
×
42
  (void)taosThreadMutexLock(&pStmt->queue.mutex);
×
43
  while (0 == atomic_load_64((int64_t*)&pStmt->queue.qRemainNum)) {
×
44
    (void)taosThreadCondWait(&pStmt->queue.waitCond, &pStmt->queue.mutex);
×
45
    if (atomic_load_8((int8_t*)&pStmt->queue.stopQueue)) {
×
46
      (void)taosThreadMutexUnlock(&pStmt->queue.mutex);
×
47
      return false;
×
48
    }
49
  }
50
  SStmtQNode* orig = pStmt->queue.head;
×
51
  SStmtQNode* node = pStmt->queue.head->next;
×
52
  pStmt->queue.head = pStmt->queue.head->next;
×
53
  *param = node;
×
54

55
  (void)atomic_sub_fetch_64((int64_t*)&pStmt->queue.qRemainNum, 1);
×
56
  (void)taosThreadMutexUnlock(&pStmt->queue.mutex);
×
57

58
  return true;
×
59
}
60

61
static void stmtEnqueue(STscStmt2* pStmt, SStmtQNode* param) {
×
62
  (void)taosThreadMutexLock(&pStmt->queue.mutex);
×
63

64
  pStmt->queue.tail->next = param;
×
65
  pStmt->queue.tail = param;
×
66
  pStmt->stat.bindDataNum++;
×
67
  (void)atomic_add_fetch_64((int64_t*)&pStmt->queue.qRemainNum, 1);
×
68
  (void)taosThreadCondSignal(&(pStmt->queue.waitCond));
×
69

70
  (void)taosThreadMutexUnlock(&pStmt->queue.mutex);
×
71
}
×
72

73
static int32_t stmtCreateRequest(STscStmt2* pStmt) {
×
74
  int32_t code = 0;
×
75

76
  if (pStmt->exec.pRequest == NULL) {
×
77
    code = buildRequest(pStmt->taos->id, pStmt->sql.sqlStr, pStmt->sql.sqlLen, NULL, false, &pStmt->exec.pRequest,
×
78
                        pStmt->reqid);
79
    if (pStmt->reqid != 0) {
×
80
      pStmt->reqid++;
×
81
    }
82
    if (pStmt->db != NULL) {
×
83
      taosMemoryFreeClear(pStmt->exec.pRequest->pDb); 
×
84
      pStmt->exec.pRequest->pDb = taosStrdup(pStmt->db);
×
85
    }
86
    if (TSDB_CODE_SUCCESS == code) {
×
87
      pStmt->exec.pRequest->syncQuery = true;
×
88
      pStmt->exec.pRequest->isStmtBind = true;
×
89
    }
90
  }
91

92
  return code;
×
93
}
94

95
static int32_t stmtSwitchStatus(STscStmt2* pStmt, STMT_STATUS newStatus) {
×
96
  int32_t code = 0;
×
97

98
  if (newStatus >= STMT_INIT && newStatus < STMT_MAX) {
×
99
    STMT_LOG_SEQ(newStatus);
×
100
  }
101

102
  if (pStmt->errCode && newStatus != STMT_PREPARE) {
×
103
    STMT_DLOG("stmt already failed with err: %s", tstrerror(pStmt->errCode));
×
104
    return pStmt->errCode;
×
105
  }
106

107
  switch (newStatus) {
×
108
    case STMT_PREPARE:
×
109
      pStmt->errCode = 0;
×
110
      break;
×
111
    case STMT_SETTBNAME:
×
112
      if (STMT_STATUS_EQ(INIT)) {
×
113
        code = TSDB_CODE_TSC_STMT_API_ERROR;
×
114
      }
115
      if (!pStmt->sql.stbInterlaceMode && (STMT_STATUS_EQ(BIND) || STMT_STATUS_EQ(BIND_COL))) {
×
116
        code = TSDB_CODE_TSC_STMT_API_ERROR;
×
117
      }
118
      break;
×
119
    case STMT_SETTAGS:
×
120
      if (STMT_STATUS_EQ(INIT)) {
×
121
        code = TSDB_CODE_TSC_STMT_API_ERROR;
×
122
      }
123
      break;
×
124
    case STMT_FETCH_FIELDS:
×
125
      if (STMT_STATUS_EQ(INIT)) {
×
126
        code = TSDB_CODE_TSC_STMT_API_ERROR;
×
127
      }
128
      break;
×
129
    case STMT_BIND:
×
130
      if (STMT_STATUS_EQ(INIT) || STMT_STATUS_EQ(BIND_COL)) {
×
131
        code = TSDB_CODE_TSC_STMT_API_ERROR;
×
132
      }
133
      /*
134
            if ((pStmt->sql.type == STMT_TYPE_MULTI_INSERT) && ()) {
135
              code = TSDB_CODE_TSC_STMT_API_ERROR;
136
            }
137
      */
138
      break;
×
139
    case STMT_BIND_COL:
×
140
      if (STMT_STATUS_EQ(INIT) || STMT_STATUS_EQ(BIND)) {
×
141
        code = TSDB_CODE_TSC_STMT_API_ERROR;
×
142
      }
143
      break;
×
144
    case STMT_ADD_BATCH:
×
145
      if (STMT_STATUS_NE(BIND) && STMT_STATUS_NE(BIND_COL) && STMT_STATUS_NE(FETCH_FIELDS)) {
×
146
        code = TSDB_CODE_TSC_STMT_API_ERROR;
×
147
      }
148
      break;
×
149
    case STMT_EXECUTE:
×
150
      if (STMT_TYPE_QUERY == pStmt->sql.type) {
×
151
        if (STMT_STATUS_NE(ADD_BATCH) && STMT_STATUS_NE(FETCH_FIELDS) && STMT_STATUS_NE(BIND) &&
×
152
            STMT_STATUS_NE(BIND_COL)) {
×
153
          code = TSDB_CODE_TSC_STMT_API_ERROR;
×
154
        }
155
      } else {
156
        if (STMT_STATUS_NE(ADD_BATCH) && STMT_STATUS_NE(FETCH_FIELDS)) {
×
157
          code = TSDB_CODE_TSC_STMT_API_ERROR;
×
158
        }
159
      }
160
      break;
×
161
    default:
×
162
      code = TSDB_CODE_APP_ERROR;
×
163
      break;
×
164
  }
165

166
  STMT_ERR_RET(code);
×
167

168
  pStmt->sql.status = newStatus;
×
169

170
  return TSDB_CODE_SUCCESS;
×
171
}
172

173
static int32_t stmtGetTbName(TAOS_STMT2* stmt, char** tbName) {
×
174
  STscStmt2* pStmt = (STscStmt2*)stmt;
×
175

176
  pStmt->sql.type = STMT_TYPE_MULTI_INSERT;
×
177

178
  if ('\0' == pStmt->bInfo.tbName[0]) {
×
179
    tscError("no table name set");
×
180
    STMT_ERR_RET(TSDB_CODE_TSC_STMT_TBNAME_ERROR);
×
181
  }
182

183
  *tbName = pStmt->bInfo.tbName;
×
184

185
  return TSDB_CODE_SUCCESS;
×
186
}
187

188
static int32_t stmtUpdateBindInfo(TAOS_STMT2* stmt, STableMeta* pTableMeta, void* tags, SName* tbName,
×
189
                                  const char* sTableName, bool autoCreateTbl, bool preCtbname) {
190
  STscStmt2* pStmt = (STscStmt2*)stmt;
×
191
  char       tbFName[TSDB_TABLE_FNAME_LEN];
192
  int32_t    code = tNameExtractFullName(tbName, tbFName);
×
193
  if (code != 0) {
×
194
    return code;
×
195
  }
196

197
  (void)memcpy(&pStmt->bInfo.sname, tbName, sizeof(*tbName));
×
198
  tstrncpy(pStmt->bInfo.tbFName, tbFName, sizeof(pStmt->bInfo.tbFName));
×
199
  pStmt->bInfo.tbFName[sizeof(pStmt->bInfo.tbFName) - 1] = 0;
×
200

201
  pStmt->bInfo.tbUid = autoCreateTbl ? 0 : pTableMeta->uid;
×
202
  pStmt->bInfo.tbSuid = pTableMeta->suid;
×
203
  pStmt->bInfo.tbVgId = pTableMeta->vgId;
×
204
  pStmt->bInfo.tbType = pTableMeta->tableType;
×
205

206
  if (!pStmt->bInfo.tagsCached) {
×
207
    qDestroyBoundColInfo(pStmt->bInfo.boundTags);
×
208
    taosMemoryFreeClear(pStmt->bInfo.boundTags);
×
209
  }
210

211
  pStmt->bInfo.boundTags = tags;
×
212
  pStmt->bInfo.tagsCached = false;
×
213
  pStmt->bInfo.preCtbname = preCtbname;
×
214
  tstrncpy(pStmt->bInfo.stbFName, sTableName, sizeof(pStmt->bInfo.stbFName));
×
215

216
  return TSDB_CODE_SUCCESS;
×
217
}
218

219
static int32_t stmtUpdateExecInfo(TAOS_STMT2* stmt, SHashObj* pVgHash, SHashObj* pBlockHash) {
×
220
  STscStmt2* pStmt = (STscStmt2*)stmt;
×
221

222
  pStmt->sql.pVgHash = pVgHash;
×
223
  pStmt->exec.pBlockHash = pBlockHash;
×
224

225
  return TSDB_CODE_SUCCESS;
×
226
}
227

228
static int32_t stmtUpdateInfo(TAOS_STMT2* stmt, STableMeta* pTableMeta, void* tags, SName* tbName, bool autoCreateTbl,
×
229
                              SHashObj* pVgHash, SHashObj* pBlockHash, const char* sTableName, bool preCtbname) {
230
  STscStmt2* pStmt = (STscStmt2*)stmt;
×
231

232
  STMT_ERR_RET(stmtUpdateBindInfo(stmt, pTableMeta, tags, tbName, sTableName, autoCreateTbl, preCtbname));
×
233
  STMT_ERR_RET(stmtUpdateExecInfo(stmt, pVgHash, pBlockHash));
×
234

235
  pStmt->sql.autoCreateTbl = autoCreateTbl;
×
236
  if (pStmt->sql.autoCreateTbl) {
×
237
    pStmt->sql.stbInterlaceMode = false;
×
238
  }
239

240
  return TSDB_CODE_SUCCESS;
×
241
}
242

243
static int32_t stmtGetExecInfo(TAOS_STMT2* stmt, SHashObj** pVgHash, SHashObj** pBlockHash) {
×
244
  STscStmt2* pStmt = (STscStmt2*)stmt;
×
245

246
  *pVgHash = pStmt->sql.pVgHash;
×
247
  pStmt->sql.pVgHash = NULL;
×
248

249
  *pBlockHash = pStmt->exec.pBlockHash;
×
250
  pStmt->exec.pBlockHash = NULL;
×
251

252
  return TSDB_CODE_SUCCESS;
×
253
}
254

255
static int32_t stmtParseSql(STscStmt2* pStmt) {
×
256
  pStmt->exec.pCurrBlock = NULL;
×
257

258
  SStmtCallback stmtCb = {
×
259
      .pStmt = pStmt,
260
      .getTbNameFn = stmtGetTbName,
261
      .setInfoFn = stmtUpdateInfo,
262
      .getExecInfoFn = stmtGetExecInfo,
263
  };
264

265
  STMT_ERR_RET(stmtCreateRequest(pStmt));
×
266

267
  pStmt->stat.parseSqlNum++;
×
268
  STMT_ERR_RET(parseSql(pStmt->exec.pRequest, false, &pStmt->sql.pQuery, &stmtCb));
×
269
  pStmt->sql.siInfo.pQuery = pStmt->sql.pQuery;
×
270

271
  pStmt->bInfo.needParse = false;
×
272

273
  if (pStmt->sql.pQuery->pRoot && 0 == pStmt->sql.type) {
×
274
    pStmt->sql.type = STMT_TYPE_INSERT;
×
275
    pStmt->sql.stbInterlaceMode = false;
×
276
  } else if (pStmt->sql.pQuery->pPrepareRoot) {
×
277
    pStmt->sql.type = STMT_TYPE_QUERY;
×
278
    pStmt->sql.stbInterlaceMode = false;
×
279

280
    return TSDB_CODE_SUCCESS;
×
281
  }
282

283
  STableDataCxt** pSrc =
284
      (STableDataCxt**)taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
×
285
  if (NULL == pSrc || NULL == *pSrc) {
×
286
    return terrno;
×
287
  }
288

289
  STableDataCxt* pTableCtx = *pSrc;
×
290
  if (pStmt->sql.stbInterlaceMode) {
×
291
    int16_t lastIdx = -1;
×
292

293
    for (int32_t i = 0; i < pTableCtx->boundColsInfo.numOfBound; ++i) {
×
294
      if (pTableCtx->boundColsInfo.pColIndex[i] < lastIdx) {
×
295
        pStmt->sql.stbInterlaceMode = false;
×
296
        break;
×
297
      }
298

299
      lastIdx = pTableCtx->boundColsInfo.pColIndex[i];
×
300
    }
301
  }
302

303
  if (NULL == pStmt->sql.pBindInfo) {
×
304
    pStmt->sql.pBindInfo = taosMemoryMalloc(pTableCtx->boundColsInfo.numOfBound * sizeof(*pStmt->sql.pBindInfo));
×
305
    if (NULL == pStmt->sql.pBindInfo) {
×
306
      return terrno;
×
307
    }
308
  }
309

310
  return TSDB_CODE_SUCCESS;
×
311
}
312

313
static int32_t stmtCleanBindInfo(STscStmt2* pStmt) {
×
314
  pStmt->bInfo.tbUid = 0;
×
315
  pStmt->bInfo.tbSuid = 0;
×
316
  pStmt->bInfo.tbVgId = -1;
×
317
  pStmt->bInfo.tbType = 0;
×
318
  pStmt->bInfo.needParse = true;
×
319
  pStmt->bInfo.inExecCache = false;
×
320

321
  pStmt->bInfo.tbName[0] = 0;
×
322
  pStmt->bInfo.tbFName[0] = 0;
×
323
  if (!pStmt->bInfo.tagsCached) {
×
324
    qDestroyBoundColInfo(pStmt->bInfo.boundTags);
×
325
    taosMemoryFreeClear(pStmt->bInfo.boundTags);
×
326
  }
327
  pStmt->bInfo.stbFName[0] = 0;
×
328

329
  return TSDB_CODE_SUCCESS;
×
330
}
331

332
static void stmtFreeTableBlkList(STableColsData* pTb) {
×
333
  (void)qResetStmtColumns(pTb->aCol, true);
×
334
  taosArrayDestroy(pTb->aCol);
×
335
}
×
336

337
static void stmtResetQueueTableBuf(STableBufInfo* pTblBuf, SStmtQueue* pQueue) {
×
338
  pTblBuf->pCurBuff = taosArrayGetP(pTblBuf->pBufList, 0);
×
339
  if (NULL == pTblBuf->pCurBuff) {
×
340
    tscError("QInfo:%p, failed to get buffer from list", pTblBuf);
×
341
    return;
×
342
  }
343
  pTblBuf->buffIdx = 1;
×
344
  pTblBuf->buffOffset = sizeof(*pQueue->head);
×
345

346
  (void)taosThreadMutexLock(&pQueue->mutex);
×
347
  pQueue->head = pQueue->tail = pTblBuf->pCurBuff;
×
348
  pQueue->qRemainNum = 0;
×
349
  pQueue->head->next = NULL;
×
350
  (void)taosThreadMutexUnlock(&pQueue->mutex);
×
351
}
352

353
static int32_t stmtCleanExecInfo(STscStmt2* pStmt, bool keepTable, bool deepClean) {
×
354
  if (pStmt->sql.stbInterlaceMode) {
×
355
    if (deepClean) {
×
356
      taosHashCleanup(pStmt->exec.pBlockHash);
×
357
      pStmt->exec.pBlockHash = NULL;
×
358

359
      if (NULL != pStmt->exec.pCurrBlock) {
×
360
        taosMemoryFreeClear(pStmt->exec.pCurrBlock->pData);
×
361
        qDestroyStmtDataBlock(pStmt->exec.pCurrBlock);
×
362
      }
363
    } else {
364
      pStmt->sql.siInfo.pTableColsIdx = 0;
×
365
      stmtResetQueueTableBuf(&pStmt->sql.siInfo.tbBuf, &pStmt->queue);
×
366
    }
367
  } else {
368
    if (STMT_TYPE_QUERY != pStmt->sql.type || deepClean) {
×
369
      // if (!pStmt->options.asyncExecFn) {
370
      taos_free_result(pStmt->exec.pRequest);
×
371
      pStmt->exec.pRequest = NULL;
×
372
      //}
373
    }
374

375
    size_t keyLen = 0;
×
376
    void*  pIter = taosHashIterate(pStmt->exec.pBlockHash, NULL);
×
377
    while (pIter) {
×
378
      STableDataCxt* pBlocks = *(STableDataCxt**)pIter;
×
379
      char*          key = taosHashGetKey(pIter, &keyLen);
×
380
      STableMeta*    pMeta = qGetTableMetaInDataBlock(pBlocks);
×
381

382
      if (keepTable && pBlocks == pStmt->exec.pCurrBlock) {
×
383
        TSWAP(pBlocks->pData, pStmt->exec.pCurrTbData);
×
384
        STMT_ERR_RET(qResetStmtDataBlock(pBlocks, false));
×
385

386
        pIter = taosHashIterate(pStmt->exec.pBlockHash, pIter);
×
387
        continue;
×
388
      }
389

390
      qDestroyStmtDataBlock(pBlocks);
×
391
      STMT_ERR_RET(taosHashRemove(pStmt->exec.pBlockHash, key, keyLen));
×
392

393
      pIter = taosHashIterate(pStmt->exec.pBlockHash, pIter);
×
394
    }
395

396
    if (keepTable) {
×
397
      return TSDB_CODE_SUCCESS;
×
398
    }
399

400
    taosHashCleanup(pStmt->exec.pBlockHash);
×
401
    pStmt->exec.pBlockHash = NULL;
×
402

403
    tDestroySubmitTbData(pStmt->exec.pCurrTbData, TSDB_MSG_FLG_ENCODE);
×
404
    taosMemoryFreeClear(pStmt->exec.pCurrTbData);
×
405
  }
406

407
  STMT_ERR_RET(stmtCleanBindInfo(pStmt));
×
408

409
  return TSDB_CODE_SUCCESS;
×
410
}
411

412
static void stmtFreeTbBuf(void* buf) {
×
413
  void* pBuf = *(void**)buf;
×
414
  taosMemoryFree(pBuf);
×
415
}
×
416

417
static void stmtFreeTbCols(void* buf) {
×
418
  SArray* pCols = *(SArray**)buf;
×
419
  taosArrayDestroy(pCols);
×
420
}
×
421

422
static int32_t stmtCleanSQLInfo(STscStmt2* pStmt) {
×
423
  STMT_DLOG_E("start to free SQL info");
×
424

425
  taosMemoryFreeClear(pStmt->db);
×
426
  taosMemoryFree(pStmt->sql.pBindInfo);
×
427
  taosMemoryFree(pStmt->sql.queryRes.fields);
×
428
  taosMemoryFree(pStmt->sql.queryRes.userFields);
×
429
  taosMemoryFree(pStmt->sql.sqlStr);
×
430
  qDestroyQuery(pStmt->sql.pQuery);
×
431
  taosArrayDestroy(pStmt->sql.nodeList);
×
432
  taosHashCleanup(pStmt->sql.pVgHash);
×
433
  pStmt->sql.pVgHash = NULL;
×
434

435
  void* pIter = taosHashIterate(pStmt->sql.pTableCache, NULL);
×
436
  while (pIter) {
×
437
    SStmtTableCache* pCache = (SStmtTableCache*)pIter;
×
438

439
    qDestroyStmtDataBlock(pCache->pDataCtx);
×
440
    qDestroyBoundColInfo(pCache->boundTags);
×
441
    taosMemoryFreeClear(pCache->boundTags);
×
442

443
    pIter = taosHashIterate(pStmt->sql.pTableCache, pIter);
×
444
  }
445
  taosHashCleanup(pStmt->sql.pTableCache);
×
446
  pStmt->sql.pTableCache = NULL;
×
447

448
  STMT_ERR_RET(stmtCleanExecInfo(pStmt, false, true));
×
449
  STMT_ERR_RET(stmtCleanBindInfo(pStmt));
×
450

451
  taos_free_result(pStmt->sql.siInfo.pRequest);
×
452
  taosHashCleanup(pStmt->sql.siInfo.pVgroupHash);
×
453
  tSimpleHashCleanup(pStmt->sql.siInfo.pTableHash);
×
454
  taosArrayDestroyEx(pStmt->sql.siInfo.tbBuf.pBufList, stmtFreeTbBuf);
×
455
  taosMemoryFree(pStmt->sql.siInfo.pTSchema);
×
456
  qDestroyStmtDataBlock(pStmt->sql.siInfo.pDataCtx);
×
457
  taosArrayDestroyEx(pStmt->sql.siInfo.pTableCols, stmtFreeTbCols);
×
458

459
  (void)memset(&pStmt->sql, 0, sizeof(pStmt->sql));
×
460
  pStmt->sql.siInfo.tableColsReady = true;
×
461

462
  STMT_DLOG_E("end to free SQL info");
×
463

464
  return TSDB_CODE_SUCCESS;
×
465
}
466

467
static int32_t stmtTryAddTableVgroupInfo(STscStmt2* pStmt, int32_t* vgId) {
×
468
  if (*vgId >= 0 && taosHashGet(pStmt->sql.pVgHash, (const char*)vgId, sizeof(*vgId))) {
×
469
    return TSDB_CODE_SUCCESS;
×
470
  }
471

472
  SVgroupInfo      vgInfo = {0};
×
473
  SRequestConnInfo conn = {.pTrans = pStmt->taos->pAppInfo->pTransporter,
×
474
                           .requestId = pStmt->exec.pRequest->requestId,
×
475
                           .requestObjRefId = pStmt->exec.pRequest->self,
×
476
                           .mgmtEps = getEpSet_s(&pStmt->taos->pAppInfo->mgmtEp)};
×
477

478
  int32_t code = catalogGetTableHashVgroup(pStmt->pCatalog, &conn, &pStmt->bInfo.sname, &vgInfo);
×
479
  if (TSDB_CODE_SUCCESS != code) {
×
480
    return code;
×
481
  }
482

483
  code =
484
      taosHashPut(pStmt->sql.pVgHash, (const char*)&vgInfo.vgId, sizeof(vgInfo.vgId), (char*)&vgInfo, sizeof(vgInfo));
×
485
  if (TSDB_CODE_SUCCESS != code) {
×
486
    return code;
×
487
  }
488

489
  *vgId = vgInfo.vgId;
×
490

491
  return TSDB_CODE_SUCCESS;
×
492
}
493

494
static int32_t stmtRebuildDataBlock(STscStmt2* pStmt, STableDataCxt* pDataBlock, STableDataCxt** newBlock, uint64_t uid,
×
495
                                    uint64_t suid, int32_t vgId) {
496
  STMT_ERR_RET(stmtTryAddTableVgroupInfo(pStmt, &vgId));
×
497
  STMT_ERR_RET(qRebuildStmtDataBlock(newBlock, pDataBlock, uid, suid, vgId, pStmt->sql.autoCreateTbl));
×
498

499
  STMT_DLOG("tableDataCxt rebuilt, uid:%" PRId64 ", vgId:%d", uid, vgId);
×
500

501
  return TSDB_CODE_SUCCESS;
×
502
}
503

504
static int32_t stmtGetFromCache(STscStmt2* pStmt) {
×
505
  if (pStmt->sql.stbInterlaceMode && pStmt->sql.siInfo.pDataCtx) {
×
506
    pStmt->bInfo.needParse = false;
×
507
    pStmt->bInfo.inExecCache = false;
×
508
    return TSDB_CODE_SUCCESS;
×
509
  }
510

511
  pStmt->bInfo.needParse = true;
×
512
  pStmt->bInfo.inExecCache = false;
×
513

514
  STableDataCxt** pCxtInExec = taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
×
515
  if (pCxtInExec) {
×
516
    pStmt->bInfo.needParse = false;
×
517
    pStmt->bInfo.inExecCache = true;
×
518

519
    pStmt->exec.pCurrBlock = *pCxtInExec;
×
520

521
    if (pStmt->sql.autoCreateTbl) {
×
522
      tscDebug("reuse stmt block for tb %s in execBlock", pStmt->bInfo.tbFName);
×
523
      return TSDB_CODE_SUCCESS;
×
524
    }
525
  }
526

527
  if (NULL == pStmt->pCatalog) {
×
528
    STMT_ERR_RET(catalogGetHandle(pStmt->taos->pAppInfo->clusterId, &pStmt->pCatalog));
×
529
    pStmt->sql.siInfo.pCatalog = pStmt->pCatalog;
×
530
  }
531

532
  if (NULL == pStmt->sql.pTableCache || taosHashGetSize(pStmt->sql.pTableCache) <= 0) {
×
533
    if (pStmt->bInfo.inExecCache) {
×
534
      pStmt->bInfo.needParse = false;
×
535
      tscDebug("reuse stmt block for tb %s in execBlock", pStmt->bInfo.tbFName);
×
536
      return TSDB_CODE_SUCCESS;
×
537
    }
538

539
    tscDebug("no stmt block cache for tb %s", pStmt->bInfo.tbFName);
×
540
    return TSDB_CODE_SUCCESS;
×
541
  }
542

543
  if (pStmt->sql.autoCreateTbl) {
×
544
    SStmtTableCache* pCache = taosHashGet(pStmt->sql.pTableCache, &pStmt->bInfo.tbSuid, sizeof(pStmt->bInfo.tbSuid));
×
545
    if (pCache) {
×
546
      pStmt->bInfo.needParse = false;
×
547
      pStmt->bInfo.tbUid = 0;
×
548

549
      STableDataCxt* pNewBlock = NULL;
×
550
      STMT_ERR_RET(stmtRebuildDataBlock(pStmt, pCache->pDataCtx, &pNewBlock, 0, pStmt->bInfo.tbSuid, -1));
×
551

552
      if (taosHashPut(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName), &pNewBlock,
×
553
                      POINTER_BYTES)) {
554
        STMT_ERR_RET(terrno);
×
555
      }
556

557
      pStmt->exec.pCurrBlock = pNewBlock;
×
558

559
      tscDebug("reuse stmt block for tb %s in sqlBlock, suid:0x%" PRIx64, pStmt->bInfo.tbFName, pStmt->bInfo.tbSuid);
×
560

561
      return TSDB_CODE_SUCCESS;
×
562
    }
563

564
    STMT_RET(stmtCleanBindInfo(pStmt));
×
565
  }
566

567
  uint64_t uid, suid;
568
  int32_t  vgId;
569
  int8_t   tableType;
570

571
  STableMeta*      pTableMeta = NULL;
×
572
  SRequestConnInfo conn = {.pTrans = pStmt->taos->pAppInfo->pTransporter,
×
573
                           .requestId = pStmt->exec.pRequest->requestId,
×
574
                           .requestObjRefId = pStmt->exec.pRequest->self,
×
575
                           .mgmtEps = getEpSet_s(&pStmt->taos->pAppInfo->mgmtEp)};
×
576
  int32_t          code = catalogGetTableMeta(pStmt->pCatalog, &conn, &pStmt->bInfo.sname, &pTableMeta);
×
577

578
  pStmt->stat.ctgGetTbMetaNum++;
×
579

580
  if (TSDB_CODE_PAR_TABLE_NOT_EXIST == code) {
×
581
    tscDebug("tb %s not exist", pStmt->bInfo.tbFName);
×
582
    STMT_ERR_RET(stmtCleanBindInfo(pStmt));
×
583

584
    STMT_ERR_RET(code);
×
585
  }
586

587
  STMT_ERR_RET(code);
×
588

589
  uid = pTableMeta->uid;
×
590
  suid = pTableMeta->suid;
×
591
  tableType = pTableMeta->tableType;
×
592
  pStmt->bInfo.tbVgId = pTableMeta->vgId;
×
593
  vgId = pTableMeta->vgId;
×
594

595
  taosMemoryFree(pTableMeta);
×
596

597
  uint64_t cacheUid = (TSDB_CHILD_TABLE == tableType) ? suid : uid;
×
598

599
  if (uid == pStmt->bInfo.tbUid) {
×
600
    pStmt->bInfo.needParse = false;
×
601

602
    tscDebug("tb %s is current table", pStmt->bInfo.tbFName);
×
603

604
    return TSDB_CODE_SUCCESS;
×
605
  }
606

607
  if (pStmt->bInfo.inExecCache) {
×
608
    SStmtTableCache* pCache = taosHashGet(pStmt->sql.pTableCache, &cacheUid, sizeof(cacheUid));
×
609
    if (NULL == pCache) {
×
610
      tscError("table [%s, %" PRIx64 ", %" PRIx64 "] found in exec blockHash, but not in sql blockHash",
×
611
               pStmt->bInfo.tbFName, uid, cacheUid);
612

613
      STMT_ERR_RET(TSDB_CODE_APP_ERROR);
×
614
    }
615

616
    pStmt->bInfo.needParse = false;
×
617

618
    pStmt->bInfo.tbUid = uid;
×
619
    pStmt->bInfo.tbSuid = suid;
×
620
    pStmt->bInfo.tbType = tableType;
×
621
    pStmt->bInfo.boundTags = pCache->boundTags;
×
622
    pStmt->bInfo.tagsCached = true;
×
623

624
    tscDebug("tb %s in execBlock list, set to current", pStmt->bInfo.tbFName);
×
625

626
    return TSDB_CODE_SUCCESS;
×
627
  }
628

629
  SStmtTableCache* pCache = taosHashGet(pStmt->sql.pTableCache, &cacheUid, sizeof(cacheUid));
×
630
  if (pCache) {
×
631
    pStmt->bInfo.needParse = false;
×
632

633
    pStmt->bInfo.tbUid = uid;
×
634
    pStmt->bInfo.tbSuid = suid;
×
635
    pStmt->bInfo.tbType = tableType;
×
636
    pStmt->bInfo.boundTags = pCache->boundTags;
×
637
    pStmt->bInfo.tagsCached = true;
×
638

639
    STableDataCxt* pNewBlock = NULL;
×
640
    STMT_ERR_RET(stmtRebuildDataBlock(pStmt, pCache->pDataCtx, &pNewBlock, uid, suid, vgId));
×
641

642
    if (taosHashPut(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName), &pNewBlock,
×
643
                    POINTER_BYTES)) {
644
      STMT_ERR_RET(terrno);
×
645
    }
646

647
    pStmt->exec.pCurrBlock = pNewBlock;
×
648

649
    tscDebug("tb %s in sqlBlock list, set to current", pStmt->bInfo.tbFName);
×
650

651
    return TSDB_CODE_SUCCESS;
×
652
  }
653

654
  STMT_ERR_RET(stmtCleanBindInfo(pStmt));
×
655

656
  return TSDB_CODE_SUCCESS;
×
657
}
658

659
static int32_t stmtResetStmt(STscStmt2* pStmt) {
×
660
  STMT_ERR_RET(stmtCleanSQLInfo(pStmt));
×
661

662
  pStmt->sql.pTableCache = taosHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
×
663
  if (NULL == pStmt->sql.pTableCache) {
×
664
    STMT_ERR_RET(terrno);
×
665
  }
666

667
  pStmt->sql.status = STMT_INIT;
×
668

669
  return TSDB_CODE_SUCCESS;
×
670
}
671

672
static int32_t stmtAsyncOutput(STscStmt2* pStmt, void* param) {
×
673
  SStmtQNode* pParam = (SStmtQNode*)param;
×
674

675
  if (pParam->restoreTbCols) {
×
676
    for (int32_t i = 0; i < pStmt->sql.siInfo.pTableColsIdx; ++i) {
×
677
      SArray** p = (SArray**)TARRAY_GET_ELEM(pStmt->sql.siInfo.pTableCols, i);
×
678
      *p = taosArrayInit(20, POINTER_BYTES);
×
679
      if (*p == NULL) {
×
680
        STMT_ERR_RET(terrno);
×
681
      }
682
    }
683

684
    atomic_store_8((int8_t*)&pStmt->sql.siInfo.tableColsReady, true);
×
685
  } else {
686
    STMT_ERR_RET(qAppendStmtTableOutput(pStmt->sql.pQuery, pStmt->sql.pVgHash, &pParam->tblData, pStmt->exec.pCurrBlock,
×
687
                                        &pStmt->sql.siInfo));
688

689
    // taosMemoryFree(pParam->pTbData);
690

691
    (void)atomic_sub_fetch_64(&pStmt->sql.siInfo.tbRemainNum, 1);
×
692
  }
693
  return TSDB_CODE_SUCCESS;
×
694
}
695

696
static void* stmtBindThreadFunc(void* param) {
×
697
  setThreadName("stmtBind");
×
698

699
  qInfo("stmt bind thread started");
×
700

701
  STscStmt2* pStmt = (STscStmt2*)param;
×
702

703
  while (true) {
×
704
    if (atomic_load_8((int8_t*)&pStmt->queue.stopQueue)) {
×
705
      break;
×
706
    }
707

708
    SStmtQNode* asyncParam = NULL;
×
709
    if (!stmtDequeue(pStmt, &asyncParam)) {
×
710
      continue;
×
711
    }
712

713
    if (stmtAsyncOutput(pStmt, asyncParam) != 0) {
×
714
      qError("stmt async output failed");
×
715
    }
716
  }
717

718
  qInfo("stmt bind thread stopped");
×
719

720
  return NULL;
×
721
}
722

723
static int32_t stmtStartBindThread(STscStmt2* pStmt) {
×
724
  TdThreadAttr thAttr;
725
  if (taosThreadAttrInit(&thAttr) != 0) {
×
726
    return TSDB_CODE_TSC_INTERNAL_ERROR;
×
727
  }
728
  if (taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE) != 0) {
×
729
    return TSDB_CODE_TSC_INTERNAL_ERROR;
×
730
  }
731

732
  if (taosThreadCreate(&pStmt->bindThread, &thAttr, stmtBindThreadFunc, pStmt) != 0) {
×
733
    terrno = TAOS_SYSTEM_ERROR(errno);
×
734
    STMT_ERR_RET(terrno);
×
735
  }
736

737
  pStmt->bindThreadInUse = true;
×
738

739
  (void)taosThreadAttrDestroy(&thAttr);
×
740
  return TSDB_CODE_SUCCESS;
×
741
}
742

743
static int32_t stmtInitQueue(STscStmt2* pStmt) {
×
744
  (void)taosThreadCondInit(&pStmt->queue.waitCond, NULL);
×
745
  (void)taosThreadMutexInit(&pStmt->queue.mutex, NULL);
×
746
  STMT_ERR_RET(stmtAllocQNodeFromBuf(&pStmt->sql.siInfo.tbBuf, (void**)&pStmt->queue.head));
×
747
  pStmt->queue.tail = pStmt->queue.head;
×
748

749
  return TSDB_CODE_SUCCESS;
×
750
}
751

752
static int32_t stmtInitTableBuf(STableBufInfo* pTblBuf) {
×
753
  pTblBuf->buffUnit = sizeof(SStmtQNode);
×
754
  pTblBuf->buffSize = pTblBuf->buffUnit * 1000;
×
755
  pTblBuf->pBufList = taosArrayInit(100, POINTER_BYTES);
×
756
  if (NULL == pTblBuf->pBufList) {
×
757
    return terrno;
×
758
  }
759
  void* buff = taosMemoryMalloc(pTblBuf->buffSize);
×
760
  if (NULL == buff) {
×
761
    return terrno;
×
762
  }
763

764
  if (taosArrayPush(pTblBuf->pBufList, &buff) == NULL) {
×
765
    return terrno;
×
766
  }
767

768
  pTblBuf->pCurBuff = buff;
×
769
  pTblBuf->buffIdx = 1;
×
770
  pTblBuf->buffOffset = 0;
×
771

772
  return TSDB_CODE_SUCCESS;
×
773
}
774

775
TAOS_STMT2* stmtInit2(STscObj* taos, TAOS_STMT2_OPTION* pOptions) {
×
776
  STscObj*   pObj = (STscObj*)taos;
×
777
  STscStmt2* pStmt = NULL;
×
778
  int32_t    code = 0;
×
779

780
  pStmt = taosMemoryCalloc(1, sizeof(STscStmt2));
×
781
  if (NULL == pStmt) {
×
782
    return NULL;
×
783
  }
784

785
  pStmt->sql.pTableCache = taosHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
×
786
  if (NULL == pStmt->sql.pTableCache) {
×
787
    taosMemoryFree(pStmt);
×
788
    return NULL;
×
789
  }
790

791
  pStmt->taos = pObj;
×
792
  pStmt->bInfo.needParse = true;
×
793
  pStmt->sql.status = STMT_INIT;
×
794
  pStmt->errCode = TSDB_CODE_SUCCESS;
×
795

796
  if (NULL != pOptions) {
×
797
    (void)memcpy(&pStmt->options, pOptions, sizeof(pStmt->options));
×
798
    if (pOptions->singleStbInsert && pOptions->singleTableBindOnce) {
×
799
      pStmt->stbInterlaceMode = true;
×
800
    }
801

802
    pStmt->reqid = pOptions->reqid;
×
803
  }
804

805
  if (pStmt->stbInterlaceMode) {
×
806
    pStmt->sql.siInfo.transport = taos->pAppInfo->pTransporter;
×
807
    pStmt->sql.siInfo.acctId = taos->acctId;
×
808
    pStmt->sql.siInfo.dbname = taos->db;
×
809
    pStmt->sql.siInfo.mgmtEpSet = getEpSet_s(&pStmt->taos->pAppInfo->mgmtEp);
×
810
    pStmt->sql.siInfo.pTableHash = tSimpleHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY));
×
811
    if (NULL == pStmt->sql.siInfo.pTableHash) {
×
812
      (void)stmtClose(pStmt);
×
813
      return NULL;
×
814
    }
815
    pStmt->sql.siInfo.pTableCols = taosArrayInit(STMT_TABLE_COLS_NUM, POINTER_BYTES);
×
816
    if (NULL == pStmt->sql.siInfo.pTableCols) {
×
817
      terrno = terrno;
×
818
      (void)stmtClose(pStmt);
×
819
      return NULL;
×
820
    }
821

822
    code = stmtInitTableBuf(&pStmt->sql.siInfo.tbBuf);
×
823
    if (TSDB_CODE_SUCCESS == code) {
×
824
      code = stmtInitQueue(pStmt);
×
825
    }
826
    if (TSDB_CODE_SUCCESS == code) {
×
827
      code = stmtStartBindThread(pStmt);
×
828
    }
829
    if (TSDB_CODE_SUCCESS != code) {
×
830
      terrno = code;
×
831
      (void)stmtClose(pStmt);
×
832
      return NULL;
×
833
    }
834
  }
835

836
  pStmt->sql.siInfo.tableColsReady = true;
×
837
  if (pStmt->options.asyncExecFn) {
×
838
    if (tsem_init(&pStmt->asyncQuerySem, 0, 1) != 0) {
×
839
      terrno = TAOS_SYSTEM_ERROR(errno);
×
840
      (void)stmtClose(pStmt);
×
841
      return NULL;
×
842
    }
843
  }
844
  pStmt->semWaited = false;
×
845

846
  STMT_LOG_SEQ(STMT_INIT);
×
847

848
  tscDebug("stmt:%p initialized", pStmt);
×
849

850
  return pStmt;
×
851
}
852

853
static int stmtSetDbName2(TAOS_STMT2* stmt, const char* dbName) {
×
854
  STscStmt2* pStmt = (STscStmt2*)stmt;
×
855

856
  STMT_DLOG("start to set dbName: %s", dbName);
×
857

858
  pStmt->db = taosStrdup(dbName);
×
859
  (void)strdequote(pStmt->db);
×
860
  STMT_ERR_RET(stmtCreateRequest(pStmt));
×
861

862
  // The SQL statement specifies a database name, overriding the previously specified database
863
  taosMemoryFreeClear(pStmt->exec.pRequest->pDb);
×
864
  pStmt->exec.pRequest->pDb = taosStrdup(pStmt->db);
×
865
  if (pStmt->exec.pRequest->pDb == NULL) {
×
866
    return terrno;
×
867
  }
868
  return TSDB_CODE_SUCCESS;
×
869
}
870

871
int stmtPrepare2(TAOS_STMT2* stmt, const char* sql, unsigned long length) {
×
872
  STscStmt2* pStmt = (STscStmt2*)stmt;
×
873

874
  STMT_DLOG_E("start to prepare");
×
875

876
  if (pStmt->errCode != TSDB_CODE_SUCCESS) {
×
877
    return pStmt->errCode;
×
878
  }
879

880
  if (pStmt->sql.status >= STMT_PREPARE) {
×
881
    STMT_ERR_RET(stmtResetStmt(pStmt));
×
882
  }
883

884
  STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_PREPARE));
×
885

886
  if (length <= 0) {
×
887
    length = strlen(sql);
×
888
  }
889

890
  pStmt->sql.sqlStr = taosStrndup(sql, length);
×
891
  if (!pStmt->sql.sqlStr) {
×
892
    return terrno;
×
893
  }
894
  pStmt->sql.sqlLen = length;
×
895
  pStmt->sql.stbInterlaceMode = pStmt->stbInterlaceMode;
×
896

897
  char* dbName = NULL;
×
898
  if (qParseDbName(sql, length, &dbName)) {
×
899
    STMT_ERR_RET(stmtSetDbName2(stmt, dbName));
×
900
    taosMemoryFreeClear(dbName);
×
901
  }
902

903
  return TSDB_CODE_SUCCESS;
×
904
}
905

906
static int32_t stmtInitStbInterlaceTableInfo(STscStmt2* pStmt) {
×
907
  STableDataCxt** pSrc = taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
×
908
  if (!pSrc) {
×
909
    return terrno;
×
910
  }
911
  STableDataCxt* pDst = NULL;
×
912

913
  STMT_ERR_RET(qCloneStmtDataBlock(&pDst, *pSrc, true));
×
914
  pStmt->sql.siInfo.pDataCtx = pDst;
×
915

916
  SArray* pTblCols = NULL;
×
917
  for (int32_t i = 0; i < STMT_TABLE_COLS_NUM; i++) {
×
918
    pTblCols = taosArrayInit(20, POINTER_BYTES);
×
919
    if (NULL == pTblCols) {
×
920
      return terrno;
×
921
    }
922

923
    if (taosArrayPush(pStmt->sql.siInfo.pTableCols, &pTblCols) == NULL) {
×
924
      return terrno;
×
925
    }
926
  }
927

928
  pStmt->sql.siInfo.boundTags = pStmt->bInfo.boundTags;
×
929

930
  return TSDB_CODE_SUCCESS;
×
931
}
932

933
int stmtIsInsert2(TAOS_STMT2* stmt, int* insert) {
×
934
  STscStmt2* pStmt = (STscStmt2*)stmt;
×
935

936
  STMT_DLOG_E("start is insert");
×
937

938
  if (pStmt->sql.type) {
×
939
    *insert = (STMT_TYPE_INSERT == pStmt->sql.type || STMT_TYPE_MULTI_INSERT == pStmt->sql.type);
×
940
  } else {
941
    *insert = qIsInsertValuesSql(pStmt->sql.sqlStr, pStmt->sql.sqlLen);
×
942
  }
943

944
  return TSDB_CODE_SUCCESS;
×
945
}
946

947
int stmtSetTbName2(TAOS_STMT2* stmt, const char* tbName) {
×
948
  STscStmt2* pStmt = (STscStmt2*)stmt;
×
949

950
  int64_t startUs = taosGetTimestampUs();
×
951

952
  STMT_DLOG("start to set tbName: %s", tbName);
×
953

954
  if (pStmt->errCode != TSDB_CODE_SUCCESS) {
×
955
    return pStmt->errCode;
×
956
  }
957

958
  STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_SETTBNAME));
×
959

960
  int32_t insert = 0;
×
961
  STMT_ERR_RET(stmtIsInsert2(stmt, &insert));
×
962
  if (0 == insert) {
×
963
    tscError("set tb name not available for none insert statement");
×
964
    STMT_ERR_RET(TSDB_CODE_TSC_STMT_API_ERROR);
×
965
  }
966

967
  if (!pStmt->sql.stbInterlaceMode || NULL == pStmt->sql.siInfo.pDataCtx) {
×
968
    STMT_ERR_RET(stmtCreateRequest(pStmt));
×
969

970
    STMT_ERR_RET(qCreateSName(&pStmt->bInfo.sname, tbName, pStmt->taos->acctId, pStmt->exec.pRequest->pDb,
×
971
                              pStmt->exec.pRequest->msgBuf, pStmt->exec.pRequest->msgBufLen));
972
    STMT_ERR_RET(tNameExtractFullName(&pStmt->bInfo.sname, pStmt->bInfo.tbFName));
×
973

974
    STMT_ERR_RET(stmtGetFromCache(pStmt));
×
975

976
    if (pStmt->bInfo.needParse) {
×
977
      tstrncpy(pStmt->bInfo.tbName, tbName, sizeof(pStmt->bInfo.tbName));
×
978
      pStmt->bInfo.tbName[sizeof(pStmt->bInfo.tbName) - 1] = 0;
×
979

980
      STMT_ERR_RET(stmtParseSql(pStmt));
×
981
    }
982
  } else {
983
    tstrncpy(pStmt->bInfo.tbName, tbName, sizeof(pStmt->bInfo.tbName));
×
984
    pStmt->bInfo.tbName[sizeof(pStmt->bInfo.tbName) - 1] = 0;
×
985
    pStmt->exec.pRequest->requestId++;
×
986
    pStmt->bInfo.needParse = false;
×
987
  }
988

989
  if (pStmt->sql.stbInterlaceMode && NULL == pStmt->sql.siInfo.pDataCtx) {
×
990
    STMT_ERR_RET(stmtInitStbInterlaceTableInfo(pStmt));
×
991
  }
992

993
  int64_t startUs2 = taosGetTimestampUs();
×
994
  pStmt->stat.setTbNameUs += startUs2 - startUs;
×
995

996
  return TSDB_CODE_SUCCESS;
×
997
}
998

999
int stmtSetTbTags2(TAOS_STMT2* stmt, TAOS_STMT2_BIND* tags) {
×
1000
  STscStmt2* pStmt = (STscStmt2*)stmt;
×
1001

1002
  STMT_DLOG_E("start to set tbTags");
×
1003

1004
  if (pStmt->errCode != TSDB_CODE_SUCCESS) {
×
1005
    return pStmt->errCode;
×
1006
  }
1007

1008
  STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_SETTAGS));
×
1009

1010
  if (pStmt->bInfo.needParse && pStmt->sql.runTimes && pStmt->sql.type > 0 &&
×
1011
      STMT_TYPE_MULTI_INSERT != pStmt->sql.type) {
×
1012
    pStmt->bInfo.needParse = false;
×
1013
  }
1014
  STMT_ERR_RET(stmtCreateRequest(pStmt));
×
1015

1016
  if (pStmt->bInfo.needParse) {
×
1017
    STMT_ERR_RET(stmtParseSql(pStmt));
×
1018
  }
1019
  if (pStmt->sql.stbInterlaceMode && NULL == pStmt->sql.siInfo.pDataCtx) {
×
1020
    STMT_ERR_RET(stmtInitStbInterlaceTableInfo(pStmt));
×
1021
  }
1022

1023
  SBoundColInfo* tags_info = (SBoundColInfo*)pStmt->bInfo.boundTags;
×
1024
  // if (tags_info->numOfBound <= 0 || tags_info->numOfCols <= 0) {
1025
  //   tscWarn("no tags or cols bound in sql, will not bound tags");
1026
  //   return TSDB_CODE_SUCCESS;
1027
  // }
1028

1029
  STableDataCxt** pDataBlock =
1030
      (STableDataCxt**)taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
×
1031
  if (NULL == pDataBlock) {
×
1032
    tscError("table %s not found in exec blockHash", pStmt->bInfo.tbFName);
×
1033
    STMT_ERR_RET(TSDB_CODE_APP_ERROR);
×
1034
  }
1035

1036
  if (pStmt->bInfo.inExecCache && !pStmt->sql.autoCreateTbl) {
×
1037
    return TSDB_CODE_SUCCESS;
×
1038
  }
1039

1040
  tscDebug("start to bind stmt tag values");
×
1041
  STMT_ERR_RET(qBindStmtTagsValue2(*pDataBlock, pStmt->bInfo.boundTags, pStmt->bInfo.tbSuid, pStmt->bInfo.stbFName,
×
1042
                                   pStmt->bInfo.sname.tname, tags, pStmt->exec.pRequest->msgBuf,
1043
                                   pStmt->exec.pRequest->msgBufLen, pStmt->taos->optionInfo.charsetCxt));
1044

1045
  return TSDB_CODE_SUCCESS;
×
1046
}
1047

1048
static int stmtFetchColFields2(STscStmt2* pStmt, int32_t* fieldNum, TAOS_FIELD_E** fields) {
×
1049
  if (pStmt->errCode != TSDB_CODE_SUCCESS) {
×
1050
    return pStmt->errCode;
×
1051
  }
1052

1053
  if (STMT_TYPE_QUERY == pStmt->sql.type) {
×
1054
    tscError("invalid operation to get query column fileds");
×
1055
    STMT_ERR_RET(TSDB_CODE_TSC_STMT_API_ERROR);
×
1056
  }
1057

1058
  STableDataCxt** pDataBlock = NULL;
×
1059

1060
  if (pStmt->sql.stbInterlaceMode) {
×
1061
    pDataBlock = &pStmt->sql.siInfo.pDataCtx;
×
1062
  } else {
1063
    pDataBlock =
1064
        (STableDataCxt**)taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
×
1065
    if (NULL == pDataBlock) {
×
1066
      tscError("table %s not found in exec blockHash", pStmt->bInfo.tbFName);
×
1067
      STMT_ERR_RET(TSDB_CODE_APP_ERROR);
×
1068
    }
1069
  }
1070

1071
  STMT_ERR_RET(qBuildStmtColFields(*pDataBlock, fieldNum, fields));
×
1072

1073
  return TSDB_CODE_SUCCESS;
×
1074
}
1075

1076
static int stmtFetchStbColFields2(STscStmt2* pStmt, int32_t* fieldNum, TAOS_FIELD_ALL** fields) {
×
1077
  int32_t    code = 0;
×
1078
  int32_t    preCode = pStmt->errCode;
×
1079

1080
  if (pStmt->errCode != TSDB_CODE_SUCCESS) {
×
1081
    return pStmt->errCode;
×
1082
  }
1083

1084
  if (STMT_TYPE_QUERY == pStmt->sql.type) {
×
1085
    tscError("invalid operation to get query column fileds");
×
1086
    STMT_ERRI_JRET(TSDB_CODE_TSC_STMT_API_ERROR);
×
1087
  }
1088

1089
  STableDataCxt** pDataBlock = NULL;
×
1090

1091
  if (pStmt->sql.stbInterlaceMode) {
×
1092
    pDataBlock = &pStmt->sql.siInfo.pDataCtx;
×
1093
  } else {
1094
    pDataBlock =
1095
        (STableDataCxt**)taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
×
1096
    if (NULL == pDataBlock) {
×
1097
      tscError("table %s not found in exec blockHash", pStmt->bInfo.tbFName);
×
1098
      STMT_ERRI_JRET(TSDB_CODE_APP_ERROR);
×
1099
    }
1100
  }
1101

1102
  STMT_ERRI_JRET(qBuildStmtStbColFields(*pDataBlock, pStmt->bInfo.boundTags, pStmt->bInfo.preCtbname, fieldNum, fields));
×
1103
  if (pStmt->bInfo.tbType == TSDB_SUPER_TABLE) {
×
1104
    pStmt->bInfo.needParse = true;
×
1105
    qDestroyStmtDataBlock(*pDataBlock);
×
1106
    if (taosHashRemove(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName)) != 0) {
×
1107
      tscError("get fileds %s remove exec blockHash fail", pStmt->bInfo.tbFName);
×
1108
      STMT_ERRI_JRET(TSDB_CODE_APP_ERROR);
×
1109
    }
1110
  }
1111

1112
_return:
×
1113

1114
  pStmt->errCode = preCode;
×
1115

1116
  return code;
×
1117
}
1118
/*
1119
SArray* stmtGetFreeCol(STscStmt2* pStmt, int32_t* idx) {
1120
  while (true) {
1121
    if (pStmt->exec.smInfo.pColIdx >= STMT_COL_BUF_SIZE) {
1122
      pStmt->exec.smInfo.pColIdx = 0;
1123
    }
1124

1125
    if ((pStmt->exec.smInfo.pColIdx + 1) == atomic_load_32(&pStmt->exec.smInfo.pColFreeIdx)) {
1126
      taosUsleep(1);
1127
      continue;
1128
    }
1129

1130
    *idx = pStmt->exec.smInfo.pColIdx;
1131
    return pStmt->exec.smInfo.pCols[pStmt->exec.smInfo.pColIdx++];
1132
  }
1133
}
1134
*/
1135
static int32_t stmtAppendTablePostHandle(STscStmt2* pStmt, SStmtQNode* param) {
×
1136
  if (NULL == pStmt->sql.siInfo.pVgroupHash) {
×
1137
    pStmt->sql.siInfo.pVgroupHash =
×
1138
        taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_ENTRY_LOCK);
×
1139
  }
1140
  if (NULL == pStmt->sql.siInfo.pVgroupList) {
×
1141
    pStmt->sql.siInfo.pVgroupList = taosArrayInit(64, POINTER_BYTES);
×
1142
  }
1143

1144
  if (NULL == pStmt->sql.siInfo.pRequest) {
×
1145
    STMT_ERR_RET(buildRequest(pStmt->taos->id, pStmt->sql.sqlStr, pStmt->sql.sqlLen, NULL, false,
×
1146
                              (SRequestObj**)&pStmt->sql.siInfo.pRequest, pStmt->reqid));
1147

1148
    if (pStmt->reqid != 0) {
×
1149
      pStmt->reqid++;
×
1150
    }
1151
    pStmt->exec.pRequest->syncQuery = true;
×
1152

1153
    pStmt->sql.siInfo.requestId = ((SRequestObj*)pStmt->sql.siInfo.pRequest)->requestId;
×
1154
    pStmt->sql.siInfo.requestSelf = ((SRequestObj*)pStmt->sql.siInfo.pRequest)->self;
×
1155
  }
1156

1157
  if (!pStmt->sql.siInfo.tbFromHash && pStmt->sql.siInfo.firstName[0] &&
×
1158
      0 == strcmp(pStmt->sql.siInfo.firstName, pStmt->bInfo.tbName)) {
×
1159
    pStmt->sql.siInfo.tbFromHash = true;
×
1160
  }
1161

1162
  if (0 == pStmt->sql.siInfo.firstName[0]) {
×
1163
    tstrncpy(pStmt->sql.siInfo.firstName, pStmt->bInfo.tbName, TSDB_TABLE_NAME_LEN);
×
1164
  }
1165

1166
  param->tblData.getFromHash = pStmt->sql.siInfo.tbFromHash;
×
1167
  param->next = NULL;
×
1168

1169
  (void)atomic_add_fetch_64(&pStmt->sql.siInfo.tbRemainNum, 1);
×
1170

1171
  stmtEnqueue(pStmt, param);
×
1172

1173
  return TSDB_CODE_SUCCESS;
×
1174
}
1175

1176
static FORCE_INLINE int32_t stmtGetTableColsFromCache(STscStmt2* pStmt, SArray** pTableCols) {
1177
  while (true) {
1178
    if (pStmt->sql.siInfo.pTableColsIdx < taosArrayGetSize(pStmt->sql.siInfo.pTableCols)) {
×
1179
      *pTableCols = (SArray*)taosArrayGetP(pStmt->sql.siInfo.pTableCols, pStmt->sql.siInfo.pTableColsIdx++);
×
1180
      break;
×
1181
    } else {
1182
      SArray* pTblCols = NULL;
×
1183
      for (int32_t i = 0; i < 100; i++) {
×
1184
        pTblCols = taosArrayInit(20, POINTER_BYTES);
×
1185
        if (NULL == pTblCols) {
×
1186
          return terrno;
×
1187
        }
1188

1189
        if (taosArrayPush(pStmt->sql.siInfo.pTableCols, &pTblCols) == NULL) {
×
1190
          return terrno;
×
1191
        }
1192
      }
1193
    }
1194
  }
1195

1196
  return TSDB_CODE_SUCCESS;
×
1197
}
1198

1199
static int32_t stmtCacheBlock(STscStmt2* pStmt) {
×
1200
  if (pStmt->sql.type != STMT_TYPE_MULTI_INSERT) {
×
1201
    return TSDB_CODE_SUCCESS;
×
1202
  }
1203

1204
  uint64_t uid = pStmt->bInfo.tbUid;
×
1205
  uint64_t cacheUid = (TSDB_CHILD_TABLE == pStmt->bInfo.tbType) ? pStmt->bInfo.tbSuid : uid;
×
1206

1207
  if (taosHashGet(pStmt->sql.pTableCache, &cacheUid, sizeof(cacheUid))) {
×
1208
    return TSDB_CODE_SUCCESS;
×
1209
  }
1210

1211
  STableDataCxt** pSrc = taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
×
1212
  if (!pSrc) {
×
1213
    return terrno;
×
1214
  }
1215
  STableDataCxt* pDst = NULL;
×
1216

1217
  STMT_ERR_RET(qCloneStmtDataBlock(&pDst, *pSrc, true));
×
1218

1219
  SStmtTableCache cache = {
×
1220
      .pDataCtx = pDst,
1221
      .boundTags = pStmt->bInfo.boundTags,
×
1222
  };
1223

1224
  if (taosHashPut(pStmt->sql.pTableCache, &cacheUid, sizeof(cacheUid), &cache, sizeof(cache))) {
×
1225
    return terrno;
×
1226
  }
1227

1228
  if (pStmt->sql.autoCreateTbl) {
×
1229
    pStmt->bInfo.tagsCached = true;
×
1230
  } else {
1231
    pStmt->bInfo.boundTags = NULL;
×
1232
  }
1233

1234
  return TSDB_CODE_SUCCESS;
×
1235
}
1236

1237
static int stmtAddBatch2(TAOS_STMT2* stmt) {
×
1238
  STscStmt2* pStmt = (STscStmt2*)stmt;
×
1239

1240
  int64_t startUs = taosGetTimestampUs();
×
1241

1242
  STMT_DLOG_E("start to add batch");
×
1243

1244
  if (pStmt->errCode != TSDB_CODE_SUCCESS) {
×
1245
    return pStmt->errCode;
×
1246
  }
1247

1248
  STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_ADD_BATCH));
×
1249

1250
  if (pStmt->sql.stbInterlaceMode) {
×
1251
    int64_t startUs2 = taosGetTimestampUs();
×
1252
    pStmt->stat.addBatchUs += startUs2 - startUs;
×
1253

1254
    pStmt->sql.siInfo.tableColsReady = false;
×
1255

1256
    SStmtQNode* param = NULL;
×
1257
    STMT_ERR_RET(stmtAllocQNodeFromBuf(&pStmt->sql.siInfo.tbBuf, (void**)&param));
×
1258
    param->restoreTbCols = true;
×
1259
    param->next = NULL;
×
1260

1261
    stmtEnqueue(pStmt, param);
×
1262

1263
    return TSDB_CODE_SUCCESS;
×
1264
  }
1265

1266
  STMT_ERR_RET(stmtCacheBlock(pStmt));
×
1267

1268
  return TSDB_CODE_SUCCESS;
×
1269
}
1270
/*
1271
static int32_t stmtBackupQueryFields(STscStmt2* pStmt) {
1272
  SStmtQueryResInfo* pRes = &pStmt->sql.queryRes;
1273
  pRes->numOfCols = pStmt->exec.pRequest->body.resInfo.numOfCols;
1274
  pRes->precision = pStmt->exec.pRequest->body.resInfo.precision;
1275

1276
  int32_t size = pRes->numOfCols * sizeof(TAOS_FIELD);
1277
  pRes->fields = taosMemoryMalloc(size);
1278
  pRes->userFields = taosMemoryMalloc(size);
1279
  if (NULL == pRes->fields || NULL == pRes->userFields) {
1280
    STMT_ERR_RET(terrno);
1281
  }
1282
  (void)memcpy(pRes->fields, pStmt->exec.pRequest->body.resInfo.fields, size);
1283
  (void)memcpy(pRes->userFields, pStmt->exec.pRequest->body.resInfo.userFields, size);
1284

1285
  return TSDB_CODE_SUCCESS;
1286
}
1287

1288
static int32_t stmtRestoreQueryFields(STscStmt2* pStmt) {
1289
  SStmtQueryResInfo* pRes = &pStmt->sql.queryRes;
1290
  int32_t            size = pRes->numOfCols * sizeof(TAOS_FIELD);
1291

1292
  pStmt->exec.pRequest->body.resInfo.numOfCols = pRes->numOfCols;
1293
  pStmt->exec.pRequest->body.resInfo.precision = pRes->precision;
1294

1295
  if (NULL == pStmt->exec.pRequest->body.resInfo.fields) {
1296
    pStmt->exec.pRequest->body.resInfo.fields = taosMemoryMalloc(size);
1297
    if (NULL == pStmt->exec.pRequest->body.resInfo.fields) {
1298
      STMT_ERR_RET(terrno);
1299
    }
1300
    (void)memcpy(pStmt->exec.pRequest->body.resInfo.fields, pRes->fields, size);
1301
  }
1302

1303
  if (NULL == pStmt->exec.pRequest->body.resInfo.userFields) {
1304
    pStmt->exec.pRequest->body.resInfo.userFields = taosMemoryMalloc(size);
1305
    if (NULL == pStmt->exec.pRequest->body.resInfo.userFields) {
1306
      STMT_ERR_RET(terrno);
1307
    }
1308
    (void)memcpy(pStmt->exec.pRequest->body.resInfo.userFields, pRes->userFields, size);
1309
  }
1310

1311
  return TSDB_CODE_SUCCESS;
1312
}
1313
*/
1314
int stmtBindBatch2(TAOS_STMT2* stmt, TAOS_STMT2_BIND* bind, int32_t colIdx) {
×
1315
  STscStmt2* pStmt = (STscStmt2*)stmt;
×
1316
  int32_t    code = 0;
×
1317

1318
  int64_t startUs = taosGetTimestampUs();
×
1319

1320
  STMT_DLOG("start to bind stmt data, colIdx: %d", colIdx);
×
1321

1322
  if (pStmt->errCode != TSDB_CODE_SUCCESS) {
×
1323
    return pStmt->errCode;
×
1324
  }
1325

1326
  STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_BIND));
×
1327

1328
  if (pStmt->bInfo.needParse && pStmt->sql.runTimes && pStmt->sql.type > 0 &&
×
1329
      STMT_TYPE_MULTI_INSERT != pStmt->sql.type) {
×
1330
    pStmt->bInfo.needParse = false;
×
1331
  }
1332

1333
  if (pStmt->exec.pRequest && STMT_TYPE_QUERY == pStmt->sql.type && pStmt->sql.runTimes) {
×
1334
    taos_free_result(pStmt->exec.pRequest);
×
1335
    pStmt->exec.pRequest = NULL;
×
1336
  }
1337

1338
  STMT_ERR_RET(stmtCreateRequest(pStmt));
×
1339

1340
  if (pStmt->bInfo.needParse) {
×
1341
    STMT_ERR_RET(stmtParseSql(pStmt));
×
1342
  }
1343

1344
  if (STMT_TYPE_QUERY == pStmt->sql.type) {
×
1345
    STMT_ERR_RET(qStmtBindParams2(pStmt->sql.pQuery, bind, colIdx, pStmt->taos->optionInfo.charsetCxt));
×
1346

1347
    SParseContext ctx = {.requestId = pStmt->exec.pRequest->requestId,
×
1348
                         .acctId = pStmt->taos->acctId,
×
1349
                         .db = pStmt->exec.pRequest->pDb,
×
1350
                         .topicQuery = false,
1351
                         .pSql = pStmt->sql.sqlStr,
×
1352
                         .sqlLen = pStmt->sql.sqlLen,
×
1353
                         .pMsg = pStmt->exec.pRequest->msgBuf,
×
1354
                         .msgLen = ERROR_MSG_BUF_DEFAULT_SIZE,
1355
                         .pTransporter = pStmt->taos->pAppInfo->pTransporter,
×
1356
                         .pStmtCb = NULL,
1357
                         .pUser = pStmt->taos->user};
×
1358
    ctx.mgmtEpSet = getEpSet_s(&pStmt->taos->pAppInfo->mgmtEp);
×
1359
    STMT_ERR_RET(catalogGetHandle(pStmt->taos->pAppInfo->clusterId, &ctx.pCatalog));
×
1360

1361
    STMT_ERR_RET(qStmtParseQuerySql(&ctx, pStmt->sql.pQuery));
×
1362

1363
    if (pStmt->sql.pQuery->haveResultSet) {
×
1364
      STMT_ERR_RET(setResSchemaInfo(&pStmt->exec.pRequest->body.resInfo, pStmt->sql.pQuery->pResSchema,
×
1365
                                    pStmt->sql.pQuery->numOfResCols));
1366
      taosMemoryFreeClear(pStmt->sql.pQuery->pResSchema);
×
1367
      setResPrecision(&pStmt->exec.pRequest->body.resInfo, pStmt->sql.pQuery->precision);
×
1368
    }
1369

1370
    TSWAP(pStmt->exec.pRequest->dbList, pStmt->sql.pQuery->pDbList);
×
1371
    TSWAP(pStmt->exec.pRequest->tableList, pStmt->sql.pQuery->pTableList);
×
1372
    TSWAP(pStmt->exec.pRequest->targetTableList, pStmt->sql.pQuery->pTargetTableList);
×
1373

1374
    // if (STMT_TYPE_QUERY == pStmt->sql.queryRes) {
1375
    //   STMT_ERR_RET(stmtRestoreQueryFields(pStmt));
1376
    // }
1377

1378
    // STMT_ERR_RET(stmtBackupQueryFields(pStmt));
1379

1380
    return TSDB_CODE_SUCCESS;
×
1381
  }
1382

1383
  if (pStmt->sql.stbInterlaceMode && NULL == pStmt->sql.siInfo.pDataCtx) {
×
1384
    STMT_ERR_RET(stmtInitStbInterlaceTableInfo(pStmt));
×
1385
  }
1386

1387
  STableDataCxt** pDataBlock = NULL;
×
1388

1389
  if (pStmt->exec.pCurrBlock) {
×
1390
    pDataBlock = &pStmt->exec.pCurrBlock;
×
1391
  } else {
1392
    pDataBlock =
1393
        (STableDataCxt**)taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
×
1394
    if (NULL == pDataBlock) {
×
1395
      tscError("table %s not found in exec blockHash", pStmt->bInfo.tbFName);
×
1396
      STMT_ERR_RET(TSDB_CODE_TSC_STMT_CACHE_ERROR);
×
1397
    }
1398
    pStmt->exec.pCurrBlock = *pDataBlock;
×
1399
    if (pStmt->sql.stbInterlaceMode) {
×
1400
      taosArrayDestroy(pStmt->exec.pCurrBlock->pData->aCol);
×
1401
      pStmt->exec.pCurrBlock->pData->aCol = NULL;
×
1402
    }
1403
  }
1404

1405
  int64_t startUs2 = taosGetTimestampUs();
×
1406
  pStmt->stat.bindDataUs1 += startUs2 - startUs;
×
1407

1408
  SStmtQNode* param = NULL;
×
1409
  if (pStmt->sql.stbInterlaceMode) {
×
1410
    STMT_ERR_RET(stmtAllocQNodeFromBuf(&pStmt->sql.siInfo.tbBuf, (void**)&param));
×
1411
    STMT_ERR_RET(stmtGetTableColsFromCache(pStmt, &param->tblData.aCol));
×
1412
    taosArrayClear(param->tblData.aCol);
×
1413

1414
    // param->tblData.aCol = taosArrayInit(20, POINTER_BYTES);
1415

1416
    param->restoreTbCols = false;
×
1417
    tstrncpy(param->tblData.tbName, pStmt->bInfo.tbName, TSDB_TABLE_NAME_LEN);
×
1418
  }
1419

1420
  int64_t startUs3 = taosGetTimestampUs();
×
1421
  pStmt->stat.bindDataUs2 += startUs3 - startUs2;
×
1422

1423
  SArray* pCols = pStmt->sql.stbInterlaceMode ? param->tblData.aCol : (*pDataBlock)->pData->aCol;
×
1424

1425
  if (colIdx < 0) {
×
1426
    if (pStmt->sql.stbInterlaceMode) {
×
1427
      (*pDataBlock)->pData->flags = 0;
×
1428
      code = qBindStmtStbColsValue2(*pDataBlock, pCols, bind, pStmt->exec.pRequest->msgBuf,
×
1429
                                    pStmt->exec.pRequest->msgBufLen, &pStmt->sql.siInfo.pTSchema, pStmt->sql.pBindInfo, pStmt->taos->optionInfo.charsetCxt);
×
1430
    } else {
1431
      code =
1432
          qBindStmtColsValue2(*pDataBlock, pCols, bind, pStmt->exec.pRequest->msgBuf, pStmt->exec.pRequest->msgBufLen, pStmt->taos->optionInfo.charsetCxt);
×
1433
    }
1434

1435
    if (code) {
×
1436
      tscError("qBindStmtColsValue failed, error:%s", tstrerror(code));
×
1437
      STMT_ERR_RET(code);
×
1438
    }
1439
  } else {
1440
    if (pStmt->sql.stbInterlaceMode) {
×
1441
      tscError("bind single column not allowed in stb insert mode");
×
1442
      STMT_ERR_RET(TSDB_CODE_TSC_STMT_API_ERROR);
×
1443
    }
1444

1445
    if (colIdx != (pStmt->bInfo.sBindLastIdx + 1) && colIdx != 0) {
×
1446
      tscError("bind column index not in sequence");
×
1447
      STMT_ERR_RET(TSDB_CODE_APP_ERROR);
×
1448
    }
1449

1450
    pStmt->bInfo.sBindLastIdx = colIdx;
×
1451

1452
    if (0 == colIdx) {
×
1453
      pStmt->bInfo.sBindRowNum = bind->num;
×
1454
    }
1455

1456
    code = qBindStmtSingleColValue2(*pDataBlock, pCols, bind, pStmt->exec.pRequest->msgBuf,
×
1457
                                    pStmt->exec.pRequest->msgBufLen, colIdx, pStmt->bInfo.sBindRowNum, pStmt->taos->optionInfo.charsetCxt);
×
1458
    if (code) {
×
1459
      tscError("qBindStmtSingleColValue failed, error:%s", tstrerror(code));
×
1460
      STMT_ERR_RET(code);
×
1461
    }
1462
  }
1463

1464
  int64_t startUs4 = taosGetTimestampUs();
×
1465
  pStmt->stat.bindDataUs3 += startUs4 - startUs3;
×
1466

1467
  if (pStmt->sql.stbInterlaceMode) {
×
1468
    STMT_ERR_RET(stmtAppendTablePostHandle(pStmt, param));
×
1469
  } else {
1470
    STMT_ERR_RET(stmtAddBatch2(pStmt));
×
1471
  }
1472

1473
  pStmt->stat.bindDataUs4 += taosGetTimestampUs() - startUs4;
×
1474

1475
  return TSDB_CODE_SUCCESS;
×
1476
}
1477
/*
1478
int stmtUpdateTableUid(STscStmt2* pStmt, SSubmitRsp* pRsp) {
1479
  tscDebug("stmt start to update tbUid, blockNum: %d", pRsp->nBlocks);
1480

1481
  int32_t code = 0;
1482
  int32_t finalCode = 0;
1483
  size_t  keyLen = 0;
1484
  void*   pIter = taosHashIterate(pStmt->exec.pBlockHash, NULL);
1485
  while (pIter) {
1486
    STableDataCxt* pBlock = *(STableDataCxt**)pIter;
1487
    char*          key = taosHashGetKey(pIter, &keyLen);
1488

1489
    STableMeta* pMeta = qGetTableMetaInDataBlock(pBlock);
1490
    if (pMeta->uid) {
1491
      pIter = taosHashIterate(pStmt->exec.pBlockHash, pIter);
1492
      continue;
1493
    }
1494

1495
    SSubmitBlkRsp* blkRsp = NULL;
1496
    int32_t        i = 0;
1497
    for (; i < pRsp->nBlocks; ++i) {
1498
      blkRsp = pRsp->pBlocks + i;
1499
      if (strlen(blkRsp->tblFName) != keyLen) {
1500
        continue;
1501
      }
1502

1503
      if (strncmp(blkRsp->tblFName, key, keyLen)) {
1504
        continue;
1505
      }
1506

1507
      break;
1508
    }
1509

1510
    if (i < pRsp->nBlocks) {
1511
      tscDebug("auto created table %s uid updated from %" PRIx64 " to %" PRIx64, blkRsp->tblFName, pMeta->uid,
1512
               blkRsp->uid);
1513

1514
      pMeta->uid = blkRsp->uid;
1515
      pStmt->bInfo.tbUid = blkRsp->uid;
1516
    } else {
1517
      tscDebug("table %s not found in submit rsp, will update from catalog", pStmt->bInfo.tbFName);
1518
      if (NULL == pStmt->pCatalog) {
1519
        code = catalogGetHandle(pStmt->taos->pAppInfo->clusterId, &pStmt->pCatalog);
1520
        if (code) {
1521
          pIter = taosHashIterate(pStmt->exec.pBlockHash, pIter);
1522
          finalCode = code;
1523
          continue;
1524
        }
1525
      }
1526

1527
      code = stmtCreateRequest(pStmt);
1528
      if (code) {
1529
        pIter = taosHashIterate(pStmt->exec.pBlockHash, pIter);
1530
        finalCode = code;
1531
        continue;
1532
      }
1533

1534
      STableMeta*      pTableMeta = NULL;
1535
      SRequestConnInfo conn = {.pTrans = pStmt->taos->pAppInfo->pTransporter,
1536
                               .requestId = pStmt->exec.pRequest->requestId,
1537
                               .requestObjRefId = pStmt->exec.pRequest->self,
1538
                               .mgmtEps = getEpSet_s(&pStmt->taos->pAppInfo->mgmtEp)};
1539
      code = catalogGetTableMeta(pStmt->pCatalog, &conn, &pStmt->bInfo.sname, &pTableMeta);
1540

1541
      pStmt->stat.ctgGetTbMetaNum++;
1542

1543
      taos_free_result(pStmt->exec.pRequest);
1544
      pStmt->exec.pRequest = NULL;
1545

1546
      if (code || NULL == pTableMeta) {
1547
        pIter = taosHashIterate(pStmt->exec.pBlockHash, pIter);
1548
        finalCode = code;
1549
        taosMemoryFree(pTableMeta);
1550
        continue;
1551
      }
1552

1553
      pMeta->uid = pTableMeta->uid;
1554
      pStmt->bInfo.tbUid = pTableMeta->uid;
1555
      taosMemoryFree(pTableMeta);
1556
    }
1557

1558
    pIter = taosHashIterate(pStmt->exec.pBlockHash, pIter);
1559
  }
1560

1561
  return finalCode;
1562
}
1563
*/
1564
/*
1565
int stmtStaticModeExec(TAOS_STMT* stmt) {
1566
  STscStmt2*   pStmt = (STscStmt2*)stmt;
1567
  int32_t     code = 0;
1568
  SSubmitRsp* pRsp = NULL;
1569
  if (pStmt->sql.staticMode) {
1570
    return TSDB_CODE_TSC_STMT_API_ERROR;
1571
  }
1572

1573
  STMT_DLOG_E("start to exec");
1574

1575
  STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_EXECUTE));
1576

1577
  STMT_ERR_RET(qBuildStmtOutputFromTbList(pStmt->sql.pQuery, pStmt->sql.pVgHash, pStmt->exec.pTbBlkList,
1578
pStmt->exec.pCurrBlock, pStmt->exec.tbBlkNum));
1579

1580
  launchQueryImpl(pStmt->exec.pRequest, pStmt->sql.pQuery, true, NULL);
1581

1582
  if (pStmt->exec.pRequest->code && NEED_CLIENT_HANDLE_ERROR(pStmt->exec.pRequest->code)) {
1583
    code = refreshMeta(pStmt->exec.pRequest->pTscObj, pStmt->exec.pRequest);
1584
    if (code) {
1585
      pStmt->exec.pRequest->code = code;
1586
    } else {
1587
      tFreeSSubmitRsp(pRsp);
1588
      STMT_ERR_RET(stmtResetStmt(pStmt));
1589
      STMT_ERR_RET(TSDB_CODE_NEED_RETRY);
1590
    }
1591
  }
1592

1593
  STMT_ERR_JRET(pStmt->exec.pRequest->code);
1594

1595
  pStmt->exec.affectedRows = taos_affected_rows(pStmt->exec.pRequest);
1596
  pStmt->affectedRows += pStmt->exec.affectedRows;
1597

1598
_return:
1599

1600
  stmtCleanExecInfo(pStmt, (code ? false : true), false);
1601

1602
  tFreeSSubmitRsp(pRsp);
1603

1604
  ++pStmt->sql.runTimes;
1605

1606
  STMT_RET(code);
1607
}
1608
*/
1609

1610
static int32_t createParseContext(const SRequestObj* pRequest, SParseContext** pCxt, SSqlCallbackWrapper* pWrapper) {
×
1611
  const STscObj* pTscObj = pRequest->pTscObj;
×
1612

1613
  *pCxt = taosMemoryCalloc(1, sizeof(SParseContext));
×
1614
  if (*pCxt == NULL) {
×
1615
    return terrno;
×
1616
  }
1617

1618
  **pCxt = (SParseContext){.requestId = pRequest->requestId,
×
1619
                           .requestRid = pRequest->self,
×
1620
                           .acctId = pTscObj->acctId,
×
1621
                           .db = pRequest->pDb,
×
1622
                           .topicQuery = false,
1623
                           .pSql = pRequest->sqlstr,
×
1624
                           .sqlLen = pRequest->sqlLen,
×
1625
                           .pMsg = pRequest->msgBuf,
×
1626
                           .msgLen = ERROR_MSG_BUF_DEFAULT_SIZE,
1627
                           .pTransporter = pTscObj->pAppInfo->pTransporter,
×
1628
                           .pStmtCb = NULL,
1629
                           .pUser = pTscObj->user,
×
1630
                           .pEffectiveUser = pRequest->effectiveUser,
×
1631
                           .isSuperUser = (0 == strcmp(pTscObj->user, TSDB_DEFAULT_USER)),
×
1632
                           .enableSysInfo = pTscObj->sysInfo,
×
1633
                           .async = true,
1634
                           .svrVer = pTscObj->sVer,
×
1635
                           .nodeOffline = (pTscObj->pAppInfo->onlineDnodes < pTscObj->pAppInfo->totalDnodes),
×
1636
                           .allocatorId = pRequest->allocatorRefId,
×
1637
                           .parseSqlFp = clientParseSql,
1638
                           .parseSqlParam = pWrapper};
1639
  int8_t biMode = atomic_load_8(&((STscObj*)pTscObj)->biMode);
×
1640
  (*pCxt)->biMode = biMode;
×
1641
  return TSDB_CODE_SUCCESS;
×
1642
}
1643

1644
static void asyncQueryCb(void* userdata, TAOS_RES* res, int code) {
×
1645
  STscStmt2*        pStmt = userdata;
×
1646
  __taos_async_fn_t fp = pStmt->options.asyncExecFn;
×
1647

1648
  pStmt->exec.affectedRows = taos_affected_rows(pStmt->exec.pRequest);
×
1649
  pStmt->affectedRows += pStmt->exec.affectedRows;
×
1650

1651
  fp(pStmt->options.userdata, res, code);
×
1652

1653
  while (0 == atomic_load_8((int8_t*)&pStmt->sql.siInfo.tableColsReady)) {
×
1654
    taosUsleep(1);
×
1655
  }
1656
  (void)stmtCleanExecInfo(pStmt, (code ? false : true), false);
×
1657
  ++pStmt->sql.runTimes;
×
1658

1659
  if (tsem_post(&pStmt->asyncQuerySem) != 0) {
×
1660
    tscError("failed to post asyncQuerySem");
×
1661
  }
1662
}
×
1663

1664
int stmtExec2(TAOS_STMT2* stmt, int* affected_rows) {
×
1665
  STscStmt2* pStmt = (STscStmt2*)stmt;
×
1666
  int32_t    code = 0;
×
1667
  int64_t    startUs = taosGetTimestampUs();
×
1668

1669
  STMT_DLOG_E("start to exec");
×
1670

1671
  if (pStmt->errCode != TSDB_CODE_SUCCESS) {
×
1672
    return pStmt->errCode;
×
1673
  }
1674

1675
  if (pStmt->sql.stbInterlaceMode) {
×
1676
    STMT_ERR_RET(stmtAddBatch2(pStmt));
×
1677
  }
1678

1679
  STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_EXECUTE));
×
1680

1681
  if (STMT_TYPE_QUERY != pStmt->sql.type) {
×
1682
    if (pStmt->sql.stbInterlaceMode) {
×
1683
      int64_t startTs = taosGetTimestampUs();
×
1684
      while (atomic_load_64(&pStmt->sql.siInfo.tbRemainNum)) {
×
1685
        taosUsleep(1);
×
1686
      }
1687
      pStmt->stat.execWaitUs += taosGetTimestampUs() - startTs;
×
1688

1689
      STMT_ERR_RET(qBuildStmtFinOutput(pStmt->sql.pQuery, pStmt->sql.pVgHash, pStmt->sql.siInfo.pVgroupList));
×
1690
      taosHashCleanup(pStmt->sql.siInfo.pVgroupHash);
×
1691
      pStmt->sql.siInfo.pVgroupHash = NULL;
×
1692
      pStmt->sql.siInfo.pVgroupList = NULL;
×
1693
    } else {
1694
      tDestroySubmitTbData(pStmt->exec.pCurrTbData, TSDB_MSG_FLG_ENCODE);
×
1695
      taosMemoryFreeClear(pStmt->exec.pCurrTbData);
×
1696

1697
      STMT_ERR_RET(qCloneCurrentTbData(pStmt->exec.pCurrBlock, &pStmt->exec.pCurrTbData));
×
1698

1699
      STMT_ERR_RET(qBuildStmtOutput(pStmt->sql.pQuery, pStmt->sql.pVgHash, pStmt->exec.pBlockHash));
×
1700
    }
1701
  }
1702

1703
  SRequestObj*      pRequest = pStmt->exec.pRequest;
×
1704
  __taos_async_fn_t fp = pStmt->options.asyncExecFn;
×
1705

1706
  if (!fp) {
×
1707
    launchQueryImpl(pStmt->exec.pRequest, pStmt->sql.pQuery, true, NULL);
×
1708

1709
    if (pStmt->exec.pRequest->code && NEED_CLIENT_HANDLE_ERROR(pStmt->exec.pRequest->code)) {
×
1710
      code = refreshMeta(pStmt->exec.pRequest->pTscObj, pStmt->exec.pRequest);
×
1711
      if (code) {
×
1712
        pStmt->exec.pRequest->code = code;
×
1713
      } else {
1714
        STMT_ERR_RET(stmtResetStmt(pStmt));
×
1715
        STMT_ERR_RET(TSDB_CODE_NEED_RETRY);
×
1716
      }
1717
    }
1718

1719
    STMT_ERR_JRET(pStmt->exec.pRequest->code);
×
1720

1721
    pStmt->exec.affectedRows = taos_affected_rows(pStmt->exec.pRequest);
×
1722
    if (affected_rows) {
×
1723
      *affected_rows = pStmt->exec.affectedRows;
×
1724
    }
1725
    pStmt->affectedRows += pStmt->exec.affectedRows;
×
1726

1727
    while (0 == atomic_load_8((int8_t*)&pStmt->sql.siInfo.tableColsReady)) {
×
1728
      taosUsleep(1);
×
1729
    }
1730

1731
    STMT_ERR_RET(stmtCleanExecInfo(pStmt, (code ? false : true), false));
×
1732

1733
    ++pStmt->sql.runTimes;
×
1734
  } else {
1735
    SSqlCallbackWrapper* pWrapper = taosMemoryCalloc(1, sizeof(SSqlCallbackWrapper));
×
1736
    if (pWrapper == NULL) {
×
1737
      code = terrno;
×
1738
    } else {
1739
      pWrapper->pRequest = pRequest;
×
1740
      pRequest->pWrapper = pWrapper;
×
1741
    }
1742
    if (TSDB_CODE_SUCCESS == code) {
×
1743
      code = createParseContext(pRequest, &pWrapper->pParseCtx, pWrapper);
×
1744
    }
1745
    pRequest->syncQuery = false;
×
1746
    pRequest->body.queryFp = asyncQueryCb;
×
1747
    ((SSyncQueryParam*)(pRequest)->body.interParam)->userParam = pStmt;
×
1748

1749
    pStmt->semWaited = false;
×
1750
    launchAsyncQuery(pRequest, pStmt->sql.pQuery, NULL, pWrapper);
×
1751
  }
1752

1753
_return:
×
1754
  pStmt->stat.execUseUs += taosGetTimestampUs() - startUs;
×
1755

1756
  STMT_RET(code);
×
1757
}
1758

1759
int stmtClose2(TAOS_STMT2* stmt) {
×
1760
  STscStmt2* pStmt = (STscStmt2*)stmt;
×
1761

1762
  STMT_DLOG_E("start to free stmt");
×
1763

1764
  pStmt->queue.stopQueue = true;
×
1765

1766
  (void)taosThreadMutexLock(&pStmt->queue.mutex);
×
1767
  (void)taosThreadCondSignal(&(pStmt->queue.waitCond));
×
1768
  (void)taosThreadMutexUnlock(&pStmt->queue.mutex);
×
1769

1770
  if (pStmt->bindThreadInUse) {
×
1771
    (void)taosThreadJoin(pStmt->bindThread, NULL);
×
1772
    pStmt->bindThreadInUse = false;
×
1773
  }
1774

1775
  (void)taosThreadCondDestroy(&pStmt->queue.waitCond);
×
1776
  (void)taosThreadMutexDestroy(&pStmt->queue.mutex);
×
1777

1778
  if (pStmt->options.asyncExecFn && !pStmt->semWaited) {
×
1779
    if (tsem_wait(&pStmt->asyncQuerySem) != 0) {
×
1780
      tscError("failed to wait asyncQuerySem");
×
1781
    }
1782
  }
1783

1784
  STMT_DLOG("stmt %p closed, stbInterlaceMode: %d, statInfo: ctgGetTbMetaNum=>%" PRId64 ", getCacheTbInfo=>%" PRId64
×
1785
            ", parseSqlNum=>%" PRId64 ", pStmt->stat.bindDataNum=>%" PRId64
1786
            ", settbnameAPI:%u, bindAPI:%u, addbatchAPI:%u, execAPI:%u"
1787
            ", setTbNameUs:%" PRId64 ", bindDataUs:%" PRId64 ",%" PRId64 ",%" PRId64 ",%" PRId64 " addBatchUs:%" PRId64
1788
            ", execWaitUs:%" PRId64 ", execUseUs:%" PRId64,
1789
            pStmt, pStmt->sql.stbInterlaceMode, pStmt->stat.ctgGetTbMetaNum, pStmt->stat.getCacheTbInfo,
1790
            pStmt->stat.parseSqlNum, pStmt->stat.bindDataNum, pStmt->seqIds[STMT_SETTBNAME], pStmt->seqIds[STMT_BIND],
1791
            pStmt->seqIds[STMT_ADD_BATCH], pStmt->seqIds[STMT_EXECUTE], pStmt->stat.setTbNameUs,
1792
            pStmt->stat.bindDataUs1, pStmt->stat.bindDataUs2, pStmt->stat.bindDataUs3, pStmt->stat.bindDataUs4,
1793
            pStmt->stat.addBatchUs, pStmt->stat.execWaitUs, pStmt->stat.execUseUs);
1794

1795
  STMT_ERR_RET(stmtCleanSQLInfo(pStmt));
×
1796

1797
  if (pStmt->options.asyncExecFn) {
×
1798
    if (tsem_destroy(&pStmt->asyncQuerySem) != 0) {
×
1799
      tscError("failed to destroy asyncQuerySem");
×
1800
    }
1801
  }
1802
  taosMemoryFree(stmt);
×
1803

1804
  return TSDB_CODE_SUCCESS;
×
1805
}
1806

1807
const char* stmtErrstr2(TAOS_STMT2* stmt) {
×
1808
  STscStmt2* pStmt = (STscStmt2*)stmt;
×
1809

1810
  if (stmt == NULL || NULL == pStmt->exec.pRequest) {
×
1811
    return (char*)tstrerror(terrno);
×
1812
  }
1813

1814
  pStmt->exec.pRequest->code = terrno;
×
1815

1816
  return taos_errstr(pStmt->exec.pRequest);
×
1817
}
1818
/*
1819
int stmtAffectedRows(TAOS_STMT* stmt) { return ((STscStmt2*)stmt)->affectedRows; }
1820

1821
int stmtAffectedRowsOnce(TAOS_STMT* stmt) { return ((STscStmt2*)stmt)->exec.affectedRows; }
1822
*/
1823

1824
int stmtParseColFields2(TAOS_STMT2* stmt) {
×
1825
  int32_t    code = 0;
×
1826
  STscStmt2* pStmt = (STscStmt2*)stmt;
×
1827
  int32_t    preCode = pStmt->errCode;
×
1828

1829
  STMT_DLOG_E("start to get col fields");
×
1830

1831
  if (pStmt->errCode != TSDB_CODE_SUCCESS) {
×
1832
    return pStmt->errCode;
×
1833
  }
1834

1835
  if (STMT_TYPE_QUERY == pStmt->sql.type) {
×
1836
    STMT_ERRI_JRET(TSDB_CODE_TSC_STMT_API_ERROR);
×
1837
  }
1838

1839
  STMT_ERRI_JRET(stmtSwitchStatus(pStmt, STMT_FETCH_FIELDS));
×
1840

1841
  if (pStmt->bInfo.needParse && pStmt->sql.runTimes && pStmt->sql.type > 0 &&
×
1842
      STMT_TYPE_MULTI_INSERT != pStmt->sql.type) {
×
1843
    pStmt->bInfo.needParse = false;
×
1844
  }
1845

1846
  if (pStmt->exec.pRequest && STMT_TYPE_QUERY == pStmt->sql.type && pStmt->sql.runTimes) {
×
1847
    taos_free_result(pStmt->exec.pRequest);
×
1848
    pStmt->exec.pRequest = NULL;
×
1849
    STMT_ERRI_JRET(stmtCreateRequest(pStmt));
×
1850
  }
1851

1852
  STMT_ERRI_JRET(stmtCreateRequest(pStmt));
×
1853

1854
  if (pStmt->bInfo.needParse) {
×
1855
    STMT_ERRI_JRET(stmtParseSql(pStmt));
×
1856
  }
1857

1858
_return:
×
1859

1860
  pStmt->errCode = preCode;
×
1861

1862
  return code;
×
1863
}
1864

1865
int stmtGetStbColFields2(TAOS_STMT2* stmt, int* nums, TAOS_FIELD_ALL** fields) {
×
1866
  int32_t code = stmtParseColFields2(stmt);
×
1867
  if (code != TSDB_CODE_SUCCESS) {
×
1868
    return code;
×
1869
  }
1870

1871
  return stmtFetchStbColFields2(stmt, nums, fields);
×
1872
}
1873

1874
int stmtGetParamNum2(TAOS_STMT2* stmt, int* nums) {
×
1875
  int32_t    code = 0;
×
1876
  STscStmt2* pStmt = (STscStmt2*)stmt;
×
1877
  int32_t    preCode = pStmt->errCode;
×
1878

1879
  STMT_DLOG_E("start to get param num");
×
1880

1881
  if (pStmt->errCode != TSDB_CODE_SUCCESS) {
×
1882
    return pStmt->errCode;
×
1883
  }
1884

1885
  STMT_ERRI_JRET(stmtSwitchStatus(pStmt, STMT_FETCH_FIELDS));
×
1886

1887
  if (pStmt->bInfo.needParse && pStmt->sql.runTimes && pStmt->sql.type > 0 &&
×
1888
      STMT_TYPE_MULTI_INSERT != pStmt->sql.type) {
×
1889
    pStmt->bInfo.needParse = false;
×
1890
  }
1891

1892
  if (pStmt->exec.pRequest && STMT_TYPE_QUERY == pStmt->sql.type && pStmt->sql.runTimes) {
×
1893
    taos_free_result(pStmt->exec.pRequest);
×
1894
    pStmt->exec.pRequest = NULL;
×
1895
  }
1896

1897
  STMT_ERRI_JRET(stmtCreateRequest(pStmt));
×
1898

1899
  if (pStmt->bInfo.needParse) {
×
1900
    STMT_ERRI_JRET(stmtParseSql(pStmt));
×
1901
  }
1902

1903
  if (STMT_TYPE_QUERY == pStmt->sql.type) {
×
1904
    *nums = taosArrayGetSize(pStmt->sql.pQuery->pPlaceholderValues);
×
1905
  } else {
1906
    STMT_ERRI_JRET(stmtFetchColFields2(stmt, nums, NULL));
×
1907
  }
1908

1909
_return:
×
1910

1911
  pStmt->errCode = preCode;
×
1912

1913
  return code;
×
1914
}
1915

1916
TAOS_RES* stmtUseResult2(TAOS_STMT2* stmt) {
×
1917
  STscStmt2* pStmt = (STscStmt2*)stmt;
×
1918

1919
  STMT_DLOG_E("start to use result");
×
1920

1921
  if (STMT_TYPE_QUERY != pStmt->sql.type) {
×
1922
    tscError("useResult only for query statement");
×
1923
    return NULL;
×
1924
  }
1925

1926
  return pStmt->exec.pRequest;
×
1927
}
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