From 950f499f12748c89090dc08d4d3e3e4d866fce89 Mon Sep 17 00:00:00 2001 From: alexpeshkoff Date: Sat, 3 Mar 2012 16:48:40 +0000 Subject: [PATCH] Backported fix for CORE-3649: gbak deletes backup file even if error happens when it's already successfully closed --- src/burp/backup.epp | 2 +- src/burp/burp.cpp | 7 ++++++- src/burp/burp.h | 1 + src/msgs/facilities2.sql | 2 +- src/msgs/messages2.sql | 9 +++++++++ 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/burp/backup.epp b/src/burp/backup.epp index 72ed86f0b8..8d022df713 100644 --- a/src/burp/backup.epp +++ b/src/burp/backup.epp @@ -523,8 +523,8 @@ int BACKUP_backup(const TEXT* dbb_file, const TEXT* file_name) // Finish up put(tdgbl, (UCHAR) rec_end); - FB_UINT64 cumul_count = MVOL_fini_write(&tdgbl->io_cnt, &tdgbl->io_ptr); + tdgbl->action->act_action = ACT_backup_fini; BURP_verbose(176, SafeArg() << cumul_count); // msg 176 closing file, committing, and finishing. %ld bytes written diff --git a/src/burp/burp.cpp b/src/burp/burp.cpp index 85868912f0..32e2872959 100644 --- a/src/burp/burp.cpp +++ b/src/burp/burp.cpp @@ -1107,6 +1107,10 @@ int gbak(Firebird::UtilSvc* uSvc) { // All calls to exit_local(), normal and error exits, wind up here tdgbl->burp_throw = false; + if (tdgbl->action->act_action == ACT_backup_fini) + { + tdgbl->exit_code = 0; + } exit_code = tdgbl->exit_code; } @@ -1183,7 +1187,8 @@ void BURP_abort() **************************************/ BurpGlobals* tdgbl = BurpGlobals::getSpecific(); - BURP_print(true, 83); + BURP_print(true, tdgbl->action->act_action == ACT_backup_fini ? 351 : 83); + // msg 351 Error closing database, but backup file is OK // msg 83 Exiting before completion due to errors tdgbl->uSvc->started(); diff --git a/src/burp/burp.h b/src/burp/burp.h index 20b10e917a..f2a86c2f74 100644 --- a/src/burp/burp.h +++ b/src/burp/burp.h @@ -764,6 +764,7 @@ enum act_t { ACT_unknown, // action is unknown ACT_backup, ACT_backup_split, + ACT_backup_fini, ACT_restore, ACT_restore_join }; diff --git a/src/msgs/facilities2.sql b/src/msgs/facilities2.sql index 4b74630074..2ef2422626 100644 --- a/src/msgs/facilities2.sql +++ b/src/msgs/facilities2.sql @@ -20,7 +20,7 @@ set bulk_insert INSERT INTO FACILITIES (LAST_CHANGE, FACILITY, FAC_CODE, MAX_NUM ('1996-11-07 13:39:40', 'INSTALL', 10, 1) ('1996-11-07 13:38:41', 'TEST', 11, 4) -- Reserved 326-334 by CVC for FB3 -('2009-11-19 11:48:00', 'GBAK', 12, 343) +('2012-03-03 19:55:44', 'GBAK', 12, 352) ('2009-06-05 23:07:00', 'SQLERR', 13, 970) ('1996-11-07 13:38:42', 'SQLWARN', 14, 613) ('2006-09-10 03:04:31', 'JRD_BUGCHK', 15, 307) diff --git a/src/msgs/messages2.sql b/src/msgs/messages2.sql index b756aea574..4c2b830076 100644 --- a/src/msgs/messages2.sql +++ b/src/msgs/messages2.sql @@ -2497,6 +2497,15 @@ ERROR: Backup incomplete', NULL, NULL); (NULL, 'burp_usage', 'burp.cpp', NULL, 12, 325, NULL, 'general options are:', NULL, NULL); ('gbak_invalid_metadata', 'general_on_error', 'restore.epp', NULL, 12, 341, NULL, 'Invalid metadata detected. Use -FIX_FSS_METADATA option.', NULL, NULL); ('gbak_invalid_data', 'get_data', 'restore.epp', NULL, 12, 342, NULL, 'Invalid data detected. Use -FIX_FSS_DATA option.', NULL, NULL); +(NULL, 'put_asciz', 'backup.epp', NULL, 12, 343, NULL, 'text for attribute @1 is too large in @2, truncating to @3 bytes', NULL, NULL); +(NULL, 'restore.epp', 'burp.cpp', 'do not change the param order', 12, 344, NULL, 'Expected backup version @2..@3. Found @1', NULL, NULL); +(NULL, 'write_relations', 'backup.epp', NULL, 12, 345, NULL, ' writing view @1', NULL, NULL); +(NULL, 'get_relation', 'restore.epp', NULL, 12, 346, NULL, ' table @1 is a view', NULL, NULL); +(NULL, 'write_secclasses', 'backup.epp', NULL, 12, 347, NULL, 'writing security classes', NULL, NULL); +(NULL, 'BACKUP_backup', 'backup.epp', NULL, 12, 348, NULL, 'database format @1 is too old to backup', NULL, NULL); +(NULL, 'restore', 'restore.epp', NULL, 12, 349, NULL, 'backup version is @1', NULL, NULL); +(NULL, 'fix_system_generators', 'restore.epp', NULL, 12, 350, NULL, 'fixing system generators', NULL, NULL); +(NULL, 'BURP_abort', 'burp.cpp', NULL, 12, 351, NULL, 'Error closing database, but backup file is OK', NULL, NULL); -- SQLERR (NULL, NULL, NULL, NULL, 13, 1, NULL, 'Firebird error', NULL, NULL); (NULL, NULL, NULL, NULL, 13, 74, NULL, 'Rollback not performed', NULL, NULL);