reform stmt2 interlace
This commit is contained in:
parent
2ca9035b6f
commit
7c400e85ac
|
@ -156,8 +156,8 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const ch
|
|||
TAOS_MULTI_BIND* bind, char* msgBuf, int32_t msgBufLen, void* charsetCxt);
|
||||
|
||||
int32_t qStmtBindParams2(SQuery* pQuery, TAOS_STMT2_BIND* pParams, int32_t colIdx, void* charsetCxt);
|
||||
int32_t qBindStmtStbColsValue2(void* pBlock, SArray* pCols, TAOS_STMT2_BIND* bind, char* msgBuf, int32_t msgBufLen,
|
||||
STSchema** pTSchema, SBindInfo2* pBindInfos, void *charsetCxt);
|
||||
// int32_t qBindStmtStbColsValue2(void* pBlock, SArray* pCols, TAOS_STMT2_BIND* bind, char* msgBuf, int32_t msgBufLen,
|
||||
// STSchema** pTSchema, SBindInfo2* pBindInfos, void *charsetCxt);
|
||||
int32_t qBindStmtColsValue2(void* pBlock, SArray* pCols, TAOS_STMT2_BIND* bind, char* msgBuf, int32_t msgBufLen, void *charsetCxt);
|
||||
int32_t qBindStmtSingleColValue2(void* pBlock, SArray* pCols, TAOS_STMT2_BIND* bind, char* msgBuf, int32_t msgBufLen,
|
||||
int32_t colIdx, int32_t rowNum, void *charsetCxt);
|
||||
|
|
|
@ -284,16 +284,17 @@ static int32_t stmtParseSql(STscStmt2* pStmt) {
|
|||
|
||||
STableDataCxt* pTableCtx = *pSrc;
|
||||
if (pStmt->sql.stbInterlaceMode) {
|
||||
int16_t lastIdx = -1;
|
||||
return TSDB_CODE_TSC_STMT_API_ERROR;
|
||||
// int16_t lastIdx = -1;
|
||||
|
||||
for (int32_t i = 0; i < pTableCtx->boundColsInfo.numOfBound; ++i) {
|
||||
if (pTableCtx->boundColsInfo.pColIndex[i] < lastIdx) {
|
||||
pStmt->sql.stbInterlaceMode = false;
|
||||
break;
|
||||
}
|
||||
// for (int32_t i = 0; i < pTableCtx->boundColsInfo.numOfBound; ++i) {
|
||||
// if (pTableCtx->boundColsInfo.pColIndex[i] < lastIdx) {
|
||||
// pStmt->sql.stbInterlaceMode = false;
|
||||
// break;
|
||||
// }
|
||||
|
||||
lastIdx = pTableCtx->boundColsInfo.pColIndex[i];
|
||||
}
|
||||
// lastIdx = pTableCtx->boundColsInfo.pColIndex[i];
|
||||
// }
|
||||
}
|
||||
|
||||
if (NULL == pStmt->sql.pBindInfo) {
|
||||
|
@ -497,9 +498,10 @@ static int32_t stmtRebuildDataBlock(STscStmt2* pStmt, STableDataCxt* pDataBlock,
|
|||
|
||||
static int32_t stmtGetFromCache(STscStmt2* pStmt) {
|
||||
if (pStmt->sql.stbInterlaceMode && pStmt->sql.siInfo.pDataCtx) {
|
||||
pStmt->bInfo.needParse = false;
|
||||
pStmt->bInfo.inExecCache = false;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return TSDB_CODE_TSC_STMT_API_ERROR;
|
||||
// pStmt->bInfo.needParse = false;
|
||||
// pStmt->bInfo.inExecCache = false;
|
||||
// return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
pStmt->bInfo.needParse = true;
|
||||
|
@ -979,6 +981,7 @@ int stmtSetTbName2(TAOS_STMT2* stmt, const char* tbName) {
|
|||
}
|
||||
|
||||
if (pStmt->sql.stbInterlaceMode && NULL == pStmt->sql.siInfo.pDataCtx) {
|
||||
return TSDB_CODE_TSC_STMT_API_ERROR;
|
||||
// STMT_ERR_RET(stmtInitStbInterlaceTableInfo(pStmt));
|
||||
}
|
||||
|
||||
|
@ -1009,6 +1012,7 @@ int stmtSetTbTags2(TAOS_STMT2* stmt, TAOS_STMT2_BIND* tags) {
|
|||
STMT_ERR_RET(stmtParseSql(pStmt));
|
||||
}
|
||||
if (pStmt->sql.stbInterlaceMode && NULL == pStmt->sql.siInfo.pDataCtx) {
|
||||
return TSDB_CODE_TSC_STMT_API_ERROR;
|
||||
// STMT_ERR_RET(stmtInitStbInterlaceTableInfo(pStmt));
|
||||
}
|
||||
|
||||
|
@ -1078,7 +1082,8 @@ static int stmtFetchStbColFields2(STscStmt2* pStmt, int32_t* fieldNum, TAOS_FIEL
|
|||
STableDataCxt** pDataBlock = NULL;
|
||||
|
||||
if (pStmt->sql.stbInterlaceMode) {
|
||||
pDataBlock = &pStmt->sql.siInfo.pDataCtx;
|
||||
return TSDB_CODE_TSC_STMT_API_ERROR;
|
||||
// pDataBlock = &pStmt->sql.siInfo.pDataCtx;
|
||||
} else {
|
||||
pDataBlock =
|
||||
(STableDataCxt**)taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
|
||||
|
@ -1158,28 +1163,28 @@ SArray* stmtGetFreeCol(STscStmt2* pStmt, int32_t* idx) {
|
|||
// return TSDB_CODE_SUCCESS;
|
||||
// }
|
||||
|
||||
static FORCE_INLINE int32_t stmtGetTableColsFromCache(STscStmt2* pStmt, SArray** pTableCols) {
|
||||
while (true) {
|
||||
if (pStmt->sql.siInfo.pTableColsIdx < taosArrayGetSize(pStmt->sql.siInfo.pTableCols)) {
|
||||
*pTableCols = (SArray*)taosArrayGetP(pStmt->sql.siInfo.pTableCols, pStmt->sql.siInfo.pTableColsIdx++);
|
||||
break;
|
||||
} else {
|
||||
SArray* pTblCols = NULL;
|
||||
for (int32_t i = 0; i < 100; i++) {
|
||||
pTblCols = taosArrayInit(20, POINTER_BYTES);
|
||||
if (NULL == pTblCols) {
|
||||
return terrno;
|
||||
}
|
||||
// static FORCE_INLINE int32_t stmtGetTableColsFromCache(STscStmt2* pStmt, SArray** pTableCols) {
|
||||
// while (true) {
|
||||
// if (pStmt->sql.siInfo.pTableColsIdx < taosArrayGetSize(pStmt->sql.siInfo.pTableCols)) {
|
||||
// *pTableCols = (SArray*)taosArrayGetP(pStmt->sql.siInfo.pTableCols, pStmt->sql.siInfo.pTableColsIdx++);
|
||||
// break;
|
||||
// } else {
|
||||
// SArray* pTblCols = NULL;
|
||||
// for (int32_t i = 0; i < 100; i++) {
|
||||
// pTblCols = taosArrayInit(20, POINTER_BYTES);
|
||||
// if (NULL == pTblCols) {
|
||||
// return terrno;
|
||||
// }
|
||||
|
||||
if (taosArrayPush(pStmt->sql.siInfo.pTableCols, &pTblCols) == NULL) {
|
||||
return terrno;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (taosArrayPush(pStmt->sql.siInfo.pTableCols, &pTblCols) == NULL) {
|
||||
// return terrno;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
// return TSDB_CODE_SUCCESS;
|
||||
// }
|
||||
|
||||
static int32_t stmtCacheBlock(STscStmt2* pStmt) {
|
||||
if (pStmt->sql.type != STMT_TYPE_MULTI_INSERT) {
|
||||
|
@ -1233,6 +1238,7 @@ static int stmtAddBatch2(TAOS_STMT2* stmt) {
|
|||
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_ADD_BATCH));
|
||||
|
||||
if (pStmt->sql.stbInterlaceMode) {
|
||||
return TSDB_CODE_TSC_STMT_API_ERROR;
|
||||
// todo:add stb interlace mode
|
||||
// int64_t startUs2 = taosGetTimestampUs();
|
||||
// pStmt->stat.addBatchUs += startUs2 - startUs;
|
||||
|
@ -1367,6 +1373,7 @@ int stmtBindBatch2(TAOS_STMT2* stmt, TAOS_STMT2_BIND* bind, int32_t colIdx) {
|
|||
}
|
||||
|
||||
if (pStmt->sql.stbInterlaceMode && NULL == pStmt->sql.siInfo.pDataCtx) {
|
||||
return TSDB_CODE_TSC_STMT_API_ERROR;
|
||||
// STMT_ERR_RET(stmtInitStbInterlaceTableInfo(pStmt));
|
||||
}
|
||||
|
||||
|
@ -1393,14 +1400,15 @@ int stmtBindBatch2(TAOS_STMT2* stmt, TAOS_STMT2_BIND* bind, int32_t colIdx) {
|
|||
|
||||
SStmtQNode* param = NULL;
|
||||
if (pStmt->sql.stbInterlaceMode) {
|
||||
STMT_ERR_RET(stmtAllocQNodeFromBuf(&pStmt->sql.siInfo.tbBuf, (void**)¶m));
|
||||
STMT_ERR_RET(stmtGetTableColsFromCache(pStmt, ¶m->tblData.aCol));
|
||||
taosArrayClear(param->tblData.aCol);
|
||||
return TSDB_CODE_TSC_STMT_API_ERROR;
|
||||
// STMT_ERR_RET(stmtAllocQNodeFromBuf(&pStmt->sql.siInfo.tbBuf, (void**)¶m));
|
||||
// STMT_ERR_RET(stmtGetTableColsFromCache(pStmt, ¶m->tblData.aCol));
|
||||
// taosArrayClear(param->tblData.aCol);
|
||||
|
||||
// param->tblData.aCol = taosArrayInit(20, POINTER_BYTES);
|
||||
// // param->tblData.aCol = taosArrayInit(20, POINTER_BYTES);
|
||||
|
||||
param->restoreTbCols = false;
|
||||
tstrncpy(param->tblData.tbName, pStmt->bInfo.tbName, TSDB_TABLE_NAME_LEN);
|
||||
// param->restoreTbCols = false;
|
||||
// tstrncpy(param->tblData.tbName, pStmt->bInfo.tbName, TSDB_TABLE_NAME_LEN);
|
||||
}
|
||||
|
||||
int64_t startUs3 = taosGetTimestampUs();
|
||||
|
@ -1410,12 +1418,15 @@ int stmtBindBatch2(TAOS_STMT2* stmt, TAOS_STMT2_BIND* bind, int32_t colIdx) {
|
|||
|
||||
if (colIdx < 0) {
|
||||
if (pStmt->sql.stbInterlaceMode) {
|
||||
(*pDataBlock)->pData->flags = 0;
|
||||
code = qBindStmtStbColsValue2(*pDataBlock, pCols, bind, pStmt->exec.pRequest->msgBuf,
|
||||
pStmt->exec.pRequest->msgBufLen, &pStmt->sql.siInfo.pTSchema, pStmt->sql.pBindInfo, pStmt->taos->optionInfo.charsetCxt);
|
||||
return TSDB_CODE_TSC_STMT_API_ERROR;
|
||||
// todo
|
||||
// (*pDataBlock)->pData->flags = 0;
|
||||
// code = qBindStmtStbColsValue2(*pDataBlock, pCols, bind, pStmt->exec.pRequest->msgBuf,
|
||||
// pStmt->exec.pRequest->msgBufLen, &pStmt->sql.siInfo.pTSchema,
|
||||
// pStmt->sql.pBindInfo, pStmt->taos->optionInfo.charsetCxt);
|
||||
} else {
|
||||
code =
|
||||
qBindStmtColsValue2(*pDataBlock, pCols, bind, pStmt->exec.pRequest->msgBuf, pStmt->exec.pRequest->msgBufLen, pStmt->taos->optionInfo.charsetCxt);
|
||||
code = qBindStmtColsValue2(*pDataBlock, pCols, bind, pStmt->exec.pRequest->msgBuf,
|
||||
pStmt->exec.pRequest->msgBufLen, pStmt->taos->optionInfo.charsetCxt);
|
||||
}
|
||||
|
||||
if (code) {
|
||||
|
@ -1424,8 +1435,9 @@ int stmtBindBatch2(TAOS_STMT2* stmt, TAOS_STMT2_BIND* bind, int32_t colIdx) {
|
|||
}
|
||||
} else {
|
||||
if (pStmt->sql.stbInterlaceMode) {
|
||||
tscError("bind single column not allowed in stb insert mode");
|
||||
STMT_ERR_RET(TSDB_CODE_TSC_STMT_API_ERROR);
|
||||
return TSDB_CODE_TSC_STMT_API_ERROR;
|
||||
// tscError("bind single column not allowed in stb insert mode");
|
||||
// STMT_ERR_RET(TSDB_CODE_TSC_STMT_API_ERROR);
|
||||
}
|
||||
|
||||
if (colIdx != (pStmt->bInfo.sBindLastIdx + 1) && colIdx != 0) {
|
||||
|
@ -1440,7 +1452,8 @@ int stmtBindBatch2(TAOS_STMT2* stmt, TAOS_STMT2_BIND* bind, int32_t colIdx) {
|
|||
}
|
||||
|
||||
code = qBindStmtSingleColValue2(*pDataBlock, pCols, bind, pStmt->exec.pRequest->msgBuf,
|
||||
pStmt->exec.pRequest->msgBufLen, colIdx, pStmt->bInfo.sBindRowNum, pStmt->taos->optionInfo.charsetCxt);
|
||||
pStmt->exec.pRequest->msgBufLen, colIdx, pStmt->bInfo.sBindRowNum,
|
||||
pStmt->taos->optionInfo.charsetCxt);
|
||||
if (code) {
|
||||
tscError("qBindStmtSingleColValue failed, error:%s", tstrerror(code));
|
||||
STMT_ERR_RET(code);
|
||||
|
@ -1451,6 +1464,7 @@ int stmtBindBatch2(TAOS_STMT2* stmt, TAOS_STMT2_BIND* bind, int32_t colIdx) {
|
|||
pStmt->stat.bindDataUs3 += startUs4 - startUs3;
|
||||
|
||||
if (pStmt->sql.stbInterlaceMode) {
|
||||
return TSDB_CODE_TSC_STMT_API_ERROR;
|
||||
// to do
|
||||
// STMT_ERR_RET(stmtAppendTablePostHandle(pStmt, param));
|
||||
} else {
|
||||
|
@ -1660,23 +1674,26 @@ int stmtExec2(TAOS_STMT2* stmt, int* affected_rows) {
|
|||
}
|
||||
|
||||
if (pStmt->sql.stbInterlaceMode) {
|
||||
STMT_ERR_RET(stmtAddBatch2(pStmt));
|
||||
return TSDB_CODE_TSC_STMT_API_ERROR;
|
||||
// STMT_ERR_RET(stmtAddBatch2(pStmt));
|
||||
}
|
||||
|
||||
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_EXECUTE));
|
||||
|
||||
if (STMT_TYPE_QUERY != pStmt->sql.type) {
|
||||
if (pStmt->sql.stbInterlaceMode) {
|
||||
int64_t startTs = taosGetTimestampUs();
|
||||
while (atomic_load_64(&pStmt->sql.siInfo.tbRemainNum)) {
|
||||
taosUsleep(1);
|
||||
}
|
||||
pStmt->stat.execWaitUs += taosGetTimestampUs() - startTs;
|
||||
return TSDB_CODE_TSC_STMT_API_ERROR;
|
||||
// todo:stb interlace mode
|
||||
// int64_t startTs = taosGetTimestampUs();
|
||||
// while (atomic_load_64(&pStmt->sql.siInfo.tbRemainNum)) {
|
||||
// taosUsleep(1);
|
||||
// }
|
||||
// pStmt->stat.execWaitUs += taosGetTimestampUs() - startTs;
|
||||
|
||||
STMT_ERR_RET(qBuildStmtFinOutput(pStmt->sql.pQuery, pStmt->sql.pVgHash, pStmt->sql.siInfo.pVgroupList));
|
||||
taosHashCleanup(pStmt->sql.siInfo.pVgroupHash);
|
||||
pStmt->sql.siInfo.pVgroupHash = NULL;
|
||||
pStmt->sql.siInfo.pVgroupList = NULL;
|
||||
// STMT_ERR_RET(qBuildStmtFinOutput(pStmt->sql.pQuery, pStmt->sql.pVgHash, pStmt->sql.siInfo.pVgroupList));
|
||||
// taosHashCleanup(pStmt->sql.siInfo.pVgroupHash);
|
||||
// pStmt->sql.siInfo.pVgroupHash = NULL;
|
||||
// pStmt->sql.siInfo.pVgroupList = NULL;
|
||||
} else {
|
||||
tDestroySubmitTbData(pStmt->exec.pCurrTbData, TSDB_MSG_FLG_ENCODE);
|
||||
taosMemoryFreeClear(pStmt->exec.pCurrTbData);
|
||||
|
|
|
@ -815,7 +815,7 @@ TEST(stmt2Case, stmt2_init_prepare_Test) {
|
|||
taos_close(taos);
|
||||
}
|
||||
|
||||
TEST(stmt2Case, stmt2_insert) {
|
||||
TEST(stmt2Case, stmt2_stb_insert) {
|
||||
TAOS* taos = taos_connect("localhost", "root", "taosdata", "", 0);
|
||||
ASSERT_NE(taos, nullptr);
|
||||
TAOS_STMT2_OPTION option = {0, true, true, NULL, NULL};
|
||||
|
@ -830,6 +830,58 @@ TEST(stmt2Case, stmt2_insert) {
|
|||
taos_close(taos);
|
||||
}
|
||||
|
||||
// TEST(stmt2Case, stmt2_insert_all_types) {
|
||||
// TAOS* taos = taos_connect("localhost", "root", "taosdata", "", 0);
|
||||
// ASSERT_NE(taos, nullptr);
|
||||
// do_query(taos, "drop database if exists example_all_type_stmt1");
|
||||
// do_query(taos, "create database example_all_type_stmt1");
|
||||
// do_query(taos,
|
||||
// "create table example_all_type_stmt1.stb (ts timestamp, int_col int,long_col bigint,double_col "
|
||||
// "double,bool_col bool,binary_col binary(20),nchar_col nchar(20),varbinary_col varbinary(20),geometry_col "
|
||||
// "geometry(200)) tags(int_tag int,long_tag bigint,double_tag double,bool_tag bool,binary_tag "
|
||||
// "binary(20),nchar_tag nchar(20),varbinary_tag varbinary(20),geometry_tag geometry(200));");
|
||||
|
||||
// TAOS_STMT2_OPTION option = {0, false, false, NULL, NULL};
|
||||
|
||||
// TAOS_STMT2* stmt = taos_stmt2_init(taos, &option);
|
||||
// ASSERT_NE(stmt, nullptr);
|
||||
|
||||
// const char* sql =
|
||||
// "INSERT INTO `example_all_type_stmt1`.`stb1` "
|
||||
// "(ts,int_col,long_col,double_col,bool_col,binary_col,nchar_col,varbinary_col,geometry_col,int_tag,long_tag,"
|
||||
// "double_tag,bool_tag,binary_tag,nchar_tag,varbinary_tag ,geometry_tag,tbname) VALUES "
|
||||
// "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
// int code = taos_stmt2_prepare(stmt, sql, 0);
|
||||
// ASSERT_EQ(code, 0);
|
||||
|
||||
// int t64_len[1] = {sizeof(int64_t)};
|
||||
// int b_len[1] = {3};
|
||||
// int64_t ts = 1591060628000;
|
||||
// TAOS_STMT2_BIND params[18] = {{TSDB_DATA_TYPE_TIMESTAMP, &ts, t64_len, NULL, 1}};
|
||||
// TAOS_STMT2_BIND* paramv = ¶ms[0];
|
||||
// char* tbname = "tb1";
|
||||
// TAOS_STMT2_BINDV bindv = {1, &tbname, NULL, ¶mv};
|
||||
// code = taos_stmt2_bind_param(stmt, &bindv, -1);
|
||||
// ASSERT_EQ(code, 0);
|
||||
|
||||
// taos_stmt2_exec(stmt, NULL);
|
||||
// ASSERT_EQ(code, 0);
|
||||
|
||||
// TAOS_RES* pRes = taos_stmt2_result(stmt);
|
||||
// ASSERT_NE(pRes, nullptr);
|
||||
|
||||
// int getRecordCounts = 0;
|
||||
// TAOS_ROW row;
|
||||
// while ((row = taos_fetch_row(pRes))) {
|
||||
// getRecordCounts++;
|
||||
// }
|
||||
// ASSERT_EQ(getRecordCounts, 1);
|
||||
// taos_free_result(pRes);
|
||||
|
||||
// taos_stmt2_close(stmt);
|
||||
// taos_close(taos);
|
||||
// }
|
||||
|
||||
TEST(stmt2Case, stmt2_query) {
|
||||
TAOS* taos = taos_connect("localhost", "root", "taosdata", "", 0);
|
||||
ASSERT_NE(taos, nullptr);
|
||||
|
@ -875,7 +927,7 @@ TEST(stmt2Case, stmt2_query) {
|
|||
getRecordCounts++;
|
||||
}
|
||||
ASSERT_EQ(getRecordCounts, 1);
|
||||
taos_free_result(pRes);
|
||||
// taos_free_result(pRes);
|
||||
|
||||
taos_stmt2_close(stmt);
|
||||
taos_close(taos);
|
||||
|
|
|
@ -636,134 +636,134 @@ end:
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t convertStmtStbNcharCol2(SMsgBuf* pMsgBuf, SSchema* pSchema, TAOS_STMT2_BIND* src, TAOS_STMT2_BIND* dst, void *charsetCxt) {
|
||||
int32_t output = 0;
|
||||
const int32_t max_buf_len = pSchema->bytes - VARSTR_HEADER_SIZE;
|
||||
// static int32_t convertStmtStbNcharCol2(SMsgBuf* pMsgBuf, SSchema* pSchema, TAOS_STMT2_BIND* src, TAOS_STMT2_BIND* dst, void *charsetCxt) {
|
||||
// int32_t output = 0;
|
||||
// const int32_t max_buf_len = pSchema->bytes - VARSTR_HEADER_SIZE;
|
||||
|
||||
dst->buffer = taosMemoryCalloc(src->num, max_buf_len);
|
||||
if (NULL == dst->buffer) {
|
||||
return terrno;
|
||||
}
|
||||
// dst->buffer = taosMemoryCalloc(src->num, max_buf_len);
|
||||
// if (NULL == dst->buffer) {
|
||||
// return terrno;
|
||||
// }
|
||||
|
||||
dst->length = taosMemoryCalloc(src->num, sizeof(int32_t));
|
||||
if (NULL == dst->length) {
|
||||
taosMemoryFreeClear(dst->buffer);
|
||||
return terrno;
|
||||
}
|
||||
// dst->length = taosMemoryCalloc(src->num, sizeof(int32_t));
|
||||
// if (NULL == dst->length) {
|
||||
// taosMemoryFreeClear(dst->buffer);
|
||||
// return terrno;
|
||||
// }
|
||||
|
||||
char* src_buf = src->buffer;
|
||||
char* dst_buf = dst->buffer;
|
||||
for (int32_t i = 0; i < src->num; ++i) {
|
||||
if (src->is_null && src->is_null[i]) {
|
||||
continue;
|
||||
}
|
||||
// char* src_buf = src->buffer;
|
||||
// char* dst_buf = dst->buffer;
|
||||
// for (int32_t i = 0; i < src->num; ++i) {
|
||||
// if (src->is_null && src->is_null[i]) {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
if (!taosMbsToUcs4(src_buf, src->length[i], (TdUcs4*)dst_buf, max_buf_len, &output, charsetCxt)) {
|
||||
if (terrno == TAOS_SYSTEM_ERROR(E2BIG)) {
|
||||
return generateSyntaxErrMsg(pMsgBuf, TSDB_CODE_PAR_VALUE_TOO_LONG, pSchema->name);
|
||||
}
|
||||
char buf[512] = {0};
|
||||
snprintf(buf, tListLen(buf), "%s", strerror(terrno));
|
||||
return buildSyntaxErrMsg(pMsgBuf, buf, NULL);
|
||||
}
|
||||
// if (!taosMbsToUcs4(src_buf, src->length[i], (TdUcs4*)dst_buf, max_buf_len, &output, charsetCxt)) {
|
||||
// if (terrno == TAOS_SYSTEM_ERROR(E2BIG)) {
|
||||
// return generateSyntaxErrMsg(pMsgBuf, TSDB_CODE_PAR_VALUE_TOO_LONG, pSchema->name);
|
||||
// }
|
||||
// char buf[512] = {0};
|
||||
// snprintf(buf, tListLen(buf), "%s", strerror(terrno));
|
||||
// return buildSyntaxErrMsg(pMsgBuf, buf, NULL);
|
||||
// }
|
||||
|
||||
dst->length[i] = output;
|
||||
src_buf += src->length[i];
|
||||
dst_buf += output;
|
||||
}
|
||||
// dst->length[i] = output;
|
||||
// src_buf += src->length[i];
|
||||
// dst_buf += output;
|
||||
// }
|
||||
|
||||
dst->buffer_type = src->buffer_type;
|
||||
dst->is_null = src->is_null;
|
||||
dst->num = src->num;
|
||||
// dst->buffer_type = src->buffer_type;
|
||||
// dst->is_null = src->is_null;
|
||||
// dst->num = src->num;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
// return TSDB_CODE_SUCCESS;
|
||||
// }
|
||||
|
||||
int32_t qBindStmtStbColsValue2(void* pBlock, SArray* pCols, TAOS_STMT2_BIND* bind, char* msgBuf, int32_t msgBufLen,
|
||||
STSchema** pTSchema, SBindInfo2* pBindInfos, void *charsetCxt) {
|
||||
STableDataCxt* pDataBlock = (STableDataCxt*)pBlock;
|
||||
SSchema* pSchema = getTableColumnSchema(pDataBlock->pMeta);
|
||||
SBoundColInfo* boundInfo = &pDataBlock->boundColsInfo;
|
||||
SMsgBuf pBuf = {.buf = msgBuf, .len = msgBufLen};
|
||||
int32_t rowNum = bind->num;
|
||||
SArray* ncharBinds = NULL;
|
||||
TAOS_STMT2_BIND ncharBind = {0};
|
||||
int32_t code = 0;
|
||||
int16_t lastColId = -1;
|
||||
bool colInOrder = true;
|
||||
int ncharColNums = 0;
|
||||
// int32_t qBindStmtStbColsValue2(void* pBlock, SArray* pCols, TAOS_STMT2_BIND* bind, char* msgBuf, int32_t msgBufLen,
|
||||
// STSchema** pTSchema, SBindInfo2* pBindInfos, void *charsetCxt) {
|
||||
// STableDataCxt* pDataBlock = (STableDataCxt*)pBlock;
|
||||
// SSchema* pSchema = getTableColumnSchema(pDataBlock->pMeta);
|
||||
// SBoundColInfo* boundInfo = &pDataBlock->boundColsInfo;
|
||||
// SMsgBuf pBuf = {.buf = msgBuf, .len = msgBufLen};
|
||||
// int32_t rowNum = bind->num;
|
||||
// SArray* ncharBinds = NULL;
|
||||
// TAOS_STMT2_BIND ncharBind = {0};
|
||||
// int32_t code = 0;
|
||||
// int16_t lastColId = -1;
|
||||
// bool colInOrder = true;
|
||||
// int ncharColNums = 0;
|
||||
|
||||
if (NULL == *pTSchema) {
|
||||
*pTSchema = tBuildTSchema(pSchema, pDataBlock->pMeta->tableInfo.numOfColumns, pDataBlock->pMeta->sversion);
|
||||
}
|
||||
// if (NULL == *pTSchema) {
|
||||
// *pTSchema = tBuildTSchema(pSchema, pDataBlock->pMeta->tableInfo.numOfColumns, pDataBlock->pMeta->sversion);
|
||||
// }
|
||||
|
||||
for (int c = 0; c < boundInfo->numOfBound; ++c) {
|
||||
if (TSDB_DATA_TYPE_NCHAR == pSchema[boundInfo->pColIndex[c]].type) {
|
||||
ncharColNums++;
|
||||
}
|
||||
}
|
||||
if (ncharColNums > 0) {
|
||||
ncharBinds = taosArrayInit(ncharColNums, sizeof(ncharBind));
|
||||
if (!ncharBinds) {
|
||||
code = terrno;
|
||||
goto _return;
|
||||
}
|
||||
}
|
||||
// for (int c = 0; c < boundInfo->numOfBound; ++c) {
|
||||
// if (TSDB_DATA_TYPE_NCHAR == pSchema[boundInfo->pColIndex[c]].type) {
|
||||
// ncharColNums++;
|
||||
// }
|
||||
// }
|
||||
// if (ncharColNums > 0) {
|
||||
// ncharBinds = taosArrayInit(ncharColNums, sizeof(ncharBind));
|
||||
// if (!ncharBinds) {
|
||||
// code = terrno;
|
||||
// goto _return;
|
||||
// }
|
||||
// }
|
||||
|
||||
for (int c = 0; c < boundInfo->numOfBound; ++c) {
|
||||
SSchema* pColSchema = &pSchema[boundInfo->pColIndex[c]];
|
||||
if (pColSchema->colId <= lastColId) {
|
||||
colInOrder = false;
|
||||
} else {
|
||||
lastColId = pColSchema->colId;
|
||||
}
|
||||
// for (int c = 0; c < boundInfo->numOfBound; ++c) {
|
||||
// SSchema* pColSchema = &pSchema[boundInfo->pColIndex[c]];
|
||||
// if (pColSchema->colId <= lastColId) {
|
||||
// colInOrder = false;
|
||||
// } else {
|
||||
// lastColId = pColSchema->colId;
|
||||
// }
|
||||
|
||||
if (bind[c].num != rowNum) {
|
||||
code = buildInvalidOperationMsg(&pBuf, "row number in each bind param should be the same");
|
||||
goto _return;
|
||||
}
|
||||
// if (bind[c].num != rowNum) {
|
||||
// code = buildInvalidOperationMsg(&pBuf, "row number in each bind param should be the same");
|
||||
// goto _return;
|
||||
// }
|
||||
|
||||
if ((!(rowNum == 1 && bind[c].is_null && *bind[c].is_null)) &&
|
||||
bind[c].buffer_type != pColSchema->type) { // for rowNum ==1 , connector may not set buffer_type
|
||||
code = buildInvalidOperationMsg(&pBuf, "column type mis-match with buffer type");
|
||||
goto _return;
|
||||
}
|
||||
// if ((!(rowNum == 1 && bind[c].is_null && *bind[c].is_null)) &&
|
||||
// bind[c].buffer_type != pColSchema->type) { // for rowNum ==1 , connector may not set buffer_type
|
||||
// code = buildInvalidOperationMsg(&pBuf, "column type mis-match with buffer type");
|
||||
// goto _return;
|
||||
// }
|
||||
|
||||
if (TSDB_DATA_TYPE_NCHAR == pColSchema->type) {
|
||||
code = convertStmtStbNcharCol2(&pBuf, pColSchema, bind + c, &ncharBind, charsetCxt);
|
||||
if (code) {
|
||||
goto _return;
|
||||
}
|
||||
if (!taosArrayPush(ncharBinds, &ncharBind)) {
|
||||
code = terrno;
|
||||
goto _return;
|
||||
}
|
||||
pBindInfos[c].bind = taosArrayGetLast(ncharBinds);
|
||||
} else {
|
||||
pBindInfos[c].bind = bind + c;
|
||||
}
|
||||
// if (TSDB_DATA_TYPE_NCHAR == pColSchema->type) {
|
||||
// code = convertStmtStbNcharCol2(&pBuf, pColSchema, bind + c, &ncharBind, charsetCxt);
|
||||
// if (code) {
|
||||
// goto _return;
|
||||
// }
|
||||
// if (!taosArrayPush(ncharBinds, &ncharBind)) {
|
||||
// code = terrno;
|
||||
// goto _return;
|
||||
// }
|
||||
// pBindInfos[c].bind = taosArrayGetLast(ncharBinds);
|
||||
// } else {
|
||||
// pBindInfos[c].bind = bind + c;
|
||||
// }
|
||||
|
||||
pBindInfos[c].columnId = pColSchema->colId;
|
||||
pBindInfos[c].type = pColSchema->type;
|
||||
pBindInfos[c].bytes = pColSchema->bytes;
|
||||
}
|
||||
// pBindInfos[c].columnId = pColSchema->colId;
|
||||
// pBindInfos[c].type = pColSchema->type;
|
||||
// pBindInfos[c].bytes = pColSchema->bytes;
|
||||
// }
|
||||
|
||||
code = tRowBuildFromBind2(pBindInfos, boundInfo->numOfBound, colInOrder, *pTSchema, pCols, &pDataBlock->ordered, &pDataBlock->duplicateTs);
|
||||
// code = tRowBuildFromBind2(pBindInfos, boundInfo->numOfBound, colInOrder, *pTSchema, pCols, &pDataBlock->ordered, &pDataBlock->duplicateTs);
|
||||
|
||||
qDebug("stmt all %d columns bind %d rows data", boundInfo->numOfBound, rowNum);
|
||||
// qDebug("stmt all %d columns bind %d rows data", boundInfo->numOfBound, rowNum);
|
||||
|
||||
_return:
|
||||
if (ncharBinds) {
|
||||
for (int i = 0; i < TARRAY_SIZE(ncharBinds); ++i) {
|
||||
TAOS_STMT2_BIND* ncBind = TARRAY_DATA(ncharBinds);
|
||||
taosMemoryFree(ncBind[i].buffer);
|
||||
taosMemoryFree(ncBind[i].length);
|
||||
}
|
||||
taosArrayDestroy(ncharBinds);
|
||||
}
|
||||
// _return:
|
||||
// if (ncharBinds) {
|
||||
// for (int i = 0; i < TARRAY_SIZE(ncharBinds); ++i) {
|
||||
// TAOS_STMT2_BIND* ncBind = TARRAY_DATA(ncharBinds);
|
||||
// taosMemoryFree(ncBind[i].buffer);
|
||||
// taosMemoryFree(ncBind[i].length);
|
||||
// }
|
||||
// taosArrayDestroy(ncharBinds);
|
||||
// }
|
||||
|
||||
return code;
|
||||
}
|
||||
// return code;
|
||||
// }
|
||||
|
||||
static int32_t convertStmtNcharCol2(SMsgBuf* pMsgBuf, SSchema* pSchema, TAOS_STMT2_BIND* src, TAOS_STMT2_BIND* dst, void *charsetCxt) {
|
||||
int32_t output = 0;
|
||||
|
|
Loading…
Reference in New Issue