Skip to content

Commit

Permalink
Improvement CORE-3588: More detail in message "wrong page type"
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPeshkoff committed Jun 28, 2012
1 parent cbcbdeb commit 64a89b7
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/jrd/cch.cpp
Expand Up @@ -61,6 +61,7 @@
#include "../common/classes/ClumpletWriter.h"
#include "../common/classes/MsgPrint.h"
#include "../jrd/CryptoManager.h"
#include "../common/utils_proto.h"

using namespace Jrd;
using namespace Ods;
Expand Down Expand Up @@ -4426,8 +4427,8 @@ static void page_validation_error(thread_db* tdbb, WIN* window, SSHORT type)
Arg::Gds(isc_db_corrupt) << Arg::Str(pages->file->fil_string) <<
Arg::Gds(isc_page_type_err) <<
Arg::Gds(isc_badpagtyp) << Arg::Num(bdb->bdb_page.getPageNum()) <<
Arg::Num(type) <<
Arg::Num(page->pag_type));
pagtype(type) <<
pagtype(page->pag_type));
// We should invalidate this bad buffer.
CCH_unwind(tdbb, true);
}
Expand Down
27 changes: 27 additions & 0 deletions src/jrd/ods.cpp
Expand Up @@ -138,4 +138,31 @@ size_t maxIndices(size_t page_size)
(sizeof(index_root_page::irt_repeat) + sizeof(irtd));
}

Firebird::string pagtype(UCHAR type)
{
// Print pretty name for database page type

const char* nameArray[pag_max + 1] = {
"purposely undefined",
"database header",
"page inventory",
"transaction inventory",
"pointer",
"data",
"index root",
"index B-tree",
"blob",
"generators",
"SCN inventory"
};

Firebird::string rc;
if (type < FB_NELEM(nameArray))
rc = nameArray[type];
else
rc.printf("unknown (%d)", type);

return rc;
}

} // namespace
3 changes: 3 additions & 0 deletions src/jrd/ods.h
Expand Up @@ -34,6 +34,7 @@
#define JRD_ODS_H

#include "../jrd/RecordNumber.h"
#include "../common/classes/fb_string.h"

// This macro enables the ability of the engine to connect to databases
// from ODS 8 up to the latest. If this macro is undefined, the engine
Expand Down Expand Up @@ -629,6 +630,8 @@ inline int IAD_LEN(int count)
#define IAD_LEN(count) (sizeof (Ods::InternalArrayDesc) + \
(count ? count - 1: count) * sizeof (Ods::InternalArrayDesc::iad_repeat))

Firebird::string pagtype(UCHAR type);

} //namespace Ods

#endif // JRD_ODS_H
5 changes: 3 additions & 2 deletions src/jrd/validation.cpp
Expand Up @@ -655,7 +655,7 @@ Vdr::Vdr()

static const TEXT msg_table[VAL_MAX_ERROR][80] =
{
"Page %ld wrong type (expected %d encountered %d)", // 0
"Page %ld wrong type (expected %s encountered %s)", // 0
"Checksum error on page %ld",
"Page %ld doubly allocated",
"Page %ld is used but marked free",
Expand Down Expand Up @@ -847,7 +847,8 @@ FETCH_CODE Vdr::fetch_page(thread_db* tdbb,

if ((*page_pointer)->pag_type != type && type != pag_undefined)
{
corrupt(tdbb, validate, VAL_PAG_WRONG_TYPE, 0, page_number, type, (*page_pointer)->pag_type);
corrupt(tdbb, validate, VAL_PAG_WRONG_TYPE, 0, page_number,
pagtype(type).c_str(), pagtype((*page_pointer)->pag_type).c_str());
return fetch_type;
}

Expand Down

0 comments on commit 64a89b7

Please sign in to comment.