mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 00:03:02 +01:00
Misc & style.
This commit is contained in:
parent
e16d8ddee2
commit
4d468895ea
@ -83,9 +83,9 @@ Syntax and notes :
|
||||
if <role_name> is omitted, NULL or equal to CURRENT_ROLE value
|
||||
then trusted autentication is performed, and
|
||||
a1) for current connection (ON EXTERNAL DATA SOURCE is omitted) -
|
||||
CURRENT_USER\CURRENT_ROLE is effective user account and role
|
||||
CURRENT_USER/CURRENT_ROLE is effective user account and role
|
||||
a2) for local database (<connection_string> refers to the current database) -
|
||||
CURRENT_USER\CURRENT_ROLE is effective user account and role
|
||||
CURRENT_USER/CURRENT_ROLE is effective user account and role
|
||||
a3) for remote database - operating system account under which engine
|
||||
process is currently run is effective user account.
|
||||
b) else only isc_dpb_user_name (and isc_dpb_sql_role_name) will be present in DPB and
|
||||
|
@ -294,8 +294,8 @@ void Connection::generateDPB(thread_db* tdbb, ClumpletWriter& dpb,
|
||||
{
|
||||
dpb.reset(isc_dpb_version1);
|
||||
|
||||
string& attUser = tdbb->getAttachment()->att_user->usr_user_name;
|
||||
string& attRole = tdbb->getAttachment()->att_user->usr_sql_role_name;
|
||||
const string& attUser = tdbb->getAttachment()->att_user->usr_user_name;
|
||||
const string& attRole = tdbb->getAttachment()->att_user->usr_sql_role_name;
|
||||
|
||||
if ((m_provider.getFlags() & prvTrustedAuth) &&
|
||||
(user.isEmpty() || user == attUser) && pwd.isEmpty() &&
|
||||
|
@ -559,7 +559,7 @@ void InternalBlob::create(thread_db* tdbb, Transaction& tran, dsc& desc, const U
|
||||
{
|
||||
EngineCallbackGuard guard(tdbb, m_connection);
|
||||
|
||||
USHORT bpb_len = bpb ? bpb->getCount() : 0;
|
||||
const USHORT bpb_len = bpb ? bpb->getCount() : 0;
|
||||
const UCHAR* bpb_buff = bpb ? bpb->begin() : NULL;
|
||||
|
||||
jrd8_create_blob2(status, &att, &transaction, &m_blob, &m_blob_id,
|
||||
|
@ -71,7 +71,8 @@ void IscProvider::getRemoteError(ISC_STATUS* status, string& err) const
|
||||
err = "";
|
||||
|
||||
char buff[512];
|
||||
ISC_STATUS* p = status, *end = status + ISC_STATUS_LENGTH;
|
||||
ISC_STATUS* p = status;
|
||||
const ISC_STATUS* const end = status + ISC_STATUS_LENGTH;
|
||||
while (p < end)
|
||||
{
|
||||
const ISC_STATUS code = *p ? p[1] : 0;
|
||||
@ -556,7 +557,7 @@ void IscBlob::create(thread_db* tdbb, Transaction& tran, dsc& desc, const UCharB
|
||||
{
|
||||
EngineCallbackGuard guard(tdbb, m_iscConnection);
|
||||
|
||||
short bpb_len = bpb ? bpb->getCount() : 0;
|
||||
ISC_USHORT bpb_len = bpb ? bpb->getCount() : 0;
|
||||
const char* bpb_buff = bpb ? reinterpret_cast<const char*>(bpb->begin()) : NULL;
|
||||
|
||||
m_iscProvider.isc_create_blob2(status, &h_db, &h_tran, &m_handle, &m_blob_id,
|
||||
@ -1521,7 +1522,7 @@ static void parseSQLDA(XSQLDA* xsqlda, UCharBuffer& buff, Firebird::Array<dsc> &
|
||||
XSQLVAR* xVar = xsqlda->sqlvar;
|
||||
for (; i < xsqlda->sqld; xVar++, i++)
|
||||
{
|
||||
UCHAR dtype = sqlTypeToDscType(xVar->sqltype & ~1);
|
||||
const UCHAR dtype = sqlTypeToDscType(xVar->sqltype & ~1);
|
||||
xVar->sqltype |= 1;
|
||||
|
||||
if (type_alignments[dtype])
|
||||
@ -1545,7 +1546,7 @@ static void parseSQLDA(XSQLDA* xsqlda, UCharBuffer& buff, Firebird::Array<dsc> &
|
||||
xVar = xsqlda->sqlvar;
|
||||
for (i = 0; i < xsqlda->sqld; xVar++, i++)
|
||||
{
|
||||
UCHAR dtype = sqlTypeToDscType(xVar->sqltype & ~1);
|
||||
const UCHAR dtype = sqlTypeToDscType(xVar->sqltype & ~1);
|
||||
if (type_alignments[dtype])
|
||||
offset = FB_ALIGN(offset, type_alignments[dtype]);
|
||||
|
||||
|
@ -65,9 +65,9 @@ static PAG db_read(SLONG);
|
||||
static FILE *trace;
|
||||
static int file;
|
||||
|
||||
/* Physical IO trace events */
|
||||
// Physical IO trace events
|
||||
|
||||
const SSHORT trace_create = 1;
|
||||
//const SSHORT trace_create = 1;
|
||||
const SSHORT trace_open = 2;
|
||||
const SSHORT trace_page_size = 3;
|
||||
const SSHORT trace_read = 4;
|
||||
@ -116,7 +116,6 @@ void main( int argc, char **argv)
|
||||
struct tms before;
|
||||
time_t elapsed = times(&before);
|
||||
|
||||
SLONG n;
|
||||
SCHAR string[128] = "";
|
||||
|
||||
const pag* page;
|
||||
@ -128,7 +127,7 @@ void main( int argc, char **argv)
|
||||
case trace_open:
|
||||
{
|
||||
const SLONG length = getc(trace);
|
||||
n = length;
|
||||
SLONG n = length;
|
||||
SCHAR* p = string;
|
||||
while (--n >= 0)
|
||||
*p++ = getc(trace);
|
||||
@ -144,23 +143,27 @@ void main( int argc, char **argv)
|
||||
break;
|
||||
|
||||
case trace_read:
|
||||
n = get_long();
|
||||
if (n < MAX_PAGES)
|
||||
++read_counts[n];
|
||||
{
|
||||
const SLONG n = get_long();
|
||||
if (n < MAX_PAGES)
|
||||
++read_counts[n];
|
||||
|
||||
if (detail && (page = db_read(n)))
|
||||
analyse(n, "Read", page, ++sequence);
|
||||
reads++;
|
||||
if (detail && (page = db_read(n)))
|
||||
analyse(n, "Read", page, ++sequence);
|
||||
reads++;
|
||||
}
|
||||
break;
|
||||
|
||||
case trace_write:
|
||||
n = get_long();
|
||||
if (n < MAX_PAGES)
|
||||
++write_counts[n];
|
||||
{
|
||||
const SLONG n = get_long();
|
||||
if (n < MAX_PAGES)
|
||||
++write_counts[n];
|
||||
|
||||
if (detail && (page = db_read(n)))
|
||||
analyse(n, "Write", page, ++sequence);
|
||||
writes++;
|
||||
if (detail && (page = db_read(n)))
|
||||
analyse(n, "Write", page, ++sequence);
|
||||
writes++;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -183,6 +186,7 @@ void main( int argc, char **argv)
|
||||
printf("High activity pages:\n");
|
||||
|
||||
const USHORT *r, *w;
|
||||
SLONG n;
|
||||
for (r = read_counts, w = write_counts, n = 0; n < MAX_PAGES; n++, r++, w++)
|
||||
{
|
||||
if (*r > 1 || *w > 1) {
|
||||
|
@ -54,9 +54,9 @@ int CLIB_ROUTINE main( int argc, char **argv)
|
||||
*
|
||||
**************************************/
|
||||
|
||||
/* Perform some special handling when run as a Firebird service. The
|
||||
first switch can be "-svc" (lower case!) or it can be "-svc_re" followed
|
||||
by 3 file descriptors to use in re-directing stdin, stdout, and stderr. */
|
||||
// Perform some special handling when run as a Firebird service. The
|
||||
// first switch can be "-svc" (lower case!) or it can be "-svc_re" followed
|
||||
// by 3 file descriptors to use in re-directing stdin, stdout, and stderr.
|
||||
|
||||
if (argc > 1 && !strcmp(argv[1], "-svc"))
|
||||
{
|
||||
@ -95,12 +95,12 @@ int CLIB_ROUTINE main( int argc, char **argv)
|
||||
setpgrp();
|
||||
#else
|
||||
setpgrp(0, 0);
|
||||
#endif /* SETPGRP_VOID */
|
||||
#endif // SETPGRP_VOID
|
||||
#else
|
||||
#ifdef HAVE_SETPGID
|
||||
setpgid(0, 0);
|
||||
#endif /* HAVE_SETPGID */
|
||||
#endif /* HAVE_SETPGRP */
|
||||
#endif // HAVE_SETPGID
|
||||
#endif // HAVE_SETPGRP
|
||||
|
||||
signal(SIGINT, SIG_IGN);
|
||||
signal(SIGQUIT, SIG_IGN);
|
||||
|
@ -69,8 +69,8 @@ static void dummy_init();
|
||||
static int shm_exclusive(SLONG, SLONG);
|
||||
#endif
|
||||
|
||||
static int orig_argc;
|
||||
static SCHAR **orig_argv;
|
||||
//static int orig_argc;
|
||||
//static SCHAR **orig_argv;
|
||||
|
||||
|
||||
int CLIB_ROUTINE main( int argc, char *argv[])
|
||||
@ -90,8 +90,8 @@ int CLIB_ROUTINE main( int argc, char *argv[])
|
||||
bool sw_version = false;
|
||||
bool sw_shutmngr = false;
|
||||
|
||||
orig_argc = argc;
|
||||
orig_argv = argv;
|
||||
//orig_argc = argc;
|
||||
//orig_argv = argv;
|
||||
|
||||
SCHAR** const end = argv + argc;
|
||||
while (++argv < end)
|
||||
@ -178,7 +178,7 @@ static SLONG get_key(const TEXT* filename)
|
||||
sprintf(expanded_filename, filename, ISC_get_host(hostname, sizeof(hostname)));
|
||||
#endif
|
||||
|
||||
/* Produce shared memory key for file */
|
||||
// Produce shared memory key for file
|
||||
|
||||
return ftok(expanded_filename, FTOK_KEY);
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ bool putFileFromArgument(char**& av, ClumpletWriter& spb, unsigned int tag)
|
||||
if (! *av)
|
||||
return false;
|
||||
|
||||
FILE* file = fopen(*av, "rb");
|
||||
FILE* const file = fopen(*av, "rb");
|
||||
if (!file) {
|
||||
(Arg::Gds(isc_fbsvcmgr_fp_open) << *av << Arg::OsError()).raise();
|
||||
}
|
||||
|
@ -128,12 +128,11 @@ namespace
|
||||
GlobalPtr<NbkStringsBuffer> nbkStringsBuffer;
|
||||
GlobalPtr<Mutex> nbkBufMutex;
|
||||
|
||||
/*
|
||||
HPUX has non-posix-conformant method to return error codes from posix_fadvise().
|
||||
Instead of error code, directly returned by function (like specified by posix),
|
||||
-1 is returned in case of error and errno is set. Luckily, we can easily detect it runtime.
|
||||
May be sometimes this function should be moved to fb_util namespace.
|
||||
*/
|
||||
// HPUX has non-posix-conformant method to return error codes from posix_fadvise().
|
||||
// Instead of error code, directly returned by function (like specified by posix),
|
||||
// -1 is returned in case of error and errno is set. Luckily, we can easily detect it runtime.
|
||||
// May be sometimes this function should be moved to fb_util namespace.
|
||||
|
||||
#ifdef HAVE_POSIX_FADVISE
|
||||
int fb_fadvise(int fd, off_t offset, size_t len, int advice)
|
||||
{
|
||||
@ -308,18 +307,22 @@ size_t NBackup::read_file(FILE_HANDLE &file, void *buffer, size_t bufsize)
|
||||
#ifdef WIN_NT
|
||||
DWORD bytesDone;
|
||||
if (!ReadFile(file, buffer, bufsize, &bytesDone, NULL))
|
||||
{
|
||||
b_error::raise(uSvc, "IO error (%d) reading file: %s",
|
||||
GetLastError(),
|
||||
&file == &dbase ? dbname.c_str() :
|
||||
&file == &backup ? bakname.c_str() : "unknown");
|
||||
}
|
||||
return bytesDone;
|
||||
#else
|
||||
const ssize_t res = read(file, buffer, bufsize);
|
||||
if (res < 0)
|
||||
{
|
||||
b_error::raise(uSvc, "IO error (%d) reading file: %s",
|
||||
errno,
|
||||
&file == &dbase ? dbname.c_str() :
|
||||
&file == &backup ? bakname.c_str() : "unknown");
|
||||
}
|
||||
return res;
|
||||
#endif
|
||||
}
|
||||
@ -337,10 +340,12 @@ void NBackup::write_file(FILE_HANDLE &file, void *buffer, size_t bufsize)
|
||||
}
|
||||
#else
|
||||
if (write(file, buffer, bufsize) != (ssize_t) bufsize)
|
||||
{
|
||||
b_error::raise(uSvc, "IO error (%d) writing file: %s",
|
||||
errno,
|
||||
&file == &dbase ? dbname.c_str() :
|
||||
&file == &backup ? bakname.c_str() : "unknown");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -361,10 +366,12 @@ void NBackup::seek_file(FILE_HANDLE &file, SINT64 pos)
|
||||
}
|
||||
#else
|
||||
if (lseek(file, pos, SEEK_SET) == (off_t) - 1)
|
||||
{
|
||||
b_error::raise(uSvc, "IO error (%d) seeking file: %s",
|
||||
errno,
|
||||
&file == &dbase ? dbname.c_str() :
|
||||
&file == &backup ? bakname.c_str() : "unknown");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -720,7 +727,8 @@ void NBackup::backup_database(int level, const PathName& fname)
|
||||
|
||||
if (fname.hasData())
|
||||
bakname = fname;
|
||||
else {
|
||||
else
|
||||
{
|
||||
// Let's generate nice new filename
|
||||
PathName begin, fil;
|
||||
PathUtils::splitLastComponent(begin, fil, database);
|
||||
@ -801,7 +809,8 @@ void NBackup::backup_database(int level, const PathName& fname)
|
||||
|
||||
// Write data to backup file
|
||||
ULONG backup_scn = header->hdr_header.pag_scn - 1;
|
||||
if (level) {
|
||||
if (level)
|
||||
{
|
||||
inc_header bh;
|
||||
memcpy(bh.signature, backup_signature, sizeof(backup_signature));
|
||||
bh.version = 1;
|
||||
@ -1001,7 +1010,8 @@ void NBackup::restore_database(const BackupFiles& files)
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
if (curLevel >= filecount) {
|
||||
close_database();
|
||||
fixup_database();
|
||||
@ -1066,7 +1076,8 @@ void NBackup::restore_database(const BackupFiles& files)
|
||||
#else
|
||||
// Use relatively small buffer to make use of prefetch and lazy flush
|
||||
char buffer[65536];
|
||||
while (true) {
|
||||
while (true)
|
||||
{
|
||||
const size_t bytesRead = read_file(backup, buffer, sizeof(buffer));
|
||||
if (bytesRead == 0)
|
||||
break;
|
||||
|
@ -94,14 +94,14 @@ static void event_list()
|
||||
{
|
||||
EVNT database_event = (EVNT) ((UCHAR*) database_que - OFFSET(EVNT, evnt_events));
|
||||
|
||||
/* Skip non-database entries */
|
||||
// Skip non-database entries
|
||||
|
||||
if (database_event->evnt_parent)
|
||||
continue;
|
||||
|
||||
/* Print out the magic name for the database, this name
|
||||
comes from the lock key_id for the database, on Unix
|
||||
this is comprised of the device number and inode */
|
||||
// Print out the magic name for the database, this name
|
||||
// comes from the lock key_id for the database, on Unix
|
||||
// this is comprised of the device number and inode
|
||||
|
||||
printf("Database: ");
|
||||
const UCHAR* p = (UCHAR *) database_event->evnt_name;
|
||||
@ -112,7 +112,7 @@ static void event_list()
|
||||
|
||||
{ // scope
|
||||
srq *interest_que;
|
||||
/* Print out the interest list for this event */
|
||||
// Print out the interest list for this event
|
||||
|
||||
SRQ_LOOP(database_event->evnt_interests, interest_que)
|
||||
{
|
||||
@ -127,7 +127,7 @@ static void event_list()
|
||||
}
|
||||
} // scope
|
||||
|
||||
/* Print out each event belonging to this database */
|
||||
// Print out each event belonging to this database
|
||||
|
||||
srq* que_inst;
|
||||
SRQ_LOOP(EVENT_header->evh_events, que_inst)
|
||||
@ -141,7 +141,7 @@ static void event_list()
|
||||
|
||||
{ // scope
|
||||
srq *interest_que;
|
||||
/* Print out the interest list for this event */
|
||||
// Print out the interest list for this event
|
||||
|
||||
SRQ_LOOP(event->evnt_interests, interest_que)
|
||||
{
|
||||
|
@ -42,8 +42,6 @@ int CLIB_ROUTINE main( int argc, char **argv)
|
||||
char buffer[512];
|
||||
char fname[512];
|
||||
ISC_STATUS_ARRAY status;
|
||||
isc_svc_handle svc_handle = NULL;
|
||||
char svc_name[256];
|
||||
|
||||
if (argc != 2 && argc != 1) {
|
||||
printf("Usage %s \n %s filename\n");
|
||||
@ -58,7 +56,10 @@ int CLIB_ROUTINE main( int argc, char **argv)
|
||||
|
||||
strcpy(buffer, fname);
|
||||
printf("Filename to dump pool info = %s \n", buffer);
|
||||
char svc_name[256];
|
||||
sprintf(svc_name, "localhost:anonymous");
|
||||
|
||||
isc_svc_handle svc_handle = NULL;
|
||||
if (isc_service_attach(status, 0, svc_name, &svc_handle, 0, NULL)) {
|
||||
printf("Failed to attach service\n");
|
||||
return 0;
|
||||
|
@ -24,7 +24,7 @@
|
||||
#ifndef UTILITIES_REBUI_PROTO_H
|
||||
#define UTILITIES_REBUI_PROTO_H
|
||||
|
||||
namespace Jrd {
|
||||
namespace Ods {
|
||||
struct pag;
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "../utilities/rebuild/rstor_proto.h"
|
||||
#include "../jrd/dmp_proto.h"
|
||||
#include "../jrd/gds_proto.h"
|
||||
#include "../common/utils_proto.h
|
||||
|
||||
#ifndef O_RDWR
|
||||
#include <fcntl.h>
|
||||
@ -53,30 +54,30 @@ const ULONG* tips;
|
||||
|
||||
FILE* dbg_file;
|
||||
|
||||
static void checksum(RBDB, ULONG, ULONG, bool);
|
||||
static USHORT compute_checksum(RBDB, PAG);
|
||||
static void checksum(rbdb*, ULONG, ULONG, bool);
|
||||
static USHORT compute_checksum(const rbdb*, PAG);
|
||||
static void db_error(int);
|
||||
static void dump(FILE *, RBDB, ULONG, ULONG, UCHAR);
|
||||
static void dump_tips(FILE *, RBDB);
|
||||
static void format_header(RBDB, header_page*, int, ULONG, ULONG, ULONG, ULONG);
|
||||
static void dump(FILE*, rbdb*, ULONG, ULONG, UCHAR);
|
||||
static void dump_tips(FILE*, rbdb*);
|
||||
static void format_header(const rbdb*, header_page*, int, ULONG, ULONG, ULONG, ULONG);
|
||||
static void format_index_root(index_root_page*, int, SSHORT, SSHORT);
|
||||
static void format_pointer(pointer_page*, int, SSHORT, SSHORT, bool, SSHORT, SLONG *);
|
||||
static void format_pip(page_inv_page*, int, int);
|
||||
static void format_tip(tx_inv_page*, int, SLONG);
|
||||
static void get_next_file(RBDB, header_page*);
|
||||
static void get_next_file(rbdb*, header_page*);
|
||||
static void get_range(TEXT***, const TEXT* const* const, ULONG*, ULONG*);
|
||||
static void get_switch(TEXT**, swc*);
|
||||
static header_page* open_database(RBDB, ULONG);
|
||||
static header_page* open_database(rbdb*, ULONG);
|
||||
static void print_db_header(FILE*, const header_page*);
|
||||
static void rebuild(RBDB);
|
||||
static void write_headers(FILE*, RBDB, ULONG, ULONG);
|
||||
static void rebuild(rbdb*);
|
||||
static void write_headers(FILE*, rbdb*, ULONG, ULONG);
|
||||
|
||||
static bool sw_rebuild;
|
||||
static bool sw_print;
|
||||
static bool sw_store;
|
||||
static bool sw_dump_pages;
|
||||
static bool sw_checksum;
|
||||
static bool sw_fudge;
|
||||
//static bool sw_fudge;
|
||||
static bool sw_fix;
|
||||
static bool sw_dump_tips;
|
||||
|
||||
@ -108,7 +109,7 @@ int main( int argc, char *argv[])
|
||||
|
||||
dbg_file = stdout;
|
||||
sw_rebuild = sw_print = sw_store = sw_dump_pages = sw_checksum = false;
|
||||
sw_dump_tips = sw_fudge = sw_fix = false;
|
||||
sw_dump_tips = /*sw_fudge = */ sw_fix = false;
|
||||
|
||||
ULONG c_lower_bound, c_upper_bound, d_lower_bound, d_upper_bound,
|
||||
p_lower_bound, p_upper_bound, pg_size;
|
||||
@ -118,10 +119,10 @@ int main( int argc, char *argv[])
|
||||
|
||||
const TEXT* const* const end = argv + argc;
|
||||
++argv;
|
||||
struct swc switch_space;
|
||||
swc switch_space;
|
||||
swc* token = &switch_space;
|
||||
|
||||
RBDB rbdb = NULL;
|
||||
rbdb* rbdb = NULL;
|
||||
header_page* header = NULL;
|
||||
TEXT* ascii_out = NULL;
|
||||
TEXT* db_in = NULL;
|
||||
@ -161,11 +162,12 @@ int main( int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
if (argv < end) {
|
||||
if (argv < end)
|
||||
{
|
||||
get_switch(argv, token);
|
||||
if (token->swc_switch)
|
||||
break;
|
||||
strcpy(out_file, token->swc_string);
|
||||
fb_utils::copy_terminate(out_file, token->swc_string, sizeof(out_file));
|
||||
ascii_out = out_file;
|
||||
argv++;
|
||||
}
|
||||
@ -192,14 +194,15 @@ int main( int argc, char *argv[])
|
||||
|
||||
if (db_in)
|
||||
{
|
||||
rbdb = (RBDB) RBDB_alloc((SLONG) (sizeof(struct rbdb) + strlen(db_in) + 1));
|
||||
rbdb = (rbdb*) RBDB_alloc((SLONG) (sizeof(struct rbdb) + strlen(db_in)));
|
||||
strcpy(rbdb->rbdb_file.fil_name, db_in);
|
||||
rbdb->rbdb_file.fil_length = strlen(db_in);
|
||||
if (header = open_database(rbdb, pg_size))
|
||||
get_next_file(rbdb, header);
|
||||
|
||||
/* some systems don't care for this write sharing stuff... */
|
||||
if (rbdb && (sw_dump_tips || sw_dump_pages)) {
|
||||
// some systems don't care for this write sharing stuff...
|
||||
if (rbdb && (sw_dump_tips || sw_dump_pages))
|
||||
{
|
||||
RBDB_close(rbdb);
|
||||
if (rbdb->rbdb_valid)
|
||||
tips = RMET_tips(db_in);
|
||||
@ -253,7 +256,7 @@ int main( int argc, char *argv[])
|
||||
|
||||
while (rbdb)
|
||||
{
|
||||
RBDB next_db = rbdb->rbdb_next;
|
||||
rbdb* const next_db = rbdb->rbdb_next;
|
||||
if (rbdb->rbdb_buffer1)
|
||||
gds__free(rbdb->rbdb_buffer1);
|
||||
if (rbdb->rbdb_buffer2)
|
||||
@ -267,7 +270,7 @@ int main( int argc, char *argv[])
|
||||
|
||||
|
||||
#ifdef HPUX
|
||||
PAG CCH_fetch(WIN * x, USHORT y, int z)
|
||||
PAG CCH_fetch(WIN* x, USHORT y, int z)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -284,7 +287,7 @@ PAG CCH_fetch(WIN * x, USHORT y, int z)
|
||||
}
|
||||
|
||||
|
||||
PAG CCH_release(WIN * x)
|
||||
PAG CCH_release(WIN* x)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -318,7 +321,7 @@ void* RBDB_alloc(SLONG size)
|
||||
}
|
||||
|
||||
|
||||
void RBDB_close( RBDB rbdb)
|
||||
void RBDB_close( rbdb* rbdb)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -334,7 +337,7 @@ void RBDB_close( RBDB rbdb)
|
||||
}
|
||||
|
||||
|
||||
void RBDB_open( RBDB rbdb)
|
||||
void RBDB_open( rbdb* rbdb)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -353,7 +356,7 @@ void RBDB_open( RBDB rbdb)
|
||||
}
|
||||
|
||||
|
||||
PAG RBDB_read(RBDB rbdb, SLONG page_number)
|
||||
PAG RBDB_read(rbdb* rbdb, SLONG page_number)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -387,7 +390,7 @@ PAG RBDB_read(RBDB rbdb, SLONG page_number)
|
||||
}
|
||||
|
||||
|
||||
void RBDB_write( RBDB rbdb, PAG page, SLONG page_number)
|
||||
void RBDB_write( rbdb* rbdb, PAG page, SLONG page_number)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -411,7 +414,7 @@ void RBDB_write( RBDB rbdb, PAG page, SLONG page_number)
|
||||
}
|
||||
|
||||
|
||||
static void checksum( RBDB rbdb, ULONG lower, ULONG upper, bool sw_fix)
|
||||
static void checksum( rbdb* rbdb, ULONG lower, ULONG upper, bool sw_fix)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -445,7 +448,7 @@ static void checksum( RBDB rbdb, ULONG lower, ULONG upper, bool sw_fix)
|
||||
}
|
||||
|
||||
|
||||
static USHORT compute_checksum( RBDB rbdb, PAG page)
|
||||
static USHORT compute_checksum( const rbdb* rbdb, PAG page)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -479,7 +482,7 @@ static USHORT compute_checksum( RBDB rbdb, PAG page)
|
||||
if (checksum)
|
||||
return checksum;
|
||||
|
||||
/* If the page is all zeros, return an artificial checksum */
|
||||
// If the page is all zeros, return an artificial checksum
|
||||
|
||||
for (p = (ULONG *) page; p < end;)
|
||||
{
|
||||
@ -487,7 +490,7 @@ static USHORT compute_checksum( RBDB rbdb, PAG page)
|
||||
return checksum;
|
||||
}
|
||||
|
||||
/* Page is all zeros -- invent a checksum */
|
||||
// Page is all zeros -- invent a checksum
|
||||
|
||||
return 12345;
|
||||
}
|
||||
@ -508,7 +511,7 @@ static void db_error( int status)
|
||||
}
|
||||
|
||||
|
||||
static void dump(FILE* file, RBDB rbdb, ULONG lower, ULONG upper, UCHAR pg_type)
|
||||
static void dump(FILE* file, rbdb* rbdb, ULONG lower, ULONG upper, UCHAR pg_type)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -545,8 +548,7 @@ static void dump(FILE* file, RBDB rbdb, ULONG lower, ULONG upper, UCHAR pg_type)
|
||||
sequence = 0;
|
||||
if (pg_type && (page->pag_type != pg_type))
|
||||
{
|
||||
printf("\nChanging page %d type from %d to %d\n", lower,
|
||||
page->pag_type, pg_type);
|
||||
fprintf(file, "\nChanging page %d type from %d to %d\n", lower, page->pag_type, pg_type);
|
||||
page->pag_type = pg_type;
|
||||
}
|
||||
DMP_fetched_page(page, lower, sequence, rbdb->rbdb_page_size);
|
||||
@ -555,16 +557,17 @@ static void dump(FILE* file, RBDB rbdb, ULONG lower, ULONG upper, UCHAR pg_type)
|
||||
while (!*p && p < end)
|
||||
++p;
|
||||
if (!*p)
|
||||
printf(" Page is all zeroes.\n");
|
||||
if (sw_fudge)
|
||||
RBDB_write(rbdb, page, lower);
|
||||
fprintf(file, " Page is all zeroes.\n");
|
||||
// This cannot be true because sw_fudge is never activated
|
||||
//if (sw_fudge)
|
||||
// RBDB_write(rbdb, page, lower);
|
||||
if (++lower > upper)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void dump_tips( FILE * file, RBDB rbdb)
|
||||
static void dump_tips( FILE* file, rbdb* rbdb)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -578,7 +581,7 @@ static void dump_tips( FILE * file, RBDB rbdb)
|
||||
*
|
||||
**************************************/
|
||||
if (!tips)
|
||||
printf("not enough database. Store headers and look there\n");
|
||||
fprintf(file, "not enough database. Store headers and look there\n");
|
||||
|
||||
PAG page;
|
||||
ULONG sequence = 1;
|
||||
@ -589,7 +592,7 @@ static void dump_tips( FILE * file, RBDB rbdb)
|
||||
}
|
||||
|
||||
|
||||
static void format_header(RBDB rbdb,
|
||||
static void format_header(const rbdb* rbdb,
|
||||
header_page* page,
|
||||
int page_size,
|
||||
ULONG oldest, ULONG active, ULONG next, ULONG imp)
|
||||
@ -685,15 +688,15 @@ static void format_pip( page_inv_page* page, int page_size, int last_flag)
|
||||
page->pag_type = pag_pages;
|
||||
page->pag_flags = 0;
|
||||
|
||||
/* Set all page bits to zero, indicating RBDB_allocated */
|
||||
// Set all page bits to zero, indicating RBDB_allocated
|
||||
|
||||
const SSHORT bytes = page_size - OFFSETA(page_inv_page*, pip_bits);
|
||||
memset(page->pip_bits, 0, bytes);
|
||||
|
||||
/* If this is the last pip, make sure the last page (which
|
||||
will become the next pip) is marked free. When the
|
||||
time comes to RBDB_allocate the next page, that page will
|
||||
be formatted as the next pip. */
|
||||
// If this is the last pip, make sure the last page (which
|
||||
// will become the next pip) is marked free. When the
|
||||
// time comes to RBDB_allocate the next page, that page will
|
||||
// be formatted as the next pip.
|
||||
|
||||
if (last_flag)
|
||||
page->pip_bits[bytes - 1] |= 1 << 7;
|
||||
@ -715,22 +718,20 @@ static void format_tip( tx_inv_page* page, int page_size, SLONG next_page)
|
||||
page->pag_type = pag_transactions;
|
||||
page->pag_flags = 0;
|
||||
|
||||
/* The "next" tip page number is included for redundancy, but is not actually
|
||||
read by the engine, so can be safely left zero. If known, it would nice
|
||||
to supply it.
|
||||
*/
|
||||
// The "next" tip page number is included for redundancy, but is not actually
|
||||
// read by the engine, so can be safely left zero. If known, it would nice
|
||||
// to supply it.
|
||||
|
||||
page->tip_next = next_page;
|
||||
|
||||
/* Code for committed transaction is 3, so just fill all
|
||||
bytes with -1 */
|
||||
// Code for committed transaction is 3, so just fill all bytes with -1
|
||||
|
||||
const SSHORT bytes = page_size - OFFSETA(tx_inv_page*, tip_transactions);
|
||||
memset(page->tip_transactions, -1, bytes);
|
||||
}
|
||||
|
||||
|
||||
static void get_next_file( RBDB rbdb, header_page* header)
|
||||
static void get_next_file( rbdb* rbdb, header_page* header)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -743,13 +744,13 @@ static void get_next_file( RBDB rbdb, header_page* header)
|
||||
* this database, get it now.
|
||||
*
|
||||
**************************************/
|
||||
RBDB* next = &rbdb->rbdb_next;
|
||||
rbdb** next = &rbdb->rbdb_next;
|
||||
const UCHAR* p = header->hdr_data;
|
||||
for (const UCHAR* const end = p + header->hdr_page_size; p < end && *p != HDR_end; p += 2 + p[1])
|
||||
{
|
||||
if (*p == HDR_file)
|
||||
{
|
||||
RBDB next_rbdb = (RBDB) RBDB_alloc(sizeof(rbdb) + (SSHORT) p[1]);
|
||||
rbdb* next_rbdb = (rbdb*) RBDB_alloc(sizeof(struct rbdb) + (SSHORT) p[1]);
|
||||
next_rbdb->rbdb_file.fil_length = (SSHORT) p[1];
|
||||
strncpy(next_rbdb->rbdb_file.fil_name, p + 2, (SSHORT) p[1]);
|
||||
*next = next_rbdb;
|
||||
@ -791,7 +792,8 @@ static void get_range(TEXT*** argv, const TEXT* const* const end, ULONG* lower,
|
||||
break;
|
||||
}
|
||||
*upper = *lower = (ULONG) atoi(token->swc_string);
|
||||
if (*p && (c == ':' || c == ',')) {
|
||||
if (*p && (c == ':' || c == ','))
|
||||
{
|
||||
if (*p == '*')
|
||||
*upper = BIG_NUMBER;
|
||||
else
|
||||
@ -807,13 +809,15 @@ static void get_range(TEXT*** argv, const TEXT* const* const end, ULONG* lower,
|
||||
if ((*token->swc_string == ':') || (*token->swc_string == ','))
|
||||
{
|
||||
const TEXT* p = token->swc_string;
|
||||
if (*++p) {
|
||||
if (*++p)
|
||||
{
|
||||
if (*p == '*')
|
||||
*upper = BIG_NUMBER;
|
||||
else
|
||||
*upper = (ULONG) atoi(p);
|
||||
}
|
||||
else if (*argv++ < end) {
|
||||
else if (*argv++ < end)
|
||||
{
|
||||
get_switch(*argv, token);
|
||||
if (token->swc_switch)
|
||||
return;
|
||||
@ -854,14 +858,14 @@ static void get_switch( TEXT** argv, swc* token)
|
||||
|
||||
if (token->swc_string[temp] == ',') {
|
||||
token->swc_string[temp] = '\0';
|
||||
token->swc_comma = true;
|
||||
//token->swc_comma = true;
|
||||
}
|
||||
else
|
||||
token->swc_comma = false;
|
||||
//else
|
||||
// token->swc_comma = false;
|
||||
}
|
||||
|
||||
|
||||
static header_page* open_database( RBDB rbdb, ULONG pg_size)
|
||||
static header_page* open_database( rbdb* rbdb, ULONG pg_size)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -890,7 +894,8 @@ static header_page* open_database( RBDB rbdb, ULONG pg_size)
|
||||
rbdb->rbdb_valid = false;
|
||||
}
|
||||
|
||||
if (header->hdr_ods_version != ODS_VERSION | ODS_TYPE_CURRENT) {
|
||||
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,
|
||||
@ -941,28 +946,19 @@ static void print_db_header( FILE* file, const header_page* header)
|
||||
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",
|
||||
header->hdr_oldest_transaction);
|
||||
fprintf(file, " Oldest transaction\t\t%ld\n", header->hdr_oldest_transaction);
|
||||
fprintf(file, " Oldest active\t\t%ld\n", header->hdr_oldest_active);
|
||||
fprintf(file, " Oldest snapshot\t\t%ld\n",
|
||||
header->hdr_oldest_snapshot);
|
||||
fprintf(file, " Next transaction\t\t%ld\n",
|
||||
header->hdr_next_transaction);
|
||||
fprintf(file, " Oldest snapshot\t\t%ld\n", header->hdr_oldest_snapshot);
|
||||
fprintf(file, " Next transaction\t\t%ld\n", header->hdr_next_transaction);
|
||||
|
||||
fprintf(file, " Data pages per pointer page\t%ld\n",
|
||||
gdbb->tdbb_database->dbb_dp_per_pp);
|
||||
fprintf(file, " Max records per page\t%ld\n",
|
||||
gdbb->tdbb_database->dbb_max_records);
|
||||
fprintf(file, " Data pages per pointer page\t%ld\n", gdbb->tdbb_database->dbb_dp_per_pp);
|
||||
fprintf(file, " Max records per page\t%ld\n", gdbb->tdbb_database->dbb_max_records);
|
||||
|
||||
/*
|
||||
fprintf (" Sequence number %d\n", header->hdr_sequence);
|
||||
fprintf (" Creation date \n", header->hdr_creation_date);
|
||||
*/
|
||||
//fprintf (" Sequence number %d\n", header->hdr_sequence);
|
||||
//fprintf (" Creation date \n", header->hdr_creation_date);
|
||||
|
||||
fprintf(file, " Next attachment ID\t\t%ld\n",
|
||||
header->hdr_attachment_id);
|
||||
fprintf(file, " Implementation ID\t\t%ld\n",
|
||||
header->hdr_implementation);
|
||||
fprintf(file, " Next attachment ID\t\t%ld\n", header->hdr_attachment_id);
|
||||
fprintf(file, " Implementation ID\t\t%ld\n", header->hdr_implementation);
|
||||
fprintf(file, " Shadow count\t\t%ld\n", header->hdr_shadow_count);
|
||||
|
||||
tm time;
|
||||
@ -972,8 +968,7 @@ fprintf (" Creation date \n", header->hdr_creation_date);
|
||||
FB_SHORT_MONTHS[time.tm_mon], time.tm_mday, time.tm_year + 1900,
|
||||
time.tm_hour, time.tm_min, time.tm_sec);
|
||||
fprintf(file, " Cache buffers\t\t%ld\n", header->hdr_cache_buffers);
|
||||
fprintf(file, " Bumped transaction\t\t%ld\n",
|
||||
header->hdr_bumped_transaction);
|
||||
fprintf(file, " Bumped transaction\t\t%ld\n", header->hdr_bumped_transaction);
|
||||
|
||||
fprintf(file, "\n Variable header data:\n");
|
||||
|
||||
@ -1032,8 +1027,7 @@ fprintf (" Creation date \n", header->hdr_creation_date);
|
||||
break;
|
||||
*/
|
||||
default:
|
||||
fprintf(file, "\tUnrecognized option %d, length %d\n", p[0],
|
||||
p[1]);
|
||||
fprintf(file, "\tUnrecognized option %d, length %d\n", p[0], p[1]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1041,7 +1035,7 @@ fprintf (" Creation date \n", header->hdr_creation_date);
|
||||
}
|
||||
|
||||
|
||||
static void rebuild( RBDB rbdb)
|
||||
static void rebuild( rbdb* rbdb)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -1056,18 +1050,17 @@ static void rebuild( RBDB rbdb)
|
||||
const ULONG page_size = rbdb->rbdb_page_size;
|
||||
pag* page = rbdb->rbdb_buffer1;
|
||||
const ULONG* page_numbers = PPG_NUMBERS;
|
||||
for (ULONG number = 5898; (number < 5899) && (page = RBDB_read(rbdb, number));
|
||||
number++)
|
||||
for (ULONG number = 5898; (number < 5899) && (page = RBDB_read(rbdb, number)); number++)
|
||||
{
|
||||
pointer_page* pointer = (pointer_page*) page;
|
||||
/* format_pointer (page, page_size, 25, 3, true, 37, page_numbers); */
|
||||
// format_pointer (page, page_size, 25, 3, true, 37, page_numbers);
|
||||
|
||||
RBDB_write(rbdb, page, number);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void write_headers(FILE* file, RBDB rbdb, ULONG lower, ULONG upper)
|
||||
static void write_headers(FILE* file, rbdb* rbdb, ULONG lower, ULONG upper)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -1079,7 +1072,7 @@ static void write_headers(FILE* file, RBDB rbdb, ULONG lower, ULONG upper)
|
||||
* Print out the page headers.
|
||||
*
|
||||
**************************************/
|
||||
pag* page;
|
||||
const pag* page;
|
||||
for (ULONG page_number = lower;
|
||||
(page_number <= upper) && (page = RBDB_read(rbdb, page_number));
|
||||
page_number++)
|
||||
@ -1089,109 +1082,94 @@ static void write_headers(FILE* file, RBDB rbdb, ULONG lower, ULONG upper)
|
||||
switch (page->pag_type)
|
||||
{
|
||||
case pag_header:
|
||||
fprintf(file, "header page, checksum %d\n",
|
||||
page->pag_checksum);
|
||||
fprintf(file, "header page, checksum %d\n", page->pag_checksum);
|
||||
print_db_header(file, (header_page*) page);
|
||||
break;
|
||||
|
||||
case pag_pages:
|
||||
{
|
||||
fprintf(file, "page inventory page, checksum %d\n",
|
||||
page->pag_checksum);
|
||||
page_inv_page* pip = (page_inv_page*) page;
|
||||
fprintf(file, "\tlowest free page %d\n\n", pip->pip_min);
|
||||
break;
|
||||
fprintf(file, "page inventory page, checksum %d\n", page->pag_checksum);
|
||||
const page_inv_page* pip = (page_inv_page*) page;
|
||||
fprintf(file, "\tlowest free page %d\n\n", pip->pip_min);
|
||||
}
|
||||
break;
|
||||
|
||||
case pag_transactions:
|
||||
fprintf(file, "TIP page, checksum %d\n", page->pag_checksum);
|
||||
fprintf(file, "\tnext tip for database %ld\n\n",
|
||||
((tx_inv_page*) page)->tip_next);
|
||||
fprintf(file, "\tnext tip for database %ld\n\n", ((tx_inv_page*) page)->tip_next);
|
||||
break;
|
||||
|
||||
case pag_pointer:
|
||||
{
|
||||
fprintf(file, "pointer page, checksum %d\n",
|
||||
page->pag_checksum);
|
||||
const pointer_page* pointer = (pointer_page*) page;
|
||||
fprintf(file,
|
||||
"\trelation %d, sequence %ld, next pip %ld, active slots %d\n",
|
||||
pointer->ppg_relation, pointer->ppg_sequence,
|
||||
pointer->ppg_next, pointer->ppg_count);
|
||||
fprintf(file,
|
||||
"\tfirst slot with space %d, last slot with space %d\n",
|
||||
pointer->ppg_min_space, pointer->ppg_max_space);
|
||||
fprintf(file, "\t%s\n",
|
||||
(pointer->pag_flags & ppg_eof) ?
|
||||
"last pointer for relation\n" : "");
|
||||
break;
|
||||
fprintf(file, "pointer page, checksum %d\n", page->pag_checksum);
|
||||
const pointer_page* pointer = (pointer_page*) page;
|
||||
fprintf(file, "\trelation %d, sequence %ld, next pip %ld, active slots %d\n",
|
||||
pointer->ppg_relation, pointer->ppg_sequence,
|
||||
pointer->ppg_next, pointer->ppg_count);
|
||||
fprintf(file, "\tfirst slot with space %d, last slot with space %d\n",
|
||||
pointer->ppg_min_space, pointer->ppg_max_space);
|
||||
fprintf(file, "\t%s\n",
|
||||
(pointer->pag_flags & ppg_eof) ? "last pointer for relation\n" : "");
|
||||
}
|
||||
break;
|
||||
|
||||
case pag_data:
|
||||
{
|
||||
fprintf(file, "data page, checksum %d\n", page->pag_checksum);
|
||||
const data_page* data = (data_page*) page;
|
||||
fprintf(file,
|
||||
"\trelation %d, sequence %ld, records on page %d\n",
|
||||
data->dpg_relation, data->dpg_sequence,
|
||||
data->dpg_count);
|
||||
fprintf(file, "\t%s%s%s%s\n",
|
||||
(data->pag_flags & dpg_orphan) ? "orphan " : "",
|
||||
(data->pag_flags & dpg_full) ? "full " : "",
|
||||
(data->pag_flags & dpg_large) ?
|
||||
"contains a large object" : "",
|
||||
(data->pag_flags) ? "\n" : "");
|
||||
break;
|
||||
fprintf(file, "data page, checksum %d\n", page->pag_checksum);
|
||||
const data_page* data = (data_page*) page;
|
||||
fprintf(file, "\trelation %d, sequence %ld, records on page %d\n",
|
||||
data->dpg_relation, data->dpg_sequence,
|
||||
data->dpg_count);
|
||||
fprintf(file, "\t%s%s%s%s\n",
|
||||
(data->pag_flags & dpg_orphan) ? "orphan " : "",
|
||||
(data->pag_flags & dpg_full) ? "full " : "",
|
||||
(data->pag_flags & dpg_large) ? "contains a large object" : "",
|
||||
(data->pag_flags) ? "\n" : "");
|
||||
}
|
||||
break;
|
||||
|
||||
case pag_root:
|
||||
{
|
||||
fprintf(file, "index root page, checksum %d\n",
|
||||
page->pag_checksum);
|
||||
const index_root_page* index_root = (index_root_page*) page;
|
||||
fprintf(file, "\trelation %d, number of indexes %d\n\n",
|
||||
index_root->irt_relation, index_root->irt_count);
|
||||
break;
|
||||
fprintf(file, "index root page, checksum %d\n", page->pag_checksum);
|
||||
const index_root_page* index_root = (index_root_page*) page;
|
||||
fprintf(file, "\trelation %d, number of indexes %d\n\n",
|
||||
index_root->irt_relation, index_root->irt_count);
|
||||
}
|
||||
break;
|
||||
|
||||
case pag_index:
|
||||
{
|
||||
fprintf(file, "btree page (bucket), checksum %d\n",
|
||||
page->pag_checksum);
|
||||
const btree_page* bucket = (btree_page*) page;
|
||||
fprintf(file, "\trelation %d, right sibling bucket: %ld,\n",
|
||||
bucket->btr_relation, bucket->btr_sibling);
|
||||
fprintf(file, "\tdata length %d, index id %d, level %d\n",
|
||||
bucket->btr_length, bucket->btr_id, bucket->btr_level);
|
||||
fprintf(file, "\t%s%s%s\n",
|
||||
(bucket->pag_flags & btr_leftmost) ? "leftmost " : "",
|
||||
(bucket->pag_flags & btr_not_prop) ?
|
||||
"all duplicates " : "",
|
||||
(bucket->Pag_flags & btr_marked) ?
|
||||
"marked for delete" : "");
|
||||
break;
|
||||
fprintf(file, "btree page (bucket), checksum %d\n", page->pag_checksum);
|
||||
const btree_page* bucket = (btree_page*) page;
|
||||
fprintf(file, "\trelation %d, right sibling bucket: %ld,\n",
|
||||
bucket->btr_relation, bucket->btr_sibling);
|
||||
fprintf(file, "\tdata length %d, index id %d, level %d\n",
|
||||
bucket->btr_length, bucket->btr_id, bucket->btr_level);
|
||||
fprintf(file, "\t%s%s%s\n",
|
||||
(bucket->pag_flags & btr_leftmost) ? "leftmost " : "",
|
||||
(bucket->pag_flags & btr_not_prop) ? "all duplicates " : "",
|
||||
(bucket->Pag_flags & btr_marked) ? "marked for delete" : "");
|
||||
}
|
||||
break;
|
||||
|
||||
case pag_blob:
|
||||
{
|
||||
fprintf(file, "blob page, checksum %d\n", page->pag_checksum);
|
||||
const blob_page* blob = (blob_page*) page;
|
||||
fprintf(file, "\tlead page: %ld, sequence: %ld, length: %d\n",
|
||||
blob->blp_lead_page, blob->blp_sequence,
|
||||
blob->blp_length);
|
||||
fprintf(file, "\tcontains %s\n",
|
||||
(blob->pag_flags & blp_pointers) ? "pointers" : "data");
|
||||
break;
|
||||
fprintf(file, "blob page, checksum %d\n", page->pag_checksum);
|
||||
const blob_page* blob = (blob_page*) page;
|
||||
fprintf(file, "\tlead page: %ld, sequence: %ld, length: %d\n",
|
||||
blob->blp_lead_page, blob->blp_sequence,
|
||||
blob->blp_length);
|
||||
fprintf(file, "\tcontains %s\n",
|
||||
(blob->pag_flags & blp_pointers) ? "pointers" : "data");
|
||||
}
|
||||
break;
|
||||
|
||||
case pag_ids:
|
||||
fprintf(file, "generator page, checksum %d\n\n",
|
||||
page->pag_checksum);
|
||||
fprintf(file, "generator page, checksum %d\n\n", page->pag_checksum);
|
||||
break;
|
||||
|
||||
case pag_log:
|
||||
fprintf(dbg_file, "write-ahead log info page, checksum %d\n\n",
|
||||
page->pag_checksum);
|
||||
fprintf(dbg_file, "write-ahead log info page, checksum %d\n\n", page->pag_checksum);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -16,6 +16,7 @@
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________.
|
||||
*/
|
||||
|
||||
#ifndef UTILITIES_REBUILD_H
|
||||
#define UTILITIES_REBUILD_H
|
||||
|
||||
@ -24,32 +25,35 @@
|
||||
|
||||
const ULONG BIG_NUMBER = (ULONG) -1;
|
||||
|
||||
typedef struct fil {
|
||||
struct fil
|
||||
{
|
||||
int fil_file;
|
||||
SSHORT fil_length;
|
||||
SCHAR fil_name[1];
|
||||
} *FIL;
|
||||
|
||||
typedef struct rbdb {
|
||||
ULONG rbdb_map_length;
|
||||
int rbdb_map_base;
|
||||
int rbdb_map_count;
|
||||
SCHAR *rbdb_map_region;
|
||||
SSHORT rbdb_page_size;
|
||||
bool rbdb_valid;
|
||||
SLONG rbdb_window_offset;
|
||||
SLONG rbdb_last_page;
|
||||
PAG rbdb_buffer1;
|
||||
PAG rbdb_buffer2;
|
||||
struct rbdb *rbdb_next;
|
||||
struct fil rbdb_file;
|
||||
} *RBDB;
|
||||
|
||||
struct swc {
|
||||
bool swc_switch;
|
||||
bool swc_comma;
|
||||
TEXT *swc_string;
|
||||
};
|
||||
|
||||
#endif /* UTILITIES_REBUILD_H */
|
||||
struct rbdb
|
||||
{
|
||||
ULONG rbdb_map_length;
|
||||
int rbdb_map_base;
|
||||
int rbdb_map_count;
|
||||
SCHAR* rbdb_map_region;
|
||||
SSHORT rbdb_page_size;
|
||||
bool rbdb_valid;
|
||||
SLONG rbdb_window_offset;
|
||||
SLONG rbdb_last_page;
|
||||
PAG rbdb_buffer1;
|
||||
PAG rbdb_buffer2; // allocated for not used?
|
||||
rbdb* rbdb_next;
|
||||
fil rbdb_file;
|
||||
};
|
||||
|
||||
struct swc
|
||||
{
|
||||
bool swc_switch;
|
||||
//bool swc_comma;
|
||||
TEXT* swc_string;
|
||||
};
|
||||
|
||||
#endif // UTILITIES_REBUILD_H
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
DATABASE DB = STATIC FILENAME "rebuild.fdb";
|
||||
|
||||
|
||||
ULONG *RMET_tips(TEXT * db_in)
|
||||
ULONG* RMET_tips(TEXT* db_in)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include "firebird.h"
|
||||
#include "../jrd/ibase.h"
|
||||
#include "../jrd/ods.h"
|
||||
#include "../utilities/rebuild/rebuild.h"
|
||||
#include "../utilities/rebuild/rebui_proto.h"
|
||||
#include "../utilities/rebuild/rstor_proto.h"
|
||||
@ -32,6 +33,8 @@ DATABASE DB = STATIC FILENAME "rebuild.fdb";
|
||||
|
||||
static void store_headers(RBDB);
|
||||
|
||||
using namespace Ods;
|
||||
|
||||
|
||||
void RSTORE( RBDB rbdb)
|
||||
{
|
||||
@ -79,14 +82,14 @@ static void store_headers( RBDB rbdb)
|
||||
* into a database.
|
||||
*
|
||||
**************************************/
|
||||
PAG page;
|
||||
header_page* header;
|
||||
BLP blob;
|
||||
BTR bucket;
|
||||
DPG data;
|
||||
IRT index_root;
|
||||
page_inv_page* pip;
|
||||
PPG pointer;
|
||||
const pag* page;
|
||||
const header_page* header;
|
||||
const blob_page* blob;
|
||||
const btree_page* bucket;
|
||||
const data_page* data;
|
||||
const index_root_page* index_root;
|
||||
const page_inv_page* pip;
|
||||
const pointer_page* pointer;
|
||||
ISC_QUAD temp;
|
||||
|
||||
ULONG page_number = 0;
|
||||
@ -173,7 +176,7 @@ static void store_headers( RBDB rbdb)
|
||||
break;
|
||||
|
||||
case pag_pointer:
|
||||
pointer = (PPG) page;
|
||||
pointer = (pointer_page*) page;
|
||||
P.PPG_NEXT.NULL = FALSE;
|
||||
P.PPG_COUNT.NULL = FALSE;
|
||||
P.PPG_MIN_SPACE.NULL = FALSE;
|
||||
@ -189,7 +192,7 @@ static void store_headers( RBDB rbdb)
|
||||
break;
|
||||
|
||||
case pag_data:
|
||||
data = (DPG) page;
|
||||
data = (data_page*) page;
|
||||
P.DPG_COUNT.NULL = FALSE;
|
||||
P.RELATION.NULL = FALSE;
|
||||
P.SEQUENCE.NULL = FALSE;
|
||||
@ -199,7 +202,7 @@ static void store_headers( RBDB rbdb)
|
||||
break;
|
||||
|
||||
case pag_root:
|
||||
index_root = (IRT) page;
|
||||
index_root = (index_root_page*) page;
|
||||
P.IRT_COUNT.NULL = FALSE;
|
||||
P.RELATION.NULL = FALSE;
|
||||
P.IRT_COUNT = index_root->irt_count;
|
||||
@ -207,7 +210,7 @@ static void store_headers( RBDB rbdb)
|
||||
break;
|
||||
|
||||
case pag_index:
|
||||
bucket = (BTR) page;
|
||||
bucket = (btree_page*) page;
|
||||
P.BTR_SIBLING.NULL = FALSE;
|
||||
P.BTR_LENGTH.NULL = FALSE;
|
||||
P.BTR_ID.NULL = FALSE;
|
||||
@ -221,7 +224,7 @@ static void store_headers( RBDB rbdb)
|
||||
break;
|
||||
|
||||
case pag_blob:
|
||||
blob = (BLP) page;
|
||||
blob = (blob_page*) page;
|
||||
P.BLP_LEAD_PAGE.NULL = FALSE;
|
||||
P.BLP_LENGTH.NULL = FALSE;
|
||||
P.SEQUENCE.NULL = FALSE;
|
||||
|
@ -61,17 +61,17 @@ int CLIB_ROUTINE main( int argc, char **argv)
|
||||
setpgrp();
|
||||
#else
|
||||
setpgrp(0, 0);
|
||||
#endif /* SETPGRP_VOID */
|
||||
#endif // SETPGRP_VOID
|
||||
#else
|
||||
#ifdef HAVE_SETPGID
|
||||
setpgid(0, 0);
|
||||
#endif /* HAVE_SETPGID */
|
||||
#endif /* HAVE_SETPGRP */
|
||||
#endif // HAVE_SETPGID
|
||||
#endif // HAVE_SETPGRP
|
||||
signal(SIGINT, SIG_IGN);
|
||||
signal(SIGQUIT, SIG_IGN);
|
||||
#endif /* !DEBUG */
|
||||
#endif // !DEBUG
|
||||
|
||||
/* Get the file descriptor ID - if it is present - make sure it's valid */
|
||||
// Get the file descriptor ID - if it is present - make sure it's valid
|
||||
int fd;
|
||||
if (argc < 2 || (!(fd = atoi(argv[1])) && strcmp(argv[1], "0")))
|
||||
fd = -1;
|
||||
@ -96,11 +96,11 @@ int CLIB_ROUTINE main( int argc, char **argv)
|
||||
if (fd == -1)
|
||||
exit(FINI_OK);
|
||||
|
||||
/* Close all files, except for the pipe input */
|
||||
// Close all files, except for the pipe input
|
||||
for (int n = 0; n < NOFILE; n++)
|
||||
{
|
||||
#ifdef DEV_BUILD
|
||||
/* Don't close stderr - we might need to report something */
|
||||
// Don't close stderr - we might need to report something
|
||||
if ((n != fd) && (n != 2))
|
||||
#else
|
||||
if (n != fd)
|
||||
@ -112,11 +112,10 @@ int CLIB_ROUTINE main( int argc, char **argv)
|
||||
while (read(fd, msg, sizeof(msg)) == sizeof(msg))
|
||||
{
|
||||
#ifdef DEV_BUILD
|
||||
/* This is #ifdef for DEV_BUILD just in case a V3 client will
|
||||
* attempt communication with this V4 version.
|
||||
*/
|
||||
// This is #ifdef for DEV_BUILD just in case a V3 client will
|
||||
// attempt communication with this V4 version.
|
||||
if (msg[2] != (msg[0] ^ msg[1])) {
|
||||
fprintf(stderr, "gds_relay received inconsistant message");
|
||||
fprintf(stderr, "gds_relay received inconsistent message");
|
||||
}
|
||||
#endif
|
||||
if (kill(msg[0], msg[1])) {
|
||||
|
@ -53,16 +53,18 @@ int CLIB_ROUTINE main( int argc, char *argv[])
|
||||
|
||||
char spb_buffer[2048];
|
||||
char* spb = spb_buffer;
|
||||
const char* const spb_end = spb_buffer + sizeof(spb_buffer) - 1;
|
||||
if (argc > 2)
|
||||
{
|
||||
*spb++ = isc_spb_version1;
|
||||
*spb++ = isc_spb_command_line;
|
||||
spb++;
|
||||
for (argv += 2, argc -= 2; argc--;) {
|
||||
for (const char* p = *argv++; *spb = *p++; spb++);
|
||||
for (argv += 2, argc -= 2; argc && spb < spb_end; --argc) {
|
||||
for (const char* p = *argv++; spb < spb_end && (*spb = *p++); spb++);
|
||||
*spb++ = ' ';
|
||||
}
|
||||
*--spb = 0;
|
||||
fb_assert(spb < spb_end);
|
||||
spb_buffer[2] = strlen(spb_buffer + 3);
|
||||
}
|
||||
|
||||
@ -100,12 +102,14 @@ int CLIB_ROUTINE main( int argc, char *argv[])
|
||||
{
|
||||
SSHORT len = gds__vax_integer(p + 1, 2);
|
||||
p += 2;
|
||||
while (len--) {
|
||||
while (len--)
|
||||
{
|
||||
p++;
|
||||
if (*p != '\001')
|
||||
putchar(*p);
|
||||
}
|
||||
if (*p++ == '\001') {
|
||||
if (*p++ == '\001')
|
||||
{
|
||||
send_buffer[0] = isc_info_svc_line;
|
||||
fgets(send_buffer + 3, sizeof(send_buffer) - 3, stdin);
|
||||
len = strlen(send_buffer + 3);
|
||||
|
@ -23,8 +23,8 @@
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _PATHNAME_H_
|
||||
#define _PATHNAME_H_
|
||||
#ifndef VULCAN_PATHNAME_H_
|
||||
#define VULCAN_PATHNAME_H_
|
||||
|
||||
#if defined _MSC_VER && _MSC_VER >= 1000
|
||||
#pragma once
|
||||
|
Loading…
Reference in New Issue
Block a user