ods.cpp (Firebird-3.0.2.32703-0.tar.bz2) | : | ods.cpp (Firebird-3.0.4.33054-0.tar.bz2) | ||
---|---|---|---|---|
skipping to change at line 26 | skipping to change at line 26 | |||
* Copyright (c) 2005 Dmitry Yemanov <dimitr@users.sf.net> | * Copyright (c) 2005 Dmitry Yemanov <dimitr@users.sf.net> | |||
* and all contributors signed below. | * and all contributors signed below. | |||
* | * | |||
* All Rights Reserved. | * All Rights Reserved. | |||
* Contributor(s): ______________________________________. | * Contributor(s): ______________________________________. | |||
*/ | */ | |||
#include "firebird.h" | #include "firebird.h" | |||
#include "../jrd/ods.h" | #include "../jrd/ods.h" | |||
#include "../jrd/ods_proto.h" | #include "../jrd/ods_proto.h" | |||
#include "../common/classes/DbImplementation.h" | ||||
using namespace Firebird; | using namespace Firebird; | |||
namespace | namespace | |||
{ | { | |||
const FB_SIZE_T NEXT_INDEX = 0; | const FB_SIZE_T NEXT_INDEX = 0; | |||
const FB_SIZE_T OIT_INDEX = 1; | const FB_SIZE_T OIT_INDEX = 1; | |||
const FB_SIZE_T OAT_INDEX = 2; | const FB_SIZE_T OAT_INDEX = 2; | |||
const FB_SIZE_T OST_INDEX = 3; | const FB_SIZE_T OST_INDEX = 3; | |||
} | } | |||
namespace Ods { | namespace Ods { | |||
bool isSupported(USHORT majorVersion, USHORT minorVersion) | bool isSupported(const header_page* hdr) | |||
{ | { | |||
USHORT majorVersion = hdr->hdr_ods_version; | ||||
USHORT minorVersion = hdr->hdr_ods_minor; | ||||
const bool isFirebird = (majorVersion & ODS_FIREBIRD_FLAG); | const bool isFirebird = (majorVersion & ODS_FIREBIRD_FLAG); | |||
majorVersion &= ~ODS_FIREBIRD_FLAG; | majorVersion &= ~ODS_FIREBIRD_FLAG; | |||
if (!isFirebird) | if (!isFirebird) | |||
return false; | return false; | |||
// Support current ODS of the engine | // Support current ODS of the engine | |||
if (majorVersion == ODS_VERSION && | if (majorVersion == ODS_VERSION && | |||
minorVersion >= ODS_RELEASED && | minorVersion >= ODS_RELEASED && | |||
minorVersion <= ODS_CURRENT) | minorVersion <= ODS_CURRENT) | |||
{ | { | |||
return true; | if (minorVersion == ODS_CURRENT12_0) | |||
{ | ||||
generator_page page; | ||||
if (!getGpgValues(&page, DbImplementation(hdr), minorVers | ||||
ion)) | ||||
return false; | ||||
} | ||||
if (minorVersion != ODS_CURRENT12_1) | ||||
return true; | ||||
} | } | |||
// Do not support anything else | // Do not support anything else | |||
return false; | return false; | |||
} | } | |||
SINT64* getGpgValues(generator_page* page, DbImplementation di, USHORT minorVers | ||||
ion) | ||||
{ | ||||
if (minorVersion >= ODS_CURRENT12_2) | ||||
return page->gpg_values; | ||||
// ODS_12_0 | ||||
if (di.same()) // use DB on same platform where it was c | ||||
reated | ||||
{ | ||||
struct generator_page_12_0 | ||||
{ | ||||
pag gpg_header; | ||||
ULONG gpg_sequence; // Sequence numbe | ||||
r | ||||
SINT64 gpg_values[1]; // Generator vector | ||||
}; | ||||
return ((generator_page_12_0*)page)->gpg_values; | ||||
} | ||||
if (di.ods12_1_gen()) // use DB known to have layout matching with 12.1 | ||||
return page->gpg_values; | ||||
if (di.ods12_0_gen()) // use DB known to have buggy layout | ||||
{ | ||||
UCHAR* p = (UCHAR*) page; | ||||
p += sizeof(pag); | ||||
p += sizeof(ULONG); | ||||
return (SINT64*)p; | ||||
} | ||||
return NULL; | ||||
} | ||||
ULONG bytesBitPIP(ULONG page_size) | ULONG bytesBitPIP(ULONG page_size) | |||
{ | { | |||
return static_cast<ULONG>(page_size - offsetof(page_inv_page, pip_bits[0] )); | return static_cast<ULONG>(page_size - offsetof(page_inv_page, pip_bits[0] )); | |||
} | } | |||
ULONG pagesPerPIP(ULONG page_size) | ULONG pagesPerPIP(ULONG page_size) | |||
{ | { | |||
return bytesBitPIP(page_size) * 8; | return bytesBitPIP(page_size) * 8; | |||
} | } | |||
End of changes. 5 change blocks. | ||||
2 lines changed or deleted | 48 lines changed or added |