"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/utilities/gstat/dba.epp" between
Firebird-3.0.2.32703-0.tar.bz2 and Firebird-3.0.4.33054-0.tar.bz2

About: Firebird is a relational database offering many ANSI SQL standard features.

dba.epp  (Firebird-3.0.2.32703-0.tar.bz2):dba.epp  (Firebird-3.0.4.33054-0.tar.bz2)
skipping to change at line 60 skipping to change at line 60
#include "../common/utils_proto.h" #include "../common/utils_proto.h"
#include "../common/classes/ClumpletWriter.h" #include "../common/classes/ClumpletWriter.h"
#include "../jrd/constants.h" #include "../jrd/constants.h"
#include "../jrd/ods_proto.h" #include "../jrd/ods_proto.h"
#include "../common/classes/MsgPrint.h" #include "../common/classes/MsgPrint.h"
#include "../common/classes/UserBlob.h" #include "../common/classes/UserBlob.h"
#include "../common/os/os_utils.h" #include "../common/os/os_utils.h"
#include "../common/StatusHolder.h" #include "../common/StatusHolder.h"
#include "../common/ThreadStart.h" #include "../common/ThreadStart.h"
#ifdef TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
using MsgFormat::SafeArg; using MsgFormat::SafeArg;
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
#ifdef HAVE_IO_H #ifdef HAVE_IO_H
#include <io.h> #include <io.h>
#endif #endif
skipping to change at line 173 skipping to change at line 184
SCHAR fil_string[1]; // Expanded file name SCHAR fil_string[1]; // Expanded file name
}; };
static char* alloc(size_t); static char* alloc(size_t);
static void analyze_blob(dba_rel*, const blh*, int length); static void analyze_blob(dba_rel*, const blh*, int length);
static void analyze_data(dba_rel*, bool); static void analyze_data(dba_rel*, bool);
static bool analyze_data_page(dba_rel*, const data_page*, bool); static bool analyze_data_page(dba_rel*, const data_page*, bool);
static ULONG analyze_fragments(dba_rel*, const rhdf*); static ULONG analyze_fragments(dba_rel*, const rhdf*);
static ULONG analyze_versions(dba_rel*, const rhdf*); static ULONG analyze_versions(dba_rel*, const rhdf*);
static void analyze_index(const dba_rel*, dba_idx*); static void analyze_index(const dba_rel*, dba_idx*);
static ULONG lastUsedPage(ULONG);
#if (defined WIN_NT) #if (defined WIN_NT)
static void db_error(SLONG); static void db_error(SLONG);
#else #else
static void db_error(int); static void db_error(int);
#endif #endif
static USHORT get_format_length(ISC_STATUS*, isc_db_handle, isc_tr_handle, ISC_Q UAD&); static USHORT get_format_length(ISC_STATUS*, isc_db_handle, isc_tr_handle, ISC_Q UAD&);
static dba_fil* db_open(const char*, USHORT); static dba_fil* db_open(const char*, USHORT);
skipping to change at line 308 skipping to change at line 320
return FB_SUCCESS; return FB_SUCCESS;
} }
void checkForShutdown(tdba* tddba) void checkForShutdown(tdba* tddba)
{ {
if (shutdownRequested) if (shutdownRequested)
{ {
dba_exit(FINI_OK, tddba); dba_exit(FINI_OK, tddba);
} }
} }
void getDateTime(char* datetime, FB_SIZE_T sizeof_datetime)
{
time_t t;
time(&t);
#if defined(HAVE_CTIME_R)
ctime_r(&t, datetime);
#elif defined(HAVE_CTIME_S)
ctime_s(datetime, sizeof_datetime, &t);
#else
error: missing thread-safe version of ctime()
#endif
}
} // namespace } // namespace
const USHORT GSTAT_MSG_FAC = 21; const USHORT GSTAT_MSG_FAC = 21;
int main_gstat(Firebird::UtilSvc* uSvc) int main_gstat(Firebird::UtilSvc* uSvc)
{ {
/********************************************** /**********************************************
* *
* m a i n _ g s t a t * m a i n _ g s t a t
* *
skipping to change at line 377 skipping to change at line 402
tdba thd_context(uSvc), *tddba; tdba thd_context(uSvc), *tddba;
tdba::putSpecific(tddba, &thd_context); tdba::putSpecific(tddba, &thd_context);
int exit_code = FINI_OK; int exit_code = FINI_OK;
const int argc = uSvc->argv.getCount(); const int argc = uSvc->argv.getCount();
const char** argv = uSvc->argv.begin(); const char** argv = uSvc->argv.begin();
ISC_STATUS* status_vector = NULL; ISC_STATUS* status_vector = NULL;
Firebird::DynamicStatusVector permStatus; Firebird::DynamicStatusVector permStatus;
bool fl_print_complete = false;
char datetime[32];
try { try {
tddba->dba_status = tddba->dba_status_vector; tddba->dba_status = tddba->dba_status_vector;
status_vector = tddba->dba_status; status_vector = tddba->dba_status;
if (argc == 1) // no parameters at all. if (argc == 1) // no parameters at all.
{ {
dba_error(45); // use gstat -? to get help' dba_error(45); // use gstat -? to get help'
} }
skipping to change at line 589 skipping to change at line 617
dba_fil* current = db_open(fileName.c_str(), fileName.length()); dba_fil* current = db_open(fileName.c_str(), fileName.length());
SCHAR temp[RAW_HEADER_SIZE]; SCHAR temp[RAW_HEADER_SIZE];
tddba->page_size = sizeof(temp); tddba->page_size = sizeof(temp);
tddba->global_buffer = (pag*) temp; tddba->global_buffer = (pag*) temp;
tddba->page_number = -1; tddba->page_number = -1;
const header_page* header = (const header_page*) db_read((SLONG) 0); const header_page* header = (const header_page*) db_read((SLONG) 0);
uSvc->started(); uSvc->started();
if (!Ods::isSupported(header->hdr_ods_version, header->hdr_ods_minor)) if (!Ods::isSupported(header))
{ {
const int oversion = (header->hdr_ods_version & ~ODS_FIREBIRD_FLA G); const int oversion = (header->hdr_ods_version & ~ODS_FIREBIRD_FLA G);
dba_error(3, SafeArg() << ODS_VERSION << oversion); dba_error(3, SafeArg() << ODS_VERSION << oversion);
// msg 3: Wrong ODS version, expected %d, encountered %d? // msg 3: Wrong ODS version, expected %d, encountered %d?
} }
char file_name[1024]; char file_name[1024];
fileName.copyTo(file_name, sizeof(file_name)); fileName.copyTo(file_name, sizeof(file_name));
dba_print(false, 6, SafeArg() << file_name); // msg 6: \nDatabase \"@1 \"\n
dba_print(false, 6, SafeArg() << file_name); // msg 6: \nDatabase \"%s getDateTime(datetime, sizeof(datetime));
\"\n dba_print(false, 59, SafeArg() << datetime); // msg 59: Gstat executio
n time @1
fl_print_complete = true;
tddba->page_size = header->hdr_page_size; tddba->page_size = header->hdr_page_size;
tddba->dp_per_pp = Ods::dataPagesPerPP(tddba->page_size); tddba->dp_per_pp = Ods::dataPagesPerPP(tddba->page_size);
tddba->max_records = Ods::maxRecsPerDP(tddba->page_size); tddba->max_records = Ods::maxRecsPerDP(tddba->page_size);
tddba->buffer1 = (pag*) alloc(tddba->page_size); tddba->buffer1 = (pag*) alloc(tddba->page_size);
tddba->buffer2 = (pag*) alloc(tddba->page_size); tddba->buffer2 = (pag*) alloc(tddba->page_size);
tddba->global_buffer = (pag*) alloc(tddba->page_size); tddba->global_buffer = (pag*) alloc(tddba->page_size);
tddba->page_number = -1; tddba->page_number = -1;
// gather continuation files // gather continuation files
skipping to change at line 682 skipping to change at line 713
bool hasCrypted() bool hasCrypted()
{ {
return enc > 0; return enc > 0;
} }
private: private:
ULONG enc, non; ULONG enc, non;
}; };
Statist data, index, blob, other; Statist data, index, blob, other;
for (page = 0; true; ++page) ULONG last = lastUsedPage(header->hdr_page_size);
for (page = 0; page <= last; ++page)
{ {
const pag* p = db_read(page, true); const pag* p = db_read(page, true);
if (!p) if (!p)
{ {
break; break;
} }
switch(p->pag_type) switch(p->pag_type)
{ {
case pag_data: case pag_data:
skipping to change at line 1127 skipping to change at line 1159
while (fb_interpret(s + 1, sizeof(s) - 1, &vector )) while (fb_interpret(s + 1, sizeof(s) - 1, &vector ))
tddba->uSvc->printf(true, "%s\n", s); tddba->uSvc->printf(true, "%s\n", s);
} }
} }
} }
// if there still exists a database handle, disconnect from the server // if there still exists a database handle, disconnect from the server
// This is isc_detach_database // This is isc_detach_database
FINISH; FINISH;
if (fl_print_complete)
{
getDateTime(datetime, sizeof(datetime));
dba_print(false, 60, SafeArg() << datetime); // msg 60: Gstat
completion time @1
}
uSvc->started(); uSvc->started();
dba_mem* alloced = tddba->head_of_mem_list; dba_mem* alloced = tddba->head_of_mem_list;
while (alloced != 0) while (alloced != 0)
{ {
delete[] alloced->memory; delete[] alloced->memory;
alloced = alloced->mem_next; alloced = alloced->mem_next;
} }
// close files // close files
open_files* open_file = tddba->head_of_files_list; open_files* open_file = tddba->head_of_files_list;
skipping to change at line 1170 skipping to change at line 1208
if ((exit_code != FINI_OK) && uSvc->isService() && tddba->dba_status[1]) if ((exit_code != FINI_OK) && uSvc->isService() && tddba->dba_status[1])
{ {
uSvc->initStatus(); uSvc->initStatus();
uSvc->setServiceStatus(tddba->dba_status); uSvc->setServiceStatus(tddba->dba_status);
} }
return exit_code; return exit_code;
} }
static ULONG lastUsedPage(ULONG pageSize)
{
const ULONG pipFirst = FIRST_PIP_PAGE;
ULONG pipLast = pipFirst;
ULONG pagesPerPIP = Ods::pagesPerPIP(pageSize);
ULONG bytesBitPIP = Ods::bytesBitPIP(pageSize);
page_inv_page* pip;
while (true)
{
const pag* page = db_read(pipLast, true);
if (page->pag_type != pag_pages)
{
tdba* tddba = tdba::getSpecific();
tddba->uSvc->printf(true, "Expected page inventory page %
" ULONGFORMAT, pipLast);
return 0;
}
pip = (page_inv_page*) page;
if (pip->pip_used != pagesPerPIP)
break;
UCHAR lastByte = pip->pip_bits[bytesBitPIP - 1];
if (lastByte & 0x80)
break;
if (pipLast == pipFirst)
pipLast = pagesPerPIP - 1;
else
pipLast += pagesPerPIP;
}
int last_bit = pip->pip_used;
int byte_num = last_bit / 8;
UCHAR mask = 1 << (last_bit % 8);
while (last_bit >= 0 && (pip->pip_bits[byte_num] & mask))
{
if (mask == 1)
{
mask = 0x80;
byte_num--;
//fb_assert(byte_num > -1); ???
}
else
mask >>= 1;
last_bit--;
}
return last_bit + (pipLast == pipFirst ? 0 : pipLast);
}
static char* alloc(size_t size) static char* alloc(size_t size)
{ {
/************************************** /**************************************
* *
* a l l o c * a l l o c
* *
************************************** **************************************
* *
* Functional description * Functional description
* Allocate and zero a piece of memory. * Allocate and zero a piece of memory.
 End of changes. 10 change blocks. 
4 lines changed or deleted 96 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)