mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-22 15:23:03 +01:00
* fixed restore deferred primary key indexes Fixed database recovery aborting on the first failure of the first problematic deferred index gbak (#7269) * Extract function activateIndex Extracted "activateIndex" function to remove duplicate code when restoring the database
This commit is contained in:
parent
a1167b4431
commit
178d83a75e
@ -275,6 +275,48 @@ static inline void collect_missing_privs(BurpGlobals* tdgbl, USHORT type, const
|
||||
|
||||
} // namespace
|
||||
|
||||
bool activateIndex(BurpGlobals* tdgbl, const char* index_name, FbLocalStatus& local_status_vector)
|
||||
{
|
||||
bool fError = false;
|
||||
|
||||
Firebird::IRequest* req_handle = nullptr;
|
||||
Firebird::ITransaction* activateIndexTran = nullptr;
|
||||
START_TRANSACTION activateIndexTran;
|
||||
|
||||
FOR (TRANSACTION_HANDLE activateIndexTran REQUEST_HANDLE req_handle)
|
||||
IND1 IN RDB$INDICES WITH IND1.RDB$INDEX_NAME EQ index_name
|
||||
MODIFY IND1 USING
|
||||
IND1.RDB$INDEX_INACTIVE = FALSE;
|
||||
END_MODIFY;
|
||||
END_FOR;
|
||||
|
||||
ON_ERROR
|
||||
fError = true;
|
||||
fb_utils::copyStatus(&local_status_vector, isc_status);
|
||||
END_ERROR;
|
||||
|
||||
MISC_release_request_silent(req_handle);
|
||||
|
||||
if (!fError)
|
||||
{
|
||||
COMMIT activateIndexTran;
|
||||
ON_ERROR
|
||||
fError = true;
|
||||
fb_utils::copyStatus(&local_status_vector, isc_status);
|
||||
END_ERROR;
|
||||
}
|
||||
|
||||
if (fError)
|
||||
{
|
||||
ROLLBACK activateIndexTran;
|
||||
ON_ERROR
|
||||
general_on_error();
|
||||
END_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int RESTORE_restore (const TEXT* file_name, const TEXT* database_name)
|
||||
{
|
||||
@ -290,7 +332,6 @@ int RESTORE_restore (const TEXT* file_name, const TEXT* database_name)
|
||||
**************************************/
|
||||
Firebird::IRequest* req_handle1 = nullptr;
|
||||
Firebird::IRequest* req_handle3 = nullptr;
|
||||
Firebird::IRequest* req_handle5 = nullptr;
|
||||
BASED_ON RDB$INDICES.RDB$INDEX_NAME index_name;
|
||||
|
||||
Firebird::DispatcherPtr provider;
|
||||
@ -388,30 +429,19 @@ int RESTORE_restore (const TEXT* file_name, const TEXT* database_name)
|
||||
IDS.RDB$FOREIGN_KEY MISSING
|
||||
|
||||
MISC_terminate(IDS.RDB$INDEX_NAME, index_name,
|
||||
(ULONG) MISC_symbol_length(IDS.RDB$INDEX_NAME, sizeof(IDS.RDB$INDEX_NAME)),
|
||||
(ULONG)MISC_symbol_length(IDS.RDB$INDEX_NAME, sizeof(IDS.RDB$INDEX_NAME)),
|
||||
sizeof(index_name));
|
||||
BURP_verbose(285, index_name);
|
||||
// activating and creating deferred index %s
|
||||
MODIFY IDS USING
|
||||
IDS.RDB$INDEX_INACTIVE = FALSE;
|
||||
END_MODIFY;
|
||||
ON_ERROR
|
||||
general_on_error();
|
||||
END_ERROR;
|
||||
|
||||
SAVE
|
||||
// existing ON_ERROR continues past error, beck
|
||||
ON_ERROR
|
||||
BURP_print (false, 173, index_name);
|
||||
BURP_print_status(false, isc_status);
|
||||
MODIFY IDS USING
|
||||
IDS.RDB$INDEX_INACTIVE = TRUE;
|
||||
END_MODIFY;
|
||||
ON_ERROR
|
||||
general_on_error ();
|
||||
END_ERROR;
|
||||
FbLocalStatus local_status_vector;
|
||||
|
||||
if (!activateIndex(tdgbl, index_name, local_status_vector))
|
||||
{
|
||||
BURP_print(false, 173, index_name);
|
||||
BURP_print_status(false, &local_status_vector);
|
||||
tdgbl->flag_on_line = false;
|
||||
END_ERROR;
|
||||
}
|
||||
END_FOR;
|
||||
ON_ERROR
|
||||
general_on_error ();
|
||||
@ -447,39 +477,11 @@ int RESTORE_restore (const TEXT* file_name, const TEXT* database_name)
|
||||
sizeof(index_name));
|
||||
BURP_verbose(285, index_name);
|
||||
// activating and creating deferred index %s
|
||||
|
||||
bool fError = false;
|
||||
Firebird::ITransaction* activateIndexTran = nullptr;
|
||||
FbLocalStatus local_status_vector;
|
||||
|
||||
START_TRANSACTION activateIndexTran;
|
||||
FOR (TRANSACTION_HANDLE activateIndexTran REQUEST_HANDLE req_handle5)
|
||||
IND1 IN RDB$INDICES WITH IND1.RDB$INDEX_NAME EQ IDS.RDB$INDEX_NAME
|
||||
MODIFY IND1 USING
|
||||
IND1.RDB$INDEX_INACTIVE = FALSE;
|
||||
END_MODIFY;
|
||||
END_FOR;
|
||||
ON_ERROR
|
||||
fError = true;
|
||||
fb_utils::copyStatus(&local_status_vector, isc_status);
|
||||
END_ERROR;
|
||||
MISC_release_request_silent(req_handle5);
|
||||
|
||||
if (!fError)
|
||||
if (!activateIndex(tdgbl, index_name, local_status_vector))
|
||||
{
|
||||
COMMIT activateIndexTran;
|
||||
ON_ERROR
|
||||
fError = true;
|
||||
fb_utils::copyStatus(&local_status_vector, isc_status);
|
||||
END_ERROR;
|
||||
}
|
||||
if (fError)
|
||||
{
|
||||
ROLLBACK activateIndexTran;
|
||||
ON_ERROR
|
||||
general_on_error ();
|
||||
END_ERROR;
|
||||
BURP_print (false, 173, index_name);
|
||||
BURP_print(false, 173, index_name);
|
||||
BURP_print_status(false, &local_status_vector);
|
||||
tdgbl->flag_on_line = false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user