mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 19:23:03 +01:00
Misc, style, fixing dangerous warnings, constness, etc.
This commit is contained in:
parent
3893f85902
commit
a18dc0519f
@ -804,7 +804,7 @@ SINT64 query_performance_counter()
|
||||
return static_cast<SINT64>(tp.tv_sec) * BILLION + tp.tv_nsec;
|
||||
#else
|
||||
|
||||
// This is not safe because of possible wrapping and very inprecise
|
||||
// This is not safe because of possible wrapping and very imprecise
|
||||
return clock();
|
||||
#endif
|
||||
}
|
||||
@ -828,7 +828,7 @@ SINT64 query_performance_frequency()
|
||||
return BILLION;
|
||||
#else
|
||||
|
||||
// This is not safe because of possible wrapping and very inprecise
|
||||
// This is not safe because of possible wrapping and very imprecise
|
||||
return CLOCKS_PER_SEC;
|
||||
#endif
|
||||
}
|
||||
|
@ -507,12 +507,9 @@ ISC_STATUS DSQL_fetch(thread_db* tdbb,
|
||||
|
||||
const dsql_par* const eof = request->req_eof;
|
||||
|
||||
bool eof_reached = false;
|
||||
if (eof) {
|
||||
eof_reached = !*((USHORT *) eof->par_desc.dsc_address);
|
||||
}
|
||||
const bool eof_reached = eof && !*((USHORT*) eof->par_desc.dsc_address);
|
||||
|
||||
if (eof_reached)
|
||||
if (eof_reached)
|
||||
{
|
||||
trace.fetch(true, res_successful);
|
||||
return 100;
|
||||
@ -2572,15 +2569,21 @@ static dsql_req* prepare(thread_db* tdbb, dsql_dbb* database, jrd_tra* transacti
|
||||
if (!node)
|
||||
return statement;
|
||||
|
||||
statement->req_traced =
|
||||
statement->req_type != REQ_COMMIT &&
|
||||
statement->req_type != REQ_COMMIT_RETAIN &&
|
||||
statement->req_type != REQ_ROLLBACK &&
|
||||
statement->req_type != REQ_ROLLBACK_RETAIN &&
|
||||
statement->req_type != REQ_GET_SEGMENT &&
|
||||
statement->req_type != REQ_PUT_SEGMENT &&
|
||||
statement->req_type != REQ_START_TRANS;
|
||||
|
||||
switch (statement->req_type)
|
||||
{
|
||||
case REQ_COMMIT:
|
||||
case REQ_COMMIT_RETAIN:
|
||||
case REQ_ROLLBACK:
|
||||
case REQ_ROLLBACK_RETAIN:
|
||||
case REQ_GET_SEGMENT:
|
||||
case REQ_PUT_SEGMENT:
|
||||
case REQ_START_TRANS:
|
||||
statement->req_traced = false;
|
||||
break;
|
||||
default:
|
||||
statement->req_traced = true;
|
||||
}
|
||||
|
||||
// stop here for statements not requiring code generation
|
||||
|
||||
if (statement->req_type == REQ_DDL && parser.isStmtAmbiguous() &&
|
||||
@ -2797,7 +2800,7 @@ static void release_request(thread_db* tdbb, dsql_req* request, bool drop)
|
||||
|
||||
Attachment* att = request->req_dbb->dbb_attachment;
|
||||
const bool need_trace_free = request->req_traced && TraceManager::need_dsql_free(att);
|
||||
if (need_trace_free)
|
||||
if (need_trace_free)
|
||||
{
|
||||
TraceSQLStatementImpl stmt(request, NULL);
|
||||
TraceManager::event_dsql_free(att, &stmt, DSQL_drop);
|
||||
|
@ -62,11 +62,11 @@ namespace Jrd
|
||||
PIO_get_unique_file_id(pageSpace->file, buffer);
|
||||
|
||||
Firebird::string file_id;
|
||||
char* s = file_id.getBuffer(2 * buffer.getCount());
|
||||
for (size_t i = 0; i < buffer.getCount(); i++)
|
||||
{
|
||||
TEXT hex[3];
|
||||
sprintf(hex, "%02x", (int) buffer[i]);
|
||||
file_id.append(hex);
|
||||
sprintf(s, "%02x", (int) buffer[i]);
|
||||
s += 2;
|
||||
}
|
||||
|
||||
return file_id;
|
||||
|
@ -34,7 +34,7 @@ GlobalPtr<RuntimeStatistics> RuntimeStatistics::dummy;
|
||||
|
||||
#ifdef REL_COUNTS_TREE
|
||||
|
||||
void RuntimeStatistics::bumpValue(StatType index, SLONG relation_id)
|
||||
void RuntimeStatistics::bumpValue(const StatType index, SLONG relation_id)
|
||||
{
|
||||
fb_assert(index >= 0);
|
||||
++relChgNumber;
|
||||
@ -77,11 +77,14 @@ void RuntimeStatistics::addRelCounts(const RelCounters& other, bool add)
|
||||
RelationCounts& dst = first.current();
|
||||
fb_assert(src.rlc_relation_id == dst.rlc_relation_id);
|
||||
|
||||
for (int index = 0; index < FB_NELEM(src.rlc_counter); index++)
|
||||
if (add)
|
||||
{
|
||||
if (add)
|
||||
for (int index = 0; index < FB_NELEM(src.rlc_counter); index++)
|
||||
dst.rlc_counter[index] += src.rlc_counter[index];
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int index = 0; index < FB_NELEM(src.rlc_counter); index++)
|
||||
dst.rlc_counter[index] -= src.rlc_counter[index];
|
||||
}
|
||||
} while(second.getNext());
|
||||
@ -210,11 +213,14 @@ void RuntimeStatistics::addRelCounts(const RelCounters& other, bool add)
|
||||
RelationCounts* dst = &(rel_counts[pos]);
|
||||
fb_assert(dst->rlc_relation_id == src->rlc_relation_id);
|
||||
|
||||
for (int index = 0; index < FB_NELEM(src->rlc_counter); index++)
|
||||
if (add)
|
||||
{
|
||||
if (add)
|
||||
for (int index = 0; index < FB_NELEM(src->rlc_counter); index++)
|
||||
dst->rlc_counter[index] += src->rlc_counter[index];
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int index = 0; index < FB_NELEM(src->rlc_counter); index++)
|
||||
dst->rlc_counter[index] -= src->rlc_counter[index];
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ public:
|
||||
TOTAL_ITEMS // last
|
||||
};
|
||||
|
||||
RuntimeStatistics(MemoryPool& pool) : rel_counts(pool)
|
||||
explicit RuntimeStatistics(MemoryPool& pool) : rel_counts(pool)
|
||||
{
|
||||
reset();
|
||||
}
|
||||
@ -120,7 +120,7 @@ public:
|
||||
++allChgNumber;
|
||||
}
|
||||
|
||||
void bumpValue(StatType index, SLONG relation_id);
|
||||
void bumpValue(const StatType index, SLONG relation_id);
|
||||
|
||||
// Calculate difference between counts stored in this object and current
|
||||
// counts of given request. Counts stored in object are destroyed.
|
||||
@ -153,7 +153,7 @@ public:
|
||||
}
|
||||
|
||||
// copy counters values from other instance
|
||||
// after copying both instances is "in-sync" i.e. have the same
|
||||
// after copying both instances are "in-sync" i.e. have the same
|
||||
// allChgNumber and relChgNumber values
|
||||
RuntimeStatistics& assign(const RuntimeStatistics& other)
|
||||
{
|
||||
|
@ -457,8 +457,8 @@ public:
|
||||
{
|
||||
if (m_options->dpb_user_name.empty())
|
||||
return m_options->dpb_trusted_login.c_str();
|
||||
else
|
||||
return m_options->dpb_user_name.c_str();
|
||||
|
||||
return m_options->dpb_user_name.c_str();
|
||||
}
|
||||
|
||||
virtual const char* getRoleName() { return m_options->dpb_role_name.c_str(); }
|
||||
|
@ -687,13 +687,13 @@ const ULONG SERVER_CAPABILITIES_FLAG = REMOTE_HOP_SUPPORT | NO_SERVER_SHUTDOWN_S
|
||||
|
||||
Service::Service(const TEXT* service_name, USHORT spb_length, const UCHAR* spb_data)
|
||||
: svc_parsed_sw(getPool()),
|
||||
svc_stdout_head(0), svc_stdout_tail(0), svc_service(NULL), svc_service_run(NULL),
|
||||
svc_stdout_head(0), svc_stdout_tail(0), svc_service(NULL), svc_service_run(NULL),
|
||||
svc_resp_alloc(getPool()), svc_resp_buf(0), svc_resp_ptr(0), svc_resp_buf_len(0),
|
||||
svc_resp_len(0), svc_flags(0), svc_user_flag(0), svc_spb_version(0), svc_do_shutdown(false),
|
||||
svc_username(getPool()), svc_enc_password(getPool()),
|
||||
svc_trusted_login(getPool()), svc_trusted_role(false), svc_uses_security_database(false),
|
||||
svc_switches(getPool()), svc_perm_sw(getPool()), svc_address_path(getPool()),
|
||||
svc_network_protocol(getPool()), svc_remote_address(getPool()), svc_remote_process(getPool()),
|
||||
svc_network_protocol(getPool()), svc_remote_address(getPool()), svc_remote_process(getPool()),
|
||||
svc_remote_pid(0), svc_strings_buffer(NULL)
|
||||
{
|
||||
svc_trace_manager = NULL;
|
||||
@ -902,7 +902,7 @@ static THREAD_ENTRY_DECLARE svcShutdownThread(THREAD_ENTRY_PARAM)
|
||||
void Service::detach()
|
||||
{
|
||||
// save it cause after call to finish() we can't access class members any more
|
||||
bool localDoShutdown = svc_do_shutdown;
|
||||
const bool localDoShutdown = svc_do_shutdown;
|
||||
|
||||
if (svc_uses_security_database)
|
||||
{
|
||||
@ -2082,7 +2082,7 @@ void Service::readFbLog()
|
||||
}
|
||||
}
|
||||
|
||||
if (!file || (file && ferror(file)))
|
||||
if (!file || (file && ferror(file)))
|
||||
{
|
||||
(Arg::Gds(isc_sys_request) << Arg::Str(file ? "fgets" : "fopen") <<
|
||||
SYS_ERR(errno)).copyTo(svc_status);
|
||||
@ -2238,7 +2238,7 @@ void Service::get(SCHAR* buffer, USHORT length, USHORT flags, USHORT timeout, US
|
||||
* characters with a space. This will ensure that the output is
|
||||
* consistent when returning a line or to eof
|
||||
*/
|
||||
if ((flags & GET_LINE) && ch == '\n')
|
||||
if ((flags & GET_LINE) && ch == '\n')
|
||||
{
|
||||
buffer[(*return_length)++] = ' ';
|
||||
length = 0;
|
||||
@ -2597,7 +2597,7 @@ bool Service::process_switches(ClumpletReader& spb, string& switches)
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case isc_action_svc_trace_start:
|
||||
case isc_action_svc_trace_stop:
|
||||
case isc_action_svc_trace_suspend:
|
||||
|
@ -168,8 +168,8 @@ public: // external interface with service
|
||||
{
|
||||
if (svc_username.empty())
|
||||
return svc_trusted_login;
|
||||
else
|
||||
return svc_username;
|
||||
|
||||
return svc_username;
|
||||
}
|
||||
|
||||
const Firebird::string& getNetworkProtocol() const { return svc_network_protocol; }
|
||||
|
@ -55,7 +55,7 @@ static void usage(UtilSvc* uSvc, const char* message, ...)
|
||||
"Actions: \n"
|
||||
" -STA[RT] Start trace session\n"
|
||||
" -STO[P] Stop trace session\n"
|
||||
" -S[USPEND] Susupend trace session\n"
|
||||
" -S[USPEND] Suspend trace session\n"
|
||||
" -R[ESUME] Resume trace session\n"
|
||||
" -L[IST] List existing trace sessions\n\n"
|
||||
"Parameters: \n"
|
||||
@ -143,11 +143,11 @@ static const in_sw_tab_t* findSwitch(const in_sw_tab_t* table, string sw)
|
||||
const char* TRACE_ERR_CONFLICT_ACTS = "conflicting actions \"%s\" and \"%s\" found";
|
||||
const char* TRACE_ERR_ACT_NOTFOUND = "action switch not found";
|
||||
const char* TRACE_ERR_SWITCH_ONCE = "switch \"%s\" must be set only once";
|
||||
const char* TRACE_ERR_PARAM_VAL_MISS = "value for switch \"%s\" is missed";
|
||||
const char* TRACE_ERR_PARAM_VAL_MISS = "value for switch \"%s\" is missing";
|
||||
const char* TRACE_ERR_PARAM_INVALID = "invalid value (\"%s\") for switch \"%s\"";
|
||||
const char* TRACE_ERR_SWITCH_UNKNOWN = "unknow switch \"%s\" encountered";
|
||||
const char* TRACE_ERR_SWITCH_UNKNOWN = "unknown switch \"%s\" encountered";
|
||||
const char* TRACE_ERR_SWITCH_SVC_ONLY = "switch \"%s\" can be used by service only";
|
||||
const char* TRACE_ERR_SWITCH_PARAM_MISS = "mandatory parameter \"%s\" for switch \"%s\" is missed";
|
||||
const char* TRACE_ERR_SWITCH_PARAM_MISS = "mandatory parameter \"%s\" for switch \"%s\" is missing";
|
||||
const char* TRACE_ERR_PARAM_ACT_NOTCOMPAT = "parameter \"%s\" is incompatible with action \"%s\"";
|
||||
|
||||
|
||||
|
@ -196,7 +196,7 @@ void ConfigStorage::checkFile()
|
||||
{
|
||||
fseek(cfgFile, 0, SEEK_SET);
|
||||
char* p = session.ses_config.getBuffer(len + 1);
|
||||
if (fread(p, 1, len, cfgFile) != len)
|
||||
if (fread(p, 1, len, cfgFile) != size_t(len))
|
||||
{
|
||||
Arg::Gds temp(isc_io_error);
|
||||
temp << Arg::Str("fopen") << Arg::Str(configFileName.c_str());
|
||||
@ -375,7 +375,11 @@ void ConfigStorage::removeSession(ULONG id)
|
||||
setDirty();
|
||||
|
||||
currID = 0;
|
||||
lseek(m_cfg_file, -len, SEEK_CUR);
|
||||
// Do not delete this temporary signed var, otherwise we get
|
||||
// warning C4146: unary minus operator applied to unsigned type, result still unsigned
|
||||
// but we need a negative offset here.
|
||||
const long local_len = len;
|
||||
lseek(m_cfg_file, -local_len, SEEK_CUR);
|
||||
write(m_cfg_file, &currID, len);
|
||||
break;
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ public:
|
||||
class StorageGuard
|
||||
{
|
||||
public:
|
||||
StorageGuard(ConfigStorage* storage) :
|
||||
explicit StorageGuard(ConfigStorage* storage) :
|
||||
m_storage(storage)
|
||||
{
|
||||
m_storage->acquire();
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
|
||||
m_start_clock = fb_utils::query_performance_counter();
|
||||
|
||||
static char empty_string[] = "";
|
||||
static const char empty_string[] = "";
|
||||
if (!m_string_len || !string)
|
||||
{
|
||||
m_string = empty_string;
|
||||
@ -95,7 +95,7 @@ public:
|
||||
|
||||
private:
|
||||
bool m_need_trace;
|
||||
Attachment* m_attachment;
|
||||
Attachment* const m_attachment;
|
||||
dsql_req* m_request;
|
||||
SINT64 m_start_clock;
|
||||
size_t m_string_len;
|
||||
@ -164,8 +164,8 @@ public:
|
||||
|
||||
private:
|
||||
bool m_need_trace;
|
||||
Attachment* m_attachment;
|
||||
dsql_req* m_request;
|
||||
Attachment* const m_attachment;
|
||||
dsql_req* const m_request;
|
||||
SINT64 m_start_clock;
|
||||
};
|
||||
|
||||
@ -216,8 +216,8 @@ public:
|
||||
|
||||
private:
|
||||
bool m_need_trace;
|
||||
Attachment* m_attachment;
|
||||
dsql_req* m_request;
|
||||
Attachment* const m_attachment;
|
||||
dsql_req* const m_request;
|
||||
SINT64 m_start_clock;
|
||||
};
|
||||
|
||||
|
@ -78,9 +78,9 @@ public:
|
||||
|
||||
private:
|
||||
bool m_need_trace;
|
||||
bool m_commit;
|
||||
bool m_retain;
|
||||
jrd_tra* m_transaction;
|
||||
const bool m_commit;
|
||||
const bool m_retain;
|
||||
jrd_tra* const m_transaction;
|
||||
SINT64 m_start_clock;
|
||||
Firebird::AutoPtr<RuntimeStatistics> m_baseline;
|
||||
};
|
||||
@ -156,8 +156,8 @@ public:
|
||||
|
||||
private:
|
||||
bool m_need_trace;
|
||||
thread_db* m_tdbb;
|
||||
jrd_req* m_request;
|
||||
thread_db* const m_tdbb;
|
||||
jrd_req* const m_request;
|
||||
SINT64 m_start_clock;
|
||||
};
|
||||
|
||||
@ -213,8 +213,8 @@ public:
|
||||
|
||||
private:
|
||||
bool m_need_trace;
|
||||
thread_db* m_tdbb;
|
||||
jrd_req* m_request;
|
||||
thread_db* const m_tdbb;
|
||||
jrd_req* const m_request;
|
||||
SINT64 m_start_clock;
|
||||
};
|
||||
|
||||
@ -278,10 +278,10 @@ public:
|
||||
|
||||
private:
|
||||
bool m_need_trace;
|
||||
thread_db* m_tdbb;
|
||||
jrd_req* m_request;
|
||||
thread_db* const m_tdbb;
|
||||
jrd_req* const m_request;
|
||||
SINT64 m_start_clock;
|
||||
int m_which_trig;
|
||||
const int m_which_trig;
|
||||
};
|
||||
|
||||
|
||||
@ -342,10 +342,10 @@ public:
|
||||
|
||||
private:
|
||||
bool m_need_trace;
|
||||
thread_db* m_tdbb;
|
||||
thread_db* const m_tdbb;
|
||||
SINT64 m_start_clock;
|
||||
size_t m_blr_length;
|
||||
const SCHAR* m_blr;
|
||||
const size_t m_blr_length;
|
||||
const SCHAR* const m_blr;
|
||||
};
|
||||
|
||||
|
||||
@ -406,8 +406,8 @@ public:
|
||||
|
||||
private:
|
||||
bool m_need_trace;
|
||||
thread_db* m_tdbb;
|
||||
jrd_req* m_request;
|
||||
thread_db* const m_tdbb;
|
||||
jrd_req* const m_request;
|
||||
SINT64 m_start_clock;
|
||||
};
|
||||
|
||||
@ -457,10 +457,10 @@ public:
|
||||
|
||||
private:
|
||||
bool m_need_trace;
|
||||
thread_db* m_tdbb;
|
||||
thread_db* const m_tdbb;
|
||||
SINT64 m_start_clock;
|
||||
size_t m_ddl_length;
|
||||
const SCHAR* m_ddl;
|
||||
const size_t m_ddl_length;
|
||||
const SCHAR* const m_ddl;
|
||||
};
|
||||
|
||||
} // namespace Jrd
|
||||
|
@ -144,7 +144,7 @@ size_t TraceLogImpl::read(void* buf, size_t size)
|
||||
const off_t len = lseek(m_fileHandle, 0, SEEK_CUR);
|
||||
if (len >= MAX_LOG_FILE_SIZE)
|
||||
{
|
||||
// this file was reads completely, go to next one
|
||||
// this file was read completely, go to next one
|
||||
::close(m_fileHandle);
|
||||
removeFile(m_fileNum);
|
||||
|
||||
@ -193,7 +193,7 @@ size_t TraceLogImpl::write(const void* buf, size_t size)
|
||||
if (!toWrite)
|
||||
{
|
||||
// While this instance of writer was idle, new log file was created.
|
||||
// More, if current file was already readed by reader, we must delete it.
|
||||
// More, if current file was already read by reader, we must delete it.
|
||||
::close(m_fileHandle);
|
||||
if (m_fileNum < m_base->readFileNum) {
|
||||
removeFile(m_fileNum);
|
||||
@ -204,6 +204,8 @@ size_t TraceLogImpl::write(const void* buf, size_t size)
|
||||
}
|
||||
|
||||
const int written = ::write(m_fileHandle, p, toWrite);
|
||||
if (written == -1 || size_t(written) != toWrite)
|
||||
system_call_failed::raise("write", errno);
|
||||
|
||||
p += toWrite;
|
||||
writeLeft -= toWrite;
|
||||
|
@ -85,18 +85,18 @@ friend class TraceLogGuard;
|
||||
class TraceLogGuard
|
||||
{
|
||||
public:
|
||||
TraceLogGuard(TraceLogImpl* log) : m_log(log)
|
||||
explicit TraceLogGuard(TraceLogImpl* log) : m_log(*log)
|
||||
{
|
||||
m_log->lock();
|
||||
m_log.lock();
|
||||
}
|
||||
|
||||
~TraceLogGuard()
|
||||
{
|
||||
m_log->unlock();
|
||||
m_log.unlock();
|
||||
}
|
||||
|
||||
private:
|
||||
TraceLogImpl* m_log;
|
||||
TraceLogImpl& m_log;
|
||||
};
|
||||
|
||||
|
||||
|
@ -79,11 +79,11 @@ bool TraceManager::check_result(const TracePlugin* plugin, const char* module, c
|
||||
return false;
|
||||
}
|
||||
|
||||
TraceManager::TraceManager(Attachment* _att) :
|
||||
attachment(_att),
|
||||
TraceManager::TraceManager(Attachment* in_att) :
|
||||
attachment(in_att),
|
||||
service(NULL),
|
||||
filename(NULL),
|
||||
trace_sessions(*_att->att_pool)
|
||||
trace_sessions(*in_att->att_pool)
|
||||
{
|
||||
change_number = 0;
|
||||
|
||||
@ -91,11 +91,11 @@ TraceManager::TraceManager(Attachment* _att) :
|
||||
load_modules();
|
||||
}
|
||||
|
||||
TraceManager::TraceManager(Service* _svc) :
|
||||
TraceManager::TraceManager(Service* in_svc) :
|
||||
attachment(NULL),
|
||||
service(_svc),
|
||||
service(in_svc),
|
||||
filename(NULL),
|
||||
trace_sessions(_svc->getPool())
|
||||
trace_sessions(in_svc->getPool())
|
||||
{
|
||||
change_number = 0;
|
||||
|
||||
@ -103,10 +103,10 @@ TraceManager::TraceManager(Service* _svc) :
|
||||
load_modules();
|
||||
}
|
||||
|
||||
TraceManager::TraceManager(const char* _filename) :
|
||||
TraceManager::TraceManager(const char* in_filename) :
|
||||
attachment(NULL),
|
||||
service(NULL),
|
||||
filename(_filename),
|
||||
filename(in_filename),
|
||||
trace_sessions(*getDefaultMemoryPool())
|
||||
{
|
||||
change_number = 0;
|
||||
@ -145,7 +145,7 @@ void TraceManager::load_modules()
|
||||
|
||||
while (plugins.next())
|
||||
{
|
||||
PathName modLib(plugins.getFileName());
|
||||
const PathName modLib(plugins.getFileName());
|
||||
if (modLib.find(NTRACE_PREFIX) == PathName::npos)
|
||||
continue;
|
||||
|
||||
|
@ -49,9 +49,9 @@ class TraceManager
|
||||
{
|
||||
public:
|
||||
/* Initializes plugins. */
|
||||
TraceManager(Attachment* att);
|
||||
TraceManager(Service* svc);
|
||||
TraceManager(const char* filename);
|
||||
explicit TraceManager(Attachment* in_att);
|
||||
explicit TraceManager(Service* in_svc);
|
||||
explicit TraceManager(const char* in_filename);
|
||||
|
||||
/* Finalize plugins. Called when database is closed by the engine */
|
||||
~TraceManager();
|
||||
|
@ -199,8 +199,8 @@ int TraceSQLStatementImpl::getStmtID()
|
||||
{
|
||||
if (m_stmt->req_request)
|
||||
return m_stmt->req_request->req_id;
|
||||
else
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char* TraceSQLStatementImpl::getText()
|
||||
@ -216,7 +216,7 @@ const char* TraceSQLStatementImpl::getPlan()
|
||||
m_plan = &buff;
|
||||
|
||||
const int len = DSQL_get_plan_info(JRD_get_thread_data(),
|
||||
const_cast<dsql_req*> (m_stmt), sizeof(buff), &m_plan);
|
||||
const_cast<dsql_req*>(m_stmt), sizeof(buff), &m_plan);
|
||||
|
||||
if (len)
|
||||
m_plan[len] = 0;
|
||||
@ -326,14 +326,14 @@ void TraceProcedureImpl::JrdParamsImpl::fillParams()
|
||||
dsc* from_desc = NULL;
|
||||
dsc desc;
|
||||
|
||||
jrd_nod* const prm = (*ptr)->nod_arg[e_asgn_to];
|
||||
const jrd_nod* const prm = (*ptr)->nod_arg[e_asgn_to];
|
||||
switch (prm->nod_type)
|
||||
{
|
||||
case nod_argument:
|
||||
{
|
||||
impure_value* impure = (impure_value*) ((SCHAR *) m_request + prm->nod_impure);
|
||||
jrd_nod* message = prm->nod_arg[e_arg_message];
|
||||
Format* format = (Format*) message->nod_arg[e_msg_format];
|
||||
//const impure_value* impure = (impure_value*) ((SCHAR *) m_request + prm->nod_impure);
|
||||
const jrd_nod* message = prm->nod_arg[e_arg_message];
|
||||
const Format* format = (Format*) message->nod_arg[e_msg_format];
|
||||
const int arg_number = (int) (IPTR) prm->nod_arg[e_arg_number];
|
||||
|
||||
desc = format->fmt_desc[arg_number];
|
||||
@ -343,7 +343,7 @@ void TraceProcedureImpl::JrdParamsImpl::fillParams()
|
||||
// handle null flag if present
|
||||
if (prm->nod_arg[e_arg_flag])
|
||||
{
|
||||
dsc* flag = EVL_expr(tdbb, prm->nod_arg[e_arg_flag]);
|
||||
const dsc* flag = EVL_expr(tdbb, prm->nod_arg[e_arg_flag]);
|
||||
if (MOV_get_long(flag, 0)) {
|
||||
from_desc->dsc_flags |= DSC_null;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
* See the License for the specific language governing rights
|
||||
* and limitations under the License.
|
||||
*
|
||||
* The Original Code was created by Khorsun Vladyslav
|
||||
* The Original Code was created by Khorsun Vladyslav
|
||||
* for the Firebird Open Source RDBMS project.
|
||||
*
|
||||
* Copyright (c) 2009 Khorsun Vladyslav <hvlad@users.sourceforge.net>
|
||||
@ -65,7 +65,7 @@ public:
|
||||
virtual const char* getRemoteProcessName();
|
||||
|
||||
private:
|
||||
const Attachment* m_att;
|
||||
const Attachment* const m_att;
|
||||
};
|
||||
|
||||
|
||||
@ -84,8 +84,8 @@ public:
|
||||
virtual PerformanceInfo* getPerf() { return m_perf; }
|
||||
|
||||
private:
|
||||
const jrd_tra* m_tran;
|
||||
PerformanceInfo* m_perf;
|
||||
const jrd_tra* const m_tran;
|
||||
PerformanceInfo* const m_perf;
|
||||
};
|
||||
|
||||
|
||||
@ -93,7 +93,7 @@ class TraceDYNRequestImpl : public TraceDYNRequest
|
||||
{
|
||||
public:
|
||||
TraceDYNRequestImpl(size_t length, const char* ddl) :
|
||||
m_ddl(ddl),
|
||||
m_ddl(ddl),
|
||||
m_length(length),
|
||||
m_text(*getDefaultMemoryPool())
|
||||
{}
|
||||
@ -105,8 +105,8 @@ public:
|
||||
private:
|
||||
static void print_dyn(void* arg, SSHORT offset, const char* line);
|
||||
|
||||
const char* m_ddl;
|
||||
size_t m_length;
|
||||
const char* const m_ddl;
|
||||
const size_t m_length;
|
||||
Firebird::string m_text;
|
||||
};
|
||||
|
||||
@ -115,7 +115,7 @@ class BLRPrinter : public TraceBLRStatement
|
||||
{
|
||||
public:
|
||||
BLRPrinter(const char* blr, size_t length) :
|
||||
m_blr(blr),
|
||||
m_blr(blr),
|
||||
m_length(length),
|
||||
m_text(*getDefaultMemoryPool())
|
||||
{}
|
||||
@ -127,8 +127,8 @@ public:
|
||||
private:
|
||||
static void print_blr(void* arg, SSHORT offset, const char* line);
|
||||
|
||||
const char* m_blr;
|
||||
size_t m_length;
|
||||
const char* const m_blr;
|
||||
const size_t m_length;
|
||||
Firebird::string m_text;
|
||||
};
|
||||
|
||||
@ -142,12 +142,12 @@ public:
|
||||
m_perf(perf)
|
||||
{}
|
||||
|
||||
virtual int getStmtID() { return m_stmt->req_id; }
|
||||
virtual int getStmtID() { return m_stmt->req_id; }
|
||||
virtual PerformanceInfo* getPerf() { return m_perf; }
|
||||
|
||||
private:
|
||||
const jrd_req* m_stmt;
|
||||
PerformanceInfo* m_perf;
|
||||
const jrd_req* const m_stmt;
|
||||
PerformanceInfo* const m_perf;
|
||||
};
|
||||
|
||||
|
||||
@ -200,8 +200,8 @@ private:
|
||||
Firebird::HalfStaticArray<dsc, 16> m_descs;
|
||||
};
|
||||
|
||||
const dsql_req* m_stmt;
|
||||
PerformanceInfo* m_perf;
|
||||
const dsql_req* const m_stmt;
|
||||
PerformanceInfo* const m_perf;
|
||||
char* m_plan;
|
||||
DSQLParamsImpl m_inputs;
|
||||
};
|
||||
@ -239,9 +239,9 @@ public:
|
||||
virtual const char* getVarValue() { return m_value; }
|
||||
|
||||
private:
|
||||
const char* m_namespace;
|
||||
const char* m_name;
|
||||
const char* m_value;
|
||||
const char* const m_namespace;
|
||||
const char* const m_name;
|
||||
const char* const m_value;
|
||||
};
|
||||
|
||||
class TraceProcedureImpl : public TraceProcedure
|
||||
@ -278,8 +278,8 @@ private:
|
||||
Firebird::HalfStaticArray<dsc, 16> m_descs;
|
||||
};
|
||||
|
||||
const jrd_req* m_request;
|
||||
PerformanceInfo* m_perf;
|
||||
const jrd_req* const m_request;
|
||||
PerformanceInfo* const m_perf;
|
||||
JrdParamsImpl m_inputs;
|
||||
};
|
||||
|
||||
@ -300,9 +300,9 @@ public:
|
||||
virtual PerformanceInfo* getPerf() { return m_perf; }
|
||||
|
||||
private:
|
||||
const jrd_req* m_trig;
|
||||
SSHORT m_which;
|
||||
PerformanceInfo* m_perf;
|
||||
const jrd_req* const m_trig;
|
||||
const SSHORT m_which;
|
||||
PerformanceInfo* const m_perf;
|
||||
};
|
||||
|
||||
|
||||
@ -325,17 +325,17 @@ public:
|
||||
virtual const char* getRemoteProcessName();
|
||||
|
||||
private:
|
||||
const Service* m_svc;
|
||||
const Service* const m_svc;
|
||||
};
|
||||
|
||||
|
||||
class TraceRuntimeStats
|
||||
{
|
||||
public:
|
||||
TraceRuntimeStats(Database* dbb, RuntimeStatistics* baseline, RuntimeStatistics* stats,
|
||||
TraceRuntimeStats(Database* dbb, RuntimeStatistics* baseline, RuntimeStatistics* stats,
|
||||
SINT64 clock, SINT64 records_fetched);
|
||||
|
||||
PerformanceInfo* getPerf() { return &m_info; }
|
||||
PerformanceInfo* getPerf() { return &m_info; }
|
||||
|
||||
private:
|
||||
PerformanceInfo m_info;
|
||||
@ -347,19 +347,19 @@ private:
|
||||
class TraceInitInfoImpl : public TraceInitInfo
|
||||
{
|
||||
public:
|
||||
TraceInitInfoImpl(const Firebird::TraceSession &session, const Attachment* att,
|
||||
TraceInitInfoImpl(const Firebird::TraceSession &session, const Attachment* att,
|
||||
const char* filename) :
|
||||
m_session(session),
|
||||
m_trace_conn(att),
|
||||
m_filename(filename)
|
||||
m_filename(filename),
|
||||
m_attachment(att)
|
||||
{
|
||||
m_attachment = att;
|
||||
if (m_attachment && !m_attachment->att_filename.empty()) {
|
||||
m_filename = m_attachment->att_filename.c_str();
|
||||
}
|
||||
m_logWriter = NULL;
|
||||
}
|
||||
|
||||
|
||||
virtual const char* getConfigText() { return m_session.ses_config.c_str(); }
|
||||
virtual int getTraceSessionID() { return m_session.ses_id; }
|
||||
virtual const char* getTraceSessionName() { return m_session.ses_name.c_str(); }
|
||||
@ -367,24 +367,24 @@ public:
|
||||
virtual const char* getDatabaseName() { return m_filename; }
|
||||
|
||||
virtual TraceConnection* getConnection()
|
||||
{
|
||||
{
|
||||
if (m_attachment)
|
||||
return &m_trace_conn;
|
||||
else
|
||||
return NULL;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
virtual TraceLogWriter* getLogWriter();
|
||||
|
||||
private:
|
||||
const Firebird::TraceSession& m_session;
|
||||
const Attachment* m_attachment;
|
||||
TraceLogWriter* m_logWriter;
|
||||
TraceConnectionImpl m_trace_conn;
|
||||
const char* m_filename;
|
||||
const Attachment* const m_attachment;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Jrd
|
||||
} // namespace Jrd
|
||||
|
||||
#endif // JRD_TRACE_OBJECTS_H
|
||||
|
@ -48,7 +48,7 @@ using namespace Jrd;
|
||||
class TraceSvcJrd : public TraceSvcIntf
|
||||
{
|
||||
public:
|
||||
TraceSvcJrd(Service& svc) :
|
||||
explicit TraceSvcJrd(Service& svc) :
|
||||
m_svc(svc),
|
||||
m_admin(false),
|
||||
m_chg_number(0)
|
||||
@ -269,7 +269,6 @@ void TraceSvcJrd::readSession(TraceSession& session)
|
||||
TraceManager* mgr = m_svc.getTraceManager();
|
||||
ConfigStorage* storage = mgr->getStorage();
|
||||
const size_t maxLogSize = Config::getMaxUserTraceLogSize(); // in MB
|
||||
bool logFull = false;
|
||||
|
||||
if (session.ses_logfile.empty())
|
||||
{
|
||||
@ -280,6 +279,7 @@ void TraceSvcJrd::readSession(TraceSession& session)
|
||||
MemoryPool& pool = *getDefaultMemoryPool();
|
||||
AutoPtr<TraceLogImpl> log(FB_NEW(pool) TraceLogImpl(pool, session.ses_logfile, true));
|
||||
|
||||
bool logFull = false;
|
||||
UCHAR buff[1024];
|
||||
while (!m_svc.finished() && checkAlive(session.ses_id))
|
||||
{
|
||||
@ -288,8 +288,8 @@ void TraceSvcJrd::readSession(TraceSession& session)
|
||||
{
|
||||
if (!checkAlive(session.ses_id))
|
||||
break;
|
||||
else
|
||||
THD_sleep(250);
|
||||
|
||||
THD_sleep(250);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -43,7 +43,7 @@ const int trs_log_full = 0x0008; // session trace log is full
|
||||
class TraceSession
|
||||
{
|
||||
public:
|
||||
TraceSession(MemoryPool& pool) :
|
||||
explicit TraceSession(MemoryPool& pool) :
|
||||
ses_id(0),
|
||||
ses_name(pool),
|
||||
ses_user(pool),
|
||||
|
@ -142,9 +142,11 @@ bool putFileFromArgument(char**& av, ClumpletWriter& spb, unsigned int tag)
|
||||
|
||||
fseek(file, 0, SEEK_SET);
|
||||
if (fread(p, 1, len, file) != len) {
|
||||
fclose(file);
|
||||
(Arg::Gds(isc_fbsvcmgr_fp_read) << *av << Arg::OsError()).raise();
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
spb.insertBytes(tag, p, len);
|
||||
++av;
|
||||
|
||||
@ -838,7 +840,7 @@ int main(int ac, char** av)
|
||||
|
||||
if (spbItems.getBufferLength() > 0)
|
||||
{
|
||||
char send[] = {isc_info_svc_timeout, 2, 0, 1, 0, 0, 0, isc_info_end};
|
||||
const char send[] = {isc_info_svc_timeout, 2, 0, 1, 0, 0, 0, isc_info_end};
|
||||
|
||||
char results[maxbuf];
|
||||
UserPrint up;
|
||||
|
@ -60,7 +60,7 @@ private:
|
||||
bool parseBoolean(const Firebird::string& value) const;
|
||||
ULONG parseUInteger(const Firebird::string& value) const;
|
||||
|
||||
const char* m_text;
|
||||
const char* const m_text;
|
||||
const Firebird::PathName& m_databaseName;
|
||||
regmatch_t m_subpatterns[10];
|
||||
TracePluginConfig& m_config;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -140,7 +140,7 @@ private:
|
||||
bool operational; // Set if plugin is fully initialized and is ready for logging
|
||||
// Keep this member field first to ensure its correctness
|
||||
// when destructor is called
|
||||
int session_id; // trace session ID, set by Firebird
|
||||
const int session_id; // trace session ID, set by Firebird
|
||||
Firebird::string session_name; // trace session name, set by Firebird
|
||||
FileObject* logFile; // Thread-safe
|
||||
TraceLogWriter* logWriter;
|
||||
@ -169,8 +169,8 @@ private:
|
||||
void rotateLog(size_t added_bytes_length);
|
||||
void writePacket(const UCHAR* packet_data, const ULONG packet_size);
|
||||
|
||||
void appendGlobalCounts(PerformanceInfo* info, Firebird::string& line);
|
||||
void appendTableCounts(PerformanceInfo* info, Firebird::string& line);
|
||||
void appendGlobalCounts(const PerformanceInfo* info, Firebird::string& line);
|
||||
void appendTableCounts(const PerformanceInfo* info, Firebird::string& line);
|
||||
void appendParams(TraceParams* params, Firebird::string& line);
|
||||
void appendServiceQueryParams(size_t send_item_length,
|
||||
const ntrace_byte_t* send_items, size_t recv_item_length,
|
||||
|
@ -26,7 +26,7 @@
|
||||
#log_filename
|
||||
|
||||
# Maximum size of log file (megabytes). Used by system audit trace for
|
||||
# log's rotation : when current log file reached this limit its renamed
|
||||
# log's rotation : when current log file reached this limit it is renamed
|
||||
# using current date and time and new log file is created
|
||||
max_log_size 0
|
||||
|
||||
|
@ -25,8 +25,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FILEOBJECT_H
|
||||
#define FILEOBJECT_H
|
||||
#ifndef OS_FILEOBJECT_H
|
||||
#define OS_FILEOBJECT_H
|
||||
|
||||
#include "../../../common/classes/fb_string.h"
|
||||
#include "../../../common/classes/locks.h"
|
||||
@ -180,4 +180,4 @@ private:
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // FILEOBJECT_H
|
||||
#endif // OS_FILEOBJECT_H
|
||||
|
@ -25,8 +25,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PLATFORM_H
|
||||
#define PLATFORM_H
|
||||
#ifndef OS_PLATFORM_H
|
||||
#define OS_PLATFORM_H
|
||||
|
||||
const char* get_error_string();
|
||||
|
||||
@ -34,4 +34,4 @@ void set_error_string(const char* str);
|
||||
|
||||
SLONG get_process_id();
|
||||
|
||||
#endif // PLATFORM_H
|
||||
#endif // OS_PLATFORM_H
|
||||
|
@ -147,7 +147,7 @@ bool FileObject::renameFile(const Firebird::PathName new_filename)
|
||||
{
|
||||
int rename_err = errno;
|
||||
if (rename_err == ENOENT || rename_err == EEXIST) {
|
||||
// Another process renames our file just now. Open new it.
|
||||
// Another process renames our file just now. Open it again.
|
||||
reopen();
|
||||
return false;
|
||||
}
|
||||
|
@ -31,8 +31,10 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define TEST
|
||||
//#undef TEST
|
||||
|
||||
#ifndef TEST
|
||||
class MallocClear
|
||||
{
|
||||
@ -60,17 +62,18 @@ void set_error_string(const char* str)
|
||||
}
|
||||
if (str)
|
||||
{
|
||||
size_t len = strlen(str);
|
||||
char* new_str = (char*) malloc(len + 1);
|
||||
const size_t size = strlen(str) + 1;
|
||||
char* new_str = (char*) malloc(size);
|
||||
if (new_str)
|
||||
{
|
||||
memcpy(new_str, str, len + 1);
|
||||
memcpy(new_str, str, size);
|
||||
error_value.set(new_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
TLS_DECLARE(char*, error_string);
|
||||
|
||||
const char* get_error_string()
|
||||
{
|
||||
return TLS_GET(error_string);
|
||||
@ -86,16 +89,17 @@ void set_error_string(const char* str)
|
||||
}
|
||||
if (str)
|
||||
{
|
||||
size_t len = strlen(str);
|
||||
char* new_str = (char*) malloc(len + 1);
|
||||
const size_t size = strlen(str) + 1;
|
||||
char* new_str = (char*) malloc(size);
|
||||
if (new_str)
|
||||
{
|
||||
memcpy(new_str, str, len + 1);
|
||||
memcpy(new_str, str, size);
|
||||
TLS_SET(error_string, new_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
SLONG get_process_id()
|
||||
{
|
||||
return getpid();
|
||||
|
@ -239,7 +239,7 @@ bool FileObject::renameFile(const Firebird::PathName new_filename)
|
||||
DWORD rename_err = GetLastError();
|
||||
if (rename_err == ERROR_ALREADY_EXISTS || rename_err == ERROR_FILE_NOT_FOUND)
|
||||
{
|
||||
// Another process renames our file just now. Open new it.
|
||||
// Another process renames our file just now. Open it again.
|
||||
reopen();
|
||||
return false;
|
||||
}
|
||||
@ -261,7 +261,6 @@ SINT64 FileObject::seek(SINT64 newOffset, SeekOrigin origin)
|
||||
{
|
||||
LARGE_INTEGER offset;
|
||||
offset.QuadPart = newOffset;
|
||||
DWORD error;
|
||||
DWORD moveMethod;
|
||||
|
||||
switch(origin)
|
||||
@ -277,6 +276,7 @@ SINT64 FileObject::seek(SINT64 newOffset, SeekOrigin origin)
|
||||
break;
|
||||
}
|
||||
|
||||
DWORD error;
|
||||
if ((offset.LowPart = SetFilePointer(file, offset.LowPart,
|
||||
&offset.HighPart, moveMethod)) == INVALID_SET_FILE_POINTER &&
|
||||
(error = GetLastError()) != NO_ERROR)
|
||||
|
@ -48,11 +48,11 @@ void set_error_string(const char* str)
|
||||
|
||||
if (str)
|
||||
{
|
||||
size_t len = strlen(str);
|
||||
char* new_str = (char*) LocalAlloc(LMEM_FIXED, len + 1);
|
||||
const size_t size = strlen(str) + 1;
|
||||
char* new_str = (char*) LocalAlloc(LMEM_FIXED, size);
|
||||
if (new_str)
|
||||
{
|
||||
memcpy(new_str, str, len + 1);
|
||||
memcpy(new_str, str, size);
|
||||
TLS_SET(error_string, new_str);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user