nbackup.cpp (Firebird-3.0.2.32703-0.tar.bz2) | : | nbackup.cpp (Firebird-3.0.4.33054-0.tar.bz2) | ||
---|---|---|---|---|
skipping to change at line 671 | skipping to change at line 671 | |||
void NBackup::create_backup() | void NBackup::create_backup() | |||
{ | { | |||
string nm = to_system(bakname); | string nm = to_system(bakname); | |||
#ifdef WIN_NT | #ifdef WIN_NT | |||
if (bakname == "stdout") { | if (bakname == "stdout") { | |||
backup = GetStdHandle(STD_OUTPUT_HANDLE); | backup = GetStdHandle(STD_OUTPUT_HANDLE); | |||
} | } | |||
else | else | |||
{ | { | |||
backup = CreateFile(nm.c_str(), GENERIC_WRITE, FILE_SHARE_DELETE, | // See CORE-4913 and "Create File" article on MSDN: | |||
// When an application creates a file across a network, it is bet | ||||
ter to use | ||||
// GENERIC_READ | GENERIC_WRITE for dwDesiredAccess than to use G | ||||
ENERIC_WRITE | ||||
// alone. The resulting code is faster, because the redirector ca | ||||
n use the | ||||
// cache manager and send fewer SMBs with more data. This combina | ||||
tion also | ||||
// avoids an issue where writing to a file across a network can o | ||||
ccasionally | ||||
// return ERROR_ACCESS_DENIED. | ||||
backup = CreateFile(nm.c_str(), GENERIC_READ | GENERIC_WRITE, FIL | ||||
E_SHARE_DELETE, | ||||
NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUE NTIAL_SCAN, NULL); | NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUE NTIAL_SCAN, NULL); | |||
} | } | |||
if (backup != INVALID_HANDLE_VALUE) | if (backup != INVALID_HANDLE_VALUE) | |||
return; | return; | |||
#else | #else | |||
if (bakname == "stdout") | if (bakname == "stdout") | |||
{ | { | |||
backup = 1; // Posix file handle for stdout | backup = 1; // Posix file handle for stdout | |||
return; | return; | |||
} | } | |||
skipping to change at line 1038 | skipping to change at line 1046 | |||
// Read database header | // Read database header | |||
char unaligned_header_buffer[SECTOR_ALIGNMENT * 2]; | char unaligned_header_buffer[SECTOR_ALIGNMENT * 2]; | |||
Ods::header_page *header = reinterpret_cast<Ods::header_page*>( | Ods::header_page *header = reinterpret_cast<Ods::header_page*>( | |||
FB_ALIGN(unaligned_header_buffer, SECTOR_ALIGNMENT)); | FB_ALIGN(unaligned_header_buffer, SECTOR_ALIGNMENT)); | |||
if (read_file(dbase, header, SECTOR_ALIGNMENT/*sizeof(*header)*/) != SECTOR_ALIGNMENT/*sizeof(*header)*/) | if (read_file(dbase, header, SECTOR_ALIGNMENT/*sizeof(*header)*/) != SECTOR_ALIGNMENT/*sizeof(*header)*/) | |||
status_exception::raise(Arg::Gds(isc_nbackup_err_eofhdrdb ) << dbname.c_str() << Arg::Num(1)); | status_exception::raise(Arg::Gds(isc_nbackup_err_eofhdrdb ) << dbname.c_str() << Arg::Num(1)); | |||
if (!Ods::isSupported(header->hdr_ods_version, header->hdr_ods_mi nor)) | if (!Ods::isSupported(header)) | |||
{ | { | |||
const USHORT ods_version = header->hdr_ods_version & ~ODS _FIREBIRD_FLAG; | const USHORT ods_version = header->hdr_ods_version & ~ODS _FIREBIRD_FLAG; | |||
status_exception::raise(Arg::Gds(isc_wrong_ods) << Arg::S tr(database.c_str()) << | status_exception::raise(Arg::Gds(isc_wrong_ods) << Arg::S tr(database.c_str()) << | |||
Arg::Num( ods_version) << | Arg::Num( ods_version) << | |||
Arg::Num( header->hdr_ods_minor) << | Arg::Num( header->hdr_ods_minor) << | |||
Arg::Num( ODS_VERSION) << | Arg::Num( ODS_VERSION) << | |||
Arg::Num( ODS_CURRENT)); | Arg::Num( ODS_CURRENT)); | |||
} | } | |||
if ((header->hdr_flags & Ods::hdr_backup_mask) != Ods::hdr_nbak_s talled) | if ((header->hdr_flags & Ods::hdr_backup_mask) != Ods::hdr_nbak_s talled) | |||
skipping to change at line 1423 | skipping to change at line 1431 | |||
A rg::Num(bakheader.version) << bakname.c_str()); | A rg::Num(bakheader.version) << bakname.c_str()); | |||
} | } | |||
if (bakheader.level != curLevel) | if (bakheader.level != curLevel) | |||
{ | { | |||
status_exception::raise(Arg::Gds(isc_nbac kup_invlevel_incbk) << | status_exception::raise(Arg::Gds(isc_nbac kup_invlevel_incbk) << | |||
Arg::Num(bakheader.level) << bakn ame.c_str() << Arg::Num(curLevel)); | Arg::Num(bakheader.level) << bakn ame.c_str() << Arg::Num(curLevel)); | |||
} | } | |||
// We may also add SCN check, but GUID check cove rs this case too | // We may also add SCN check, but GUID check cove rs this case too | |||
if (memcmp(&bakheader.prev_guid, &prev_guid, size of(Guid)) != 0) | if (memcmp(&bakheader.prev_guid, &prev_guid, size of(Guid)) != 0) | |||
status_exception::raise(Arg::Gds(isc_nbac kup_wrong_orderbk) << bakname.c_str()); | status_exception::raise(Arg::Gds(isc_nbac kup_wrong_orderbk) << bakname.c_str()); | |||
seek_file(backup, bakheader.page_size); | ||||
// Emulate seek_file(backup, bakheader.page_size) | ||||
// Backup is stream-oriented, if -decompress is u | ||||
sed pipe can't be seek()'ed | ||||
FB_SIZE_T left = bakheader.page_size - sizeof(bak | ||||
header); | ||||
while (left) | ||||
{ | ||||
char char_buf[1024]; | ||||
FB_SIZE_T step = left > sizeof(char_buf) | ||||
? sizeof(char_buf) : left; | ||||
if (read_file(backup, &char_buf, step) != | ||||
step) | ||||
status_exception::raise(Arg::Gds( | ||||
isc_nbackup_err_eofhdrbk) << bakname.c_str()); | ||||
left -= step; | ||||
} | ||||
delete_database = true; | delete_database = true; | |||
prev_guid = bakheader.backup_guid; | prev_guid = bakheader.backup_guid; | |||
while (true) | while (true) | |||
{ | { | |||
const FB_SIZE_T bytesDone = read_file(bac kup, page_buffer, bakheader.page_size); | const FB_SIZE_T bytesDone = read_file(bac kup, page_buffer, bakheader.page_size); | |||
if (bytesDone == 0) | if (bytesDone == 0) | |||
break; | break; | |||
if (bytesDone != bakheader.page_size) { | if (bytesDone != bakheader.page_size) { | |||
status_exception::raise(Arg::Gds( isc_nbackup_err_eofbk) << bakname.c_str()); | status_exception::raise(Arg::Gds( isc_nbackup_err_eofbk) << bakname.c_str()); | |||
End of changes. 3 change blocks. | ||||
3 lines changed or deleted | 33 lines changed or added |