MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / PAG_header_init

Function PAG_header_init

src/jrd/pag.cpp:1259–1337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1257
1258
1259void PAG_header_init(thread_db* tdbb)
1260{
1261/**************************************
1262 *
1263 * P A G _ h e a d e r _ i n i t
1264 *
1265 **************************************
1266 *
1267 * Functional description
1268 * Checkout the core part of the database header page.
1269 * It includes the fields required to setup the I/O layer:
1270 * ODS version, page size, page buffers.
1271 * Done using a physical page read.
1272 *
1273 **************************************/
1274 SET_TDBB(tdbb);
1275 Database* const dbb = tdbb->getDatabase();
1276
1277 Jrd::Attachment* const attachment = tdbb->getAttachment();
1278 fb_assert(attachment);
1279
1280 // Allocate a spare buffer which is large enough,
1281 // and set up to release it in case of error; note
1282 // that dbb_page_size has not been set yet, so we
1283 // can't depend on this.
1284 //
1285 // Make sure that buffer is aligned on a page boundary
1286 // and unit of transfer is a multiple of physical disk
1287 // sector for raw disk access.
1288
1289 const ULONG ioBlockSize = dbb->getIOBlockSize();
1290 const ULONG headerSize = MAX(RAW_HEADER_SIZE, ioBlockSize);
1291
1292 HalfStaticArray<UCHAR, RAW_HEADER_SIZE + PAGE_ALIGNMENT> temp;
1293 UCHAR* const temp_page = temp.getAlignedBuffer(headerSize, ioBlockSize);
1294
1295 PIO_header(tdbb, temp_page, headerSize);
1296 const header_page* header = (header_page*) temp_page;
1297
1298 if (header->hdr_header.pag_type != pag_header || header->hdr_sequence)
1299 ERR_post(Arg::Gds(isc_bad_db_format) << Arg::Str(attachment->att_filename));
1300
1301 const USHORT ods_version = header->hdr_ods_version & ~ODS_FIREBIRD_FLAG;
1302
1303 if (!Ods::isSupported(header))
1304 {
1305 ERR_post(Arg::Gds(isc_wrong_ods) << Arg::Str(attachment->att_filename) <<
1306 Arg::Num(ods_version) <<
1307 Arg::Num(header->hdr_ods_minor) <<
1308 Arg::Num(ODS_VERSION) <<
1309 Arg::Num(ODS_CURRENT));
1310 }
1311
1312 // Note that if this check is turned on, it should be recoded in order that
1313 // the Intel platforms can share databases. At present (Feb 95) it is possible
1314 // to share databases between Windows and NT, but not with NetWare. Sharing
1315 // databases with OS/2 is unknown and needs to be investigated. The CLASS was
1316 // initially 8 for all Intel platforms, but was changed after 4.0 was released

Callers 1

internalAttachMethod · 0.85

Calls 13

SET_TDBBFunction · 0.85
GdsClass · 0.85
StrClass · 0.85
isSupportedFunction · 0.85
NumClass · 0.85
DbImplementationClass · 0.85
getDatabaseMethod · 0.80
getIOBlockSizeMethod · 0.80
getAlignedBufferMethod · 0.80
compatibleMethod · 0.80
ERR_postFunction · 0.70
PIO_headerFunction · 0.50

Tested by

no test coverage detected