mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-22 22:43:03 +01:00
Fixed #7800: Default publication status is not preserved after backup/restore
This commit is contained in:
parent
858d5b0c0d
commit
a6d322f1b2
@ -2517,6 +2517,7 @@ void write_database( const TEXT* dbb_file)
|
||||
FbLocalStatus status_vector;
|
||||
UCHAR buffer[256];
|
||||
Firebird::IRequest* req_handle1 = nullptr;
|
||||
Firebird::IRequest* req_handle2 = nullptr;
|
||||
|
||||
BurpGlobals* tdgbl = BurpGlobals::getSpecific();
|
||||
|
||||
@ -2619,6 +2620,23 @@ void write_database( const TEXT* dbb_file)
|
||||
ON_ERROR
|
||||
general_on_error();
|
||||
END_ERROR;
|
||||
|
||||
FOR (REQUEST_HANDLE req_handle2)
|
||||
PUB IN RDB$PUBLICATIONS
|
||||
WITH PUB.RDB$PUBLICATION_NAME EQ DEFAULT_PUBLICATION
|
||||
{
|
||||
fb_assert(PUB.RDB$SYSTEM_FLAG != 0);
|
||||
|
||||
if (!PUB.RDB$ACTIVE_FLAG.NULL)
|
||||
put_boolean(att_default_pub_active, PUB.RDB$ACTIVE_FLAG);
|
||||
|
||||
if (!PUB.RDB$AUTO_ENABLE.NULL)
|
||||
put_boolean(att_default_pub_auto_enable, PUB.RDB$AUTO_ENABLE);
|
||||
}
|
||||
END_FOR
|
||||
ON_ERROR
|
||||
general_on_error();
|
||||
END_ERROR
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2636,6 +2654,7 @@ void write_database( const TEXT* dbb_file)
|
||||
}
|
||||
|
||||
MISC_release_request_silent(req_handle1);
|
||||
MISC_release_request_silent(req_handle2);
|
||||
|
||||
put(tdgbl, att_end);
|
||||
}
|
||||
|
@ -257,6 +257,8 @@ enum att_type {
|
||||
att_database_sql_security_deprecated, // can be removed later
|
||||
att_replica_mode, // replica mode
|
||||
att_database_sql_security, // default sql security value
|
||||
att_default_pub_active, // default publication status
|
||||
att_default_pub_auto_enable,
|
||||
|
||||
// Relation attributes
|
||||
|
||||
@ -1065,6 +1067,8 @@ public:
|
||||
UCHAR* gbl_crypt_buffer;
|
||||
ULONG gbl_crypt_left;
|
||||
UCHAR* gbl_decompress;
|
||||
bool gbl_default_pub_active = false;
|
||||
bool gbl_default_pub_auto_enable = false;
|
||||
|
||||
burp_rel* relations;
|
||||
burp_pkg* packages;
|
||||
|
@ -198,7 +198,7 @@ static inline UCHAR get(BurpGlobals* tdgbl)
|
||||
return tdgbl->get();
|
||||
}
|
||||
|
||||
static inline FB_BOOLEAN get_boolean(BurpGlobals* tdgbl, bool deprecated)
|
||||
static inline FB_BOOLEAN get_boolean(BurpGlobals* tdgbl, bool deprecated = false)
|
||||
{
|
||||
if (!deprecated)
|
||||
{
|
||||
@ -531,6 +531,40 @@ int RESTORE_restore (const TEXT* file_name, const TEXT* database_name)
|
||||
MISC_release_request_silent(req_handle1);
|
||||
}
|
||||
|
||||
// If the default publication was backed up with non-default values,
|
||||
// update the table accorgingly.
|
||||
// NOTE: This change should be performed in the last transaction
|
||||
// of the restore process, to avoid generating a replication stream
|
||||
// before the database is restored successfully.
|
||||
|
||||
if ((tdgbl->gbl_default_pub_active || tdgbl->gbl_default_pub_auto_enable) &&
|
||||
tdgbl->runtimeODS >= DB_VERSION_DDL12)
|
||||
{
|
||||
FOR (REQUEST_HANDLE req_handle1)
|
||||
PUB IN RDB$PUBLICATIONS
|
||||
WITH PUB.RDB$PUBLICATION_NAME EQ DEFAULT_PUBLICATION
|
||||
{
|
||||
fb_assert(PUB.RDB$SYSTEM_FLAG != 0);
|
||||
|
||||
MODIFY PUB USING
|
||||
PUB.RDB$ACTIVE_FLAG.NULL = FALSE;
|
||||
PUB.RDB$ACTIVE_FLAG = tdgbl->gbl_default_pub_active ? 1 : 0;
|
||||
|
||||
PUB.RDB$AUTO_ENABLE.NULL = FALSE;
|
||||
PUB.RDB$AUTO_ENABLE = tdgbl->gbl_default_pub_auto_enable ? 1 : 0;
|
||||
END_MODIFY;
|
||||
ON_ERROR
|
||||
general_on_error();
|
||||
END_ERROR;
|
||||
}
|
||||
END_FOR;
|
||||
ON_ERROR
|
||||
general_on_error();
|
||||
END_ERROR;
|
||||
|
||||
MISC_release_request_silent(req_handle1);
|
||||
}
|
||||
|
||||
// Add missing privileges
|
||||
fix_missing_privileges(tdgbl);
|
||||
|
||||
@ -10496,6 +10530,28 @@ bool restore(BurpGlobals* tdgbl, Firebird::IProvider* provider, const TEXT* file
|
||||
}
|
||||
break;
|
||||
|
||||
case att_default_pub_active:
|
||||
if (tdgbl->RESTORE_format >= 11)
|
||||
tdgbl->gbl_default_pub_active = get_boolean(tdgbl);
|
||||
else
|
||||
{
|
||||
// Functions that use scan_next_attr initialize it to NO_SKIP using skip_init().
|
||||
// Here we don't use that logic, hence the first param to bad_attribute is hardcoded.
|
||||
bad_attribute(NO_SKIP, attribute, 352);
|
||||
}
|
||||
break;
|
||||
|
||||
case att_default_pub_auto_enable:
|
||||
if (tdgbl->RESTORE_format >= 11)
|
||||
tdgbl->gbl_default_pub_auto_enable = get_boolean(tdgbl);
|
||||
else
|
||||
{
|
||||
// Functions that use scan_next_attr initialize it to NO_SKIP using skip_init().
|
||||
// Here we don't use that logic, hence the first param to bad_attribute is hardcoded.
|
||||
bad_attribute(NO_SKIP, attribute, 352);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
SSHORT l = get(tdgbl);
|
||||
|
Loading…
Reference in New Issue
Block a user