8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 18:43:02 +01:00

Additional patch for #7269 (PR #8170):

- move more duplicated code into activateIndex,
- cache request that modifies RDB$INDICES.RDB$INDEX_INACTIVE.
This commit is contained in:
Vlad Khorsun 2024-10-24 14:26:05 +03:00
parent 6c1a95f045
commit ab50e20815
2 changed files with 15 additions and 29 deletions

View File

@ -1154,6 +1154,7 @@ public:
Firebird::IRequest* handles_get_type_req_handle1;
Firebird::IRequest* handles_get_user_privilege_req_handle1;
Firebird::IRequest* handles_get_view_req_handle1;
Firebird::IRequest* handles_activateIndex_req_handle1;
// The handles_put.. are for backup.
Firebird::IRequest* handles_put_index_req_handle1;

View File

@ -274,15 +274,18 @@ static inline void collect_missing_privs(BurpGlobals* tdgbl, USHORT type, const
} // namespace
bool activateIndex(BurpGlobals* tdgbl, const char* index_name, FbLocalStatus& local_status_vector)
void activateIndex(BurpGlobals* tdgbl, const char* index_name)
{
bool fError = false;
BURP_verbose(285, index_name);
// activating and creating deferred index %s
Firebird::IRequest* req_handle = nullptr;
Firebird::ITransaction* activateIndexTran = nullptr;
bool fError = false;
FbLocalStatus local_status_vector;
ITransaction* activateIndexTran = nullptr;
START_TRANSACTION activateIndexTran;
FOR (TRANSACTION_HANDLE activateIndexTran REQUEST_HANDLE req_handle)
FOR (TRANSACTION_HANDLE activateIndexTran REQUEST_HANDLE tdgbl->handles_activateIndex_req_handle1)
IND1 IN RDB$INDICES WITH IND1.RDB$INDEX_NAME EQ index_name
MODIFY IND1 USING
IND1.RDB$INDEX_INACTIVE = FALSE;
@ -294,8 +297,6 @@ bool activateIndex(BurpGlobals* tdgbl, const char* index_name, FbLocalStatus& lo
fb_utils::copyStatus(&local_status_vector, isc_status);
END_ERROR;
MISC_release_request_silent(req_handle);
if (!fError)
{
COMMIT activateIndexTran;
@ -307,14 +308,15 @@ bool activateIndex(BurpGlobals* tdgbl, const char* index_name, FbLocalStatus& lo
if (fError)
{
BURP_print(false, 173, index_name);
BURP_print_status(false, &local_status_vector);
tdgbl->flag_on_line = false;
ROLLBACK activateIndexTran;
ON_ERROR
general_on_error();
END_ERROR;
return false;
}
return true;
}
int RESTORE_restore (const TEXT* file_name, const TEXT* database_name)
@ -430,17 +432,8 @@ int RESTORE_restore (const TEXT* file_name, const TEXT* database_name)
MISC_terminate(IDS.RDB$INDEX_NAME, 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
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;
}
activateIndex(tdgbl, index_name);
END_FOR;
ON_ERROR
general_on_error ();
@ -474,16 +467,8 @@ int RESTORE_restore (const TEXT* file_name, const TEXT* database_name)
MISC_terminate(IDS.RDB$INDEX_NAME, 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
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;
}
activateIndex(tdgbl, index_name);
END_FOR;
ON_ERROR
general_on_error ();