提交 31245370 编写于 作者: L lichuang

[TD-4034]restore last not NULL column

上级 08848116
...@@ -691,11 +691,24 @@ int tsdbRestoreInfo(STsdbRepo *pRepo) { ...@@ -691,11 +691,24 @@ int tsdbRestoreInfo(STsdbRepo *pRepo) {
// restore NULL columns // restore NULL columns
if (CACHE_LAST_NULL_COLUMN(pCfg)) { if (CACHE_LAST_NULL_COLUMN(pCfg)) {
if (tsdbLoadBlockInfo(&readh, NULL) < 0) {
tsdbDestroyReadH(&readh);
return -1;
}
pBlock = readh.pBlkInfo->blocks + pIdx->numOfBlocks - 1;
if (tsdbLoadBlockData(&readh, pBlock, NULL) < 0) {
tsdbDestroyReadH(&readh);
return -1;
}
STSchema *pSchema = tsdbGetTableSchema(pTable); STSchema *pSchema = tsdbGetTableSchema(pTable);
int numColumns = schemaNCols(pSchema); int numColumns = schemaNCols(pSchema);
pTable->lastCols = (SDataCol*)malloc(numColumns * sizeof(SDataCol)); pTable->lastCols = (SDataCol*)malloc(numColumns * sizeof(SDataCol));
if (pTable->lastCols == NULL) { if (pTable->lastCols == NULL) {
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
tsdbDestroyReadH(&readh);
return -1; return -1;
} }
pTable->lastColNum = numColumns; pTable->lastColNum = numColumns;
...@@ -704,11 +717,18 @@ int tsdbRestoreInfo(STsdbRepo *pRepo) { ...@@ -704,11 +717,18 @@ int tsdbRestoreInfo(STsdbRepo *pRepo) {
if (row == NULL) { if (row == NULL) {
tfree(pTable->lastCols); tfree(pTable->lastCols);
pTable->lastColNum = 0; pTable->lastColNum = 0;
tsdbDestroyReadH(&readh);
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
return -1; return -1;
} }
tdInitDataRow(row, pSchema); tdInitDataRow(row, pSchema);
for (int icol = 0; icol < schemaNCols(pSchema); icol++) {
STColumn *pCol = schemaColAt(pSchema, icol);
SDataCol *pDataCol = readh.pDCols[0]->cols + icol;
tdAppendColVal(row, tdGetColDataOfRow(pDataCol, pBlock->numOfRows - 1), pCol->type, pCol->bytes,
pCol->offset);
}
SDataCol *pLatestCols = pTable->lastCols; SDataCol *pLatestCols = pTable->lastCols;
for (i = 0; i < pTable->lastColNum; ++i) { for (i = 0; i < pTable->lastColNum; ++i) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册