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

Fixed CORE-5629: gstat output does not include datetime of analysis

This commit is contained in:
AlexPeshkoff 2017-11-14 14:04:57 +03:00
parent 7ab99eb3ba
commit 4eac3228fa
5 changed files with 40 additions and 2 deletions

View File

@ -957,6 +957,7 @@ AC_CHECK_FUNCS(pthread_keycreate pthread_key_create)
AC_CHECK_FUNCS(llrint)
AC_CHECK_FUNCS(localtime_r)
AC_CHECK_FUNCS(gmtime_r)
AC_CHECK_FUNCS(ctime_r)
AC_CHECK_FUNCS(fchmod)
AC_CHECK_FUNCS(semtimedop)
AC_CHECK_FUNCS(fegetenv)

View File

@ -197,6 +197,8 @@
#undef HAVE_LLRINT
#undef HAVE_LOCALTIME_R
#define HAVE_LOCALTIME_S
#undef HAVE_CTIME_R
#define HAVE_CTIME_S
#undef HAVE_GMTIME_R
#undef HAVE_SYS_SELECT_H

View File

@ -15,7 +15,7 @@ set bulk_insert INSERT INTO FACILITIES (LAST_CHANGE, FACILITY, FAC_CODE, MAX_NUM
('2006-09-10 03:04:31', 'JRD_BUGCHK', 15, 307)
('2016-05-26 13:53:45', 'ISQL', 17, 196)
('2010-07-10 10:50:30', 'GSEC', 18, 105)
('2017-03-09 21:51:33', 'GSTAT', 21, 59)
('2017-03-09 21:51:33', 'GSTAT', 21, 61)
('2013-12-19 17:31:31', 'FBSVCMGR', 22, 58)
('2009-07-18 12:12:12', 'UTL', 23, 2)
('2016-03-20 15:30:00', 'NBACKUP', 24, 80)

View File

@ -3326,6 +3326,8 @@ Analyzing database pages ...', NULL, NULL);
(NULL, 'main', 'dba.epp', NULL, 21, 56, NULL, ' Empty pages: @1, full pages: @2', NULL, NULL);
(NULL, 'dba_in_sw_table', 'dbaswi.h', NULL, 21, 57, NULL, ' -role SQL role name', NULL, NULL);
(NULL, 'main', 'dba.epp', NULL, 21, 58, NULL, 'Other pages: total @1, ENCRYPTED @2 (DB problem!), non-crypted @3', NULL, NULL)
(NULL, 'main', 'dba.epp', NULL, 21, 59, NULL, 'Gstat execution time @1', NULL, NULL)
(NULL, 'main', 'dba.epp', NULL, 21, 60, NULL, 'Gstat completion time @1', NULL, NULL)
-- FBSVCMGR
-- All messages use the new format.
('fbsvcmgr_bad_am', 'putAccessMode', 'fbsvcmgr.cpp', NULL, 22, 1, NULL, 'Wrong value for access mode', NULL, NULL);

View File

@ -58,6 +58,17 @@
#include "../common/StatusHolder.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;
@ -310,6 +321,19 @@ namespace
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
const USHORT GSTAT_MSG_FAC = 21;
@ -381,6 +405,9 @@ int gstat(Firebird::UtilSvc* uSvc)
ISC_STATUS* status_vector = NULL;
Firebird::DynamicStatusVector permStatus;
bool fl_print_complete = false;
char datetime[32];
try {
tddba->dba_status = tddba->dba_status_vector;
@ -602,8 +629,11 @@ int gstat(Firebird::UtilSvc* uSvc)
char file_name[1024];
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\"\n
getDateTime(datetime, sizeof(datetime));
dba_print(false, 59, SafeArg() << datetime); // msg 59: Gstat execution time @1
fl_print_complete = true;
tddba->page_size = header->hdr_page_size;
tddba->dp_per_pp = Ods::dataPagesPerPP(tddba->page_size);
@ -1132,6 +1162,9 @@ int gstat(Firebird::UtilSvc* uSvc)
// This is isc_detach_database
FINISH;
getDateTime(datetime, sizeof(datetime));
dba_print(false, 60, SafeArg() << datetime); // msg 60: Gstat completion time @1
uSvc->started();
dba_mem* alloced = tddba->head_of_mem_list;
while (alloced != 0)