mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 23:23:04 +01:00
Fixed CORE-1139. An ugly solution, but nbackup supposes that the delta file can be deleted by other processes. Sigh.
This commit is contained in:
parent
915e91905c
commit
5e0d0fe2b1
@ -812,7 +812,7 @@ ISC_STATUS GDS_ATTACH_DATABASE(ISC_STATUS* user_status,
|
||||
dbb->dbb_flags |= DBB_lck_init_done;
|
||||
INI_init();
|
||||
dbb->dbb_file =
|
||||
PIO_open(dbb, expanded_name, options.dpb_trace != 0, NULL, file_name);
|
||||
PIO_open(dbb, expanded_name, options.dpb_trace != 0, NULL, file_name, false);
|
||||
SHUT_init(dbb);
|
||||
PAG_header_init();
|
||||
INI_init2();
|
||||
@ -1946,7 +1946,7 @@ ISC_STATUS GDS_CREATE_DATABASE(ISC_STATUS* user_status,
|
||||
try
|
||||
{
|
||||
// try to create with overwrite = false
|
||||
dbb->dbb_file = PIO_create(dbb, expanded_name, false);
|
||||
dbb->dbb_file = PIO_create(dbb, expanded_name, false, false);
|
||||
}
|
||||
catch (Firebird::status_exception)
|
||||
{
|
||||
@ -1976,7 +1976,7 @@ ISC_STATUS GDS_CREATE_DATABASE(ISC_STATUS* user_status,
|
||||
{
|
||||
// file is a database and the user (SYSDBA or owner) has right to overwrite
|
||||
dbb->dbb_file =
|
||||
PIO_create(dbb, expanded_name, options.dpb_overwrite);
|
||||
PIO_create(dbb, expanded_name, options.dpb_overwrite, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -567,7 +567,7 @@ void BackupManager::begin_backup(thread_db* tdbb)
|
||||
}
|
||||
// Create file
|
||||
NBAK_TRACE(("Creating difference file %s", diff_name));
|
||||
diff_file = PIO_create(database, diff_name, true);
|
||||
diff_file = PIO_create(database, diff_name, true, true);
|
||||
#ifdef UNIX
|
||||
// adjust difference file access rights to make it match main DB ones
|
||||
if (diff_file && geteuid() == 0) {
|
||||
@ -1193,7 +1193,7 @@ bool BackupManager::actualize_state(thread_db* tdbb) throw()
|
||||
#endif
|
||||
try {
|
||||
NBAK_TRACE(("Open difference file"));
|
||||
diff_file = PIO_open(database, diff_name, false, NULL, diff_name);
|
||||
diff_file = PIO_open(database, diff_name, false, NULL, diff_name, true);
|
||||
} catch(const std::exception& ex) {
|
||||
#ifdef SUPERSERVER
|
||||
adjust_state_lock->leave();
|
||||
|
@ -36,7 +36,7 @@ struct blk;
|
||||
|
||||
int PIO_add_file(Jrd::Database*, Jrd::jrd_file*, const Firebird::PathName&, SLONG);
|
||||
void PIO_close(Jrd::jrd_file*);
|
||||
Jrd::jrd_file* PIO_create(Jrd::Database*, const Firebird::PathName&, bool);
|
||||
Jrd::jrd_file* PIO_create(Jrd::Database*, const Firebird::PathName&, bool, bool);
|
||||
int PIO_connection(const Firebird::PathName&);
|
||||
int PIO_expand(const TEXT*, USHORT, TEXT*, size_t);
|
||||
void PIO_flush(Jrd::jrd_file*);
|
||||
@ -45,7 +45,7 @@ void PIO_header(Jrd::Database*, SCHAR*, int);
|
||||
SLONG PIO_max_alloc(Jrd::Database*);
|
||||
SLONG PIO_act_alloc(Jrd::Database*);
|
||||
Jrd::jrd_file* PIO_open(Jrd::Database*, const Firebird::PathName&, bool,
|
||||
blk*, const Firebird::PathName&);
|
||||
blk*, const Firebird::PathName&, bool);
|
||||
bool PIO_read(Jrd::jrd_file*, Jrd::BufferDesc*, Ods::pag*, ISC_STATUS*);
|
||||
|
||||
#ifdef SUPERSERVER_V2
|
||||
|
@ -159,7 +159,7 @@ int PIO_add_file(Database* dbb, jrd_file* main_file, const Firebird::PathName& f
|
||||
* have been locked before entry.
|
||||
*
|
||||
**************************************/
|
||||
jrd_file* new_file = PIO_create(dbb, file_name, false);
|
||||
jrd_file* new_file = PIO_create(dbb, file_name, false, false);
|
||||
if (!new_file)
|
||||
return 0;
|
||||
|
||||
@ -227,7 +227,7 @@ int PIO_connection(const Firebird::PathName& file_name)
|
||||
}
|
||||
|
||||
|
||||
jrd_file* PIO_create(Database* dbb, const Firebird::PathName& string, bool overwrite)
|
||||
jrd_file* PIO_create(Database* dbb, const Firebird::PathName& string, bool overwrite, bool share_delete)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -558,7 +558,8 @@ jrd_file* PIO_open(Database* dbb,
|
||||
const Firebird::PathName& string,
|
||||
bool trace_flag,
|
||||
blk* connection,
|
||||
const Firebird::PathName& file_name)
|
||||
const Firebird::PathName& file_name,
|
||||
bool share_delete)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
|
@ -108,7 +108,7 @@ int PIO_add_file(Database* dbb, jrd_file* main_file, const Firebird::PathName& f
|
||||
* sequence of 0.
|
||||
*
|
||||
**************************************/
|
||||
jrd_file* new_file = PIO_create(dbb, file_name, false);
|
||||
jrd_file* new_file = PIO_create(dbb, file_name, false, false);
|
||||
if (!new_file) {
|
||||
return 0;
|
||||
}
|
||||
@ -181,7 +181,7 @@ int PIO_connection(const Firebird::PathName& file_name)
|
||||
|
||||
|
||||
|
||||
jrd_file* PIO_create(Database* dbb, const Firebird::PathName& string, bool overwrite)
|
||||
jrd_file* PIO_create(Database* dbb, const Firebird::PathName& string, bool overwrite, bool share_delete)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -195,9 +195,12 @@ jrd_file* PIO_create(Database* dbb, const Firebird::PathName& string, bool overw
|
||||
**************************************/
|
||||
const TEXT* file_name = string.c_str();
|
||||
|
||||
if (!ISC_is_WinNT())
|
||||
share_delete = false;
|
||||
|
||||
const HANDLE desc = CreateFile(file_name,
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
g_dwShareFlags,
|
||||
g_dwShareFlags | (share_delete ? FILE_SHARE_DELETE : 0),
|
||||
NULL,
|
||||
(overwrite ? CREATE_ALWAYS : CREATE_NEW),
|
||||
FILE_ATTRIBUTE_NORMAL |
|
||||
@ -478,7 +481,8 @@ jrd_file* PIO_open(Database* dbb,
|
||||
const Firebird::PathName& string,
|
||||
bool trace_flag,
|
||||
blk* connection,
|
||||
const Firebird::PathName& file_name)
|
||||
const Firebird::PathName& file_name,
|
||||
bool share_delete)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -494,9 +498,12 @@ jrd_file* PIO_open(Database* dbb,
|
||||
**************************************/
|
||||
const TEXT* ptr = (string.hasData() ? string : file_name).c_str();
|
||||
|
||||
if (!ISC_is_WinNT())
|
||||
share_delete = false;
|
||||
|
||||
HANDLE desc = CreateFile(ptr,
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
g_dwShareFlags,
|
||||
g_dwShareFlags | (share_delete ? FILE_SHARE_DELETE : 0),
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL |
|
||||
@ -1070,18 +1077,19 @@ static jrd_file* setup_file(Database* dbb,
|
||||
if (!LCK_lock(NULL, lock, LCK_EX, LCK_NO_WAIT)) {
|
||||
dbb->dbb_flags &= ~DBB_exclusive;
|
||||
thread_db* tdbb = JRD_get_thread_data();
|
||||
|
||||
|
||||
while (!LCK_lock(tdbb, lock, LCK_SW, -1)) {
|
||||
tdbb->tdbb_status_vector[0] = 0; // Clean status vector from lock manager error code
|
||||
// If we are in a single-threaded maintenance mode then clean up and stop waiting
|
||||
SCHAR spare_memory[MIN_PAGE_SIZE*2];
|
||||
SCHAR *header_page_buffer = (SCHAR*) FB_ALIGN((IPTR)spare_memory, MIN_PAGE_SIZE);
|
||||
|
||||
SCHAR spare_memory[MIN_PAGE_SIZE * 2];
|
||||
SCHAR *header_page_buffer = (SCHAR*) FB_ALIGN((IPTR) spare_memory, MIN_PAGE_SIZE);
|
||||
Ods::header_page* header = reinterpret_cast<Ods::header_page*>(header_page_buffer);
|
||||
|
||||
try {
|
||||
dbb->dbb_file = file;
|
||||
PIO_header(dbb, header_page_buffer, MIN_PAGE_SIZE);
|
||||
if ((reinterpret_cast<Ods::header_page*>(header_page_buffer)->hdr_flags & Ods::hdr_shutdown_mask) == Ods::hdr_shutdown_single)
|
||||
ERR_post(isc_shutdown, isc_arg_cstring, file_name.length(), ERR_cstring(file_name), 0);
|
||||
if ((header->hdr_flags & Ods::hdr_shutdown_mask) == Ods::hdr_shutdown_single)
|
||||
ERR_post(isc_shutdown, isc_arg_string, ERR_string(file_name), 0);
|
||||
dbb->dbb_file = NULL; // Will be set again later by the caller
|
||||
} catch(const std::exception&) {
|
||||
delete dbb->dbb_lock;
|
||||
|
@ -1496,7 +1496,7 @@ void PAG_init2(USHORT shadow_number)
|
||||
isc_arg_end);
|
||||
}
|
||||
|
||||
file->fil_next = PIO_open(dbb, file_name, false, 0, file_name);
|
||||
file->fil_next = PIO_open(dbb, file_name, false, 0, file_name, false);
|
||||
file->fil_max_page = last_page;
|
||||
file = file->fil_next;
|
||||
if (dbb->dbb_flags & DBB_force_write)
|
||||
|
@ -92,7 +92,7 @@ void SDW_add(const TEXT* file_name, USHORT shadow_number, USHORT file_flags)
|
||||
isc_arg_end);
|
||||
}
|
||||
|
||||
jrd_file* shadow_file = PIO_create(dbb, file_name, false);
|
||||
jrd_file* shadow_file = PIO_create(dbb, file_name, false, false);
|
||||
|
||||
if (dbb->dbb_flags & DBB_force_write)
|
||||
PIO_force_write(shadow_file, true);
|
||||
@ -973,8 +973,7 @@ void SDW_start(const TEXT* file_name,
|
||||
|
||||
try {
|
||||
|
||||
shadow_file =
|
||||
PIO_open(dbb, expanded_name, false, 0, file_name);
|
||||
shadow_file = PIO_open(dbb, expanded_name, false, 0, file_name, false);
|
||||
|
||||
if (dbb->dbb_flags & DBB_force_write) {
|
||||
PIO_force_write(shadow_file, true);
|
||||
@ -1234,7 +1233,7 @@ static bool check_for_file(const SCHAR* name, USHORT length)
|
||||
// This use of PIO_open is NOT checked against DatabaseAccess configuration
|
||||
// parameter. It's not required, because here we only check for presence of
|
||||
// existing file, never really use (or create) it.
|
||||
jrd_file* temp_file = PIO_open(dbb, path, false, 0, path);
|
||||
jrd_file* temp_file = PIO_open(dbb, path, false, 0, path, false);
|
||||
PIO_close(temp_file);
|
||||
} // try
|
||||
catch (const std::exception& ex) {
|
||||
|
Loading…
Reference in New Issue
Block a user