@@ -183,6 +183,7 @@ void update_ownership(BurpGlobals* tdgbl);
183183void update_view_dbkey_lengths(BurpGlobals* tdgbl);
184184void fix_missing_privileges(BurpGlobals* tdgbl);
185185void fix_system_generators(BurpGlobals* tdgbl);
186+ void set_transaction(BurpGlobals* tdgbl);
186187void general_on_error();
187188#ifdef DEBUG
188189UCHAR debug_on = 0; // able to turn this on in the debugger
@@ -421,7 +422,7 @@ int RESTORE_restore (const TEXT* file_name, const TEXT* database_name)
421422 // Block added to verbose index creation by Toni Martir
422423 // Always try to activate deferred indices - it helps for some broken backups,
423424 // and in normal cases doesn't take much time to look for such indices. AP-2008.
424- EXEC SQL SET TRANSACTION ISOLATION LEVEL READ COMMITTED NO_AUTO_UNDO AUTO_RELEASE_TEMP_BLOBID ;
425+ EXEC SQL SET TRANSACTION ISOLATION LEVEL READ COMMITTED NO_AUTO_UNDO;
425426 if (gds_status->hasData())
426427 EXEC SQL SET TRANSACTION;
427428
@@ -445,7 +446,7 @@ int RESTORE_restore (const TEXT* file_name, const TEXT* database_name)
445446 general_on_error ();
446447 END_ERROR;
447448
448- EXEC SQL SET TRANSACTION ISOLATION LEVEL READ COMMITTED NO_AUTO_UNDO AUTO_RELEASE_TEMP_BLOBID ;
449+ EXEC SQL SET TRANSACTION ISOLATION LEVEL READ COMMITTED NO_AUTO_UNDO;
449450 if (gds_status->hasData())
450451 EXEC SQL SET TRANSACTION;
451452
@@ -481,7 +482,7 @@ int RESTORE_restore (const TEXT* file_name, const TEXT* database_name)
481482 END_ERROR;
482483 }
483484
484- EXEC SQL SET TRANSACTION ISOLATION LEVEL READ COMMITTED NO_AUTO_UNDO AUTO_RELEASE_TEMP_BLOBID ;
485+ EXEC SQL SET TRANSACTION ISOLATION LEVEL READ COMMITTED NO_AUTO_UNDO;
485486 if (gds_status->hasData())
486487 EXEC SQL SET TRANSACTION;
487488
@@ -745,9 +746,7 @@ void add_files(BurpGlobals* tdgbl, const char* file_name)
745746 END_ERROR;
746747 END_ERROR;
747748
748- EXEC SQL SET TRANSACTION NO_AUTO_UNDO AUTO_RELEASE_TEMP_BLOBID;
749- if (gds_status->hasData())
750- EXEC SQL SET TRANSACTION;
749+ set_transaction(tdgbl);
751750 }
752751}
753752
@@ -3166,9 +3165,7 @@ static void commit_relation_data(BurpGlobals* tdgbl, burp_rel* relation)
31663165 } // end of while
31673166 END_ERROR;
31683167
3169- EXEC SQL SET TRANSACTION NO_AUTO_UNDO AUTO_RELEASE_TEMP_BLOBID;
3170- if (gds_status->hasData())
3171- EXEC SQL SET TRANSACTION;
3168+ set_transaction(tdgbl);
31723169}
31733170
31743171// We have a corrupt backup, save the restore process from becoming useless.
@@ -7777,9 +7774,7 @@ bool get_relation(BurpGlobals* tdgbl, Coordinator* coord, RestoreRelationTask* t
77777774 general_on_error ();
77787775 END_ERROR;
77797776
7780- EXEC SQL SET TRANSACTION NO_AUTO_UNDO AUTO_RELEASE_TEMP_BLOBID;
7781- if (gds_status->hasData())
7782- EXEC SQL SET TRANSACTION;
7777+ set_transaction(tdgbl);
77837778 }
77847779
77857780 // Pick up relation attributes
@@ -8004,9 +7999,8 @@ bool get_relation(BurpGlobals* tdgbl, Coordinator* coord, RestoreRelationTask* t
80047999 general_on_error ();
80058000 END_ERROR;
80068001 END_ERROR;
8007- EXEC SQL SET TRANSACTION NO_AUTO_UNDO AUTO_RELEASE_TEMP_BLOBID;
8008- if (gds_status->hasData())
8009- EXEC SQL SET TRANSACTION;
8002+
8003+ set_transaction(tdgbl);
80108004 }
80118005 return true;
80128006
@@ -8041,9 +8035,7 @@ bool get_relation(BurpGlobals* tdgbl, Coordinator* coord, RestoreRelationTask* t
80418035 general_on_error ();
80428036 END_ERROR;
80438037
8044- EXEC SQL SET TRANSACTION NO_AUTO_UNDO AUTO_RELEASE_TEMP_BLOBID;
8045- if (gds_status->hasData())
8046- EXEC SQL SET TRANSACTION;
8038+ set_transaction(tdgbl);
80478039
80488040 // If we're only doing meta-data, ignore data records
80498041
@@ -9085,9 +9077,8 @@ bool get_trigger_old (BurpGlobals* tdgbl, burp_rel* relation)
90859077 general_on_error ();
90869078 END_ERROR;
90879079 END_ERROR;
9088- EXEC SQL SET TRANSACTION NO_AUTO_UNDO AUTO_RELEASE_TEMP_BLOBID;
9089- if (gds_status->hasData())
9090- EXEC SQL SET TRANSACTION;
9080+
9081+ set_transaction(tdgbl);
90919082 }
90929083
90939084 return true;
@@ -9441,9 +9432,8 @@ bool get_trigger(BurpGlobals* tdgbl)
94419432 general_on_error ();
94429433 END_ERROR;
94439434 END_ERROR;
9444- EXEC SQL SET TRANSACTION NO_AUTO_UNDO AUTO_RELEASE_TEMP_BLOBID;
9445- if (gds_status->hasData())
9446- EXEC SQL SET TRANSACTION;
9435+
9436+ set_transaction(tdgbl);
94479437 }
94489438
94499439 return true;
@@ -9537,9 +9527,8 @@ bool get_trigger_message(BurpGlobals* tdgbl)
95379527 general_on_error ();
95389528 END_ERROR;
95399529 END_ERROR;
9540- EXEC SQL SET TRANSACTION NO_AUTO_UNDO AUTO_RELEASE_TEMP_BLOBID;
9541- if (gds_status->hasData())
9542- EXEC SQL SET TRANSACTION;
9530+
9531+ set_transaction(tdgbl);
95439532 }
95449533
95459534 return true;
@@ -10391,9 +10380,7 @@ bool restore(BurpGlobals* tdgbl, Firebird::IProvider* provider, const TEXT* file
1039110380
1039210381 create_database(tdgbl, provider, database_name);
1039310382
10394- EXEC SQL SET TRANSACTION NO_AUTO_UNDO AUTO_RELEASE_TEMP_BLOBID;
10395- if (gds_status->hasData())
10396- EXEC SQL SET TRANSACTION;
10383+ set_transaction(tdgbl);
1039710384
1039810385 // For V4.0, start a read commited transaction. This will be used
1039910386 // to create blobs for global fields and update the record in the
@@ -10751,9 +10738,8 @@ bool restore(BurpGlobals* tdgbl, Firebird::IProvider* provider, const TEXT* file
1075110738 ON_ERROR
1075210739 general_on_error ();
1075310740 END_ERROR;
10754- EXEC SQL SET TRANSACTION NO_AUTO_UNDO AUTO_RELEASE_TEMP_BLOBID;
10755- if (gds_status->hasData())
10756- EXEC SQL SET TRANSACTION;
10741+
10742+ set_transaction(tdgbl);
1075710743 flag = false;
1075810744 }
1075910745 if (!get_relation_data(tdgbl, &coord, &task))
@@ -10875,9 +10861,8 @@ bool restore(BurpGlobals* tdgbl, Firebird::IProvider* provider, const TEXT* file
1087510861 ON_ERROR
1087610862 general_on_error ();
1087710863 END_ERROR;
10878- EXEC SQL SET TRANSACTION NO_AUTO_UNDO AUTO_RELEASE_TEMP_BLOBID;
10879- if (gds_status->hasData())
10880- EXEC SQL SET TRANSACTION;
10864+
10865+ set_transaction(tdgbl);
1088110866 }
1088210867
1088310868 // put validation clauses for global fields
@@ -11625,6 +11610,52 @@ void fix_system_generators(BurpGlobals* tdgbl)
1162511610 }
1162611611}
1162711612
11613+ void set_transaction(BurpGlobals* tdgbl)
11614+ {
11615+ /**************************************
11616+ *
11617+ * s e t _ t r a n s a c t i o n
11618+ *
11619+ **************************************
11620+ *
11621+ * Functional description
11622+ * Start a transaction with options
11623+ * supported by the target server.
11624+ *
11625+ **************************************/
11626+
11627+ while (true)
11628+ {
11629+ if (tdgbl->gbl_use_auto_release_temp_blobid && tdgbl->gbl_use_no_auto_undo)
11630+ {
11631+ EXEC SQL SET TRANSACTION NO_AUTO_UNDO AUTO_RELEASE_TEMP_BLOBID;
11632+ if (gds_status->hasData())
11633+ {
11634+ // First try to disable AUTO_RELEASE_TEMP_BLOBID transaction
11635+ // option because it was implemented later than NO_AUTO_UNDO
11636+ tdgbl->gbl_use_auto_release_temp_blobid = false;
11637+ continue;
11638+ }
11639+ }
11640+ else if (tdgbl->gbl_use_no_auto_undo)
11641+ {
11642+ EXEC SQL SET TRANSACTION NO_AUTO_UNDO;
11643+ if (gds_status->hasData())
11644+ {
11645+ tdgbl->gbl_use_no_auto_undo = false;
11646+ continue;
11647+ }
11648+ }
11649+ else
11650+ {
11651+ fb_assert(!tdgbl->gbl_use_auto_release_temp_blobid);
11652+ EXEC SQL SET TRANSACTION;
11653+ }
11654+
11655+ break;
11656+ }
11657+ }
11658+
1162811659} // namespace
1162911660
1163011661namespace Burp
0 commit comments