提交 58b6ed11 编写于 作者: S shenglian zhou

<fix> stmt affected rows: handle multi vnode subquery and insert batch clean...

<fix> stmt affected rows: handle multi vnode subquery and insert batch clean after execute and normal stmt execute
上级 fbb6fc9e
......@@ -78,6 +78,8 @@ typedef struct STscStmt {
SSqlObj* pSql;
SMultiTbStmt mtb;
SNormalStmt normal;
int numOfRows;
} STscStmt;
#define STMT_RET(c) do { \
......@@ -1212,6 +1214,8 @@ static int insertStmtExecute(STscStmt* stmt) {
// wait for the callback function to post the semaphore
tsem_wait(&pSql->rspSem);
stmt->numOfRows += pSql->res.numOfRows;
// data block reset
pCmd->batchSize = 0;
for(int32_t i = 0; i < pCmd->insertParam.numOfTables; ++i) {
......@@ -1285,6 +1289,8 @@ static int insertBatchStmtExecute(STscStmt* pStmt) {
code = pStmt->pSql->res.code;
pStmt->numOfRows += pStmt->pSql->res.numOfRows;
insertBatchClean(pStmt);
return code;
......@@ -1521,6 +1527,7 @@ TAOS_STMT* taos_stmt_init(TAOS* taos) {
pSql->maxRetry = TSDB_MAX_REPLICA;
pStmt->pSql = pSql;
pStmt->last = STMT_INIT;
pStmt->numOfRows = 0;
registerSqlObj(pSql);
return pStmt;
......@@ -1564,9 +1571,7 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) {
}
pRes->qId = 0;
pRes->numOfRows = 1;
registerSqlObj(pSql);
pRes->numOfRows = 0;
strtolower(pSql->sqlstr, sql);
tscDebugL("0x%"PRIx64" SQL: %s", pSql->self, pSql->sqlstr);
......@@ -1981,6 +1986,7 @@ int taos_stmt_execute(TAOS_STMT* stmt) {
} else {
taosReleaseRef(tscObjRef, pStmt->pSql->self);
pStmt->pSql = taos_query((TAOS*)pStmt->taos, sql);
pStmt->numOfRows += taos_affected_rows(pStmt->pSql);
ret = taos_errno(pStmt->pSql);
free(sql);
}
......@@ -1992,12 +1998,12 @@ int taos_stmt_execute(TAOS_STMT* stmt) {
int taos_stmt_affected_rows(TAOS_STMT* stmt) {
STscStmt* pStmt = (STscStmt*)stmt;
if (pStmt == NULL || pStmt->pSql == NULL || pStmt->pSql->signature != pStmt->pSql) {
if (pStmt == NULL) {
tscError("statement is invalid");
return 0;
}
return pStmt->pSql->res.numOfRows;
return pStmt->numOfRows;
}
TAOS_RES *taos_stmt_use_result(TAOS_STMT* stmt) {
......
......@@ -184,6 +184,10 @@ void verify_prepare(TAOS* taos) {
taos_stmt_close(stmt);
exit(EXIT_FAILURE);
}
int affectedRows = taos_stmt_affected_rows(stmt);
printf("sucessfully inserted %d rows\n", affectedRows);
taos_stmt_close(stmt);
// query the records
......@@ -400,6 +404,9 @@ void verify_prepare2(TAOS* taos) {
exit(EXIT_FAILURE);
}
int affectedRows = taos_stmt_affected_rows(stmt);
printf("sucessfully inserted %d rows\n", affectedRows);
taos_stmt_close(stmt);
// query the records
......@@ -784,6 +791,10 @@ void verify_prepare3(TAOS* taos) {
taos_stmt_close(stmt);
exit(EXIT_FAILURE);
}
int affectedRows = taos_stmt_affected_rows(stmt);
printf("successfully inserted %d rows\n", affectedRows);
taos_stmt_close(stmt);
// query the records
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册