fix(query): fix invalid read.
This commit is contained in:
parent
a0a6c9e9b9
commit
3c952a337e
|
@ -124,7 +124,7 @@ static SBlockData* loadBlockIfMissing(SLDataIter *pIter) {
|
||||||
static FORCE_INLINE int32_t findEarliestIndex(int32_t index, uint64_t uid, const SSttBlk* pBlockList, int32_t num, int32_t backward) {
|
static FORCE_INLINE int32_t findEarliestIndex(int32_t index, uint64_t uid, const SSttBlk* pBlockList, int32_t num, int32_t backward) {
|
||||||
int32_t i = index;
|
int32_t i = index;
|
||||||
int32_t step = backward? 1:-1;
|
int32_t step = backward? 1:-1;
|
||||||
while (uid >= pBlockList[i].minUid && uid <= pBlockList[i].maxUid && i >= 0 && i < num) {
|
while (i >= 0 && i < num && uid >= pBlockList[i].minUid && uid <= pBlockList[i].maxUid) {
|
||||||
i += step;
|
i += step;
|
||||||
}
|
}
|
||||||
return i - step;
|
return i - step;
|
||||||
|
@ -169,7 +169,7 @@ static int32_t binarySearchForStartBlock(SSttBlk*pBlockList, int32_t num, uint64
|
||||||
static FORCE_INLINE int32_t findEarliestRow(int32_t index, uint64_t uid, const uint64_t* uidList, int32_t num, int32_t backward) {
|
static FORCE_INLINE int32_t findEarliestRow(int32_t index, uint64_t uid, const uint64_t* uidList, int32_t num, int32_t backward) {
|
||||||
int32_t i = index;
|
int32_t i = index;
|
||||||
int32_t step = backward? 1:-1;
|
int32_t step = backward? 1:-1;
|
||||||
while (uid == uidList[i] && i >= 0 && i < num) {
|
while (i >= 0 && i < num && uid == uidList[i]) {
|
||||||
i += step;
|
i += step;
|
||||||
}
|
}
|
||||||
return i - step;
|
return i - step;
|
||||||
|
|
|
@ -3256,11 +3256,18 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE: the endVersion in pCond is the data version not schema version, so pCond->endVersion is not correct here.
|
||||||
if (pCond->suid != 0) {
|
if (pCond->suid != 0) {
|
||||||
pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, pReader->suid, pCond->endVersion);
|
pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, pReader->suid, /*pCond->endVersion*/ -1);
|
||||||
|
if (pReader->pSchema == NULL) {
|
||||||
|
tsdbError("failed to get table schema, suid:%"PRIu64", ver:%"PRId64" , %s", pReader->suid, -1, pReader->idStr);
|
||||||
|
}
|
||||||
} else if (taosArrayGetSize(pTableList) > 0) {
|
} else if (taosArrayGetSize(pTableList) > 0) {
|
||||||
STableKeyInfo* pKey = taosArrayGet(pTableList, 0);
|
STableKeyInfo* pKey = taosArrayGet(pTableList, 0);
|
||||||
pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, pKey->uid, pCond->endVersion);
|
pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, pKey->uid, /*pCond->endVersion*/ -1);
|
||||||
|
if (pReader->pSchema == NULL) {
|
||||||
|
tsdbError("failed to get table schema, uid:%"PRIu64", ver:%"PRId64" , %s", pKey->uid, -1, pReader->idStr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t numOfTables = taosArrayGetSize(pTableList);
|
int32_t numOfTables = taosArrayGetSize(pTableList);
|
||||||
|
|
Loading…
Reference in New Issue