8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 06:03:02 +01:00

Fixed CORE-2984: gbak -v srv:db stdout creates a broken backup

This commit is contained in:
alexpeshkoff 2010-05-06 13:42:20 +00:00
parent cc2f463d73
commit 965b851b77
17 changed files with 338 additions and 277 deletions

View File

@ -687,6 +687,6 @@ static void alice_output(const SCHAR* format, ...)
buf.vprintf(format, arglist);
va_end(arglist);
tdgbl->uSvc->output(buf.c_str());
tdgbl->uSvc->outputError(buf.c_str());
}

View File

@ -65,7 +65,7 @@ DATABASE DB = STATIC FILENAME "yachts.lnk";
#define DB tdgbl->db_handle
#define gds_trans tdgbl->tr_handle
#define isc_status tdgbl->status
#define isc_status tdgbl->status_vector
void detectRuntimeODS()

View File

@ -73,7 +73,7 @@ DATABASE DB = STATIC FILENAME "yachts.lnk" RUNTIME * dbb_file;
#define DB tdgbl->db_handle
#define gds_trans tdgbl->tr_handle
#define isc_status tdgbl->status
#define isc_status tdgbl->status_vector
namespace // unnamed, private
{
@ -1110,7 +1110,7 @@ void put_array( burp_fld* field, burp_rel* relation, ISC_QUAD* blob_id)
NULL, // param for subset of an array handling
slice_length, slice, (SLONG*) &return_length))
{
BURP_print(81, field->fld_name);
BURP_print(true, 81, field->fld_name);
// msg 81 error accessing blob field %s -- continuing
BURP_print_status(status_vector);
#ifdef DEBUG
@ -1215,7 +1215,7 @@ void put_asciz( const att_type attribute, const TEXT* string)
// We can't honor operating systems that allow longer file names.
if (l >= MAX_FILE_NAME_SIZE)
{
BURP_print(343, SafeArg() << int(attribute) << "put_asciz()" << (MAX_FILE_NAME_SIZE - 1));
BURP_print(true, 343, SafeArg() << int(attribute) << "put_asciz()" << (MAX_FILE_NAME_SIZE - 1));
// msg 343: text for attribute @1 is too large in @2, truncating to @3 bytes
l = MAX_FILE_NAME_SIZE - 1;
}
@ -1255,7 +1255,7 @@ void put_blob( burp_fld* field, ISC_QUAD& blob_id)
if (!blob.open(DB, gds_trans, blob_id))
{
BURP_print(81, field->fld_name);
BURP_print(true, 81, field->fld_name);
// msg 81 error accessing blob field %s -- continuing
BURP_print_status(status_vector);
return;
@ -1426,7 +1426,7 @@ bool put_blr_blob( att_type attribute, ISC_QUAD& blob_id)
break;
default:
BURP_print(79, SafeArg() << int(item));
BURP_print(true, 79, SafeArg() << int(item));
// msg 79 don't understand blob info item %ld
if (!blob.close())
BURP_error_redirect(status_vector, 23);
@ -1854,7 +1854,7 @@ void put_index( burp_rel* relation)
if (count != (ULONG) X.RDB$SEGMENT_COUNT)
{
BURP_print(180, SafeArg() << X.RDB$INDEX_NAME << count << X.RDB$SEGMENT_COUNT);
BURP_print(true, 180, SafeArg() << X.RDB$INDEX_NAME << count << X.RDB$SEGMENT_COUNT);
continue;
}
@ -2269,7 +2269,7 @@ bool put_source_blob(att_type attribute, att_type old_attribute, ISC_QUAD& blob_
break;
default:
BURP_print(79, SafeArg() << int(item));
BURP_print(true, 79, SafeArg() << int(item));
// msg 79 don't understand blob info item %ld
if (!blob.close())
{
@ -2352,7 +2352,7 @@ int put_text( att_type attribute, const TEXT* text, SSHORT size_len)
fb_assert(l <= MAX_UCHAR);
if (l > MAX_UCHAR)
{
BURP_print(343, SafeArg() << int(attribute) << "put_text()" << MAX_UCHAR);
BURP_print(true, 343, SafeArg() << int(attribute) << "put_text()" << MAX_UCHAR);
// msg 343: text for attribute @1 is too large in @2, truncating to @3 bytes
l = MAX_UCHAR;
}

View File

@ -108,7 +108,7 @@ static ULONG get_size(const SCHAR*, burp_fil*);
static gbak_action open_files(const TEXT *, const TEXT**, bool, USHORT,
const Firebird::ClumpletWriter&);
static int api_gbak(Firebird::UtilSvc*, const Switches& switches);
static void burp_output(const SCHAR*, ...) ATTRIBUTE_FORMAT(1,2);
static void burp_output(bool err, const SCHAR*, ...) ATTRIBUTE_FORMAT(2,3);
static void burp_usage(const Switches& switches);
static Switches::in_sw_tab_t* findSwitchOrThrow(Switches& switches, Firebird::string& sw);
@ -315,7 +315,7 @@ static int api_gbak(Firebird::UtilSvc* uSvc, const Switches& switches)
spb.getBufferLength(), reinterpret_cast<const char*>(spb.getBuffer())))
{
BURP_print_status(status);
BURP_print(83);
BURP_print(true, 83);
// msg 83 Exiting before completion due to errors
return FINI_ERROR;
}
@ -349,7 +349,7 @@ static int api_gbak(Firebird::UtilSvc* uSvc, const Switches& switches)
{
BURP_print_status(status);
isc_service_detach(status, &svc_handle);
BURP_print(83); // msg 83 Exiting before completion due to errors
BURP_print(true, 83); // msg 83 Exiting before completion due to errors
return FINI_ERROR;
}
@ -363,7 +363,7 @@ static int api_gbak(Firebird::UtilSvc* uSvc, const Switches& switches)
{
BURP_print_status(status);
isc_service_detach(status, &svc_handle);
BURP_print(83); // msg 83 Exiting before completion due to errors
BURP_print(true, 83); // msg 83 Exiting before completion due to errors
return FINI_ERROR;
}
@ -385,7 +385,7 @@ static int api_gbak(Firebird::UtilSvc* uSvc, const Switches& switches)
fb_assert(p + len < respbuf + sizeof(respbuf));
p[len] = '\0';
burp_output("%s\n", p);
burp_output(false, "%s\n", p);
}
} while (*sl == isc_info_svc_line);
@ -400,7 +400,7 @@ static int api_gbak(Firebird::UtilSvc* uSvc, const Switches& switches)
{
isc_service_detach(status, &svc_handle);
}
BURP_print(83); // msg 83 Exiting before completion due to errors
BURP_print(true, 83); // msg 83 Exiting before completion due to errors
return FINI_ERROR;
}
}
@ -427,7 +427,7 @@ static Switches::in_sw_tab_t* findSwitchOrThrow(Switches& switches, Firebird::st
if (invalid)
{
BURP_print(137, sw.c_str());
BURP_print(true, 137, sw.c_str());
// msg 137 unknown switch %s
burp_usage(switches);
BURP_error(1, true);
@ -473,7 +473,6 @@ int gbak(Firebird::UtilSvc* uSvc)
if (switches.exists(IN_SW_BURP_SE, argv.begin(), 1, argc))
return api_gbak(uSvc, switches);
tdgbl->status = tdgbl->status_vector;
uSvc->started();
if (argc <= 1)
@ -782,14 +781,14 @@ int gbak(Firebird::UtilSvc* uSvc)
FILE* tmp_outfile = fopen(redirect, fopen_read_type);
if (tmp_outfile)
{
BURP_print(66, redirect);
BURP_print(true, 66, redirect);
// msg 66 can't open status and error output file %s
fclose(tmp_outfile);
BURP_exit_local(FINI_ERROR, tdgbl);
}
if (! (tdgbl->output_file = fopen(redirect, fopen_write_type)))
{
BURP_print(66, redirect);
BURP_print(true, 66, redirect);
// msg 66 can't open status and error output file %s
BURP_exit_local(FINI_ERROR, tdgbl);
}
@ -1049,7 +1048,7 @@ int gbak(Firebird::UtilSvc* uSvc)
#endif
case IN_SW_BURP_Z:
BURP_print(91, GDS_VERSION);
BURP_print(false, 91, GDS_VERSION);
// msg 91 gbak version %s
tdgbl->gbl_sw_version = true;
break;
@ -1062,6 +1061,18 @@ int gbak(Firebird::UtilSvc* uSvc)
if (!sw_replace)
sw_replace = IN_SW_BURP_B;
if (sw_replace == IN_SW_BURP_B)
{
for (burp_fil* f = tdgbl->gbl_sw_files; f; f = f->fil_next)
{
if (f->fil_name == "stdout")
{
// the very first thing to do not to corrupt backup file...
tdgbl->uSvc->setDataMode(true);
}
}
}
if (tdgbl->gbl_sw_page_size)
{
if (sw_replace == IN_SW_BURP_B)
@ -1082,7 +1093,7 @@ int gbak(Firebird::UtilSvc* uSvc)
}
if (temp != tdgbl->gbl_sw_page_size)
{
BURP_print(103, SafeArg() << tdgbl->gbl_sw_page_size << temp);
BURP_print(false, 103, SafeArg() << tdgbl->gbl_sw_page_size << temp);
// msg 103 page size specified (%ld bytes) rounded up to %ld bytes
tdgbl->gbl_sw_page_size = temp;
}
@ -1232,7 +1243,7 @@ int gbak(Firebird::UtilSvc* uSvc)
tdgbl->burp_throw = false;
e.stuff_exception(tdgbl->status_vector);
BURP_print_status(tdgbl->status_vector, true);
BURP_print(83); // msg 83 Exiting before completion due to errors
BURP_print(true, 83); // msg 83 Exiting before completion due to errors
exit_code = FINI_ERROR;
}
@ -1283,12 +1294,6 @@ int gbak(Firebird::UtilSvc* uSvc)
}
#endif
if ((exit_code != FINI_OK) && uSvc->isService())
{
uSvc->initStatus();
uSvc->setServiceStatus(tdgbl->status);
}
return exit_code;
}
@ -1308,7 +1313,7 @@ void BURP_abort()
**************************************/
BurpGlobals* tdgbl = BurpGlobals::getSpecific();
BURP_print(83);
BURP_print(true, 83);
// msg 83 Exiting before completion due to errors
tdgbl->uSvc->started();
@ -1332,8 +1337,12 @@ void BURP_error(USHORT errcode, bool abort, const SafeArg& arg)
tdgbl->uSvc->setServiceStatus(burp_msg_fac, errcode, arg);
tdgbl->uSvc->started();
BURP_msg_partial(256); // msg 256: gbak: ERROR:
BURP_msg_put(errcode, arg);
if (!tdgbl->uSvc->isService())
{
BURP_msg_partial(true, 256); // msg 256: gbak: ERROR:
BURP_msg_put(true, errcode, arg);
}
if (abort)
{
BURP_abort();
@ -1389,7 +1398,7 @@ void BURP_exit_local(int code, BurpGlobals* tdgbl)
}
void BURP_msg_partial(USHORT number, const SafeArg& arg)
void BURP_msg_partial(bool err, USHORT number, const SafeArg& arg)
{
/**************************************
*
@ -1405,11 +1414,11 @@ void BURP_msg_partial(USHORT number, const SafeArg& arg)
TEXT buffer[256];
fb_msg_format(NULL, burp_msg_fac, number, sizeof(buffer), buffer, arg);
burp_output("%s", buffer);
burp_output(err, "%s", buffer);
}
void BURP_msg_put(USHORT number, const SafeArg& arg)
void BURP_msg_put(bool err, USHORT number, const SafeArg& arg)
{
/**************************************
*
@ -1424,7 +1433,7 @@ void BURP_msg_put(USHORT number, const SafeArg& arg)
TEXT buffer[256];
fb_msg_format(NULL, burp_msg_fac, number, sizeof(buffer), buffer, arg);
burp_output("%s\n", buffer);
burp_output(err, "%s\n", buffer);
}
@ -1462,11 +1471,11 @@ void BURP_output_version(void* arg1, const TEXT* arg2)
*
**************************************/
burp_output(static_cast<const char*>(arg1), arg2);
burp_output(false, static_cast<const char*>(arg1), arg2);
}
void BURP_print(USHORT number, const SafeArg& arg)
void BURP_print(bool err, USHORT number, const SafeArg& arg)
{
/**************************************
*
@ -1481,12 +1490,12 @@ void BURP_print(USHORT number, const SafeArg& arg)
*
**************************************/
BURP_msg_partial(169); // msg 169: gbak:
BURP_msg_put(number, arg);
BURP_msg_partial(err, 169); // msg 169: gbak:
BURP_msg_put(err, number, arg);
}
void BURP_print(USHORT number, const char* str)
void BURP_print(bool err, USHORT number, const char* str)
{
/**************************************
*
@ -1502,8 +1511,8 @@ void BURP_print(USHORT number, const char* str)
**************************************/
static const SafeArg dummy;
BURP_msg_partial(169, dummy); // msg 169: gbak:
BURP_msg_put(number, SafeArg() << str);
BURP_msg_partial(err, 169, dummy); // msg 169: gbak:
BURP_msg_put(err, number, SafeArg() << str);
}
@ -1520,25 +1529,26 @@ void BURP_print_status(const ISC_STATUS* status_vector, bool flagStuff)
* to allow redirecting output.
*
**************************************/
if (status_vector)
{
if (status_vector) {
const ISC_STATUS* vector = status_vector;
if (flagStuff)
{
if (flagStuff) {
BurpGlobals* tdgbl = BurpGlobals::getSpecific();
tdgbl->uSvc->setServiceStatus(vector);
tdgbl->uSvc->started();
if (tdgbl->uSvc->isService())
{
return;
}
}
SCHAR s[1024];
if (fb_interpret(s, sizeof(s), &vector))
{
BURP_msg_partial(256); // msg 256: gbak: ERROR:
burp_output("%s\n", s);
while (fb_interpret(s, sizeof(s), &vector))
{
BURP_msg_partial(256); // msg 256: gbak: ERROR:
burp_output(" %s\n", s);
if (fb_interpret(s, sizeof(s), &vector)) {
BURP_msg_partial(true, 256); // msg 256: gbak: ERROR:
burp_output(true, "%s\n", s);
while (fb_interpret(s, sizeof(s), &vector)) {
BURP_msg_partial(true, 256); // msg 256: gbak: ERROR:
burp_output(true, " %s\n", s);
}
}
}
@ -1566,14 +1576,12 @@ void BURP_print_warning(const ISC_STATUS* status_vector)
// print the warning message
const ISC_STATUS* vector = &status_vector[2];
SCHAR s[1024];
if (fb_interpret(s, sizeof(s), &vector))
{
BURP_msg_partial(255); // msg 255: gbak: WARNING:
burp_output("%s\n", s);
while (fb_interpret(s, sizeof(s), &vector))
{
BURP_msg_partial(255); // msg 255: gbak: WARNING:
burp_output(" %s\n", s);
if (fb_interpret(s, sizeof(s), &vector)) {
BURP_msg_partial(true, 255); // msg 255: gbak: WARNING:
burp_output(true, "%s\n", s);
while (fb_interpret(s, sizeof(s), &vector)) {
BURP_msg_partial(true, 255); // msg 255: gbak: WARNING:
burp_output(true, " %s\n", s);
}
}
}
@ -1597,9 +1605,9 @@ void BURP_verbose(USHORT number, const SafeArg& arg)
BurpGlobals* tdgbl = BurpGlobals::getSpecific();
if (tdgbl->gbl_sw_verbose)
BURP_print(number, arg);
BURP_print(false, number, arg);
else
burp_output("%s", "");
burp_output(false, "%s", "");
}
@ -1620,9 +1628,9 @@ void BURP_verbose(USHORT number, const char* str)
BurpGlobals* tdgbl = BurpGlobals::getSpecific();
if (tdgbl->gbl_sw_verbose)
BURP_print(number, str);
BURP_print(false, number, str);
else
burp_output("%s", "");
burp_output(false, "%s", "");
}
@ -1746,11 +1754,11 @@ static gbak_action open_files(const TEXT* file1,
if (tdgbl->gbl_sw_version)
{
// msg 139 Version(s) for database "%s"
BURP_print(139, file1);
BURP_print(false, 139, file1);
isc_version(&tdgbl->db_handle, BURP_output_version, (void*) "\t%s\n");
}
if (sw_verbose)
BURP_print(166, file1); // msg 166: readied database %s for backup
BURP_print(false, 166, file1); // msg 166: readied database %s for backup
}
else if (sw_replace == IN_SW_BURP_B ||
(status_vector[1] != isc_io_error && status_vector[1] != isc_bad_db_format))
@ -1808,7 +1816,7 @@ static gbak_action open_files(const TEXT* file1,
}
if (sw_verbose)
{
BURP_print(75, fil->fil_name.c_str()); // msg 75 creating file %s
BURP_print(false, 75, fil->fil_name.c_str()); // msg 75 creating file %s
}
if (fil->fil_name == "stdout")
{
@ -1822,10 +1830,10 @@ static gbak_action open_files(const TEXT* file1,
// We ignore SIGPIPE so that we can report an IO error when we
// try to write to the broken pipe.
#ifndef WIN_NT
signal(SIGPIPE, SIG_IGN);
#endif
tdgbl->uSvc->setDataMode(true);
fil->fil_fd = GBAK_STDOUT_DESC();
break;
}
@ -1950,7 +1958,7 @@ static gbak_action open_files(const TEXT* file1,
if (sw_verbose)
{
BURP_print(100, fil->fil_name.c_str());
BURP_print(false, 100, fil->fil_name.c_str());
// msg 100 opened file %s
}
@ -1998,7 +2006,7 @@ static gbak_action open_files(const TEXT* file1,
if (sw_verbose)
{
BURP_print(100, fil->fil_name.c_str());
BURP_print(false, 100, fil->fil_name.c_str());
// msg 100 opened file %s
}
if (MVOL_split_hdr_read())
@ -2099,14 +2107,6 @@ static gbak_action open_files(const TEXT* file1,
// or owner of the existing database.
}
// if we got here, then all is well, remove any error condition from the
// status vector when running as a service thread. If we don't then the
// service will think that there is an error if isc_attach_database failed
// like it should have (if creating a database).
if (tdgbl->uSvc->isService())
memset(tdgbl->status, 0, sizeof(ISC_STATUS_ARRAY));
// check the file size specification
for (fil = tdgbl->gbl_sw_files; fil; fil = fil->fil_next)
{
@ -2121,7 +2121,7 @@ static gbak_action open_files(const TEXT* file1,
}
static void burp_output( const SCHAR* format, ...)
static void burp_output(bool err, const SCHAR* format, ...)
{
/**************************************
*
@ -2151,8 +2151,10 @@ static void burp_output( const SCHAR* format, ...)
Firebird::string buf;
buf.vprintf(format, arglist);
va_end(arglist);
tdgbl->uSvc->output(buf.c_str());
fflush(stdout);
if (err)
tdgbl->uSvc->outputError(buf.c_str());
else
tdgbl->uSvc->outputVerbose(buf.c_str());
}
}
}
@ -2173,40 +2175,40 @@ static void burp_usage(const Switches& switches)
const SafeArg sa(SafeArg() << switch_char);
const SafeArg dummy;
BURP_print(317); // usage
BURP_print(true, 317); // usage
for (int i = 318; i < 323; ++i)
BURP_msg_put(i, dummy); // usage
BURP_msg_put(true, i, dummy); // usage
BURP_print(95); // msg 95 legal switches are
BURP_print(true, 95); // msg 95 legal switches are
const Switches::in_sw_tab_t* const base = switches.getTable();
for (const Switches::in_sw_tab_t* p = base; p->in_sw; ++p)
{
if (p->in_sw_msg && p->in_sw_optype == boMain)
BURP_msg_put(p->in_sw_msg, sa);
BURP_msg_put(true, p->in_sw_msg, sa);
}
BURP_print(323); // backup options are
BURP_print(true, 323); // backup options are
for (const Switches::in_sw_tab_t* p = base; p->in_sw; ++p)
{
if (p->in_sw_msg && p->in_sw_optype == boBackup)
BURP_msg_put(p->in_sw_msg, sa);
BURP_msg_put(true, p->in_sw_msg, sa);
}
BURP_print(324); // restore options are
BURP_print(true, 324); // restore options are
for (const Switches::in_sw_tab_t* p = base; p->in_sw; ++p)
{
if (p->in_sw_msg && p->in_sw_optype == boRestore)
BURP_msg_put(p->in_sw_msg, sa);
BURP_msg_put(true, p->in_sw_msg, sa);
}
BURP_print(325); // general options are
BURP_print(true, 325); // 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 == boGeneral)
BURP_msg_put(p->in_sw_msg, sa);
BURP_msg_put(true, p->in_sw_msg, sa);
}
BURP_print(132); // msg 132 switches can be abbreviated to the unparenthesized characters
BURP_print(true, 132); // msg 132 switches can be abbreviated to the unparenthesized characters
}

View File

@ -949,7 +949,6 @@ public:
isc_tr_handle tr_handle;
isc_tr_handle global_trans;
DESC file_desc;
ISC_STATUS* status; // points to either the tdgbl status or service status
ISC_STATUS_ARRAY status_vector;
int exit_code;
UCHAR* head_of_mem_list;

View File

@ -35,13 +35,13 @@ void BURP_abort();
void BURP_error(USHORT, bool, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg());
void BURP_error(USHORT, bool, const char* str);
void BURP_error_redirect(const ISC_STATUS*, USHORT, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg());
void BURP_msg_partial(USHORT, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg());
void BURP_msg_put(USHORT, const MsgFormat::SafeArg& arg);
void BURP_msg_partial(bool, USHORT, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg());
void BURP_msg_put(bool, USHORT, const MsgFormat::SafeArg& arg);
const int BURP_MSG_GET_SIZE = 128; // Use it for buffers passed to this function.
void BURP_msg_get(USHORT, TEXT*, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg());
void BURP_output_version(void*, const TEXT*);
void BURP_print(USHORT, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg());
void BURP_print(USHORT, const char* str);
void BURP_print(bool err, USHORT, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg());
void BURP_print(bool err, USHORT, const char* str);
void BURP_print_status(const ISC_STATUS* status, bool stuffFlag = false);
void BURP_print_warning(const ISC_STATUS*);
void BURP_verbose(USHORT, const MsgFormat::SafeArg& arg = MsgFormat::SafeArg());

View File

@ -589,7 +589,7 @@ UCHAR MVOL_write(const UCHAR c, int* io_cnt, UCHAR** io_ptr)
}
tdgbl->action->act_file->fil_fd = INVALID_HANDLE_VALUE;
BURP_print(272, SafeArg() <<
BURP_print(true, 272, SafeArg() <<
tdgbl->action->act_file->fil_name.c_str() <<
tdgbl->action->act_file->fil_length <<
tdgbl->action->act_file->fil_next->fil_name.c_str());
@ -737,7 +737,7 @@ static void bad_attribute(int attribute, USHORT type)
BurpGlobals* tdgbl = BurpGlobals::getSpecific();
static const SafeArg dummy;
fb_msg_format(NULL, burp_msg_fac, type, sizeof(name), name, dummy);
BURP_print(80, SafeArg() << name << attribute);
BURP_print(true, 80, SafeArg() << name << attribute);
// msg 80 don't recognize %s attribute %ld -- continuing
for (int l = get(tdgbl); l; --l)
get(tdgbl);
@ -867,7 +867,7 @@ static DESC next_volume( DESC handle, ULONG mode, bool full_buffer)
if (new_desc < 0)
#endif // WIN_NT
{
BURP_print(222, new_file);
BURP_print(true, 222, new_file);
// msg 222 \n\nCould not open file name \"%s\"\n
continue;
}
@ -882,13 +882,13 @@ static DESC next_volume( DESC handle, ULONG mode, bool full_buffer)
{
if (!write_header(new_desc, 0L, full_buffer))
{
BURP_print(223, new_file);
BURP_print(true, 223, new_file);
// msg223 \n\nCould not write to file \"%s\"\n
continue;
}
else
{
BURP_msg_put(261, SafeArg() << tdgbl->mvol_volume_count << new_file);
BURP_msg_put(false, 261, SafeArg() << tdgbl->mvol_volume_count << new_file);
// Starting with volume #vol_count, new_file
BURP_verbose(75, new_file); // msg 75 creating file %s
}
@ -901,12 +901,12 @@ static DESC next_volume( DESC handle, ULONG mode, bool full_buffer)
USHORT format;
if (!read_header(new_desc, &temp_buffer_size, &format, false))
{
BURP_print(224, new_file);
BURP_print(true, 224, new_file);
continue;
}
else
{
BURP_msg_put(261, SafeArg() << tdgbl->mvol_volume_count << new_file);
BURP_msg_put(false, 261, SafeArg() << tdgbl->mvol_volume_count << new_file);
// Starting with volume #vol_count, new_file
BURP_verbose(100, new_file); // msg 100 opened file %s
}

View File

@ -68,7 +68,7 @@ DATABASE DB = STATIC FILENAME "yachts.lnk";
#define DB tdgbl->db_handle
#define gds_trans tdgbl->tr_handle
#define isc_status tdgbl->status
#define isc_status tdgbl->status_vector
namespace // unnamed, private
@ -292,23 +292,23 @@ int RESTORE_restore (const TEXT* file_name, const TEXT* database_name)
MODIFY IDX USING
IDX.RDB$INDEX_INACTIVE = TRUE;
END_MODIFY;
BURP_print(240, index_name);
BURP_print(true, 240, index_name);
// msg 240 Index \"%s\" failed to activate because:
if ( error_code == isc_no_dup )
{
BURP_print(241);
BURP_print(true, 241);
// msg 241 The unique index has duplicate values or NULLs
BURP_print(242);
BURP_print(true, 242);
// msg 242 Delete or Update duplicate values or NULLs, and activate index with
}
else
{
BURP_print(244);
BURP_print(true, 244);
// msg 244 Not enough disk space to create the sort file for an index
BURP_print(245);
BURP_print(true, 245);
// msg 245 Set the TMP environment variable to a directory on a filesystem that does have enough space, and activate index with
}
BURP_print(243, index_name);
BURP_print(true, 243, index_name);
// msg 243 ALTER INDEX \"%s\" ACTIVE;
END_FOR;
// don't bring the database on-line
@ -356,7 +356,7 @@ int RESTORE_restore (const TEXT* file_name, const TEXT* database_name)
SAVE
// existing ON_ERROR continues past error, beck
ON_ERROR
BURP_print (173, index_name);
BURP_print (true, 173, index_name);
BURP_print_status(isc_status);
MODIFY IDS USING
IDS.RDB$INDEX_INACTIVE = TRUE;
@ -433,7 +433,7 @@ int RESTORE_restore (const TEXT* file_name, const TEXT* database_name)
ON_ERROR
general_on_error ();
END_ERROR;
BURP_print (173, index_name);
BURP_print (true, 173, index_name);
BURP_print_status(local_status);
tdgbl->flag_on_line = false;
}
@ -676,9 +676,9 @@ int RESTORE_restore (const TEXT* file_name, const TEXT* database_name)
if (!tdgbl->flag_on_line)
{
BURP_print(246);
BURP_print(true, 246);
// msg 246 Database is not online due to failure to activate one or more indices.
BURP_print(247);
BURP_print(true, 247);
// msg 247 Run gfix -online to bring database online without active indices.
return FINI_DB_NOT_ONLINE;
}
@ -765,7 +765,7 @@ void add_files(BurpGlobals* tdgbl, const char* file_name)
file->fil_length -= start - 1;
else
{
BURP_print (96, SafeArg() << file->fil_length << (start - 1));
BURP_print (true, 96, SafeArg() << file->fil_length << (start - 1));
// msg 96 length given for initial file (%ld) is less than minimum (%ld)
file->fil_length = 0;
}
@ -780,7 +780,7 @@ void add_files(BurpGlobals* tdgbl, const char* file_name)
COMMIT
// existing ON_ERROR continues past error, beck
ON_ERROR
BURP_print (174);
BURP_print (true, 174);
// msg 174 cannot commit files
BURP_print_status (tdgbl->status_vector);
ROLLBACK;
@ -819,7 +819,7 @@ void bad_attribute(scan_attr_t scan_next_attr, att_type bad_attr, USHORT type)
static const SafeArg dummy;
TEXT t_name[128];
fb_msg_format(NULL, burp_msg_fac, type, sizeof(t_name), t_name, dummy);
BURP_print (80, SafeArg() << t_name << int(bad_attr));
BURP_print (true, 80, SafeArg() << t_name << int(bad_attr));
// msg 80 don't recognize %s attribute %ld -- continuing
int skip_l = get(tdgbl);
if (skip_l)
@ -831,13 +831,13 @@ void bad_attribute(scan_attr_t scan_next_attr, att_type bad_attr, USHORT type)
{
skip_count = tdgbl->gbl_sw_skip_count;
get_skip(tdgbl, skip_count);
BURP_print (203, SafeArg() << skip_count << int(bad_attr));
BURP_print (true, 203, SafeArg() << skip_count << int(bad_attr));
// msg 203: skipped %d bytes after reading a bad attribute %d
}
else
{
++skip_count;
BURP_print (205, SafeArg() << skip_count << int(bad_attr));
BURP_print (true, 205, SafeArg() << skip_count << int(bad_attr));
// msg 205: skipped %d bytes looking for next valid attribute, encountered attribute %d
}
scan_next_attr = AFTER_SKIP;
@ -930,7 +930,7 @@ void create_database(BurpGlobals* tdgbl, const TEXT* file_name)
{
if (tdgbl->gbl_sw_page_size < page_size)
{
BURP_print (110, SafeArg() << page_size << tdgbl->gbl_sw_page_size);
BURP_print (true, 110, SafeArg() << page_size << tdgbl->gbl_sw_page_size);
// msg 110 Reducing the database page size from %ld bytes to %ld bytes
}
page_size = tdgbl->gbl_sw_page_size;
@ -1024,7 +1024,7 @@ void create_database(BurpGlobals* tdgbl, const TEXT* file_name)
if (tdgbl->gbl_sw_version)
{
BURP_print(139, file_name);
BURP_print(true, 139, file_name);
// msg 139 Version(s) for database "%s"
isc_version(&DB, BURP_output_version, (void*)"\t%s\n");
}
@ -1059,7 +1059,7 @@ void decompress(BurpGlobals* tdgbl, UCHAR* buffer, USHORT length)
{
if (end - p < count)
{
BURP_print (202, SafeArg() << count << (end - p));
BURP_print (true, 202, SafeArg() << count << (end - p));
// msg 202: adjusting a decompression length error: invalid length %d was adjusted to %d
count = end - p;
}
@ -1069,7 +1069,7 @@ void decompress(BurpGlobals* tdgbl, UCHAR* buffer, USHORT length)
{
if (end + count < p)
{
BURP_print(202, SafeArg() << count << (p - end));
BURP_print(true, 202, SafeArg() << count << (p - end));
// msg 202: adjusting a decompression length error: invalid length %d was adjusted to %d
count = p - end;
}
@ -1267,7 +1267,7 @@ void general_on_error()
BURP_print_status (isc_status, true);
if (isc_status[1] == isc_malformed_string)
BURP_print(341); // isc_gbak_invalid_metadata
BURP_print(true, 341); // isc_gbak_invalid_metadata
BURP_abort ();
}
@ -1358,7 +1358,7 @@ bool get_acl(BurpGlobals* tdgbl, const TEXT* owner_nm, ISC_QUAD* blob_id, ISC_QU
default:
// msg 79 don't understand blob info item %ld
BURP_print (79, SafeArg() << int(item));
BURP_print (true, 79, SafeArg() << int(item));
// CVC: do you return, without closing the blob, dear function???
if (!blob.close())
{
@ -1827,7 +1827,7 @@ void get_array(BurpGlobals* tdgbl, burp_rel* relation, UCHAR* record_buffer)
NULL, // param for subset of an array handling
elements_written * field->fld_length, buffer + data_at))
{
BURP_print (81, field->fld_name);
BURP_print (true, 81, field->fld_name);
// msg 81 error accessing blob field %s -- continuing
BURP_print_status (status_vector);
#ifdef DEBUG
@ -1955,7 +1955,7 @@ void get_array(BurpGlobals* tdgbl, burp_rel* relation, UCHAR* record_buffer)
NULL, // param for subset of an array handling
return_length, buffer))
{
BURP_print (81, field->fld_name);
BURP_print (true, 81, field->fld_name);
// msg 81 error accessing blob field %s -- continuing
BURP_print_status (status_vector);
#ifdef DEBUG
@ -3070,7 +3070,7 @@ rec_type get_data(BurpGlobals* tdgbl, burp_rel* relation)
{
if (tdgbl->gbl_sw_incremental)
{
BURP_print (138, relation->rel_name);
BURP_print (true, 138, relation->rel_name);
// msg 138 validation error on field in relation %s
BURP_print_status (status_vector);
}
@ -3083,10 +3083,10 @@ rec_type get_data(BurpGlobals* tdgbl, burp_rel* relation)
if (tdgbl->gbl_sw_incremental)
{
// msg 114 restore failed for record in relation %s
BURP_print(114, relation->rel_name);
BURP_print(true, 114, relation->rel_name);
BURP_print_status(status_vector);
BURP_print(342); // isc_gbak_invalid_data
BURP_print(true, 342); // isc_gbak_invalid_data
}
else
BURP_error_redirect(status_vector, 342); // isc_gbak_invalid_data
@ -3095,7 +3095,7 @@ rec_type get_data(BurpGlobals* tdgbl, burp_rel* relation)
{
if (tdgbl->gbl_sw_incremental)
{
BURP_print (114, relation->rel_name);
BURP_print (true, 114, relation->rel_name);
// msg 114 restore failed for record in relation %s
BURP_print_status (status_vector);
}
@ -3137,23 +3137,23 @@ rec_type get_data(BurpGlobals* tdgbl, burp_rel* relation)
IDX IN RDB$INDICES WITH IDX.RDB$INDEX_NAME EQ index_name
MODIFY IDX USING
IDX.RDB$INDEX_INACTIVE = TRUE;
BURP_print(240, index_name);
BURP_print(true, 240, index_name);
// msg 240 Index \"%s\" failed to activate because:
if ( error_code == isc_no_dup )
{
BURP_print(241);
BURP_print(true, 241);
// msg 241 The unique index has duplicate values or NULLs
BURP_print(242);
BURP_print(true, 242);
// msg 242 Delete or Update duplicate values or NULLs, and activate index with
}
else
{
BURP_print(244);
BURP_print(true, 244);
// msg 244 Not enough disk space to create the sort file for an index
BURP_print(245);
BURP_print(true, 245);
// msg 245 Set the TMP environment variable to a directory on a filesystem that does have enough space, and activate index with
}
BURP_print(243, index_name);
BURP_print(true, 243, index_name);
// msg 243 ALTER INDEX \"%s\" ACTIVE
END_MODIFY;
END_FOR;
@ -3166,7 +3166,7 @@ rec_type get_data(BurpGlobals* tdgbl, burp_rel* relation)
END_ERROR
break;
default:
BURP_print (69, relation->rel_name);
BURP_print (true, 69, relation->rel_name);
// msg 69 commit failed on relation %s
BURP_print_status (tdgbl->status_vector);
ROLLBACK;
@ -3197,7 +3197,7 @@ void fix_exception(BurpGlobals* tdgbl, const char* exc_name, scan_attr_t& scan_n
if (!failed_attrib)
{
failed_attrib = attribute;
BURP_print(313, SafeArg() << failed_attrib << exc_name);
BURP_print(true, 313, SafeArg() << failed_attrib << exc_name);
}
// Notice we use 1021 instead of 1023 because this is the maximum length
@ -3310,7 +3310,7 @@ bool get_exception(BurpGlobals* tdgbl)
else if (!X.RDB$MESSAGE.NULL)
{
msg_seen = true;
BURP_print(312, SafeArg() << attribute << X.RDB$EXCEPTION_NAME);
BURP_print(true, 312, SafeArg() << attribute << X.RDB$EXCEPTION_NAME);
eat_text(tdgbl);
}
else
@ -3327,7 +3327,7 @@ bool get_exception(BurpGlobals* tdgbl)
BURP_error(311, true, SafeArg() << attribute << X.RDB$EXCEPTION_NAME);
else if (!X.RDB$MESSAGE.NULL)
{
BURP_print(312, SafeArg() << attribute << X.RDB$EXCEPTION_NAME);
BURP_print(true, 312, SafeArg() << attribute << X.RDB$EXCEPTION_NAME);
eat_text2(tdgbl);
}
else
@ -3454,7 +3454,7 @@ bool get_exception(BurpGlobals* tdgbl)
else if (!X.RDB$MESSAGE.NULL)
{
msg_seen = true;
BURP_print(312, SafeArg() << attribute << X.RDB$EXCEPTION_NAME);
BURP_print(true, 312, SafeArg() << attribute << X.RDB$EXCEPTION_NAME);
eat_text(tdgbl);
}
else
@ -3471,7 +3471,7 @@ bool get_exception(BurpGlobals* tdgbl)
BURP_error(311, true, SafeArg() << attribute << X.RDB$EXCEPTION_NAME);
else if (!X.RDB$MESSAGE.NULL)
{
BURP_print(312, SafeArg() << attribute << X.RDB$EXCEPTION_NAME);
BURP_print(true, 312, SafeArg() << attribute << X.RDB$EXCEPTION_NAME);
eat_text2(tdgbl);
}
else
@ -7454,7 +7454,7 @@ bool get_relation(BurpGlobals* tdgbl)
COMMIT
// existing ON_ERROR continues past error, beck
ON_ERROR
BURP_print (171, relation->rel_name);
BURP_print (true, 171, relation->rel_name);
// msg 171: error committing metadata for relation %s
BURP_print_status (tdgbl->status_vector);
ROLLBACK;
@ -7887,9 +7887,9 @@ bool get_mapping(BurpGlobals* tdgbl)
"UPDATE OR INSERT INTO RDB$ROLES(RDB$ROLE_NAME, RDB$SYSTEM_FLAG) VALUES",
ADMIN_ROLE, ROLE_FLAG_MAY_TRUST | ROLE_FLAG_DBO,
"MATCHING (RDB$ROLE_NAME)");
isc_dsql_execute_immediate(tdgbl->status, &tdgbl->db_handle, &tdgbl->tr_handle,
isc_dsql_execute_immediate(tdgbl->status_vector, &tdgbl->db_handle, &tdgbl->tr_handle,
sql.length(), sql.c_str(), 1, NULL);
if (tdgbl->status[1])
if (tdgbl->status_vector[1])
{
general_on_error ();
}
@ -7963,7 +7963,7 @@ bool get_security_class(BurpGlobals* tdgbl)
if (!is_valid_sec_class)
{
MISC_terminate (X.RDB$SECURITY_CLASS, temp, l, sizeof(temp));
BURP_print (234, temp);
BURP_print (true, 234, temp);
// msg 234 Skipped bad security class entry: %s
break;
}
@ -8256,7 +8256,7 @@ bool get_trigger_old (BurpGlobals* tdgbl, burp_rel* relation)
COMMIT
// existing ON_ERROR continues past error, beck
ON_ERROR
BURP_print (94, name);
BURP_print (true, 94, name);
// msg 94 trigger %s is invalid
BURP_print_status (tdgbl->status_vector);
ROLLBACK;
@ -8554,7 +8554,7 @@ bool get_trigger(BurpGlobals* tdgbl)
COMMIT
// existing ON_ERROR continues past error, beck
ON_ERROR
BURP_print (94, name);
BURP_print (true, 94, name);
// msg 94 trigger %s is invalid
BURP_print_status (tdgbl->status_vector);
ROLLBACK;
@ -8650,7 +8650,7 @@ bool get_trigger_message(BurpGlobals* tdgbl)
COMMIT
// existing ON_ERROR continues past error, beck
ON_ERROR
BURP_print (94, name);
BURP_print (true, 94, name);
// msg 94 trigger %s is invalid
BURP_print_status (tdgbl->status_vector);
ROLLBACK;

View File

@ -38,6 +38,26 @@
namespace Firebird {
namespace {
void outputFile(FILE* f, const void* text, size_t len)
{
if (::fwrite(text, 1, len, f) != len)
{
// ASF: If the console is configured to UTF-8 (chcp 65001) with TrueType font, the MSVC
// runtime returns the number of characters (instead of bytes) written and make
// ferror(stdout) return true. So lets not check for errors here.
#ifndef WIN_NT
Firebird::system_call_failed::raise("StandaloneUtilityInterface::output()/fwrite()");
#endif
}
}
void outputFile(FILE* std, const char* text)
{
outputFile(std, text, strlen(text));
}
}
class StandaloneUtilityInterface : public UtilSvc
{
public:
@ -50,30 +70,32 @@ public:
}
}
virtual void output(const char* text)
void outputVerbose(const char* text)
{
size_t len = strlen(text);
if (::fwrite(text, 1, len, stdout) != len)
{
// ASF: If the console is configured to UTF-8 (chcp 65001) with TrueType font, the MSVC
// runtime returns the number of characters (instead of bytes) written and make
// ferror(stdout) return true. So lets not check for errors here.
#ifndef WIN_NT
system_call_failed::raise("StandaloneUtilityInterface::output()/fwrite()");
#endif
}
outputFile(usvcDataMode ? stderr : stdout, text);
}
void outputError(const char* text)
{
outputFile(stderr, text);
}
virtual void printf(const SCHAR* format, ...)
void outputData(const void* data, size_t size)
{
fb_assert(usvcDataMode);
outputFile(stdout, data, size);
}
virtual void printf(bool err, const SCHAR* format, ...)
{
va_list arglist;
va_start(arglist, format);
int rc = ::vprintf(format, arglist);
int rc = ::vfprintf((usvcDataMode || err) ? stderr : stdout, format, arglist);
va_end(arglist);
if (rc < 0)
{
system_call_failed::raise("StandaloneUtilityInterface::printf()/vprintf()");
system_call_failed::raise("StandaloneUtilityInterface::printf()/vfprintf()");
}
}

View File

@ -50,25 +50,31 @@ public:
typedef Firebird::HalfStaticArray<const char*, 20> ArgvType;
public:
UtilSvc() : argv(getPool()) { }
UtilSvc() : argv(getPool()), usvcDataMode(false) { }
virtual void output(const char* text) = 0;
virtual void printf(const SCHAR* format, ...) = 0;
virtual bool isService() = 0;
virtual void started() = 0;
virtual void finish() = 0;
virtual void putLine(char, const char*) = 0;
virtual void putSLong(char, SLONG) = 0;
virtual void outputVerbose(const char* text) = 0;
virtual void outputError(const char* text) = 0;
virtual void outputData(const void* text, size_t size) = 0;
virtual void printf(bool err, const SCHAR* format, ...) = 0;
virtual void putLine(char, const char*) = 0;
virtual void putSLong(char, SLONG) = 0;
virtual void putChar(char, char) = 0;
virtual void putBytes(const UCHAR*, size_t) = 0;
virtual void setServiceStatus(const ISC_STATUS*) = 0;
virtual void setServiceStatus(const USHORT, const USHORT, const MsgFormat::SafeArg&) = 0;
virtual void hidePasswd(ArgvType&, int) = 0;
virtual const ISC_STATUS* getStatus() = 0;
virtual void initStatus() = 0;
virtual void checkService() = 0;
virtual void hidePasswd(ArgvType&, int) = 0;
virtual void getAddressPath(Firebird::ClumpletWriter& dpb) = 0;
virtual bool finished() = 0;
void setDataMode(bool value)
{
usvcDataMode = value;
}
virtual ~UtilSvc() { }
@ -96,6 +102,7 @@ public:
public:
ArgvType argv;
bool usvcDataMode;
};

View File

@ -369,14 +369,35 @@ void Service::parseSwitches()
}
}
void Service::output(const char* text)
void Service::outputVerbose(const char* text)
{
size_t len = strlen(text);
enqueue(reinterpret_cast<const UCHAR*>(text), len);
if (!usvcDataMode)
{
ULONG len = strlen(text);
enqueue(reinterpret_cast<const UCHAR*>(text), len);
}
}
void Service::printf(const SCHAR* format, ...)
void Service::outputError(const char* text)
{
fb_assert(false);
}
void Service::outputData(const void* data, size_t len)
{
fb_assert(usvcDataMode);
enqueue(reinterpret_cast<const UCHAR*>(data), len);
}
void Service::printf(bool err, const SCHAR* format, ...)
{
// Errors are returned from services as vectors
fb_assert(!err);
if (err || usvcDataMode)
{
return;
}
// Ensure that service is not detached.
if (svc_flags & SVC_detached)
{
@ -1521,6 +1542,11 @@ ISC_STATUS Service::query2(thread_db* tdbb,
recv_item_length, recv_items, res_successful);
}
if (status.hasData())
{
status.raise();
}
} // try
catch (const Firebird::Exception& ex)
{
@ -1544,7 +1570,6 @@ ISC_STATUS Service::query2(thread_db* tdbb,
finish(SVC_finished);
}
status.copyTo(svc_status);
return svc_status[1];
}
@ -2138,11 +2163,13 @@ void Service::readFbLog()
started();
svc_started = true;
TEXT buffer[100];
setDataMode(true);
while (!feof(file) && !ferror(file))
{
fgets(buffer, sizeof(buffer), file);
output(buffer);
outputData(buffer, strlen(buffer));
}
setDataMode(false);
}
if (!file || (file && ferror(file)))

View File

@ -95,10 +95,14 @@ class TraceManager;
class Service : public Firebird::UtilSvc, public TypedHandle<type_svc>
{
public: // utilities interface with service
// output to svc_stdout
virtual void output(const char* text);
// output to svc_stdout verbose info
virtual void outputVerbose(const char* text);
// outpur error text
virtual void outputError(const char* text);
// output some data to service
virtual void outputData(const void* data, size_t len);
// printf() to svc_stdout
virtual void printf(const SCHAR* format, ...);
virtual void printf(bool err, const SCHAR* format, ...);
// returns true - it's service :)
virtual bool isService();
// client thread started

View File

@ -85,7 +85,7 @@ void TraceSvcJrd::startSession(TraceSession& session, bool interactive)
{
if (!TraceManager::pluginsCount())
{
m_svc.printf("Can not start trace session. There are no trace plugins loaded\n");
m_svc.printf(false, "Can not start trace session. There are no trace plugins loaded\n");
return;
}
@ -117,7 +117,7 @@ void TraceSvcJrd::startSession(TraceSession& session, bool interactive)
}
m_svc.started();
m_svc.printf("Trace session ID %ld started\n", session.ses_id);
m_svc.printf(false, "Trace session ID %ld started\n", session.ses_id);
if (interactive)
{
@ -147,15 +147,15 @@ void TraceSvcJrd::stopSession(ULONG id)
if (m_admin || m_user == session.ses_user)
{
storage->removeSession(id);
m_svc.printf("Trace session ID %ld stopped\n", id);
m_svc.printf(false, "Trace session ID %ld stopped\n", id);
}
else
m_svc.printf("No permissions to stop other user trace session\n");
m_svc.printf(false, "No permissions to stop other user trace session\n");
return;
}
m_svc.printf("Trace session ID %d not found\n", id);
m_svc.printf(false, "Trace session ID %d not found\n", id);
}
void TraceSvcJrd::setActive(ULONG id, bool active)
@ -163,13 +163,13 @@ void TraceSvcJrd::setActive(ULONG id, bool active)
if (active)
{
if (changeFlags(id, trs_active, 0)) {
m_svc.printf("Trace session ID %ld resumed\n", id);
m_svc.printf(false, "Trace session ID %ld resumed\n", id);
}
}
else
{
if (changeFlags(id, 0, trs_active)) {
m_svc.printf("Trace session ID %ld paused\n", id);
m_svc.printf(false, "Trace session ID %ld paused\n", id);
}
}
}
@ -201,11 +201,11 @@ bool TraceSvcJrd::changeFlags(ULONG id, int setFlags, int clearFlags)
return true;
}
m_svc.printf("No permissions to change other user trace session\n");
m_svc.printf(false, "No permissions to change other user trace session\n");
return false;
}
m_svc.printf("Trace session ID %d not found\n", id);
m_svc.printf(false, "Trace session ID %d not found\n", id);
return false;
}
@ -223,14 +223,14 @@ void TraceSvcJrd::listSessions()
{
if (m_admin || m_user == session.ses_user)
{
m_svc.printf("\nSession ID: %d\n", session.ses_id);
m_svc.printf(false, "\nSession ID: %d\n", session.ses_id);
if (!session.ses_name.empty()) {
m_svc.printf(" name: %s\n", session.ses_name.c_str());
m_svc.printf(false, " name: %s\n", session.ses_name.c_str());
}
m_svc.printf(" user: %s\n", session.ses_user.c_str());
m_svc.printf(false, " user: %s\n", session.ses_user.c_str());
struct tm* t = localtime(&session.ses_start);
m_svc.printf(" date: %04d-%02d-%02d %02d:%02d:%02d\n",
m_svc.printf(false, " date: %04d-%02d-%02d %02d:%02d:%02d\n",
t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
t->tm_hour, t->tm_min, t->tm_sec);
@ -256,7 +256,7 @@ void TraceSvcJrd::listSessions()
if (session.ses_flags & trs_log_full) {
flags += ", log full";
}
m_svc.printf(" flags: %s\n", flags.c_str());
m_svc.printf(false, " flags: %s\n", flags.c_str());
}
}
}
@ -267,7 +267,7 @@ void TraceSvcJrd::readSession(TraceSession& session)
if (session.ses_logfile.empty())
{
m_svc.printf("Can't open trace data log file");
m_svc.printf(false, "Can't open trace data log file");
return;
}

View File

@ -1271,7 +1271,7 @@ static void util_output(const SCHAR* format, ...)
Firebird::string buf;
buf.vprintf(format, arglist);
tdsec->utilSvc->output(buf.c_str());
tdsec->utilSvc->outputError(buf.c_str());
}
va_end(arglist);
}

View File

@ -865,7 +865,7 @@ int gstat(Firebird::UtilSvc* uSvc)
continue;
}
uSvc->printf("%s (%d)\n", relation->rel_name, relation->rel_id);
uSvc->printf(false, "false, %s (%d)\n", relation->rel_name, relation->rel_id);
if (sw_data)
{
@ -874,13 +874,13 @@ int gstat(Firebird::UtilSvc* uSvc)
if (sw_record)
{
uSvc->printf(" Total formats: %d, used formats: %d\n",
uSvc->printf(false, " Total formats: %d, used formats: %d\n",
relation->rel_total_formats, relation->rel_used_formats);
double average = relation->rel_records ?
(double) relation->rel_record_space / relation->rel_records : 0.0;
sprintf((char*) buf, "%.2f", average);
uSvc->printf(" Average record length: %s, total records: %" UQUADFORMAT "\n",
uSvc->printf(false, " Average record length: %s, total records: %" UQUADFORMAT "\n",
buf, relation->rel_records);
// dba_print(18, SafeArg() << buf << relation->rel_records);
// msg 18: " Average record length: %s, total records: %ld
@ -888,7 +888,7 @@ int gstat(Firebird::UtilSvc* uSvc)
average = relation->rel_versions ?
(double) relation->rel_version_space / relation->rel_versions : 0.0;
sprintf((char*) buf, "%.2f", average);
uSvc->printf(" Average version length: %s, total versions: %" UQUADFORMAT ", max versions: %" UQUADFORMAT "\n",
uSvc->printf(false, " Average version length: %s, total versions: %" UQUADFORMAT ", max versions: %" UQUADFORMAT "\n",
buf, relation->rel_versions, relation->rel_max_versions);
// dba_print(19, SafeArg() << buf << relation->rel_versions <<
// relation->rel_max_versions);
@ -897,7 +897,7 @@ int gstat(Firebird::UtilSvc* uSvc)
average = relation->rel_fragments ?
(double) relation->rel_fragment_space / relation->rel_fragments : 0.0;
sprintf((char*) buf, "%.2f", average);
uSvc->printf(" Average fragment length: %s, total fragments: %" UQUADFORMAT ", max fragments: %" UQUADFORMAT "\n",
uSvc->printf(false, " Average fragment length: %s, total fragments: %" UQUADFORMAT ", max fragments: %" UQUADFORMAT "\n",
buf, relation->rel_fragments, relation->rel_max_fragments);
average = relation->rel_records ?
@ -906,12 +906,12 @@ int gstat(Firebird::UtilSvc* uSvc)
average = relation->rel_record_space ?
(double) relation->rel_format_space / relation->rel_record_space : 0.0;
sprintf((char*) buf2, "%.2f", average);
uSvc->printf(" Average unpacked length: %s, compression ratio: %s\n",
uSvc->printf(false, " Average unpacked length: %s, compression ratio: %s\n",
buf, buf2);
}
uSvc->printf(" Pointer pages: %ld, data page slots: %ld\n",
uSvc->printf(false, " Pointer pages: %ld, data page slots: %ld\n",
relation->rel_pointer_pages, relation->rel_slots);
const double average = (relation->rel_data_pages) ?
@ -920,7 +920,7 @@ int gstat(Firebird::UtilSvc* uSvc)
sprintf((char*) buf, "%.0f%%", average);
//dba_print(12, SafeArg() << relation->rel_data_pages << relation->rel_slots << buf);
// msg 12: " Data pages: %ld, data page slots: %ld, average fill: %s
uSvc->printf(" Data pages: %ld, average fill: %s\n", relation->rel_data_pages, buf);
uSvc->printf(false, " Data pages: %ld, average fill: %s\n", relation->rel_data_pages, buf);
dba_print(46, SafeArg() << relation->rel_primary_pages << relation->rel_full_pages <<
relation->rel_swept_pages);
@ -947,7 +947,7 @@ int gstat(Firebird::UtilSvc* uSvc)
dba_print(13); // msg 13: " Fill distribution:"
print_distribution("\t", relation->rel_fill_distribution);
}
uSvc->printf("\n");
uSvc->printf(false, "\n");
for (const dba_idx* index = relation->rel_indexes; index; index = index->idx_next)
{
@ -955,14 +955,14 @@ int gstat(Firebird::UtilSvc* uSvc)
// msg 14: " Index %s (%d)"
//dba_print(15, SafeArg() << index->idx_depth << index->idx_leaf_buckets << index->idx_nodes);
// msg 15: \tDepth: %d, leaf buckets: %ld, nodes: %ld
uSvc->printf("\tRoot page: %d, depth: %d, leaf buckets: %" UQUADFORMAT ", nodes: %" UQUADFORMAT "\n",
uSvc->printf(false, "\tRoot page: %d, depth: %d, leaf buckets: %" UQUADFORMAT ", nodes: %" UQUADFORMAT "\n",
index->idx_root, index->idx_depth, index->idx_leaf_buckets, index->idx_nodes);
double average = (index->idx_nodes) ?
(double) index->idx_total_length / index->idx_nodes : 0.0;
sprintf((char*) buf, "%.2f", average);
// dba_print(16, SafeArg() << buf << index->idx_total_duplicates << index->idx_max_duplicates);
// msg 16: \tAverage data length: %s, total dup: %ld, max dup: %ld"
uSvc->printf("\tAverage node length: %s, total dup: %" UQUADFORMAT ", max dup: %" UQUADFORMAT "\n",
uSvc->printf(false, "\tAverage node length: %s, total dup: %" UQUADFORMAT ", max dup: %" UQUADFORMAT "\n",
buf, index->idx_total_duplicates, index->idx_max_duplicates);
average = (index->idx_nodes) ?
(double) index->idx_packed_length / index->idx_nodes : 0.0;
@ -970,23 +970,23 @@ int gstat(Firebird::UtilSvc* uSvc)
average = index->idx_packed_length ?
(double) index->idx_unpacked_length / index->idx_packed_length : 0.0;
sprintf((char*) buf2, "%.2f", average);
uSvc->printf("\tAverage key length: %s, compression ratio: %s\n", buf, buf2);
uSvc->printf(false, "\tAverage key length: %s, compression ratio: %s\n", buf, buf2);
average = (index->idx_nodes) ?
(double) index->idx_prefix_length / index->idx_nodes : 0.0;
sprintf((char*) buf, "%.2f", average);
average = (index->idx_nodes) ?
(double) index->idx_data_length / index->idx_nodes : 0.0;
sprintf((char*) buf2, "%.2f", average);
uSvc->printf("\tAverage prefix length: %s, average data length: %s\n", buf, buf2);
uSvc->printf(false, "\tAverage prefix length: %s, average data length: %s\n", buf, buf2);
average = (index->idx_nodes) ?
(double) index->idx_diff_pages / index->idx_nodes : 0.0;
sprintf((char*) buf, "%.2f", average);
uSvc->printf("\tClustering factor: %" UQUADFORMAT ", ratio: %s\n",
uSvc->printf(false, "\tClustering factor: %" UQUADFORMAT ", ratio: %s\n",
index->idx_diff_pages, buf);
dba_print(17);
// msg 17: \tFill distribution:
print_distribution("\t ", index->idx_fill_distribution);
uSvc->printf("\n");
uSvc->printf(false, "\n");
}
}
@ -1005,10 +1005,10 @@ int gstat(Firebird::UtilSvc* uSvc)
SCHAR s[1024];
if (fb_interpret(s, sizeof(s), &vector))
{
tddba->uSvc->printf("%s\n", s);
tddba->uSvc->printf(true, "%s\n", s);
s[0] = '-';
while (fb_interpret(s + 1, sizeof(s) - 1, &vector)) {
tddba->uSvc->printf("%s\n", s);
tddba->uSvc->printf(true, "%s\n", s);
}
}
}
@ -1615,7 +1615,7 @@ static void db_error( SLONG status)
sprintf(s, "unknown Windows NT error %ld", status);
}
tddba->uSvc->printf("%s\n", s);
tddba->uSvc->printf(true, "%s\n", s);
dba_exit(FINI_ERROR, tddba);
}
@ -1796,7 +1796,7 @@ static void db_error( int status)
// FIXME: The strerror() function returns the appropriate description
// string, or an unknown error message if the error code is unknown.
// EKU: p cannot be NULL!
tddba->uSvc->printf("%s\n", strerror(status));
tddba->uSvc->printf(true, "%s\n", strerror(status));
dba_exit(FINI_ERROR, tddba);
}
@ -1965,7 +1965,7 @@ static void dba_print(USHORT number, const SafeArg& arg)
tdba* tddba = tdba::getSpecific();
fb_msg_format(NULL, GSTAT_MSG_FAC, number, sizeof(buffer), buffer, arg);
tddba->uSvc->printf("%s\n", buffer);
tddba->uSvc->printf(true, "%s\n", buffer);
}
@ -1985,7 +1985,7 @@ static void print_distribution(const SCHAR* prefix, const ULONG* vector)
for (SSHORT n = 0; n < BUCKETS; n++)
{
tddba->uSvc->printf("%s%2d - %2d%% = %ld\n",
tddba->uSvc->printf(false, "%s%2d - %2d%% = %ld\n",
prefix, n * 100 / BUCKETS, (n + 1) * 100 / BUCKETS - 1, vector[n]);
}
}

View File

@ -55,38 +55,38 @@ void PPG_print_header(const header_page* header, SLONG page,
*
**************************************/
if (page == HEADER_PAGE)
uSvc->printf("Database header page information:\n");
uSvc->printf(false, "Database header page information:\n");
else
uSvc->printf("Database overflow header page information:\n");
uSvc->printf(false, "Database overflow header page information:\n");
if (page == HEADER_PAGE)
{
uSvc->printf("\tFlags\t\t\t%d\n", header->hdr_header.pag_flags);
uSvc->printf(false, "\tFlags\t\t\t%d\n", header->hdr_header.pag_flags);
//uSvc->printf("\tChecksum\t\t%d\n", header->hdr_header.pag_checksum);
uSvc->printf("\tGeneration\t\t%"ULONGFORMAT"\n", header->hdr_header.pag_generation);
uSvc->printf("\tSystem Change Number\t%"ULONGFORMAT"\n", header->hdr_header.pag_scn);
uSvc->printf("\tPage size\t\t%d\n", header->hdr_page_size);
uSvc->printf("\tODS version\t\t%d.%d\n",
uSvc->printf(false, "\tGeneration\t\t%"ULONGFORMAT"\n", header->hdr_header.pag_generation);
uSvc->printf(false, "\tSystem Change Number\t%"ULONGFORMAT"\n", header->hdr_header.pag_scn);
uSvc->printf(false, "\tPage size\t\t%d\n", header->hdr_page_size);
uSvc->printf(false, "\tODS version\t\t%d.%d\n",
header->hdr_ods_version & ~ODS_FIREBIRD_FLAG, header->hdr_ods_minor);
uSvc->printf("\tOldest transaction\t%"SLONGFORMAT"\n", header->hdr_oldest_transaction);
uSvc->printf("\tOldest active\t\t%"SLONGFORMAT"\n", header->hdr_oldest_active);
uSvc->printf("\tOldest snapshot\t\t%"SLONGFORMAT"\n", header->hdr_oldest_snapshot);
uSvc->printf("\tNext transaction\t%"SLONGFORMAT"\n", header->hdr_next_transaction);
uSvc->printf("\tSequence number\t\t%d\n", header->hdr_sequence);
uSvc->printf(false, "\tOldest transaction\t%"SLONGFORMAT"\n", header->hdr_oldest_transaction);
uSvc->printf(false, "\tOldest active\t\t%"SLONGFORMAT"\n", header->hdr_oldest_active);
uSvc->printf(false, "\tOldest snapshot\t\t%"SLONGFORMAT"\n", header->hdr_oldest_snapshot);
uSvc->printf(false, "\tNext transaction\t%"SLONGFORMAT"\n", header->hdr_next_transaction);
uSvc->printf(false, "\tSequence number\t\t%d\n", header->hdr_sequence);
uSvc->printf("\tNext attachment ID\t%"SLONGFORMAT"\n", header->hdr_attachment_id);
uSvc->printf(false, "\tNext attachment ID\t%"SLONGFORMAT"\n", header->hdr_attachment_id);
Firebird::DbImplementation imp(header);
uSvc->printf("\tImplementation\t\tHW=%s %s-endian OS=%s CC=%s\n",
uSvc->printf(false, "\tImplementation\t\tHW=%s %s-endian OS=%s CC=%s\n",
imp.cpu(), imp.endianess(), imp.os(), imp.cc());
uSvc->printf("\tShadow count\t\t%"SLONGFORMAT"\n", header->hdr_shadow_count);
uSvc->printf("\tPage buffers\t\t%"ULONGFORMAT"\n", header->hdr_page_buffers);
uSvc->printf(false, "\tShadow count\t\t%"SLONGFORMAT"\n", header->hdr_shadow_count);
uSvc->printf(false, "\tPage buffers\t\t%"ULONGFORMAT"\n", header->hdr_page_buffers);
}
uSvc->printf("\tNext header page\t%"ULONGFORMAT"\n", header->hdr_next_page);
uSvc->printf(false, "\tNext header page\t%"ULONGFORMAT"\n", header->hdr_next_page);
#ifdef DEV_BUILD
uSvc->printf("\tClumplet End\t\t%d\n", header->hdr_end);
uSvc->printf(false, "\tClumplet End\t\t%d\n", header->hdr_end);
#endif
if (page == HEADER_PAGE)
@ -96,16 +96,16 @@ void PPG_print_header(const header_page* header, SLONG page,
// assume it was set to 1. The reason for this is that a dialect
// 1 database has no dialect information written to the header.
if (header->hdr_flags & hdr_SQL_dialect_3)
uSvc->printf("\tDatabase dialect\t3\n");
uSvc->printf(false, "\tDatabase dialect\t3\n");
else
uSvc->printf("\tDatabase dialect\t1\n");
uSvc->printf(false, "\tDatabase dialect\t1\n");
if (!nocreation)
{
struct tm time;
isc_decode_timestamp(reinterpret_cast<const ISC_TIMESTAMP*>(header->hdr_creation_date),
&time);
uSvc->printf("\tCreation date\t\t%s %d, %d %d:%02d:%02d\n",
uSvc->printf(false, "\tCreation date\t\t%s %d, %d %d:%02d:%02d\n",
FB_SHORT_MONTHS[time.tm_mon], time.tm_mday, time.tm_year + 1900,
time.tm_hour, time.tm_min, time.tm_sec);
}
@ -116,81 +116,81 @@ void PPG_print_header(const header_page* header, SLONG page,
{
int flag_count = 0;
uSvc->printf("\tAttributes\t\t");
uSvc->printf(false, "\tAttributes\t\t");
if (flags & hdr_force_write)
{
uSvc->printf("force write");
uSvc->printf(false, "force write");
flag_count++;
}
if (flags & hdr_no_reserve)
{
if (flag_count++)
uSvc->printf(", ");
uSvc->printf("no reserve");
uSvc->printf(false, ", ");
uSvc->printf(false, "no reserve");
}
/*
if (flags & hdr_disable_cache)
{
if (flag_count++)
uSvc->printf(", ");
uSvc->printf("shared cache disabled");
uSvc->printf(false, ", ");
uSvc->printf(false, "shared cache disabled");
}
*/
if (flags & hdr_active_shadow)
{
if (flag_count++)
uSvc->printf(", ");
uSvc->printf("active shadow");
uSvc->printf(false, ", ");
uSvc->printf(false, "active shadow");
}
const USHORT sd_flags = flags & hdr_shutdown_mask;
if (sd_flags == hdr_shutdown_multi)
{
if (flag_count++)
uSvc->printf(", ");
uSvc->printf("multi-user maintenance");
uSvc->printf(false, ", ");
uSvc->printf(false, "multi-user maintenance");
}
if (sd_flags == hdr_shutdown_single)
{
if (flag_count++)
uSvc->printf(", ");
uSvc->printf("single-user maintenance");
uSvc->printf(false, ", ");
uSvc->printf(false, "single-user maintenance");
}
if (sd_flags == hdr_shutdown_full)
{
if (flag_count++)
uSvc->printf(", ");
uSvc->printf("full shutdown");
uSvc->printf(false, ", ");
uSvc->printf(false, "full shutdown");
}
if (flags & hdr_read_only)
{
if (flag_count++)
uSvc->printf(", ");
uSvc->printf("read only");
uSvc->printf(false, ", ");
uSvc->printf(false, "read only");
}
if (flags & hdr_backup_mask)
{
if (flag_count++)
uSvc->printf(", ");
uSvc->printf(false, ", ");
switch (flags & hdr_backup_mask)
{
case Jrd::nbak_state_stalled:
uSvc->printf("backup lock");
uSvc->printf(false, "backup lock");
break;
case Jrd::nbak_state_merge:
uSvc->printf("backup merge");
uSvc->printf(false, "backup merge");
break;
default:
uSvc->printf("wrong backup state %d", flags & hdr_backup_mask);
uSvc->printf(false, "wrong backup state %d", flags & hdr_backup_mask);
}
}
uSvc->printf("\n");
uSvc->printf(false, "\n");
}
uSvc->printf("\n Variable header data:\n");
uSvc->printf(false, "\n Variable header data:\n");
TEXT temp[257];
@ -204,71 +204,71 @@ void PPG_print_header(const header_page* header, SLONG page,
case HDR_root_file_name:
memcpy(temp, p + 2, p[1]);
temp[p[1]] = '\0';
uSvc->printf("\tRoot file name:\t\t%s\n", temp);
uSvc->printf(false, "\tRoot file name:\t\t%s\n", temp);
break;
/*
case HDR_journal_server:
memcpy(temp, p + 2, p[1]);
temp[p[1]] = '\0';
uSvc->printf("\tJournal server:\t\t%s\n", temp);
uSvc->printf(false, "\tJournal server:\t\t%s\n", temp);
break;
*/
case HDR_file:
memcpy(temp, p + 2, p[1]);
temp[p[1]] = '\0';
uSvc->printf("\tContinuation file:\t\t%s\n", temp);
uSvc->printf(false, "\tContinuation file:\t\t%s\n", temp);
break;
case HDR_last_page:
memcpy(&number, p + 2, sizeof(number));
uSvc->printf("\tLast logical page:\t\t%ld\n", number);
uSvc->printf(false, "\tLast logical page:\t\t%ld\n", number);
break;
/*
case HDR_unlicensed:
memcpy(&number, p + 2, sizeof(number));
uSvc->printf("\tUnlicensed accesses:\t\t%ld\n", number);
uSvc->printf(false, "\tUnlicensed accesses:\t\t%ld\n", number);
break;
*/
case HDR_sweep_interval:
memcpy(&number, p + 2, sizeof(number));
uSvc->printf("\tSweep interval:\t\t%ld\n", number);
uSvc->printf(false, "\tSweep interval:\t\t%ld\n", number);
break;
/*
case HDR_log_name:
memcpy(temp, p + 2, p[1]);
temp[p[1]] = '\0';
uSvc->printf("\tReplay logging file:\t\t%s\n", temp);
uSvc->printf(false, "\tReplay logging file:\t\t%s\n", temp);
break;
case HDR_cache_file:
memcpy(temp, p + 2, p[1]);
temp[p[1]] = '\0';
uSvc->printf("\tShared Cache file:\t\t%s\n", temp);
uSvc->printf(false, "\tShared Cache file:\t\t%s\n", temp);
break;
*/
case HDR_difference_file:
memcpy(temp, p + 2, p[1]);
temp[p[1]] = '\0';
uSvc->printf("\tBackup difference file:\t%s\n", temp);
uSvc->printf(false, "\tBackup difference file:\t%s\n", temp);
break;
case HDR_backup_guid:
{
char buff[GUID_BUFF_SIZE];
GuidToString(buff, reinterpret_cast<const FB_GUID*>(p + 2), true);
uSvc->printf("\tDatabase backup GUID:\t%s\n", buff);
uSvc->printf(false, "\tDatabase backup GUID:\t%s\n", buff);
break;
}
default:
if (*p > HDR_max)
uSvc->printf("\tUnrecognized option %d, length %d\n", p[0], p[1]);
uSvc->printf(false, "\tUnrecognized option %d, length %d\n", p[0], p[1]);
else
uSvc->printf("\tEncoded option %d, length %d\n", p[0], p[1]);
uSvc->printf(false, "\tEncoded option %d, length %d\n", p[0], p[1]);
break;
}
}
uSvc->printf("\t*END*\n");
uSvc->printf(false, "\t*END*\n");
}

View File

@ -1132,7 +1132,7 @@ void NBackup::backup_database(int level, const PathName& fname)
time_t finish = time(NULL);
double elapsed = difftime(finish, start);
uSvc->printf("time elapsed\t%.0f sec \npage reads\t%u \npage writes\t%u\n",
uSvc->printf(false, "time elapsed\t%.0f sec \npage reads\t%u \npage writes\t%u\n",
elapsed, page_reads, page_writes);
}