1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

MCOL-1408 Multiple API HWM boundary fixes

Fixes the following:

* Generate error if calculateRowId fails
* No data written when first extent is completely full on a write, all
data going to second extent.
* 0 byte valArray malloc
* valArray free() on no malloc
* Column touched but no data written if all data going to second extent
* Wrong colWidth used on second extent calculateRowId
* Out of bounds memory write (crash) when no data for first extent
* Extent not committed if all data going to second extent
This commit is contained in:
Andrew Hutchings
2018-06-06 16:18:54 +01:00
parent 36a536f472
commit 2bbb70f61b

View File

@ -2008,7 +2008,6 @@ timer.stop("tokenize");
if (it != aColExtsInfo.end()) //update hwm info if (it != aColExtsInfo.end()) //update hwm info
{ {
oldHwm = it->hwm; oldHwm = it->hwm;
}
// save hwm for the old extent // save hwm for the old extent
colWidth = colStructList[i].colWidth; colWidth = colStructList[i].colWidth;
@ -2032,6 +2031,7 @@ timer.stop("tokenize");
else else
return ERR_INVALID_PARAM; return ERR_INVALID_PARAM;
}
//update hwm for the new extent //update hwm for the new extent
if (newExtent) if (newExtent)
{ {
@ -2043,6 +2043,7 @@ timer.stop("tokenize");
break; break;
it++; it++;
} }
colWidth = newColStructList[i].colWidth;
succFlag = colOp->calculateRowId(lastRidNew, BYTE_PER_BLOCK/colWidth, colWidth, curFbo, curBio); succFlag = colOp->calculateRowId(lastRidNew, BYTE_PER_BLOCK/colWidth, colWidth, curFbo, curBio);
if (succFlag) if (succFlag)
{ {
@ -2107,6 +2108,9 @@ timer.start("writeColumnRec");
curFbo)); curFbo));
} }
} }
else
return ERR_INVALID_PARAM;
}
} }
// If we create a new extent for this batch // If we create a new extent for this batch
for (unsigned i = 0; i < newColStructList.size(); i++) for (unsigned i = 0; i < newColStructList.size(); i++)
@ -2123,7 +2127,8 @@ timer.start("writeColumnRec");
curFbo)); curFbo));
} }
} }
} else
return ERR_INVALID_PARAM;
} }
if (lbids.size() > 0) if (lbids.size() > 0)
@ -4604,7 +4609,7 @@ int WriteEngineWrapper::writeColumnRecBinary(const TxnID& txnid,
bool versioning) bool versioning)
{ {
int rc = 0; int rc = 0;
void* valArray; void* valArray = NULL;
string segFile; string segFile;
Column curCol; Column curCol;
ColStructList::size_type totalColumn; ColStructList::size_type totalColumn;
@ -4629,12 +4634,14 @@ StopWatch timer;
totalRow2 = 0; totalRow2 = 0;
} }
valArray = malloc(sizeof(uint64_t) * totalRow1); // It is possible totalRow1 is zero but totalRow2 has values
if ((totalRow1 == 0) && (totalRow2 == 0))
if (totalRow1 == 0)
return rc; return rc;
TableMetaData* aTbaleMetaData = TableMetaData::makeTableMetaData(tableOid); TableMetaData* aTbaleMetaData = TableMetaData::makeTableMetaData(tableOid);
if (totalRow1)
{
valArray = malloc(sizeof(uint64_t) * totalRow1);
for (i = 0; i < totalColumn; i++) for (i = 0; i < totalColumn; i++)
{ {
//@Bug 2205 Check if all rows go to the new extent //@Bug 2205 Check if all rows go to the new extent
@ -4735,11 +4742,11 @@ StopWatch timer;
#ifdef PROFILE #ifdef PROFILE
timer.start("writeRow "); timer.start("writeRow ");
#endif #endif
rc = colOp->writeRow(curCol, totalRow1, firstPart, valArray); rc = colOp->writeRow(curCol, totalRow1, firstPart, valArray);
#ifdef PROFILE #ifdef PROFILE
timer.stop("writeRow "); timer.stop("writeRow ");
#endif #endif
colOp->closeColumnFile(curCol); colOp->closeColumnFile(curCol);
@ -4756,6 +4763,7 @@ timer.stop("writeRow ");
free(valArray); free(valArray);
valArray = NULL; valArray = NULL;
} }
}
// MCOL-1176 - Write second extent // MCOL-1176 - Write second extent
if (totalRow2) if (totalRow2)