diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index 67fd3d24bd..d1136ca4de 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -1991,7 +1991,22 @@ static void tscAbortFurtherRetryRetrieval(SRetrieveSupport *trsupport, TAOS_RES * current query failed, and the retry count is less than the available * count, retry query clear previous retrieved data, then launch a new sub query */ -static int32_t tscReissueSubquery(SRetrieveSupport *trsupport, SSqlObj *pSql, int32_t code) { +static int32_t tscReissueSubquery(SRetrieveSupport *oriTrs, SSqlObj *pSql, int32_t code) { + SRetrieveSupport *trsupport = malloc(sizeof(SRetrieveSupport)); + if (trsupport == NULL) { + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + + memcpy(trsupport, oriTrs, sizeof(*trsupport)); + + const uint32_t nBufferSize = (1u << 16u); // 64KB + trsupport->localBuffer = (tFilePage *)calloc(1, nBufferSize + sizeof(tFilePage)); + if (trsupport->localBuffer == NULL) { + tscError("%p failed to malloc buffer for local buffer, reason:%s", pSql, strerror(errno)); + tfree(trsupport); + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + SSqlObj *pParentSql = trsupport->pParentSql; int32_t subqueryIndex = trsupport->subqueryIndex; diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index d045000e24..824fff574e 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -2127,7 +2127,11 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, __async_cb_func_t pTableMetaInfo->tagColList, pTableMetaInfo->pVgroupTables); } else { // transfer the ownership of pTableMeta to the newly create sql object. STableMetaInfo* pPrevInfo = tscGetTableMetaInfoFromCmd(&pPrevSql->cmd, pPrevSql->cmd.clauseIndex, 0); - + if (pPrevInfo->pTableMeta && pPrevInfo->pTableMeta->tableType < 0) { + terrno = TSDB_CODE_TSC_APP_ERROR; + goto _error; + } + STableMeta* pPrevTableMeta = tscTableMetaDup(pPrevInfo->pTableMeta); SVgroupsInfo* pVgroupsInfo = pPrevInfo->vgroupList; pFinalInfo = tscAddTableMetaInfo(pNewQueryInfo, &pTableMetaInfo->name, pPrevTableMeta, pVgroupsInfo, pTableMetaInfo->tagColList,