From 07a75e3534f9a147c02e01184cc1a57f7883abc4 Mon Sep 17 00:00:00 2001 From: hvlad Date: Sat, 20 Jun 2020 16:16:54 +0300 Subject: [PATCH] Move declarations into namespace, force zero-based enum as Dmitry suggested. --- src/include/firebird/Interface.h | 7 +++- src/jrd/RuntimeStatistics.h | 11 ++++-- src/jrd/trace/TraceObjects.h | 50 +++++++++++++------------- src/utilities/ntrace/TracePluginImpl.h | 4 +-- 4 files changed, 41 insertions(+), 31 deletions(-) diff --git a/src/include/firebird/Interface.h b/src/include/firebird/Interface.h index 2f373fc282..1e8b40fa82 100644 --- a/src/include/firebird/Interface.h +++ b/src/include/firebird/Interface.h @@ -38,6 +38,9 @@ struct dsc; +namespace Firebird +{ + // Performance counters for individual table typedef int ntrace_relation_t; struct TraceCounts @@ -47,7 +50,7 @@ struct TraceCounts // Used with trc_counters. enum RecordCounters { - SEQ_READS, + SEQ_READS = 0, IDX_READS, UPDATES, INSERTS, @@ -91,6 +94,8 @@ struct PerformanceInfo ISC_INT64 pin_records_fetched; // records fetched from statement/procedure }; +}; // namespace Firebird + #include "IdlFbInterfaces.h" namespace Firebird diff --git a/src/jrd/RuntimeStatistics.h b/src/jrd/RuntimeStatistics.h index 69faadadd4..90d76b92fb 100644 --- a/src/jrd/RuntimeStatistics.h +++ b/src/jrd/RuntimeStatistics.h @@ -28,10 +28,15 @@ #include "../common/classes/init.h" #include "../common/classes/tree.h" +namespace Firebird { + // declared in firebird/Interface.h struct TraceCounts; struct PerformanceInfo; +}; // namespace Firebird + + namespace Jrd { class Attachment; @@ -39,7 +44,7 @@ class Database; class thread_db; class jrd_rel; -typedef Firebird::HalfStaticArray TraceCountsArray; +typedef Firebird::HalfStaticArray TraceCountsArray; // Runtime statistics class @@ -217,8 +222,8 @@ public: // Calculate difference between counts stored in this object and current // counts of given request. Counts stored in object are destroyed. - PerformanceInfo* computeDifference(Attachment* att, const RuntimeStatistics& new_stat, - PerformanceInfo& dest, TraceCountsArray& temp); + Firebird::PerformanceInfo* computeDifference(Attachment* att, const RuntimeStatistics& new_stat, + Firebird::PerformanceInfo& dest, TraceCountsArray& temp); // add difference between newStats and baseStats to our counters // newStats and baseStats must be "in-sync" diff --git a/src/jrd/trace/TraceObjects.h b/src/jrd/trace/TraceObjects.h index 1b869c73c9..35be8584ef 100644 --- a/src/jrd/trace/TraceObjects.h +++ b/src/jrd/trace/TraceObjects.h @@ -84,7 +84,7 @@ class TraceTransactionImpl : public Firebird::AutoIface > { public: - TraceTransactionImpl(const jrd_tra* tran, PerformanceInfo* perf = NULL, ISC_INT64 prevID = 0) : + TraceTransactionImpl(const jrd_tra* tran, Firebird::PerformanceInfo* perf = NULL, ISC_INT64 prevID = 0) : m_tran(tran), m_perf(perf), m_prevID(prevID) @@ -95,13 +95,13 @@ public: FB_BOOLEAN getReadOnly(); int getWait(); unsigned getIsolation(); - PerformanceInfo* getPerf() { return m_perf; } + Firebird::PerformanceInfo* getPerf() { return m_perf; } ISC_INT64 getInitialID(); ISC_INT64 getPreviousID() { return m_prevID; } private: const jrd_tra* const m_tran; - PerformanceInfo* const m_perf; + Firebird::PerformanceInfo* const m_perf; const ISC_INT64 m_prevID; }; @@ -146,18 +146,18 @@ private: class TraceBLRStatementImpl : public BLRPrinter { public: - TraceBLRStatementImpl(const jrd_req* stmt, PerformanceInfo* perf) : + TraceBLRStatementImpl(const jrd_req* stmt, Firebird::PerformanceInfo* perf) : BLRPrinter(stmt->getStatement()->blr.begin(), stmt->getStatement()->blr.getCount()), m_stmt(stmt), m_perf(perf) {} ISC_INT64 getStmtID() { return m_stmt->req_id; } - PerformanceInfo* getPerf() { return m_perf; } + Firebird::PerformanceInfo* getPerf() { return m_perf; } private: const jrd_req* const m_stmt; - PerformanceInfo* const m_perf; + Firebird::PerformanceInfo* const m_perf; }; @@ -169,7 +169,7 @@ public: {} ISC_INT64 getStmtID() { return 0; } - PerformanceInfo* getPerf() { return NULL; } + Firebird::PerformanceInfo* getPerf() { return NULL; } }; @@ -177,7 +177,7 @@ class TraceSQLStatementImpl : public Firebird::AutoIface > { public: - TraceSQLStatementImpl(const dsql_req* stmt, PerformanceInfo* perf) : + TraceSQLStatementImpl(const dsql_req* stmt, Firebird::PerformanceInfo* perf) : m_stmt(stmt), m_perf(perf), m_planExplained(false), @@ -186,7 +186,7 @@ public: // TraceSQLStatement implementation ISC_INT64 getStmtID(); - PerformanceInfo* getPerf(); + Firebird::PerformanceInfo* getPerf(); Firebird::ITraceParams* getInputs(); const char* getText(); const char* getPlan(); @@ -224,7 +224,7 @@ private: void fillPlan(bool explained); const dsql_req* const m_stmt; - PerformanceInfo* const m_perf; + Firebird::PerformanceInfo* const m_perf; Firebird::string m_plan; bool m_planExplained; DSQLParamsImpl m_inputs; @@ -242,7 +242,7 @@ public: // TraceSQLStatement implementation ISC_INT64 getStmtID() { return 0; } - PerformanceInfo* getPerf() { return NULL; } + Firebird::PerformanceInfo* getPerf() { return NULL; } Firebird::ITraceParams* getInputs() { return NULL; } const char* getText() { return m_text.c_str(); } const char* getPlan() { return ""; } @@ -402,7 +402,7 @@ class TraceProcedureImpl : public Firebird::AutoIface > { public: - TraceProcedureImpl(jrd_req* request, PerformanceInfo* perf) : + TraceProcedureImpl(jrd_req* request, Firebird::PerformanceInfo* perf) : m_request(request), m_perf(perf), m_inputs(*getDefaultMemoryPool(), request->req_proc_caller, request->req_proc_inputs), @@ -417,11 +417,11 @@ public: } Firebird::ITraceParams* getInputs() { return m_inputs; } - PerformanceInfo* getPerf() { return m_perf; }; + Firebird::PerformanceInfo* getPerf() { return m_perf; }; private: jrd_req* const m_request; - PerformanceInfo* const m_perf; + Firebird::PerformanceInfo* const m_perf; TraceDscFromValues m_inputs; Firebird::string m_name; }; @@ -431,7 +431,7 @@ class TraceFunctionImpl : public Firebird::AutoIface > { public: - TraceFunctionImpl(jrd_req* request, Firebird::ITraceParams* inputs, PerformanceInfo* perf, const dsc* value) : + TraceFunctionImpl(jrd_req* request, Firebird::ITraceParams* inputs, Firebird::PerformanceInfo* perf, const dsc* value) : m_request(request), m_perf(perf), m_inputs(inputs), @@ -447,11 +447,11 @@ public: Firebird::ITraceParams* getInputs() { return m_inputs; } Firebird::ITraceParams* getResult() { return m_value; } - PerformanceInfo* getPerf() { return m_perf; }; + Firebird::PerformanceInfo* getPerf() { return m_perf; }; private: jrd_req* const m_request; - PerformanceInfo* const m_perf; + Firebird::PerformanceInfo* const m_perf; Firebird::ITraceParams* m_inputs; TraceDscFromDsc m_value; Firebird::string m_name; @@ -462,7 +462,7 @@ class TraceTriggerImpl : public Firebird::AutoIface > { public: - TraceTriggerImpl(const jrd_req* trig, SSHORT which, PerformanceInfo* perf) : + TraceTriggerImpl(const jrd_req* trig, SSHORT which, Firebird::PerformanceInfo* perf) : m_trig(trig), m_which(which), m_perf(perf) @@ -473,12 +473,12 @@ public: const char* getRelationName(); int getAction() { return m_trig->req_trigger_action; } int getWhich() { return m_which; } - PerformanceInfo* getPerf() { return m_perf; } + Firebird::PerformanceInfo* getPerf() { return m_perf; } private: const jrd_req* const m_trig; const SSHORT m_which; - PerformanceInfo* const m_perf; + Firebird::PerformanceInfo* const m_perf; }; @@ -516,10 +516,10 @@ public: TraceRuntimeStats(Attachment* att, RuntimeStatistics* baseline, RuntimeStatistics* stats, SINT64 clock, SINT64 records_fetched); - PerformanceInfo* getPerf() { return &m_info; } + Firebird::PerformanceInfo* getPerf() { return &m_info; } private: - PerformanceInfo m_info; + Firebird::PerformanceInfo m_info; TraceCountsArray m_counts; static SINT64 m_dummy_counts[RuntimeStatistics::TOTAL_ITEMS]; // Zero-initialized array with zero counts }; @@ -623,7 +623,7 @@ public: m_next = Ods::getNT(header); } - void setPerf(PerformanceInfo* perf) + void setPerf(Firebird::PerformanceInfo* perf) { m_perf = perf; } @@ -632,14 +632,14 @@ public: ISC_INT64 getOST() { return m_ost; }; ISC_INT64 getOAT() { return m_oat; }; ISC_INT64 getNext() { return m_next; }; - PerformanceInfo* getPerf() { return m_perf; }; + Firebird::PerformanceInfo* getPerf() { return m_perf; }; private: TraNumber m_oit; TraNumber m_ost; TraNumber m_oat; TraNumber m_next; - PerformanceInfo* m_perf; + Firebird::PerformanceInfo* m_perf; }; } // namespace Jrd diff --git a/src/utilities/ntrace/TracePluginImpl.h b/src/utilities/ntrace/TracePluginImpl.h index 3d991b88ce..563720b85e 100644 --- a/src/utilities/ntrace/TracePluginImpl.h +++ b/src/utilities/ntrace/TracePluginImpl.h @@ -178,8 +178,8 @@ private: GdsCodesArray include_codes; GdsCodesArray exclude_codes; - void appendGlobalCounts(const PerformanceInfo* info); - void appendTableCounts(const PerformanceInfo* info); + void appendGlobalCounts(const Firebird::PerformanceInfo* info); + void appendTableCounts(const Firebird::PerformanceInfo* info); void appendParams(Firebird::ITraceParams* params); void appendServiceQueryParams(size_t send_item_length, const ntrace_byte_t* send_items, size_t recv_item_length, const ntrace_byte_t* recv_items);