8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 18:43:03 +01:00

Introduce concept of ODS type to be able to distinguish between Interbase databases, Firebird databases, databases created by debugging builds of Firebird and private forks

This commit is contained in:
skidder 2004-08-23 20:44:49 +00:00
parent a5d7c89654
commit e0ac81de4a
7 changed files with 65 additions and 47 deletions

View File

@ -660,10 +660,11 @@ static void dmp_header(const header_page* page)
const USHORT minor_version = page->hdr_ods_minor;
fprintf(dbg_file,
"HEADER PAGE\t checksum %d\t generation %ld\n\tPage size: %d, version: %d.%d(%d), pages: %ld\n",
"HEADER PAGE\t checksum %d\t generation %ld\n\tPage size: %d, version: %d.%d(%d) type %04x, pages: %ld\n",
((PAG) page)->pag_checksum, ((PAG) page)->pag_generation,
page->hdr_page_size, page->hdr_ods_version, minor_version,
page->hdr_ods_minor_original, page->hdr_PAGES);
page->hdr_page_size, page->hdr_ods_version & ~ODS_TYPE_MASK,
minor_version, page->hdr_ods_minor_original,
page->hdr_ods_version & ODS_TYPE_MASK, page->hdr_PAGES);
struct tm time;
isc_decode_timestamp((GDS_TIMESTAMP *) page->hdr_creation_date, &time);

View File

@ -33,6 +33,12 @@
#ifndef JRD_ODS_H
#define JRD_ODS_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
* only opens a database of the current ODS major version.
*/
#define ODS_8_TO_CURRENT
/**********************************************************************
**
** NOTE:
@ -127,12 +133,45 @@ const USHORT ODS_CURRENT = ODS_CURRENT11; /* the highest defined minor version
number for this ODS_VERSION!! */
const USHORT ODS_CURRENT_VERSION = ODS_11_0; /* Current ODS version in use which includes
both Major and Minor ODS versions! */
// ODS types.
const USHORT ODS_TYPE_MASK = 0xFF00;
const USHORT ODS_TYPE_INTERBASE = 0x0000; // Interbase ODS (we support it up to ODS10)
const USHORT ODS_TYPE_FIREBIRD = 0x0100; // Official Firebird ODS (used since ODS11)
const USHORT ODS_TYPE_TRANSIENT = 0x0200; // Firebird ODS with some unfinished changes
// ODS types in range 0x80-0xFF are reserved for private builds and forks
const USHORT ODS_TYPE_PRIVATE_0 = 0x8000; // ODS used for private versions, such as BroadView builds
const USHORT ODS_TYPE_CURRENT = ODS_TYPE_TRANSIENT;
//const USHORT ODS_TYPE_CURRENT = ODS_TYPE_PRIVATE_0;
const USHORT USER_REL_INIT_ID_ODS8 = 31; /* ODS <= 8 */
const USHORT USER_DEF_REL_INIT_ID = 128; /* ODS >= 9 */
static inline bool ODS_SUPPORTED(USHORT hdr_version) {
USHORT ods_version = hdr_version & ~ODS_TYPE_MASK;
USHORT ods_type = hdr_version & ODS_TYPE_MASK;
#ifdef ODS_8_TO_CURRENT
// Support Interbase ODS from 8 to 10;
if (ods_type == ODS_TYPE_INTERBASE)
return ods_version >= ODS_VERSION8 && ods_version <= ODS_VERSION10;
// This is for future ODS versions
if (ods_type == ODS_TYPE_FIREBIRD &&
ods_version > ODS_VERSION10 && ods_version <= ODS_VERSION - 1)
return true;
#endif
// Support current ODS of the engine
if (ods_type == ODS_TYPE_CURRENT && ods_version == ODS_VERSION)
return true;
// Do not support anything else
return false;
}
/* Page types */
const SCHAR pag_undefined = 0;

View File

@ -1301,15 +1301,7 @@ static bool raw_devices_validate_database (
if (hp->hdr_header.pag_type != pag_header /*|| hp->hdr_sequence*/)
goto quit;
#ifdef ODS_8_TO_CURRENT
/* This Server understands ODS greater than 8 *ONLY* upto current major
* ODS_VERSION defined in ods.h, Refuse connections to older or newer ODS's.
*/
if ((hp->hdr_ods_version < ODS_VERSION8)
|| (hp->hdr_ods_version > ODS_VERSION))
#else
if (hp->hdr_ods_version != ODS_VERSION)
#endif
if (!ODS_SUPPORTED(hp->hdr_ods_version))
goto quit;
if (hp->hdr_page_size < MIN_PAGE_SIZE || hp->hdr_page_size > MAX_PAGE_SIZE)

View File

@ -102,12 +102,6 @@ static bool find_type(SLONG, WIN*, pag**, USHORT, USHORT, UCHAR**,
#define ERR_POST_IF_DATABASE_IS_READONLY(dbb) {if (dbb->dbb_flags & DBB_read_only) ERR_post (isc_read_only_database, 0);}
/* 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
* only opens a database of the current ODS major version.
*/
#define ODS_8_TO_CURRENT
/* Class definitions
1 Apollo 68K, Dn 10K
@ -391,7 +385,7 @@ USHORT PAG_add_file(const TEXT* file_name, SLONG start)
/* The following lines (taken from PAG_format_header) are needed to identify
this file in raw_devices_validate_database as a valid database attachment. */
MOV_time_stamp(reinterpret_cast<ISC_TIMESTAMP*>(header->hdr_creation_date));
header->hdr_ods_version = ODS_VERSION;
header->hdr_ods_version = ODS_VERSION | ODS_TYPE_CURRENT;
header->hdr_implementation = CLASS;
header->hdr_ods_minor = ODS_CURRENT;
header->hdr_ods_minor_original = ODS_CURRENT;
@ -813,7 +807,7 @@ void PAG_format_header(void)
ISC_TIMESTAMP * >(header->hdr_creation_date));
header->hdr_header.pag_type = pag_header;
header->hdr_page_size = dbb->dbb_page_size;
header->hdr_ods_version = ODS_VERSION;
header->hdr_ods_version = ODS_VERSION | ODS_TYPE_CURRENT;
header->hdr_implementation = CLASS;
header->hdr_ods_minor = ODS_CURRENT;
header->hdr_ods_minor_original = ODS_CURRENT;
@ -829,7 +823,7 @@ void PAG_format_header(void)
header->hdr_flags |= hdr_SQL_dialect_3;
}
dbb->dbb_ods_version = header->hdr_ods_version;
dbb->dbb_ods_version = header->hdr_ods_version & ~ODS_TYPE_MASK;
dbb->dbb_minor_version = header->hdr_ods_minor;
dbb->dbb_minor_original = header->hdr_ods_minor_original;
@ -993,20 +987,13 @@ void PAG_header(const TEXT* file_name, USHORT file_length)
file_length), 0);
}
#ifdef ODS_8_TO_CURRENT
/* This Server understands ODS greater than 8 *ONLY* upto current major
ODS_VERSION defined in ods.h, Refuse connections to older or newer ODS's */
if ((header->hdr_ods_version < ODS_VERSION8)
|| (header->hdr_ods_version > ODS_VERSION))
#else
if (header->hdr_ods_version != ODS_VERSION)
#endif
if (!ODS_SUPPORTED(header->hdr_ods_version))
{
ERR_post(isc_wrong_ods,
isc_arg_cstring, file_length, ERR_string(file_name,
file_length),
isc_arg_number, (SLONG) header->hdr_ods_version,
isc_arg_number, (SLONG) ODS_VERSION, 0);
isc_arg_number, (SLONG) ODS_VERSION | ODS_TYPE_CURRENT, 0);
}
/****
@ -1043,7 +1030,7 @@ if (header->hdr_implementation && header->hdr_implementation != CLASS)
BUGCHECK(267); /* next transaction older than oldest transaction */
}
dbb->dbb_ods_version = header->hdr_ods_version;
dbb->dbb_ods_version = header->hdr_ods_version & ~ODS_TYPE_MASK;
dbb->dbb_minor_version = header->hdr_ods_minor;
dbb->dbb_minor_original = header->hdr_ods_minor_original;

View File

@ -530,22 +530,16 @@ int CLIB_ROUTINE main(int argc, char** argv)
service->svc_started();
#endif
/* ODS7 was not released as a shipping ODS and was replaced
* by ODS 8 in version 4.0 of InterBase. There will not be any
* customer databases which have an ODS of 7 */
if (header->hdr_ods_version > ODS_VERSION ||
(header->hdr_ods_version < ODS_VERSION8 &&
header->hdr_ods_version != ODS_VERSION6))
if (!ODS_SUPPORTED(header->hdr_ods_version))
{
#ifdef SUPERSERVER
CMD_UTIL_put_svc_status(tddba->dba_service_blk->svc_status,
GSTAT_MSG_FAC, 3,
isc_arg_number, (void*)(IPTR)ODS_VERSION,
isc_arg_number, (void*)(IPTR)(ODS_VERSION | ODS_TYPE_CURRENT),
isc_arg_number, (void*)(IPTR)header->hdr_ods_version,
0, NULL, 0, NULL, 0, NULL);
#endif
dba_error(3, (TEXT *)(IPTR) ODS_VERSION, (TEXT *)(IPTR) header->hdr_ods_version,
dba_error(3, (TEXT *)(IPTR) (ODS_VERSION | ODS_TYPE_CURRENT), (TEXT *)(IPTR) header->hdr_ods_version,
0, 0, 0); /* msg 3: Wrong ODS version, expected %d, encountered %d? */
}

View File

@ -90,8 +90,8 @@ void PPG_print_header(const header_page* header, SLONG page, bool nocreation,
FPRINTF(outfile, "\tGeneration\t\t%"ULONGFORMAT"\n",
header->hdr_header.pag_generation);
FPRINTF(outfile, "\tPage size\t\t%d\n", header->hdr_page_size);
FPRINTF(outfile, "\tODS version\t\t%d.%d\n", header->hdr_ods_version,
header->hdr_ods_minor);
FPRINTF(outfile, "\tODS version\t\t%d.%d type %04x\n", header->hdr_ods_version & ~ODS_TYPE_MASK,
header->hdr_ods_minor, header->hdr_ods_version & ODS_TYPE_MASK);
FPRINTF(outfile, "\tOldest transaction\t%"SLONGFORMAT"\n",
header->hdr_oldest_transaction);
FPRINTF(outfile, "\tOldest active\t\t%"SLONGFORMAT"\n",

View File

@ -615,7 +615,7 @@ static void format_header(
memset(page, 0, page_size);
page->hdr_page_size = page_size;
page->pag_type = pag_header;
page->hdr_ods_version = ODS_VERSION;
page->hdr_ods_version = ODS_VERSION | ODS_TYPE_CURRENT;
page->hdr_PAGES = 2;
page->hdr_oldest_transaction = oldest;
page->hdr_oldest_active = active;
@ -919,9 +919,12 @@ static header_page* open_database( RBDB rbdb, ULONG pg_size)
rbdb->rbdb_valid = FALSE;
}
if (header->hdr_ods_version != ODS_VERSION) {
printf("Wrong ODS version, expected %d, encountered %d.\n",
ODS_VERSION, header->hdr_ods_version);
if (header->hdr_ods_version != ODS_VERSION | ODS_TYPE_CURRENT) {
printf("Wrong ODS version, expected %d type %04x, encountered %d type %04x.\n",
ODS_VERSION, ODS_TYPE_CURRENT,
header->hdr_ods_version & ~ODS_TYPE_MASK,
header->hdr_ods_version & ODS_TYPE_MASK
);
rbdb->rbdb_valid = FALSE;
}
@ -962,7 +965,9 @@ static void print_db_header( FILE* file, const header_page* header)
**************************************/
fprintf(file, "Database header page information:\n");
fprintf(file, " Page size\t\t\t%d\n", header->hdr_page_size);
fprintf(file, " ODS version\t\t\t%d\n", header->hdr_ods_version);
fprintf(file, " ODS version\t\t\t%d type %04x\n",
header->hdr_ods_version & ~ODS_TYPE_MASK,
header->hdr_ods_version & ODS_TYPE_MASK);
fprintf(file, " PAGES\t\t\t%d\n", header->hdr_PAGES);
fprintf(file, " next page\t\t\t%d\n", header->hdr_next_page);
fprintf(file, " Oldest transaction\t\t%ld\n",