From c1e7b3be662e98e6b2316e75a6c86189228b4485 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 13 Feb 2023 19:10:31 +0800 Subject: [PATCH] fix(query): 1. reset the pointer, when initialize the reader failed. 2. add check for null pointer when extracting cached rows. --- source/dnode/vnode/src/tsdb/tsdbCacheRead.c | 7 +++++++ source/dnode/vnode/src/tsdb/tsdbRead.c | 1 + 2 files changed, 8 insertions(+) diff --git a/source/dnode/vnode/src/tsdb/tsdbCacheRead.c b/source/dnode/vnode/src/tsdb/tsdbCacheRead.c index fd5e8eb6e0..cf2e348fb2 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCacheRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbCacheRead.c @@ -41,6 +41,13 @@ static int32_t saveOneRow(SArray* pRow, SSDataBlock* pBlock, SCacheRowsReader* p int32_t slotId = slotIds[i]; SLastCol* pColVal = (SLastCol*)taosArrayGet(pRow, slotId); + // add check for null value, caused by the modification of table schema (new column added). + if (pColVal == NULL) { + p->ts = 0; + p->isNull = true; + continue; + } + p->ts = pColVal->ts; p->isNull = !COL_VAL_IS_VALUE(&pColVal->colVal); allNullRow = p->isNull & allNullRow; diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index e9bb7e3d09..eb083a75cd 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -3942,6 +3942,7 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableL _err: tsdbError("failed to create data reader, code:%s %s", tstrerror(code), idstr); tsdbReaderClose(pReader); + *ppReader = NULL; // reset the pointer value. return code; }