diff options
author | Shauren <shauren.trinity@gmail.com> | 2021-11-04 22:27:28 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2021-11-04 22:27:28 +0100 |
commit | 270db9a3524a478600250402f79be0d8383c1e4e (patch) | |
tree | 3b39a278f0ec7c6dd5b7e003364b6f7608928198 /src/common/DataStores/DB2FileLoader.cpp | |
parent | 5c8a058120dcf2c3ff8592886cb842ca889e0411 (diff) |
Core/DataStores: Add a bit more info to db2 file loader sign check assertions
Diffstat (limited to 'src/common/DataStores/DB2FileLoader.cpp')
-rw-r--r-- | src/common/DataStores/DB2FileLoader.cpp | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/src/common/DataStores/DB2FileLoader.cpp b/src/common/DataStores/DB2FileLoader.cpp index 274f5c0d796..abeeec006be 100644 --- a/src/common/DataStores/DB2FileLoader.cpp +++ b/src/common/DataStores/DB2FileLoader.cpp @@ -183,6 +183,7 @@ public: virtual DB2FileLoadInfo const* GetLoadInfo() const = 0; virtual DB2SectionHeader& GetSection(uint32 section) const = 0; virtual bool IsSignedField(uint32 field) const = 0; + virtual char const* GetExpectedSignMismatchReason(uint32 field) const = 0; private: friend class DB2Record; @@ -223,6 +224,7 @@ public: DB2FileLoadInfo const* GetLoadInfo() const override; DB2SectionHeader& GetSection(uint32 section) const override; bool IsSignedField(uint32 field) const override; + char const* GetExpectedSignMismatchReason(uint32 field) const override; private: void FillParentLookup(char* dataTable); @@ -282,6 +284,7 @@ public: DB2FileLoadInfo const* GetLoadInfo() const override; DB2SectionHeader& GetSection(uint32 section) const override; bool IsSignedField(uint32 field) const override; + char const* GetExpectedSignMismatchReason(uint32 field) const override; private: void FillParentLookup(char* dataTable); @@ -960,6 +963,39 @@ bool DB2FileLoaderRegularImpl::IsSignedField(uint32 field) const return false; } +char const* DB2FileLoaderRegularImpl::GetExpectedSignMismatchReason(uint32 field) const +{ + if (field >= _header->TotalFieldCount) + { + ASSERT(field == _header->TotalFieldCount); + ASSERT(int32(field) == _loadInfo->Meta->ParentIndexField); + return " (ParentIndexField must always be unsigned)"; + } + + DB2ColumnCompression compressionType = _columnMeta ? _columnMeta[field].CompressionType : DB2ColumnCompression::None; + switch (compressionType) + { + case DB2ColumnCompression::None: + case DB2ColumnCompression::CommonData: + case DB2ColumnCompression::Pallet: + case DB2ColumnCompression::PalletArray: + if (int32(field) == _loadInfo->Meta->IndexField) + return " (IndexField must always be unsigned)"; + if (int32(field) == _loadInfo->Meta->ParentIndexField) + return " (ParentIndexField must always be unsigned)"; + return ""; + case DB2ColumnCompression::SignedImmediate: + return " (CompressionType is SignedImmediate)"; + case DB2ColumnCompression::Immediate: + return " (CompressionType is Immediate)"; + default: + ASSERT(false, "Unhandled compression type %u in %s", uint32(_columnMeta[field].CompressionType), _fileName); + break; + } + + return ""; +} + DB2FileLoaderSparseImpl::DB2FileLoaderSparseImpl(char const* fileName, DB2FileLoadInfo const* loadInfo, DB2Header const* header, DB2FileSource* source) : _fileName(fileName), _loadInfo(loadInfo), @@ -1564,6 +1600,16 @@ bool DB2FileLoaderSparseImpl::IsSignedField(uint32 field) const return _loadInfo->Meta->IsSignedField(field); } +char const* DB2FileLoaderSparseImpl::GetExpectedSignMismatchReason(uint32 field) const +{ + ASSERT(field < _header->FieldCount); + if (int32(field) == _loadInfo->Meta->IndexField) + return " (IndexField must always be unsigned)"; + if (int32(field) == _loadInfo->Meta->ParentIndexField) + return " (ParentIndexField must always be unsigned)"; + return ""; +} + DB2Record::DB2Record(DB2FileLoaderImpl const& db2, uint32 recordIndex, std::size_t* fieldOffsets) : _db2(db2), _recordIndex(recordIndex), _recordData(db2.GetRawRecordData(recordIndex, nullptr)), _fieldOffsets(fieldOffsets) { @@ -1949,7 +1995,9 @@ void DB2FileLoader::Load(DB2FileSource* source, DB2FileLoadInfo const* loadInfo) for (uint32 f = 0; f < loadInfo->Meta->FieldCount; ++f) { ASSERT(loadInfo->Fields[fieldIndex].IsSigned == _impl->IsSignedField(f), - "Field %s in %s must be %s", loadInfo->Fields[fieldIndex].Name, source->GetFileName(), _impl->IsSignedField(f) ? "signed" : "unsigned"); + "Field %s in %s must be %s%s", loadInfo->Fields[fieldIndex].Name, source->GetFileName(), _impl->IsSignedField(f) ? "signed" : "unsigned", + _impl->GetExpectedSignMismatchReason(f)); + fieldIndex += loadInfo->Meta->Fields[f].ArraySize; } } |