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

Add procedure RDB$PROFILER.DISCARD.

This commit is contained in:
Adriano dos Santos Fernandes 2022-05-12 21:43:53 -03:00
parent 9365493cde
commit 0c5874eed9
3 changed files with 43 additions and 0 deletions

View File

@ -162,6 +162,12 @@ All session data present in the profiler plugin is discarded and will not be flu
Data already flushed is not deleted automatically.
## Procedure `DISCARD`
`RDB$PROFILER.DISCARD` removes all sessions from memory, without flushing them.
If there is a active session, it is cancelled.
## Procedure `FLUSH`
`RDB$PROFILER.FLUSH` updates the snapshot tables with data from the profile sessions in memory.

View File

@ -37,6 +37,19 @@ using namespace Firebird;
//--------------------------------------
IExternalResultSet* ProfilerPackage::discardProcedure(ThrowStatusExceptionWrapper* /*status*/,
IExternalContext* context, const void* in, void* out)
{
const auto tdbb = JRD_get_thread_data();
const auto attachment = tdbb->getAttachment();
const auto profilerManager = attachment->getProfilerManager(tdbb);
profilerManager->discard();
return nullptr;
}
IExternalResultSet* ProfilerPackage::flushProcedure(ThrowStatusExceptionWrapper* /*status*/,
IExternalContext* context, const void* in, void* out)
{
@ -360,6 +373,12 @@ void ProfilerManager::afterRecordSourceGetRecord(jrd_req* request, const RecordS
}
}
void ProfilerManager::discard()
{
currentSession = nullptr;
activePlugins.clear();
}
void ProfilerManager::flush(ITransaction* transaction)
{
auto pluginAccessor = activePlugins.accessor();
@ -488,6 +507,18 @@ ProfilerPackage::ProfilerPackage(MemoryPool& pool)
{
}
),
SystemProcedure(
pool,
"DISCARD",
SystemProcedureFactory<VoidMessage, VoidMessage, discardProcedure>(),
prc_executable,
// input parameters
{
},
// output parameters
{
}
),
SystemProcedure(
pool,
"FINISH_SESSION",

View File

@ -106,6 +106,7 @@ public:
}
private:
void discard();
void flush(Firebird::ITransaction* transaction);
Statement* getStatement(jrd_req* request);
SINT64 getRequest(jrd_req* request, unsigned flags);
@ -123,6 +124,11 @@ public:
ProfilerPackage(Firebird::MemoryPool& pool);
private:
static Firebird::IExternalResultSet* discardProcedure(Firebird::ThrowStatusExceptionWrapper* status,
Firebird::IExternalContext* context, const void* in, void* out);
//----------
static Firebird::IExternalResultSet* flushProcedure(Firebird::ThrowStatusExceptionWrapper* status,
Firebird::IExternalContext* context, const void* in, void* out);