diff --git a/configure.ac b/configure.ac index 52020e3cca..9c040c2a0b 100644 --- a/configure.ac +++ b/configure.ac @@ -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) diff --git a/src/include/gen/autoconfig_msvc.h b/src/include/gen/autoconfig_msvc.h index bbbbf1724b..e131a992c0 100644 --- a/src/include/gen/autoconfig_msvc.h +++ b/src/include/gen/autoconfig_msvc.h @@ -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 diff --git a/src/msgs/facilities2.sql b/src/msgs/facilities2.sql index 88ea0173e7..800053e783 100644 --- a/src/msgs/facilities2.sql +++ b/src/msgs/facilities2.sql @@ -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) diff --git a/src/msgs/messages2.sql b/src/msgs/messages2.sql index e1ce68c6b7..452fc643b9 100644 --- a/src/msgs/messages2.sql +++ b/src/msgs/messages2.sql @@ -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); diff --git a/src/utilities/gstat/dba.epp b/src/utilities/gstat/dba.epp index 387fcb102e..296895d64e 100644 --- a/src/utilities/gstat/dba.epp +++ b/src/utilities/gstat/dba.epp @@ -58,6 +58,17 @@ #include "../common/StatusHolder.h" #include "../common/ThreadStart.h" +#ifdef TIME_WITH_SYS_TIME +# include +# include +#else +# ifdef HAVE_SYS_TIME_H +# include +# else +# include +# 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)