From 1ddece969b6d031e333dd0a338c870ef91fc6756 Mon Sep 17 00:00:00 2001 From: AlexPeshkoff Date: Fri, 22 Mar 2019 17:55:54 +0300 Subject: [PATCH] Postfix for CORE-6028, thanks to Adriano --- src/burp/backup.epp | 11 +++-------- src/burp/burp.cpp | 37 ++++++++++++++++++------------------- src/burp/burp_proto.h | 1 + src/burp/restore.epp | 20 ++++++++++++++++++-- 4 files changed, 40 insertions(+), 29 deletions(-) diff --git a/src/burp/backup.epp b/src/burp/backup.epp index 425047b698..fd28489253 100644 --- a/src/burp/backup.epp +++ b/src/burp/backup.epp @@ -4179,14 +4179,9 @@ void write_triggers() if (tdgbl->runtimeODS >= DB_VERSION_DDL11_1) { FOR (REQUEST_HANDLE req_handle1) - X IN RDB$TRIGGERS - CROSS Y IN RDB$RELATIONS OVER RDB$RELATION_NAME - WITH - (X.RDB$SYSTEM_FLAG NE 1 OR - X.RDB$SYSTEM_FLAG MISSING) - AND - (Y.RDB$SYSTEM_FLAG NE 1 OR - Y.RDB$SYSTEM_FLAG MISSING) + X IN RDB$TRIGGERS WITH + X.RDB$SYSTEM_FLAG NE 1 OR + X.RDB$SYSTEM_FLAG MISSING put(tdgbl, rec_trigger); const SSHORT l = PUT_TEXT (att_trig_name, X.RDB$TRIGGER_NAME); diff --git a/src/burp/burp.cpp b/src/burp/burp.cpp index 0c02dee258..bd3873dcbb 100644 --- a/src/burp/burp.cpp +++ b/src/burp/burp.cpp @@ -111,7 +111,6 @@ static ULONG get_size(const SCHAR*, burp_fil*); static gbak_action open_files(const TEXT *, const TEXT**, USHORT, const Firebird::ClumpletWriter&); static int svc_api_gbak(Firebird::UtilSvc*, const Switches& switches); -static void burp_output(bool err, const SCHAR*, ...) ATTRIBUTE_FORMAT(2,3); static void burp_usage(const Switches& switches); static Switches::in_sw_tab_t* findSwitchOrThrow(Firebird::UtilSvc*, Switches& switches, Firebird::string& sw); @@ -392,7 +391,7 @@ static int svc_api_gbak(Firebird::UtilSvc* uSvc, const Switches& switches) fb_assert(p + len < respbuf + sizeof(respbuf)); p[len] = '\0'; - burp_output(false, "%s\n", p); + BURP_output(false, "%s\n", p); } } while (*sl == isc_info_svc_line); @@ -1472,7 +1471,7 @@ void BURP_msg_partial(bool err, USHORT number, const SafeArg& arg) TEXT buffer[256]; fb_msg_format(NULL, burp_msg_fac, number, sizeof(buffer), buffer, arg); - burp_output(err, "%s", buffer); + BURP_output(err, "%s", buffer); } @@ -1491,7 +1490,7 @@ void BURP_msg_put(bool err, USHORT number, const SafeArg& arg) TEXT buffer[256]; fb_msg_format(NULL, burp_msg_fac, number, sizeof(buffer), buffer, arg); - burp_output(err, "%s\n", buffer); + BURP_output(err, "%s\n", buffer); } @@ -1529,7 +1528,7 @@ void BURP_output_version(void* arg1, const TEXT* arg2) * **************************************/ - burp_output(false, static_cast(arg1), arg2); + BURP_output(false, static_cast(arg1), arg2); } @@ -1607,12 +1606,12 @@ void BURP_print_status(bool err, const ISC_STATUS* status_vector) if (fb_interpret(s, sizeof(s), &vector)) { BURP_msg_partial(err, 256); // msg 256: gbak: ERROR: - burp_output(err, "%s\n", s); + BURP_output(err, "%s\n", s); while (fb_interpret(s, sizeof(s), &vector)) { BURP_msg_partial(err, 256); // msg 256: gbak: ERROR: - burp_output(err, " %s\n", s); + BURP_output(err, " %s\n", s); } } } @@ -1645,12 +1644,12 @@ void BURP_print_warning(const ISC_STATUS* status_vector) if (fb_interpret(s, sizeof(s), &vector)) { BURP_msg_partial(false, 255); // msg 255: gbak: WARNING: - burp_output(false, "%s\n", s); + BURP_output(false, "%s\n", s); while (fb_interpret(s, sizeof(s), &vector)) { BURP_msg_partial(false, 255); // msg 255: gbak: WARNING: - burp_output(false, " %s\n", s); + BURP_output(false, " %s\n", s); } } } @@ -1681,7 +1680,7 @@ void BURP_verbose(USHORT number, const SafeArg& arg) BURP_msg_put(false, number, arg); } else - burp_output(false, "%s", ""); + BURP_output(false, "%s", ""); } @@ -1709,7 +1708,7 @@ void BURP_verbose(USHORT number, const char* str) BURP_msg_put(false, number, SafeArg() << str); } else - burp_output(false, "%s", ""); + BURP_output(false, "%s", ""); } @@ -2195,7 +2194,7 @@ static gbak_action open_files(const TEXT* file1, } -static void burp_output(bool err, const SCHAR* format, ...) +void BURP_output(bool err, const SCHAR* format, ...) { /************************************** * @@ -2504,7 +2503,7 @@ void BurpGlobals::print_stats(USHORT number) const bool total = (number == 369); // msg 369 total statistics - burp_output(false, " "); + BURP_output(false, " "); const int time_mask = (1 << TIME_TOTAL) | (1 << TIME_DELTA); if (gbl_stat_flags & time_mask) @@ -2515,13 +2514,13 @@ void BurpGlobals::print_stats(USHORT number) if (gbl_stat_flags & (1 << TIME_TOTAL)) { SINT64 t1 = (t0 - gbl_stats[TIME_TOTAL]) / freq_ms; - burp_output(false, STAT_FORMATS[TIME_TOTAL].format, (int)(t1 / 1000), (int)(t1 % 1000)); + BURP_output(false, STAT_FORMATS[TIME_TOTAL].format, (int)(t1 / 1000), (int)(t1 % 1000)); } if (gbl_stat_flags & (1 << TIME_DELTA)) { SINT64 t2 = (t0 - gbl_stats[TIME_DELTA]) / freq_ms; - burp_output(false, STAT_FORMATS[TIME_DELTA].format, (int)(t2 / 1000), (int)(t2 % 1000)); + BURP_output(false, STAT_FORMATS[TIME_DELTA].format, (int)(t2 / 1000), (int)(t2 % 1000)); gbl_stats[TIME_DELTA] = t0; } @@ -2543,7 +2542,7 @@ void BurpGlobals::print_stats(USHORT number) gbl_stats[i] = cur_stats[i]; - burp_output(false, STAT_FORMATS[i].format, val); + BURP_output(false, STAT_FORMATS[i].format, val); } } @@ -2559,15 +2558,15 @@ void BurpGlobals::print_stats_header() gbl_stat_header = true; BURP_msg_partial(false, 169); // msg 169: gbak: - burp_output(false, " "); + BURP_output(false, " "); for (int i = 0; i < LAST_COUNTER; i++) { if (gbl_stat_flags & (1 << i)) - burp_output(false, "%-*s", STAT_FORMATS[i].width, STAT_FORMATS[i].header); + BURP_output(false, "%-*s", STAT_FORMATS[i].width, STAT_FORMATS[i].header); } - burp_output(false, "\n"); + BURP_output(false, "\n"); } UnicodeCollationHolder::UnicodeCollationHolder(MemoryPool& pool) diff --git a/src/burp/burp_proto.h b/src/burp/burp_proto.h index b8487b86ae..c97539d0af 100644 --- a/src/burp/burp_proto.h +++ b/src/burp/burp_proto.h @@ -39,6 +39,7 @@ void BURP_msg_partial(bool, USHORT, const MsgFormat::SafeArg& arg = MsgFormat::S void BURP_msg_put(bool, USHORT, const MsgFormat::SafeArg& arg); const int BURP_MSG_GET_SIZE = 128; // Use it for buffers passed to this function. void BURP_msg_get(USHORT, TEXT*, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg()); +void BURP_output(bool err, const SCHAR*, ...) ATTRIBUTE_FORMAT(2,3); void BURP_output_version(void*, const TEXT*); void BURP_print(bool err, USHORT, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg()); void BURP_print(bool err, USHORT, const char* str); diff --git a/src/burp/restore.epp b/src/burp/restore.epp index 56061263d4..08ccfc16bd 100644 --- a/src/burp/restore.epp +++ b/src/burp/restore.epp @@ -8463,6 +8463,11 @@ bool get_trigger_old (BurpGlobals* tdgbl, burp_rel* relation) return true; } +void write_skip_message(const char* trigName, const char* relName) +{ + BURP_output(false, "gbak:Skipped trigger %s on system table %s\n", trigName, relName); +} + bool get_trigger(BurpGlobals* tdgbl) { /************************************** @@ -8477,6 +8482,7 @@ bool get_trigger(BurpGlobals* tdgbl) **************************************/ att_type attribute; BASED_ON RDB$TRIGGERS.RDB$TRIGGER_NAME name; + BASED_ON RDB$TRIGGERS.RDB$RELATION_NAME relName; scan_attr_t scan_next_attr; bool skipTrig = false; @@ -8546,10 +8552,12 @@ bool get_trigger(BurpGlobals* tdgbl) case att_trig_relation_name: X.RDB$RELATION_NAME.NULL = FALSE; GET_TEXT(X.RDB$RELATION_NAME); + strcpy (relName, X.RDB$RELATION_NAME); + // Check for trigger on system relation FOR (TRANSACTION_HANDLE local_trans REQUEST_HANDLE tdgbl->handles_get_trigger_req_handle2) Y IN RDB$RELATIONS - WITH Y.RDB$RELATION_NAME EQ X.RDB$RELATION_NAME + WITH Y.RDB$RELATION_NAME EQ relName AND Y.RDB$SYSTEM_FLAG EQ 1 skipTrig = true; @@ -8628,7 +8636,10 @@ bool get_trigger(BurpGlobals* tdgbl) // Skip trigger on system relation if (skipTrig) + { + write_skip_message(name, relName); return true; + } END_STORE; ON_ERROR @@ -8688,10 +8699,12 @@ bool get_trigger(BurpGlobals* tdgbl) case att_trig_relation_name: X.RDB$RELATION_NAME.NULL = FALSE; GET_TEXT(X.RDB$RELATION_NAME); + strcpy (relName, X.RDB$RELATION_NAME); + // Check for trigger on system relation FOR (TRANSACTION_HANDLE local_trans REQUEST_HANDLE tdgbl->handles_get_trigger_req_handle2) Y IN RDB$RELATIONS - WITH Y.RDB$RELATION_NAME EQ X.RDB$RELATION_NAME + WITH Y.RDB$RELATION_NAME EQ relName AND Y.RDB$SYSTEM_FLAG EQ 1 skipTrig = true; @@ -8759,7 +8772,10 @@ bool get_trigger(BurpGlobals* tdgbl) // Skip trigger on system relation if (skipTrig) + { + write_skip_message(name, relName); return true; + } END_STORE; ON_ERROR