refactor stmt2 stb interlace mode
This commit is contained in:
parent
eafbe63683
commit
8d3c0a8d91
|
@ -58,13 +58,13 @@ static bool stmtDequeue(STscStmt2* pStmt, SStmtQNode** param) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stmtEnqueue(STscStmt2* pStmt, SStmtQNode* param) {
|
// static void stmtEnqueue(STscStmt2* pStmt, SStmtQNode* param) {
|
||||||
pStmt->queue.tail->next = param;
|
// pStmt->queue.tail->next = param;
|
||||||
pStmt->queue.tail = param;
|
// pStmt->queue.tail = param;
|
||||||
|
|
||||||
pStmt->stat.bindDataNum++;
|
// pStmt->stat.bindDataNum++;
|
||||||
(void)atomic_add_fetch_64((int64_t*)&pStmt->queue.qRemainNum, 1);
|
// (void)atomic_add_fetch_64((int64_t*)&pStmt->queue.qRemainNum, 1);
|
||||||
}
|
// }
|
||||||
|
|
||||||
static int32_t stmtCreateRequest(STscStmt2* pStmt) {
|
static int32_t stmtCreateRequest(STscStmt2* pStmt) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
@ -325,10 +325,10 @@ static int32_t stmtCleanBindInfo(STscStmt2* pStmt) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stmtFreeTableBlkList(STableColsData* pTb) {
|
// static void stmtFreeTableBlkList(STableColsData* pTb) {
|
||||||
(void)qResetStmtColumns(pTb->aCol, true);
|
// (void)qResetStmtColumns(pTb->aCol, true);
|
||||||
taosArrayDestroy(pTb->aCol);
|
// taosArrayDestroy(pTb->aCol);
|
||||||
}
|
// }
|
||||||
|
|
||||||
static void stmtResetQueueTableBuf(STableBufInfo* pTblBuf, SStmtQueue* pQueue) {
|
static void stmtResetQueueTableBuf(STableBufInfo* pTblBuf, SStmtQueue* pQueue) {
|
||||||
pTblBuf->pCurBuff = taosArrayGetP(pTblBuf->pBufList, 0);
|
pTblBuf->pCurBuff = taosArrayGetP(pTblBuf->pBufList, 0);
|
||||||
|
@ -895,32 +895,32 @@ int stmtPrepare2(TAOS_STMT2* stmt, const char* sql, unsigned long length) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t stmtInitStbInterlaceTableInfo(STscStmt2* pStmt) {
|
// static int32_t stmtInitStbInterlaceTableInfo(STscStmt2* pStmt) {
|
||||||
STableDataCxt** pSrc = taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
|
// STableDataCxt** pSrc = taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
|
||||||
if (!pSrc) {
|
// if (!pSrc) {
|
||||||
return terrno;
|
// return terrno;
|
||||||
}
|
// }
|
||||||
STableDataCxt* pDst = NULL;
|
// STableDataCxt* pDst = NULL;
|
||||||
|
|
||||||
STMT_ERR_RET(qCloneStmtDataBlock(&pDst, *pSrc, true));
|
// STMT_ERR_RET(qCloneStmtDataBlock(&pDst, *pSrc, true));
|
||||||
pStmt->sql.siInfo.pDataCtx = pDst;
|
// pStmt->sql.siInfo.pDataCtx = pDst;
|
||||||
|
|
||||||
SArray* pTblCols = NULL;
|
// SArray* pTblCols = NULL;
|
||||||
for (int32_t i = 0; i < STMT_TABLE_COLS_NUM; i++) {
|
// for (int32_t i = 0; i < STMT_TABLE_COLS_NUM; i++) {
|
||||||
pTblCols = taosArrayInit(20, POINTER_BYTES);
|
// pTblCols = taosArrayInit(20, POINTER_BYTES);
|
||||||
if (NULL == pTblCols) {
|
// if (NULL == pTblCols) {
|
||||||
return terrno;
|
// return terrno;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (taosArrayPush(pStmt->sql.siInfo.pTableCols, &pTblCols) == NULL) {
|
// if (taosArrayPush(pStmt->sql.siInfo.pTableCols, &pTblCols) == NULL) {
|
||||||
return terrno;
|
// return terrno;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
pStmt->sql.siInfo.boundTags = pStmt->bInfo.boundTags;
|
// pStmt->sql.siInfo.boundTags = pStmt->bInfo.boundTags;
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
// return TSDB_CODE_SUCCESS;
|
||||||
}
|
// }
|
||||||
|
|
||||||
int stmtIsInsert2(TAOS_STMT2* stmt, int* insert) {
|
int stmtIsInsert2(TAOS_STMT2* stmt, int* insert) {
|
||||||
STscStmt2* pStmt = (STscStmt2*)stmt;
|
STscStmt2* pStmt = (STscStmt2*)stmt;
|
||||||
|
@ -979,7 +979,7 @@ int stmtSetTbName2(TAOS_STMT2* stmt, const char* tbName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pStmt->sql.stbInterlaceMode && NULL == pStmt->sql.siInfo.pDataCtx) {
|
if (pStmt->sql.stbInterlaceMode && NULL == pStmt->sql.siInfo.pDataCtx) {
|
||||||
STMT_ERR_RET(stmtInitStbInterlaceTableInfo(pStmt));
|
// STMT_ERR_RET(stmtInitStbInterlaceTableInfo(pStmt));
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t startUs2 = taosGetTimestampUs();
|
int64_t startUs2 = taosGetTimestampUs();
|
||||||
|
@ -1009,7 +1009,7 @@ int stmtSetTbTags2(TAOS_STMT2* stmt, TAOS_STMT2_BIND* tags) {
|
||||||
STMT_ERR_RET(stmtParseSql(pStmt));
|
STMT_ERR_RET(stmtParseSql(pStmt));
|
||||||
}
|
}
|
||||||
if (pStmt->sql.stbInterlaceMode && NULL == pStmt->sql.siInfo.pDataCtx) {
|
if (pStmt->sql.stbInterlaceMode && NULL == pStmt->sql.siInfo.pDataCtx) {
|
||||||
STMT_ERR_RET(stmtInitStbInterlaceTableInfo(pStmt));
|
// STMT_ERR_RET(stmtInitStbInterlaceTableInfo(pStmt));
|
||||||
}
|
}
|
||||||
|
|
||||||
SBoundColInfo* tags_info = (SBoundColInfo*)pStmt->bInfo.boundTags;
|
SBoundColInfo* tags_info = (SBoundColInfo*)pStmt->bInfo.boundTags;
|
||||||
|
@ -1037,33 +1037,33 @@ int stmtSetTbTags2(TAOS_STMT2* stmt, TAOS_STMT2_BIND* tags) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int stmtFetchColFields2(STscStmt2* pStmt, int32_t* fieldNum, TAOS_FIELD_E** fields) {
|
// static int stmtFetchColFields2(STscStmt2* pStmt, int32_t* fieldNum, TAOS_FIELD_E** fields) {
|
||||||
if (pStmt->errCode != TSDB_CODE_SUCCESS) {
|
// if (pStmt->errCode != TSDB_CODE_SUCCESS) {
|
||||||
return pStmt->errCode;
|
// return pStmt->errCode;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (STMT_TYPE_QUERY == pStmt->sql.type) {
|
// if (STMT_TYPE_QUERY == pStmt->sql.type) {
|
||||||
tscError("invalid operation to get query column fileds");
|
// tscError("invalid operation to get query column fileds");
|
||||||
STMT_ERR_RET(TSDB_CODE_TSC_STMT_API_ERROR);
|
// STMT_ERR_RET(TSDB_CODE_TSC_STMT_API_ERROR);
|
||||||
}
|
// }
|
||||||
|
|
||||||
STableDataCxt** pDataBlock = NULL;
|
// STableDataCxt** pDataBlock = NULL;
|
||||||
|
|
||||||
if (pStmt->sql.stbInterlaceMode) {
|
// if (pStmt->sql.stbInterlaceMode) {
|
||||||
pDataBlock = &pStmt->sql.siInfo.pDataCtx;
|
// pDataBlock = &pStmt->sql.siInfo.pDataCtx;
|
||||||
} else {
|
// } else {
|
||||||
pDataBlock =
|
// pDataBlock =
|
||||||
(STableDataCxt**)taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
|
// (STableDataCxt**)taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
|
||||||
if (NULL == pDataBlock) {
|
// if (NULL == pDataBlock) {
|
||||||
tscError("table %s not found in exec blockHash", pStmt->bInfo.tbFName);
|
// tscError("table %s not found in exec blockHash", pStmt->bInfo.tbFName);
|
||||||
STMT_ERR_RET(TSDB_CODE_APP_ERROR);
|
// STMT_ERR_RET(TSDB_CODE_APP_ERROR);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
STMT_ERR_RET(qBuildStmtColFields(*pDataBlock, fieldNum, fields));
|
// STMT_ERR_RET(qBuildStmtColFields(*pDataBlock, fieldNum, fields));
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
// return TSDB_CODE_SUCCESS;
|
||||||
}
|
// }
|
||||||
|
|
||||||
static int stmtFetchStbColFields2(STscStmt2* pStmt, int32_t* fieldNum, TAOS_FIELD_ALL** fields) {
|
static int stmtFetchStbColFields2(STscStmt2* pStmt, int32_t* fieldNum, TAOS_FIELD_ALL** fields) {
|
||||||
if (pStmt->errCode != TSDB_CODE_SUCCESS) {
|
if (pStmt->errCode != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -1117,46 +1117,46 @@ SArray* stmtGetFreeCol(STscStmt2* pStmt, int32_t* idx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
static int32_t stmtAppendTablePostHandle(STscStmt2* pStmt, SStmtQNode* param) {
|
// static int32_t stmtAppendTablePostHandle(STscStmt2* pStmt, SStmtQNode* param) {
|
||||||
if (NULL == pStmt->sql.siInfo.pVgroupHash) {
|
// if (NULL == pStmt->sql.siInfo.pVgroupHash) {
|
||||||
pStmt->sql.siInfo.pVgroupHash =
|
// pStmt->sql.siInfo.pVgroupHash =
|
||||||
taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_ENTRY_LOCK);
|
// taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_ENTRY_LOCK);
|
||||||
}
|
// }
|
||||||
if (NULL == pStmt->sql.siInfo.pVgroupList) {
|
// if (NULL == pStmt->sql.siInfo.pVgroupList) {
|
||||||
pStmt->sql.siInfo.pVgroupList = taosArrayInit(64, POINTER_BYTES);
|
// pStmt->sql.siInfo.pVgroupList = taosArrayInit(64, POINTER_BYTES);
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (NULL == pStmt->sql.siInfo.pRequest) {
|
// if (NULL == pStmt->sql.siInfo.pRequest) {
|
||||||
STMT_ERR_RET(buildRequest(pStmt->taos->id, pStmt->sql.sqlStr, pStmt->sql.sqlLen, NULL, false,
|
// STMT_ERR_RET(buildRequest(pStmt->taos->id, pStmt->sql.sqlStr, pStmt->sql.sqlLen, NULL, false,
|
||||||
(SRequestObj**)&pStmt->sql.siInfo.pRequest, pStmt->reqid));
|
// (SRequestObj**)&pStmt->sql.siInfo.pRequest, pStmt->reqid));
|
||||||
|
|
||||||
if (pStmt->reqid != 0) {
|
// if (pStmt->reqid != 0) {
|
||||||
pStmt->reqid++;
|
// pStmt->reqid++;
|
||||||
}
|
// }
|
||||||
pStmt->exec.pRequest->syncQuery = true;
|
// pStmt->exec.pRequest->syncQuery = true;
|
||||||
|
|
||||||
pStmt->sql.siInfo.requestId = ((SRequestObj*)pStmt->sql.siInfo.pRequest)->requestId;
|
// pStmt->sql.siInfo.requestId = ((SRequestObj*)pStmt->sql.siInfo.pRequest)->requestId;
|
||||||
pStmt->sql.siInfo.requestSelf = ((SRequestObj*)pStmt->sql.siInfo.pRequest)->self;
|
// pStmt->sql.siInfo.requestSelf = ((SRequestObj*)pStmt->sql.siInfo.pRequest)->self;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (!pStmt->sql.siInfo.tbFromHash && pStmt->sql.siInfo.firstName[0] &&
|
// if (!pStmt->sql.siInfo.tbFromHash && pStmt->sql.siInfo.firstName[0] &&
|
||||||
0 == strcmp(pStmt->sql.siInfo.firstName, pStmt->bInfo.tbName)) {
|
// 0 == strcmp(pStmt->sql.siInfo.firstName, pStmt->bInfo.tbName)) {
|
||||||
pStmt->sql.siInfo.tbFromHash = true;
|
// pStmt->sql.siInfo.tbFromHash = true;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (0 == pStmt->sql.siInfo.firstName[0]) {
|
// if (0 == pStmt->sql.siInfo.firstName[0]) {
|
||||||
tstrncpy(pStmt->sql.siInfo.firstName, pStmt->bInfo.tbName, TSDB_TABLE_NAME_LEN);
|
// tstrncpy(pStmt->sql.siInfo.firstName, pStmt->bInfo.tbName, TSDB_TABLE_NAME_LEN);
|
||||||
}
|
// }
|
||||||
|
|
||||||
param->tblData.getFromHash = pStmt->sql.siInfo.tbFromHash;
|
// param->tblData.getFromHash = pStmt->sql.siInfo.tbFromHash;
|
||||||
param->next = NULL;
|
// param->next = NULL;
|
||||||
|
|
||||||
(void)atomic_add_fetch_64(&pStmt->sql.siInfo.tbRemainNum, 1);
|
// (void)atomic_add_fetch_64(&pStmt->sql.siInfo.tbRemainNum, 1);
|
||||||
|
|
||||||
stmtEnqueue(pStmt, param);
|
// stmtEnqueue(pStmt, param);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
// return TSDB_CODE_SUCCESS;
|
||||||
}
|
// }
|
||||||
|
|
||||||
static FORCE_INLINE int32_t stmtGetTableColsFromCache(STscStmt2* pStmt, SArray** pTableCols) {
|
static FORCE_INLINE int32_t stmtGetTableColsFromCache(STscStmt2* pStmt, SArray** pTableCols) {
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -1233,19 +1233,20 @@ static int stmtAddBatch2(TAOS_STMT2* stmt) {
|
||||||
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_ADD_BATCH));
|
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_ADD_BATCH));
|
||||||
|
|
||||||
if (pStmt->sql.stbInterlaceMode) {
|
if (pStmt->sql.stbInterlaceMode) {
|
||||||
int64_t startUs2 = taosGetTimestampUs();
|
// todo:add stb interlace mode
|
||||||
pStmt->stat.addBatchUs += startUs2 - startUs;
|
// int64_t startUs2 = taosGetTimestampUs();
|
||||||
|
// pStmt->stat.addBatchUs += startUs2 - startUs;
|
||||||
|
|
||||||
pStmt->sql.siInfo.tableColsReady = false;
|
// pStmt->sql.siInfo.tableColsReady = false;
|
||||||
|
|
||||||
SStmtQNode* param = NULL;
|
// SStmtQNode* param = NULL;
|
||||||
STMT_ERR_RET(stmtAllocQNodeFromBuf(&pStmt->sql.siInfo.tbBuf, (void**)¶m));
|
// STMT_ERR_RET(stmtAllocQNodeFromBuf(&pStmt->sql.siInfo.tbBuf, (void**)¶m));
|
||||||
param->restoreTbCols = true;
|
// param->restoreTbCols = true;
|
||||||
param->next = NULL;
|
// param->next = NULL;
|
||||||
|
|
||||||
stmtEnqueue(pStmt, param);
|
// stmtEnqueue(pStmt, param);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
// return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
STMT_ERR_RET(stmtCacheBlock(pStmt));
|
STMT_ERR_RET(stmtCacheBlock(pStmt));
|
||||||
|
@ -1366,7 +1367,7 @@ int stmtBindBatch2(TAOS_STMT2* stmt, TAOS_STMT2_BIND* bind, int32_t colIdx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pStmt->sql.stbInterlaceMode && NULL == pStmt->sql.siInfo.pDataCtx) {
|
if (pStmt->sql.stbInterlaceMode && NULL == pStmt->sql.siInfo.pDataCtx) {
|
||||||
STMT_ERR_RET(stmtInitStbInterlaceTableInfo(pStmt));
|
// STMT_ERR_RET(stmtInitStbInterlaceTableInfo(pStmt));
|
||||||
}
|
}
|
||||||
|
|
||||||
STableDataCxt** pDataBlock = NULL;
|
STableDataCxt** pDataBlock = NULL;
|
||||||
|
@ -1450,7 +1451,8 @@ int stmtBindBatch2(TAOS_STMT2* stmt, TAOS_STMT2_BIND* bind, int32_t colIdx) {
|
||||||
pStmt->stat.bindDataUs3 += startUs4 - startUs3;
|
pStmt->stat.bindDataUs3 += startUs4 - startUs3;
|
||||||
|
|
||||||
if (pStmt->sql.stbInterlaceMode) {
|
if (pStmt->sql.stbInterlaceMode) {
|
||||||
STMT_ERR_RET(stmtAppendTablePostHandle(pStmt, param));
|
// to do
|
||||||
|
// STMT_ERR_RET(stmtAppendTablePostHandle(pStmt, param));
|
||||||
} else {
|
} else {
|
||||||
STMT_ERR_RET(stmtAddBatch2(pStmt));
|
STMT_ERR_RET(stmtAddBatch2(pStmt));
|
||||||
}
|
}
|
||||||
|
@ -1876,11 +1878,11 @@ int stmtGetParamNum2(TAOS_STMT2* stmt, int* nums) {
|
||||||
STMT_ERR_RET(stmtParseSql(pStmt));
|
STMT_ERR_RET(stmtParseSql(pStmt));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (STMT_TYPE_QUERY == pStmt->sql.type) {
|
// if (STMT_TYPE_QUERY == pStmt->sql.type) {
|
||||||
*nums = taosArrayGetSize(pStmt->sql.pQuery->pPlaceholderValues);
|
*nums = taosArrayGetSize(pStmt->sql.pQuery->pPlaceholderValues);
|
||||||
} else {
|
// } else {
|
||||||
STMT_ERR_RET(stmtFetchColFields2(stmt, nums, NULL));
|
// // STMT_ERR_RET(stmtFetchColFields2(stmt, nums, NULL));
|
||||||
}
|
// }
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -880,75 +880,44 @@ TEST(stmt2Case, stmt2_query) {
|
||||||
taos_close(taos);
|
taos_close(taos);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(stmt2Case, stmt2_interlace) {
|
TEST(stmt2Case, stmt2_ntb_insert) {
|
||||||
TAOS* taos = taos_connect("localhost", "root", "taosdata", "", 0);
|
TAOS* taos = taos_connect("localhost", "root", "taosdata", "", 0);
|
||||||
ASSERT_NE(taos, nullptr);
|
ASSERT_NE(taos, nullptr);
|
||||||
TAOS_STMT2_OPTION option = {0, true, true, NULL, NULL};
|
TAOS_STMT2_OPTION option = {0, true, true, NULL, NULL};
|
||||||
do_query(taos, "drop database if exists db1");
|
do_query(taos, "drop database if exists db");
|
||||||
do_query(taos, "create database db1");
|
do_query(taos, "create database db");
|
||||||
do_query(taos, "create table db1.ntb(ts timestamp, b binary(10))");
|
do_query(taos, "create table db.ntb(ts timestamp, b binary(10))");
|
||||||
do_query(taos, "use db1");
|
do_query(taos, "use db");
|
||||||
TAOS_STMT2* stmt = taos_stmt2_init(taos, &option);
|
TAOS_STMT2* stmt = taos_stmt2_init(taos, &option);
|
||||||
ASSERT_NE(stmt, nullptr);
|
ASSERT_NE(stmt, nullptr);
|
||||||
|
|
||||||
const char* sql = "insert into db1.ntb values(?,?)";
|
const char* sql = "insert into db.ntb values(?,?)";
|
||||||
int code = taos_stmt2_prepare(stmt, sql, 0);
|
int code = taos_stmt2_prepare(stmt, sql, 0);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
ASSERT_EQ(terrno, 0);
|
ASSERT_EQ(terrno, 0);
|
||||||
|
|
||||||
|
|
||||||
for (int r = 0; r < 3; r++) {
|
|
||||||
// col params
|
|
||||||
int64_t** ts = (int64_t**)taosMemoryMalloc(3 * sizeof(int64_t*));
|
|
||||||
char** b = (char**)taosMemoryMalloc(3 * sizeof(char*));
|
|
||||||
int* ts_len = (int*)taosMemoryMalloc(3 * sizeof(int));
|
|
||||||
int* b_len = (int*)taosMemoryMalloc(3 * sizeof(int));
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
ts_len[i] = sizeof(int64_t);
|
int64_t ts[3] = {1591060628000 + i * 3, 1591060628001 + i * 3, 1591060628002 + i * 3};
|
||||||
b_len[i] = 1;
|
int t64_len[3] = {sizeof(int64_t), sizeof(int64_t), sizeof(int64_t)};
|
||||||
}
|
int b_len[3] = {5,5,5};
|
||||||
for (int i = 0; i < 3; i++) {
|
|
||||||
ts[i] = (int64_t*)taosMemoryMalloc(3 * sizeof(int64_t));
|
|
||||||
b[i] = (char*)taosMemoryMalloc(3 * sizeof(char));
|
|
||||||
for (int j = 0; j < 3; j++) {
|
|
||||||
ts[i][j] = 1591060628000 + r * 100000 + j;
|
|
||||||
b[i][j] = 'a' + j;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// bind params
|
TAOS_STMT2_BIND params1 = {TSDB_DATA_TYPE_TIMESTAMP, &ts[0], &t64_len[0], NULL, 3};
|
||||||
TAOS_STMT2_BIND** paramv = (TAOS_STMT2_BIND**)taosMemoryMalloc(3 * sizeof(TAOS_STMT2_BIND*));
|
TAOS_STMT2_BIND params2 = {TSDB_DATA_TYPE_BINARY, (void*)"abcdefghijklmnopqrstuvwxyz", &b_len[0], NULL, 3};
|
||||||
|
TAOS_STMT2_BIND* paramv1 = ¶ms1;
|
||||||
|
TAOS_STMT2_BIND* paramv2 = ¶ms2;
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
TAOS_STMT2_BINDV bindv1 = {1, NULL, NULL, ¶mv1};
|
||||||
// create col params
|
TAOS_STMT2_BINDV bindv2 = {1, NULL, NULL, ¶mv2};
|
||||||
paramv[i] = (TAOS_STMT2_BIND*)taosMemoryMalloc(2 * sizeof(TAOS_STMT2_BIND));
|
|
||||||
paramv[i][0] = {TSDB_DATA_TYPE_TIMESTAMP, &ts[i][0], &ts_len[0], NULL, 3};
|
taos_stmt2_bind_param(stmt, &bindv1, 0);
|
||||||
paramv[i][1] = {TSDB_DATA_TYPE_BINARY, &b[i][0], &b_len[0], NULL, 3};
|
taos_stmt2_bind_param(stmt, &bindv2, 1);
|
||||||
}
|
|
||||||
// bind
|
|
||||||
TAOS_STMT2_BINDV bindv = {1, NULL, NULL, paramv};
|
|
||||||
code = taos_stmt2_bind_param(stmt, &bindv, -1);
|
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
ASSERT_EQ(errno, 0);
|
ASSERT_EQ(errno, 0);
|
||||||
|
|
||||||
// exec
|
|
||||||
code = taos_stmt2_exec(stmt, NULL);
|
code = taos_stmt2_exec(stmt, NULL);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
ASSERT_EQ(errno, 0);
|
ASSERT_EQ(errno, 0);
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
|
||||||
taosMemoryFree(paramv[i]);
|
|
||||||
taosMemoryFree(ts[i]);
|
|
||||||
taosMemoryFree(b[i]);
|
|
||||||
}
|
}
|
||||||
taosMemoryFree(ts);
|
checkRows(taos, "select * from db.ntb", 9);
|
||||||
taosMemoryFree(b);
|
|
||||||
taosMemoryFree(ts_len);
|
|
||||||
taosMemoryFree(b_len);
|
|
||||||
taosMemoryFree(paramv);
|
|
||||||
}
|
|
||||||
|
|
||||||
checkRows(taos, "select * from db1.ntb", 9);
|
|
||||||
|
|
||||||
taos_stmt2_close(stmt);
|
taos_stmt2_close(stmt);
|
||||||
taos_close(taos);
|
taos_close(taos);
|
||||||
|
|
Loading…
Reference in New Issue