Merge pull request #20301 from taosdata/fix/main_bugfix_wxy
fix: insert data crash after empty table last_row cache
This commit is contained in:
commit
4ea87deef7
|
@ -257,9 +257,6 @@ int32_t tsdbCacheInsertLastrow(SLRUCache *pCache, STsdb *pTsdb, tb_uid_t uid, TS
|
||||||
|
|
||||||
SLastCol lastCol = {.ts = keyTs, .colVal = colVal};
|
SLastCol lastCol = {.ts = keyTs, .colVal = colVal};
|
||||||
if (IS_VAR_DATA_TYPE(colVal.type) && colVal.value.nData > 0) {
|
if (IS_VAR_DATA_TYPE(colVal.type) && colVal.value.nData > 0) {
|
||||||
SLastCol *pLastCol = (SLastCol *)taosArrayGet(pLast, iCol);
|
|
||||||
taosMemoryFree(pLastCol->colVal.value.pData);
|
|
||||||
|
|
||||||
lastCol.colVal.value.pData = taosMemoryMalloc(colVal.value.nData);
|
lastCol.colVal.value.pData = taosMemoryMalloc(colVal.value.nData);
|
||||||
if (lastCol.colVal.value.pData == NULL) {
|
if (lastCol.colVal.value.pData == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
|
@ -81,6 +81,11 @@ static int32_t saveOneRow(SArray* pRow, SSDataBlock* pBlock, SCacheRowsReader* p
|
||||||
colDataSetVal(pColInfoData, numOfRows, (const char*)&pColVal->ts, false);
|
colDataSetVal(pColInfoData, numOfRows, (const char*)&pColVal->ts, false);
|
||||||
} else {
|
} else {
|
||||||
int32_t slotId = slotIds[i];
|
int32_t slotId = slotIds[i];
|
||||||
|
// add check for null value, caused by the modification of table schema (new column added).
|
||||||
|
if (slotId >= taosArrayGetSize(pRow)) {
|
||||||
|
colDataSetNULL(pColInfoData, numOfRows);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
SLastCol* pColVal = (SLastCol*)taosArrayGet(pRow, slotId);
|
SLastCol* pColVal = (SLastCol*)taosArrayGet(pRow, slotId);
|
||||||
SColVal* pVal = &pColVal->colVal;
|
SColVal* pVal = &pColVal->colVal;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue