提交 6bba28ab 编写于 作者: C Cary Xu

[TS-995]<fix>(query): validate pTableCheckInfo when querying last/last_row

上级 efaaad27
...@@ -596,6 +596,11 @@ void tsdbResetQueryHandleForNewTable(TsdbQueryHandleT queryHandle, STsdbQueryCon ...@@ -596,6 +596,11 @@ void tsdbResetQueryHandleForNewTable(TsdbQueryHandleT queryHandle, STsdbQueryCon
static int32_t lazyLoadCacheLast(STsdbQueryHandle* pQueryHandle) { static int32_t lazyLoadCacheLast(STsdbQueryHandle* pQueryHandle) {
STsdbRepo* pRepo = pQueryHandle->pTsdb; STsdbRepo* pRepo = pQueryHandle->pTsdb;
if (!pQueryHandle->pTableCheckInfo) {
tsdbError("%p table check info is NULL", pQueryHandle);
return -1;
}
size_t numOfTables = taosArrayGetSize(pQueryHandle->pTableCheckInfo); size_t numOfTables = taosArrayGetSize(pQueryHandle->pTableCheckInfo);
int32_t code = 0; int32_t code = 0;
for (size_t i = 0; i < numOfTables; ++i) { for (size_t i = 0; i < numOfTables; ++i) {
...@@ -627,7 +632,7 @@ TsdbQueryHandleT tsdbQueryLastRow(STsdbRepo *tsdb, STsdbQueryCond *pCond, STable ...@@ -627,7 +632,7 @@ TsdbQueryHandleT tsdbQueryLastRow(STsdbRepo *tsdb, STsdbQueryCond *pCond, STable
if (pQueryHandle == NULL) { if (pQueryHandle == NULL) {
return NULL; return NULL;
} }
pQueryHandle->pTableCheckInfo = NULL;
lazyLoadCacheLast(pQueryHandle); lazyLoadCacheLast(pQueryHandle);
int32_t code = checkForCachedLastRow(pQueryHandle, groupList); int32_t code = checkForCachedLastRow(pQueryHandle, groupList);
...@@ -2754,6 +2759,10 @@ static bool loadBlockOfActiveTable(STsdbQueryHandle* pQueryHandle) { ...@@ -2754,6 +2759,10 @@ static bool loadBlockOfActiveTable(STsdbQueryHandle* pQueryHandle) {
static bool loadCachedLastRow(STsdbQueryHandle* pQueryHandle) { static bool loadCachedLastRow(STsdbQueryHandle* pQueryHandle) {
// the last row is cached in buffer, return it directly. // the last row is cached in buffer, return it directly.
// here note that the pQueryHandle->window must be the TS_INITIALIZER // here note that the pQueryHandle->window must be the TS_INITIALIZER
if (!pQueryHandle || !pQueryHandle->pTableCheckInfo) {
return false;
}
int32_t numOfCols = (int32_t)(QH_GET_NUM_OF_COLS(pQueryHandle)); int32_t numOfCols = (int32_t)(QH_GET_NUM_OF_COLS(pQueryHandle));
size_t numOfTables = taosArrayGetSize(pQueryHandle->pTableCheckInfo); size_t numOfTables = taosArrayGetSize(pQueryHandle->pTableCheckInfo);
assert(numOfTables > 0 && numOfCols > 0); assert(numOfTables > 0 && numOfCols > 0);
...@@ -2793,6 +2802,10 @@ static bool loadCachedLastRow(STsdbQueryHandle* pQueryHandle) { ...@@ -2793,6 +2802,10 @@ static bool loadCachedLastRow(STsdbQueryHandle* pQueryHandle) {
static bool loadCachedLast(STsdbQueryHandle* pQueryHandle) { static bool loadCachedLast(STsdbQueryHandle* pQueryHandle) {
// the last row is cached in buffer, return it directly. // the last row is cached in buffer, return it directly.
// here note that the pQueryHandle->window must be the TS_INITIALIZER // here note that the pQueryHandle->window must be the TS_INITIALIZER
if (!pQueryHandle || !pQueryHandle->pTableCheckInfo) {
return false;
}
int32_t tgNumOfCols = (int32_t)QH_GET_NUM_OF_COLS(pQueryHandle); int32_t tgNumOfCols = (int32_t)QH_GET_NUM_OF_COLS(pQueryHandle);
size_t numOfTables = taosArrayGetSize(pQueryHandle->pTableCheckInfo); size_t numOfTables = taosArrayGetSize(pQueryHandle->pTableCheckInfo);
int32_t numOfRows = 0; int32_t numOfRows = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册