mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 04:03:03 +01:00
Added switch to nbackup, controlling direct access to database file
This commit is contained in:
parent
728c890299
commit
1bb19c721d
@ -502,6 +502,7 @@
|
||||
#define isc_spb_nbk_level 5
|
||||
#define isc_spb_nbk_file 6
|
||||
#define isc_spb_nbk_no_triggers 0x01
|
||||
#define isc_spb_nbk_direct 0x02
|
||||
|
||||
/***************************************
|
||||
* Parameters for isc_action_svc_trace *
|
||||
|
@ -2501,7 +2501,7 @@ bool Service::process_switches(ClumpletReader& spb, string& switches)
|
||||
break;
|
||||
|
||||
case isc_spb_options:
|
||||
if (!get_action_svc_bitmask(spb, nbackup_in_sw_table, switches))
|
||||
if (!get_action_svc_bitmask(spb, nbackup_option_in_sw_table, switches))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ set bulk_insert INSERT INTO FACILITIES (LAST_CHANGE, FACILITY, FAC_CODE, MAX_NUM
|
||||
('2009-06-22 05:57:59', 'GSTAT', 21, 46)
|
||||
('2008-09-16 01:10:30', 'FBSVCMGR', 22, 52)
|
||||
('2009-07-18 12:12:12', 'UTL', 23, 2)
|
||||
('2009-11-09 07:31:40', 'NBACKUP', 24, 70)
|
||||
('2009-12-16 19:27:50', 'NBACKUP', 24, 71)
|
||||
('2009-07-20 07:55:48', 'FBTRACEMGR', 25, 41)
|
||||
stop
|
||||
|
||||
|
@ -3366,7 +3366,7 @@ Analyzing database pages ...', NULL, NULL);
|
||||
(NULL, 'usage', 'nbackup.cpp', NULL, 24, 21, NULL, ' Incremental backups of multi-file databases are not supported yet.', NULL, NULL)
|
||||
(NULL, 'usage', 'nbackup.cpp', NULL, 24, 22, NULL, ' "stdout" may be used as a value of <filename> for -B option.', NULL, NULL)
|
||||
(NULL, 'usage', 'nbackup.cpp', NULL, 24, 23, NULL, 'PROBLEM ON "@1".', NULL, NULL)
|
||||
(NULL, 'usage', 'nbackup.cpp', NULL, 24, 24, NULL, 'general options are:', NULL, NULL)
|
||||
(NULL, 'usage', 'nbackup.cpp', NULL, 24, 24, NULL, ' -D(IRECT) Use direct I/O when scanning database', NULL, NULL)
|
||||
(NULL, 'usage', 'nbackup.cpp', NULL, 24, 25, NULL, 'switches can be abbreviated to the unparenthesized characters', NULL, NULL)
|
||||
(NULL, 'usage', 'nbackup.cpp', NULL, 24, 26, NULL, ' Option -S(IZE) only is valid together with -L(OCK).', NULL, NULL)
|
||||
(NULL, 'usage', 'nbackup.cpp', NULL, 24, 27, NULL, ' For historical reasons, -N is equivalent to -UN(LOCK)', NULL, NULL)
|
||||
@ -3412,6 +3412,7 @@ Analyzing database pages ...', NULL, NULL);
|
||||
('nbackup_lostguid_l0bk', 'NBackup::restore_database', 'nbackup.cpp', NULL, 24, 67, NULL, 'Cannot get backup guid clumplet from L0 backup', NULL, NULL)
|
||||
(NULL, 'nbackup', 'nbackup.cpp', NULL, 24, 68, NULL, 'Physical Backup Manager version @1', NULL, NULL)
|
||||
(NULL, 'restore_database', 'nbackup.cpp', NULL, 24, 69, NULL, 'Enter name of the backup file of level @1 ("." - do not restore further):', NULL, NULL)
|
||||
(NULL, 'usage', 'nbackup.cpp', NULL, 24, 70, NULL, 'general options are:', NULL, NULL)
|
||||
--('nbackup_', '', 'nbackup.cpp', NULL, 24, , NULL, '', NULL, NULL)
|
||||
-- FBTRACEMGR
|
||||
-- All messages use the new format.
|
||||
|
@ -453,6 +453,7 @@ const SvcSwitches nbackOptions[] =
|
||||
{"nbk_file", putStringArgument, 0, isc_spb_nbk_file, 0},
|
||||
{"nbk_level", putNumericArgument, 0, isc_spb_nbk_level, 0},
|
||||
{"nbk_no_triggers", putOption, 0, isc_spb_nbk_no_triggers, 0},
|
||||
{"nbk_direct", putOption, 0, isc_spb_nbk_direct, 0},
|
||||
{0, 0, 0, 0, 0}
|
||||
};
|
||||
|
||||
|
@ -156,7 +156,7 @@ namespace
|
||||
printMsg(p->in_sw_msg);
|
||||
}
|
||||
|
||||
printMsg(24); // general options are:
|
||||
printMsg(70); // general options are:
|
||||
for (const Switches::in_sw_tab_t* p = base; p->in_sw; ++p)
|
||||
{
|
||||
if (p->in_sw_msg && p->in_sw_optype == nboGeneral)
|
||||
@ -248,10 +248,10 @@ class NBackup
|
||||
public:
|
||||
NBackup(UtilSvc* _uSvc, const PathName& _database, const string& _username,
|
||||
const string& _password, bool _run_db_triggers, const string& _trustedUser,
|
||||
bool _trustedRole)
|
||||
bool _trustedRole, bool _direct_io)
|
||||
: uSvc(_uSvc), newdb(0), trans(0), database(_database),
|
||||
username(_username), password(_password), trustedUser(_trustedUser),
|
||||
run_db_triggers(_run_db_triggers), trustedRole(_trustedRole),
|
||||
run_db_triggers(_run_db_triggers), trustedRole(_trustedRole), direct_io(_direct_io),
|
||||
dbase(0), backup(0), db_size_pages(0), m_silent(false)
|
||||
{
|
||||
// Recognition of local prefix allows to work with
|
||||
@ -283,7 +283,7 @@ private:
|
||||
|
||||
PathName database;
|
||||
string username, password, trustedUser;
|
||||
bool run_db_triggers, trustedRole;
|
||||
bool run_db_triggers, trustedRole, direct_io;
|
||||
|
||||
PathName dbname; // Database file name
|
||||
PathName bakname;
|
||||
@ -425,9 +425,12 @@ void NBackup::open_database_scan()
|
||||
#define O_DIRECT 0
|
||||
#endif // O_DIRECT
|
||||
|
||||
dbase = open(dbname.c_str(), O_RDONLY | O_LARGEFILE | O_NOATIME | O_DIRECT);
|
||||
dbase = open(dbname.c_str(), O_RDONLY | O_LARGEFILE | O_NOATIME | (direct_io ? O_DIRECT : 0));
|
||||
if (dbase < 0)
|
||||
status_exception::raise(Arg::Gds(isc_nbackup_err_opendb) << Arg::OsError() << dbname.c_str());
|
||||
{
|
||||
status_exception::raise(Arg::Gds(isc_nbackup_err_opendb) << Arg::OsError() <<
|
||||
dbname.c_str());
|
||||
}
|
||||
|
||||
int rc = fb_fadvise(dbase, 0, 0, POSIX_FADV_SEQUENTIAL);
|
||||
if (rc)
|
||||
@ -435,11 +438,14 @@ void NBackup::open_database_scan()
|
||||
status_exception::raise(Arg::Gds(isc_nbackup_err_fadvice) << Arg::Num(rc) <<
|
||||
"SEQUENTIAL" << dbname.c_str());
|
||||
}
|
||||
rc = fb_fadvise(dbase, 0, 0, POSIX_FADV_NOREUSE);
|
||||
if (rc)
|
||||
if (direct_io)
|
||||
{
|
||||
status_exception::raise(Arg::Gds(isc_nbackup_err_fadvice) << Arg::Num(rc) <<
|
||||
"NOREUSE" << dbname.c_str());
|
||||
rc = fb_fadvise(dbase, 0, 0, POSIX_FADV_NOREUSE);
|
||||
if (rc)
|
||||
{
|
||||
status_exception::raise(Arg::Gds(isc_nbackup_err_fadvice) << Arg::Num(rc) <<
|
||||
"NOREUSE" << dbname.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
#endif // WIN_NT
|
||||
@ -1264,6 +1270,7 @@ void nbackup(UtilSvc* uSvc)
|
||||
string username, password;
|
||||
PathName database, filename;
|
||||
bool run_db_triggers = true;
|
||||
bool direct_io = false;
|
||||
NBackup::BackupFiles backup_files;
|
||||
int level;
|
||||
bool print_size = false, version = false;
|
||||
@ -1322,6 +1329,10 @@ void nbackup(UtilSvc* uSvc)
|
||||
run_db_triggers = false;
|
||||
break;
|
||||
|
||||
case IN_SW_NBK_DIRECT:
|
||||
direct_io = true;
|
||||
break;
|
||||
|
||||
case IN_SW_NBK_FIXUP:
|
||||
if (op != nbNone)
|
||||
singleAction(uSvc);
|
||||
@ -1442,7 +1453,7 @@ void nbackup(UtilSvc* uSvc)
|
||||
if (print_size && (op != nbLock))
|
||||
usage(uSvc, isc_nbackup_size_with_lock);
|
||||
|
||||
NBackup nbk(uSvc, database, username, password, run_db_triggers, trustedUser, trustedRole);
|
||||
NBackup nbk(uSvc, database, username, password, run_db_triggers, trustedUser, trustedRole, direct_io);
|
||||
switch (op)
|
||||
{
|
||||
case nbNone:
|
||||
|
@ -47,12 +47,14 @@ const int IN_SW_NBK_VERSION = 11;
|
||||
const int IN_SW_NBK_TRUSTED_USER = 12;
|
||||
const int IN_SW_NBK_TRUSTED_ROLE = 13;
|
||||
const int IN_SW_NBK_HELP = 14;
|
||||
const int IN_SW_NBK_DIRECT = 15;
|
||||
|
||||
|
||||
static const struct Switches::in_sw_tab_t nbackup_in_sw_table [] =
|
||||
static const struct Switches::in_sw_tab_t nbackup_option_in_sw_table [] =
|
||||
{
|
||||
{IN_SW_NBK_NODBTRIG, isc_spb_nbk_no_triggers, "T", 0, 0, 0, false, 0, 1, NULL},
|
||||
{IN_SW_NBK_0, 0, NULL, 0, 0, 0, false, 0, 0, NULL} // End of List
|
||||
{IN_SW_NBK_NODBTRIG, isc_spb_nbk_no_triggers, "T", 0, 0, 0, false, 0, 1, NULL},
|
||||
{IN_SW_NBK_DIRECT, isc_spb_nbk_direct, "DIRECT", 0, 0, 0, false, 0, 1, NULL},
|
||||
{IN_SW_NBK_0, 0, NULL, 0, 0, 0, false, 0, 0, NULL} // End of List
|
||||
};
|
||||
|
||||
enum NbakOptionType { nboGeneral, nboExclusive };
|
||||
@ -65,11 +67,12 @@ static const struct Switches::in_sw_tab_t nbackup_action_in_sw_table [] =
|
||||
{IN_SW_NBK_FIXUP, 0, "FIXUP", 0, 0, 0, false, 10, 1, NULL, nboExclusive},
|
||||
{IN_SW_NBK_BACKUP, isc_action_svc_nbak, "BACKUP", 0, 0, 0, false, 11, 1, NULL, nboExclusive},
|
||||
{IN_SW_NBK_RESTORE, isc_action_svc_nrest, "RESTORE", 0, 0, 0, false, 12, 1, NULL, nboExclusive},
|
||||
{IN_SW_NBK_DIRECT, 0, "DIRECT", 0, 0, 0, false, 24, 1, NULL, nboExclusive},
|
||||
{IN_SW_NBK_SIZE, 0, "SIZE", 0, 0, 0, false, 17, 1, NULL, nboExclusive},
|
||||
{IN_SW_NBK_NODBTRIG, 0, "T", 0, 0, 0, false, 0, 1, NULL, nboGeneral},
|
||||
{IN_SW_NBK_NODBTRIG, 0, "NODBTRIGGERS", 0, 0, 0, false, 16, 3, NULL, nboGeneral},
|
||||
{IN_SW_NBK_USER_NAME, 0, "USER", 0, 0, 0, false, 13, 1, NULL, nboGeneral},
|
||||
{IN_SW_NBK_PASSWORD, 0, "PASSWORD", 0, 0, 0, false, 14, 1, NULL, nboGeneral},
|
||||
{IN_SW_NBK_SIZE, 0, "SIZE", 0, 0, 0, false, 17, 1, NULL, nboGeneral},
|
||||
{IN_SW_NBK_FETCH, 0, "FETCH_PASSWORD", 0, 0, 0, false, 15, 2, NULL, nboGeneral},
|
||||
{IN_SW_NBK_VERSION, 0, "Z", 0, 0, 0, false, 18, 1, NULL, nboGeneral},
|
||||
{IN_SW_NBK_TRUSTED_USER, 0, TRUSTED_USER_SWITCH, 0, 0, 0, false, 0, TRUSTED_USER_SWITCH_LEN, NULL, nboGeneral},
|
||||
|
Loading…
Reference in New Issue
Block a user