From 9fcc676e3f8801c553f888db528a8f9c6f9a8e33 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Wed, 11 May 2022 16:04:33 +0800 Subject: [PATCH] stmt auto create table --- source/client/src/clientStmt.c | 6 +++++- source/libs/parser/src/parInsert.c | 2 +- tests/script/api/batchprepare.c | 12 +++++++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/source/client/src/clientStmt.c b/source/client/src/clientStmt.c index 3a2363f882..2dff1c458c 100644 --- a/source/client/src/clientStmt.c +++ b/source/client/src/clientStmt.c @@ -339,6 +339,7 @@ int32_t stmtGetFromCache(STscStmt* pStmt) { STableDataBlocks *pBlockInExec = taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName)); if (pBlockInExec) { + pStmt->bInfo.needParse = false; pStmt->bInfo.inExecCache = true; if (pStmt->sql.autoCreateTbl) { @@ -364,7 +365,10 @@ int32_t stmtGetFromCache(STscStmt* pStmt) { SStmtTableCache* pCache = taosHashGet(pStmt->sql.pTableCache, &pStmt->bInfo.tbSuid, sizeof(pStmt->bInfo.tbSuid)); if (pCache) { pStmt->bInfo.needParse = false; - + pStmt->exec.autoCreateTbl = true; + + pStmt->bInfo.tbUid = 0; + STableDataBlocks* pNewBlock = NULL; STMT_ERR_RET(stmtRebuildDataBlock(pStmt, pCache->pDataBlock, &pNewBlock, 0)); diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index ad0319cf69..c38d577abf 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -1393,7 +1393,6 @@ int32_t qBindStmtColsValue(void* pBlock, TAOS_MULTI_BIND* bind, char* msgBuf, in tdSRowPrint(row, pSTSchema, __func__); taosMemoryFree(pSTSchema); #endif - pDataBlock->size += extendedRowSize; } @@ -1480,6 +1479,7 @@ int32_t qBindStmtSingleColValue(void* pBlock, TAOS_MULTI_BIND* bind, char* msgBu taosMemoryFree(pSTSchema); } #endif + } if (rowEnd) { diff --git a/tests/script/api/batchprepare.c b/tests/script/api/batchprepare.c index 4423ee3bc8..9f9ed88b89 100644 --- a/tests/script/api/batchprepare.c +++ b/tests/script/api/batchprepare.c @@ -233,9 +233,9 @@ CaseCtrl gCaseCtrl = { .printRes = false, .runTimes = 0, .caseIdx = -1, - .caseNum = -1, - .caseRunIdx = -1, - .caseRunNum = -1, + .caseNum = 1, + .caseRunIdx = 20, + .caseRunNum = 1, }; #endif @@ -2988,7 +2988,7 @@ void prepareCheckResultImpl(TAOS * taos, char *tname, bool printr, int expec } } else { printf("!!!expect rows %d mis-match rows %d fetched from %s\n", expected, rows, tname); - //exit(1); + exit(1); } } @@ -3465,11 +3465,13 @@ void* runCaseList(TAOS *taos) { } void runAll(TAOS *taos) { +#if 0 strcpy(gCaseCtrl.caseCatalog, "Normal Test"); printf("%s Begin\n", gCaseCtrl.caseCatalog); runCaseList(taos); +#endif -#if 0 +#if 1 strcpy(gCaseCtrl.caseCatalog, "Auto Create Table Test"); gCaseCtrl.autoCreateTbl = true; printf("%s Begin\n", gCaseCtrl.caseCatalog);