2001-05-23 15:26:42 +02:00
|
|
|
/*
|
|
|
|
* PROGRAM: JRD Access Method
|
2003-11-10 10:16:38 +01:00
|
|
|
* MODULE: ppg.cpp
|
2001-05-23 15:26:42 +02:00
|
|
|
* DESCRIPTION: Database page print module
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Interbase Public
|
|
|
|
* License Version 1.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy
|
|
|
|
* of the License at http://www.Inprise.com/IPL.html
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an
|
|
|
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
|
|
|
|
* or implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
|
|
|
*
|
|
|
|
* The Original Code was created by Inprise Corporation
|
|
|
|
* and its predecessors. Portions created by Inprise Corporation are
|
|
|
|
* Copyright (C) Inprise Corporation.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
* Contributor(s): ______________________________________.
|
2001-08-08 04:01:26 +02:00
|
|
|
*
|
|
|
|
* 2001.08.07 Sean Leyne - Code Cleanup, removed "#ifdef READONLY_DATABASE"
|
|
|
|
* conditionals, second attempt
|
2001-05-23 15:26:42 +02:00
|
|
|
*/
|
|
|
|
|
2001-07-30 01:43:24 +02:00
|
|
|
#include "firebird.h"
|
2004-04-29 00:36:29 +02:00
|
|
|
#include <stdio.h>
|
2001-05-23 15:26:42 +02:00
|
|
|
#include <string.h>
|
|
|
|
#include "../jrd/common.h"
|
2006-02-03 14:13:27 +01:00
|
|
|
#include "../common/classes/timestamp.h"
|
2003-11-08 17:40:17 +01:00
|
|
|
#include "../jrd/ibase.h"
|
2001-05-23 15:26:42 +02:00
|
|
|
#include "../jrd/ods.h"
|
2003-09-08 22:23:46 +02:00
|
|
|
#include "../jrd/os/guid.h"
|
|
|
|
#include "../jrd/nbak.h"
|
2001-05-23 15:26:42 +02:00
|
|
|
#include "../jrd/gds_proto.h"
|
|
|
|
|
2003-07-15 04:43:36 +02:00
|
|
|
#include "../utilities/gstat/ppg_proto.h"
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-03-20 15:57:40 +01:00
|
|
|
// gstat directly reads database files, therefore
|
|
|
|
using namespace Ods;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2008-12-05 02:20:14 +01:00
|
|
|
void PPG_print_header(const header_page* header, SLONG page,
|
2008-01-16 08:55:28 +01:00
|
|
|
bool nocreation, Firebird::UtilSvc* uSvc)
|
2001-05-23 15:26:42 +02:00
|
|
|
{
|
|
|
|
/**************************************
|
|
|
|
*
|
|
|
|
* P P G _ p r i n t _ h e a d e r
|
|
|
|
*
|
|
|
|
**************************************
|
|
|
|
*
|
|
|
|
* Functional description
|
|
|
|
* Print database header page.
|
|
|
|
*
|
|
|
|
**************************************/
|
|
|
|
if (page == HEADER_PAGE)
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf("Database header page information:\n");
|
2001-05-23 15:26:42 +02:00
|
|
|
else
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf("Database overflow header page information:\n");
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
|
2009-01-18 12:29:24 +01:00
|
|
|
if (page == HEADER_PAGE)
|
|
|
|
{
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf("\tFlags\t\t\t%d\n", header->hdr_header.pag_flags);
|
2009-01-18 12:29:24 +01:00
|
|
|
uSvc->printf("\tChecksum\t\t%d\n", header->hdr_header.pag_checksum);
|
|
|
|
uSvc->printf("\tGeneration\t\t%"ULONGFORMAT"\n", header->hdr_header.pag_generation);
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf("\tPage size\t\t%d\n", header->hdr_page_size);
|
|
|
|
uSvc->printf("\tODS version\t\t%d.%d\n",
|
2005-06-26 18:11:59 +02:00
|
|
|
header->hdr_ods_version & ~ODS_FIREBIRD_FLAG, header->hdr_ods_minor);
|
2009-01-18 12:29:24 +01:00
|
|
|
uSvc->printf("\tOldest transaction\t%"SLONGFORMAT"\n", header->hdr_oldest_transaction);
|
|
|
|
uSvc->printf("\tOldest active\t\t%"SLONGFORMAT"\n", header->hdr_oldest_active);
|
|
|
|
uSvc->printf("\tOldest snapshot\t\t%"SLONGFORMAT"\n", header->hdr_oldest_snapshot);
|
|
|
|
uSvc->printf("\tNext transaction\t%"SLONGFORMAT"\n", header->hdr_next_transaction);
|
|
|
|
uSvc->printf("\tBumped transaction\t%"SLONGFORMAT"\n", header->hdr_bumped_transaction);
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf("\tSequence number\t\t%d\n", header->hdr_sequence);
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2009-01-18 12:29:24 +01:00
|
|
|
uSvc->printf("\tNext attachment ID\t%"SLONGFORMAT"\n", header->hdr_attachment_id);
|
|
|
|
uSvc->printf("\tImplementation ID\t%d\n", header->hdr_implementation);
|
|
|
|
uSvc->printf("\tShadow count\t\t%"SLONGFORMAT"\n", header->hdr_shadow_count);
|
|
|
|
uSvc->printf("\tPage buffers\t\t%"ULONGFORMAT"\n", header->hdr_page_buffers);
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
|
2009-01-18 12:29:24 +01:00
|
|
|
uSvc->printf("\tNext header page\t%"ULONGFORMAT"\n", header->hdr_next_page);
|
2001-05-23 15:26:42 +02:00
|
|
|
#ifdef DEV_BUILD
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf("\tClumplet End\t\t%d\n", header->hdr_end);
|
2001-05-23 15:26:42 +02:00
|
|
|
#endif
|
|
|
|
|
2009-01-18 12:29:24 +01:00
|
|
|
if (page == HEADER_PAGE)
|
|
|
|
{
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
/* If the database dialect is not set to 3, then we need to
|
|
|
|
* assume it was set to 1. The reason for this is that a dialect
|
|
|
|
* 1 database has no dialect information written to the header.
|
|
|
|
*/
|
|
|
|
if (header->hdr_flags & hdr_SQL_dialect_3)
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf("\tDatabase dialect\t3\n");
|
2001-05-23 15:26:42 +02:00
|
|
|
else
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf("\tDatabase dialect\t1\n");
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2009-01-18 12:29:24 +01:00
|
|
|
if (!nocreation)
|
|
|
|
{
|
2006-05-20 05:31:05 +02:00
|
|
|
struct tm time;
|
2005-05-03 06:11:57 +02:00
|
|
|
isc_decode_timestamp(reinterpret_cast<const ISC_TIMESTAMP*>(header->hdr_creation_date),
|
2004-06-01 18:22:34 +02:00
|
|
|
&time);
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf("\tCreation date\t\t%s %d, %d %d:%02d:%02d\n",
|
2004-06-01 18:22:34 +02:00
|
|
|
FB_SHORT_MONTHS[time.tm_mon], time.tm_mday, time.tm_year + 1900,
|
|
|
|
time.tm_hour, time.tm_min, time.tm_sec);
|
|
|
|
}
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
|
2006-05-20 05:31:05 +02:00
|
|
|
ULONG flags;
|
|
|
|
int flag_count = 0;
|
2004-03-07 08:58:55 +01:00
|
|
|
|
2009-01-18 12:29:24 +01:00
|
|
|
if ((page == HEADER_PAGE) && (flags = header->hdr_flags))
|
|
|
|
{
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf("\tAttributes\t\t");
|
2001-05-23 15:26:42 +02:00
|
|
|
if (flags & hdr_force_write) {
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf("force write");
|
2001-05-23 15:26:42 +02:00
|
|
|
flag_count++;
|
|
|
|
}
|
|
|
|
if (flags & hdr_no_reserve) {
|
|
|
|
if (flag_count++)
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf(", ");
|
|
|
|
uSvc->printf("no reserve");
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
2004-10-03 06:49:04 +02:00
|
|
|
/*
|
2001-05-23 15:26:42 +02:00
|
|
|
if (flags & hdr_disable_cache) {
|
|
|
|
if (flag_count++)
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf(", ");
|
|
|
|
uSvc->printf("shared cache disabled");
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
2004-10-03 06:49:04 +02:00
|
|
|
*/
|
2001-05-23 15:26:42 +02:00
|
|
|
if (flags & hdr_active_shadow) {
|
|
|
|
if (flag_count++)
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf(", ");
|
|
|
|
uSvc->printf("active shadow");
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
|
2004-03-07 08:58:55 +01:00
|
|
|
const USHORT sd_flags = flags & hdr_shutdown_mask;
|
|
|
|
if (sd_flags == hdr_shutdown_multi) {
|
2001-05-23 15:26:42 +02:00
|
|
|
if (flag_count++)
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf(", ");
|
|
|
|
uSvc->printf("multi-user maintenance");
|
2004-02-25 02:50:40 +01:00
|
|
|
}
|
|
|
|
|
2004-03-07 08:58:55 +01:00
|
|
|
if (sd_flags == hdr_shutdown_single) {
|
2004-02-25 02:50:40 +01:00
|
|
|
if (flag_count++)
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf(", ");
|
|
|
|
uSvc->printf("single-user maintenance");
|
2004-02-25 02:50:40 +01:00
|
|
|
}
|
|
|
|
|
2004-03-07 08:58:55 +01:00
|
|
|
if (sd_flags == hdr_shutdown_full) {
|
2004-02-25 02:50:40 +01:00
|
|
|
if (flag_count++)
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf(", ");
|
|
|
|
uSvc->printf("full shutdown");
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & hdr_read_only) {
|
|
|
|
if (flag_count++)
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf(", ");
|
|
|
|
uSvc->printf("read only");
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
2009-01-18 12:29:24 +01:00
|
|
|
if (flags & hdr_backup_mask)
|
|
|
|
{
|
2003-09-08 22:23:46 +02:00
|
|
|
if (flag_count++)
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf(", ");
|
2004-05-14 01:20:50 +02:00
|
|
|
if ((flags & hdr_backup_mask) == Jrd::nbak_state_stalled)
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf("backup lock");
|
2003-09-08 22:23:46 +02:00
|
|
|
else
|
2004-05-14 01:20:50 +02:00
|
|
|
if ((flags & hdr_backup_mask) == Jrd::nbak_state_merge)
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf("backup merge");
|
2003-09-08 22:23:46 +02:00
|
|
|
else
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf("wrong backup state %d", flags & hdr_backup_mask);
|
2003-09-08 22:23:46 +02:00
|
|
|
}
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf("\n");
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|
|
|
|
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf("\n Variable header data:\n");
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2006-05-20 05:31:05 +02:00
|
|
|
SLONG number;
|
|
|
|
TEXT temp[257];
|
|
|
|
|
2003-12-05 11:35:47 +01:00
|
|
|
const UCHAR* p = header->hdr_data;
|
2009-01-18 12:29:24 +01:00
|
|
|
for (const UCHAR* const end = p + header->hdr_page_size; p < end && *p != HDR_end; p += 2 + p[1])
|
2003-12-05 11:35:47 +01:00
|
|
|
{
|
2009-01-18 12:29:24 +01:00
|
|
|
switch (*p)
|
|
|
|
{
|
2001-05-23 15:26:42 +02:00
|
|
|
case HDR_root_file_name:
|
|
|
|
memcpy(temp, p + 2, p[1]);
|
|
|
|
temp[p[1]] = '\0';
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf("\tRoot file name:\t\t%s\n", temp);
|
2001-05-23 15:26:42 +02:00
|
|
|
break;
|
2004-10-03 06:49:04 +02:00
|
|
|
/*
|
2001-05-23 15:26:42 +02:00
|
|
|
case HDR_journal_server:
|
|
|
|
memcpy(temp, p + 2, p[1]);
|
|
|
|
temp[p[1]] = '\0';
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf("\tJournal server:\t\t%s\n", temp);
|
2001-05-23 15:26:42 +02:00
|
|
|
break;
|
2004-10-03 06:49:04 +02:00
|
|
|
*/
|
2001-05-23 15:26:42 +02:00
|
|
|
case HDR_file:
|
|
|
|
memcpy(temp, p + 2, p[1]);
|
|
|
|
temp[p[1]] = '\0';
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf("\tContinuation file:\t\t%s\n", temp);
|
2001-05-23 15:26:42 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HDR_last_page:
|
|
|
|
memcpy(&number, p + 2, sizeof(number));
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf("\tLast logical page:\t\t%ld\n", number);
|
2001-05-23 15:26:42 +02:00
|
|
|
break;
|
2004-10-03 06:49:04 +02:00
|
|
|
/*
|
2001-05-23 15:26:42 +02:00
|
|
|
case HDR_unlicensed:
|
|
|
|
memcpy(&number, p + 2, sizeof(number));
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf("\tUnlicensed accesses:\t\t%ld\n", number);
|
2001-05-23 15:26:42 +02:00
|
|
|
break;
|
2004-10-03 06:49:04 +02:00
|
|
|
*/
|
2001-05-23 15:26:42 +02:00
|
|
|
case HDR_sweep_interval:
|
|
|
|
memcpy(&number, p + 2, sizeof(number));
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf("\tSweep interval:\t\t%ld\n", number);
|
2001-05-23 15:26:42 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HDR_log_name:
|
|
|
|
memcpy(temp, p + 2, p[1]);
|
|
|
|
temp[p[1]] = '\0';
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf("\tReplay logging file:\t\t%s\n", temp);
|
2001-05-23 15:26:42 +02:00
|
|
|
break;
|
2004-10-03 06:49:04 +02:00
|
|
|
/*
|
2001-05-23 15:26:42 +02:00
|
|
|
case HDR_cache_file:
|
2003-09-08 22:23:46 +02:00
|
|
|
memcpy(temp, p + 2, p[1]);
|
|
|
|
temp[p[1]] = '\0';
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf("\tShared Cache file:\t\t%s\n", temp);
|
2001-05-23 15:26:42 +02:00
|
|
|
break;
|
2004-10-03 06:49:04 +02:00
|
|
|
*/
|
2003-09-08 22:23:46 +02:00
|
|
|
case HDR_difference_file:
|
|
|
|
memcpy(temp, p + 2, p[1]);
|
|
|
|
temp[p[1]] = '\0';
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf("\tBackup difference file:\t%s\n", temp);
|
2003-09-08 22:23:46 +02:00
|
|
|
break;
|
|
|
|
|
2005-07-31 02:45:38 +02:00
|
|
|
case HDR_backup_guid:
|
|
|
|
{
|
2003-09-08 22:23:46 +02:00
|
|
|
char buff[GUID_BUFF_SIZE];
|
2004-11-30 07:18:39 +01:00
|
|
|
GuidToString(buff, reinterpret_cast<const FB_GUID*>(p + 2));
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf("\tDatabase backup GUID:\t%s\n", buff);
|
2003-09-08 22:23:46 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-05-23 15:26:42 +02:00
|
|
|
default:
|
|
|
|
if (*p > HDR_max)
|
2009-01-18 12:29:24 +01:00
|
|
|
uSvc->printf("\tUnrecognized option %d, length %d\n", p[0], p[1]);
|
2001-05-23 15:26:42 +02:00
|
|
|
else
|
2009-01-18 12:29:24 +01:00
|
|
|
uSvc->printf("\tEncoded option %d, length %d\n", p[0], p[1]);
|
2001-05-23 15:26:42 +02:00
|
|
|
break;
|
|
|
|
}
|
2003-12-05 11:35:47 +01:00
|
|
|
}
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2008-01-16 08:55:28 +01:00
|
|
|
uSvc->printf("\t*END*\n");
|
2001-05-23 15:26:42 +02:00
|
|
|
}
|