Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/burp/BurpTasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,8 @@ void RestoreRelationTask::initItem(BurpGlobals* tdgbl, Item& item)
tdgbl->verboseInterval = m_masterGbl->verboseInterval;
tdgbl->RESTORE_format = m_masterGbl->RESTORE_format;
tdgbl->runtimeODS = m_masterGbl->runtimeODS;
tdgbl->gbl_use_no_auto_undo = m_masterGbl->gbl_use_no_auto_undo;
tdgbl->gbl_use_auto_release_temp_blobid = m_masterGbl->gbl_use_auto_release_temp_blobid;

if (item.m_ownAttach)
{
Expand All @@ -893,7 +895,7 @@ void RestoreRelationTask::initItem(BurpGlobals* tdgbl, Item& item)
if (status->getState() & IStatus::STATE_ERRORS)
BURP_abort(&status);

// SET TRANSACTION NO_AUTO_UNDO, see at the end of get_data()
// SET TRANSACTION NO_AUTO_UNDO AUTO_RELEASE_TEMP_BLOBID, see at the end of get_data()

ClumpletWriter tpb(ClumpletReader::Tpb, 128, isc_tpb_version3);
tpb.insertTag(isc_tpb_concurrency);
Expand Down
3 changes: 3 additions & 0 deletions src/burp/burp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1227,6 +1227,9 @@ class BurpGlobals : public Firebird::ThreadData, public GblPool
bool gbl_stat_header; // true, if stats header was printed
bool gbl_stat_done; // true, if main process is done, stop to collect db-level stats
SINT64 gbl_stats[LAST_COUNTER];

bool gbl_use_no_auto_undo = true;
bool gbl_use_auto_release_temp_blobid = true;
};

// CVC: This aux routine declared here to not force inclusion of burp.h with burp_proto.h
Expand Down
103 changes: 67 additions & 36 deletions src/burp/restore.epp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ void update_ownership(BurpGlobals* tdgbl);
void update_view_dbkey_lengths(BurpGlobals* tdgbl);
void fix_missing_privileges(BurpGlobals* tdgbl);
void fix_system_generators(BurpGlobals* tdgbl);
void set_transaction(BurpGlobals* tdgbl);
void general_on_error();
#ifdef DEBUG
UCHAR debug_on = 0; // able to turn this on in the debugger
Expand Down Expand Up @@ -421,7 +422,7 @@ int RESTORE_restore (const TEXT* file_name, const TEXT* database_name)
// Block added to verbose index creation by Toni Martir
// Always try to activate deferred indices - it helps for some broken backups,
// and in normal cases doesn't take much time to look for such indices. AP-2008.
EXEC SQL SET TRANSACTION ISOLATION LEVEL READ COMMITTED NO_AUTO_UNDO AUTO_RELEASE_TEMP_BLOBID;
EXEC SQL SET TRANSACTION ISOLATION LEVEL READ COMMITTED NO_AUTO_UNDO;
if (gds_status->hasData())
EXEC SQL SET TRANSACTION;

Expand All @@ -445,7 +446,7 @@ int RESTORE_restore (const TEXT* file_name, const TEXT* database_name)
general_on_error ();
END_ERROR;

EXEC SQL SET TRANSACTION ISOLATION LEVEL READ COMMITTED NO_AUTO_UNDO AUTO_RELEASE_TEMP_BLOBID;
EXEC SQL SET TRANSACTION ISOLATION LEVEL READ COMMITTED NO_AUTO_UNDO;
if (gds_status->hasData())
EXEC SQL SET TRANSACTION;

Expand Down Expand Up @@ -481,7 +482,7 @@ int RESTORE_restore (const TEXT* file_name, const TEXT* database_name)
END_ERROR;
}

EXEC SQL SET TRANSACTION ISOLATION LEVEL READ COMMITTED NO_AUTO_UNDO AUTO_RELEASE_TEMP_BLOBID;
EXEC SQL SET TRANSACTION ISOLATION LEVEL READ COMMITTED NO_AUTO_UNDO;
if (gds_status->hasData())
EXEC SQL SET TRANSACTION;

Expand Down Expand Up @@ -745,9 +746,7 @@ void add_files(BurpGlobals* tdgbl, const char* file_name)
END_ERROR;
END_ERROR;

EXEC SQL SET TRANSACTION NO_AUTO_UNDO AUTO_RELEASE_TEMP_BLOBID;
if (gds_status->hasData())
EXEC SQL SET TRANSACTION;
set_transaction(tdgbl);
}
}

Expand Down Expand Up @@ -3166,9 +3165,7 @@ static void commit_relation_data(BurpGlobals* tdgbl, burp_rel* relation)
} // end of while
END_ERROR;

EXEC SQL SET TRANSACTION NO_AUTO_UNDO AUTO_RELEASE_TEMP_BLOBID;
if (gds_status->hasData())
EXEC SQL SET TRANSACTION;
set_transaction(tdgbl);
}

// We have a corrupt backup, save the restore process from becoming useless.
Expand Down Expand Up @@ -7777,9 +7774,7 @@ bool get_relation(BurpGlobals* tdgbl, Coordinator* coord, RestoreRelationTask* t
general_on_error ();
END_ERROR;

EXEC SQL SET TRANSACTION NO_AUTO_UNDO AUTO_RELEASE_TEMP_BLOBID;
if (gds_status->hasData())
EXEC SQL SET TRANSACTION;
set_transaction(tdgbl);
}

// Pick up relation attributes
Expand Down Expand Up @@ -8004,9 +7999,8 @@ bool get_relation(BurpGlobals* tdgbl, Coordinator* coord, RestoreRelationTask* t
general_on_error ();
END_ERROR;
END_ERROR;
EXEC SQL SET TRANSACTION NO_AUTO_UNDO AUTO_RELEASE_TEMP_BLOBID;
if (gds_status->hasData())
EXEC SQL SET TRANSACTION;

set_transaction(tdgbl);
}
return true;

Expand Down Expand Up @@ -8041,9 +8035,7 @@ bool get_relation(BurpGlobals* tdgbl, Coordinator* coord, RestoreRelationTask* t
general_on_error ();
END_ERROR;

EXEC SQL SET TRANSACTION NO_AUTO_UNDO AUTO_RELEASE_TEMP_BLOBID;
if (gds_status->hasData())
EXEC SQL SET TRANSACTION;
set_transaction(tdgbl);

// If we're only doing meta-data, ignore data records

Expand Down Expand Up @@ -9085,9 +9077,8 @@ bool get_trigger_old (BurpGlobals* tdgbl, burp_rel* relation)
general_on_error ();
END_ERROR;
END_ERROR;
EXEC SQL SET TRANSACTION NO_AUTO_UNDO AUTO_RELEASE_TEMP_BLOBID;
if (gds_status->hasData())
EXEC SQL SET TRANSACTION;

set_transaction(tdgbl);
}

return true;
Expand Down Expand Up @@ -9441,9 +9432,8 @@ bool get_trigger(BurpGlobals* tdgbl)
general_on_error ();
END_ERROR;
END_ERROR;
EXEC SQL SET TRANSACTION NO_AUTO_UNDO AUTO_RELEASE_TEMP_BLOBID;
if (gds_status->hasData())
EXEC SQL SET TRANSACTION;

set_transaction(tdgbl);
}

return true;
Expand Down Expand Up @@ -9537,9 +9527,8 @@ bool get_trigger_message(BurpGlobals* tdgbl)
general_on_error ();
END_ERROR;
END_ERROR;
EXEC SQL SET TRANSACTION NO_AUTO_UNDO AUTO_RELEASE_TEMP_BLOBID;
if (gds_status->hasData())
EXEC SQL SET TRANSACTION;

set_transaction(tdgbl);
}

return true;
Expand Down Expand Up @@ -10391,9 +10380,7 @@ bool restore(BurpGlobals* tdgbl, Firebird::IProvider* provider, const TEXT* file

create_database(tdgbl, provider, database_name);

EXEC SQL SET TRANSACTION NO_AUTO_UNDO AUTO_RELEASE_TEMP_BLOBID;
if (gds_status->hasData())
EXEC SQL SET TRANSACTION;
set_transaction(tdgbl);

// For V4.0, start a read commited transaction. This will be used
// to create blobs for global fields and update the record in the
Expand Down Expand Up @@ -10751,9 +10738,8 @@ bool restore(BurpGlobals* tdgbl, Firebird::IProvider* provider, const TEXT* file
ON_ERROR
general_on_error ();
END_ERROR;
EXEC SQL SET TRANSACTION NO_AUTO_UNDO AUTO_RELEASE_TEMP_BLOBID;
if (gds_status->hasData())
EXEC SQL SET TRANSACTION;

set_transaction(tdgbl);
flag = false;
}
if (!get_relation_data(tdgbl, &coord, &task))
Expand Down Expand Up @@ -10875,9 +10861,8 @@ bool restore(BurpGlobals* tdgbl, Firebird::IProvider* provider, const TEXT* file
ON_ERROR
general_on_error ();
END_ERROR;
EXEC SQL SET TRANSACTION NO_AUTO_UNDO AUTO_RELEASE_TEMP_BLOBID;
if (gds_status->hasData())
EXEC SQL SET TRANSACTION;

set_transaction(tdgbl);
}

// put validation clauses for global fields
Expand Down Expand Up @@ -11625,6 +11610,52 @@ void fix_system_generators(BurpGlobals* tdgbl)
}
}

void set_transaction(BurpGlobals* tdgbl)
{
/**************************************
*
* s e t _ t r a n s a c t i o n
*
**************************************
*
* Functional description
* Start a transaction with options
* supported by the target server.
*
**************************************/

while (true)
{
if (tdgbl->gbl_use_auto_release_temp_blobid && tdgbl->gbl_use_no_auto_undo)
{
EXEC SQL SET TRANSACTION NO_AUTO_UNDO AUTO_RELEASE_TEMP_BLOBID;
if (gds_status->hasData())
{
// First try to disable AUTO_RELEASE_TEMP_BLOBID transaction
// option because it was implemented later than NO_AUTO_UNDO
tdgbl->gbl_use_auto_release_temp_blobid = false;
continue;
}
}
else if (tdgbl->gbl_use_no_auto_undo)
{
EXEC SQL SET TRANSACTION NO_AUTO_UNDO;
if (gds_status->hasData())
{
tdgbl->gbl_use_no_auto_undo = false;
continue;
}
}
else
{
fb_assert(!tdgbl->gbl_use_auto_release_temp_blobid);
EXEC SQL SET TRANSACTION;
}

break;
}
}

} // namespace

namespace Burp
Expand Down