mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 22:03:03 +01:00
Improvement CORE-2303: Include plan in MON$STATEMENTS.
This commit is contained in:
parent
1d18b9cefc
commit
2c4b4f61eb
@ -43,6 +43,7 @@
|
||||
#include "../jrd/lck_proto.h"
|
||||
#include "../jrd/met_proto.h"
|
||||
#include "../jrd/mov_proto.h"
|
||||
#include "../jrd/opt_proto.h"
|
||||
#include "../jrd/os/pio_proto.h"
|
||||
#include "../jrd/pag_proto.h"
|
||||
#include "../jrd/thread_proto.h"
|
||||
@ -364,7 +365,7 @@ int DatabaseSnapshot::blockingAst(void* ast_object)
|
||||
// Write the data to the shared memory
|
||||
try
|
||||
{
|
||||
dumpData(dbb, backup_state_unknown);
|
||||
dumpData(tdbb, backup_state_unknown);
|
||||
}
|
||||
catch (const Exception& ex)
|
||||
{
|
||||
@ -499,7 +500,7 @@ DatabaseSnapshot::DatabaseSnapshot(thread_db* tdbb, MemoryPool& pool)
|
||||
dbb->dbb_ast_flags &= ~DBB_monitor_off;
|
||||
|
||||
// Dump our own data
|
||||
dumpData(dbb, backup_state);
|
||||
dumpData(tdbb, backup_state);
|
||||
}
|
||||
|
||||
// Signal other processes to dump their data
|
||||
@ -810,8 +811,9 @@ void DataDump::putField(thread_db* tdbb, Record* record, const DumpField& field,
|
||||
}
|
||||
|
||||
|
||||
void DatabaseSnapshot::dumpData(Database* dbb, int backup_state)
|
||||
void DatabaseSnapshot::dumpData(thread_db* tdbb, int backup_state)
|
||||
{
|
||||
Database* const dbb = tdbb->getDatabase();
|
||||
MemoryPool& pool = *dbb->dbb_permanent;
|
||||
|
||||
if (!dbb->dbb_monitoring_data)
|
||||
@ -860,20 +862,20 @@ void DatabaseSnapshot::dumpData(Database* dbb, int backup_state)
|
||||
Attachment* const attachment = jAtt->getHandle();
|
||||
|
||||
if (attachment && attachment->att_user)
|
||||
dumpAttachment(record, attachment, writer);
|
||||
dumpAttachment(tdbb, record, attachment, writer);
|
||||
}
|
||||
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseSnapshot::dumpAttachment(DumpRecord& record, const Attachment* attachment,
|
||||
void DatabaseSnapshot::dumpAttachment(thread_db* tdbb, DumpRecord& record,
|
||||
const Attachment* attachment,
|
||||
Writer& writer)
|
||||
{
|
||||
putAttachment(record, attachment, writer, fb_utils::genUniqueId());
|
||||
|
||||
jrd_tra* transaction = NULL;
|
||||
jrd_req* request = NULL;
|
||||
|
||||
// Transaction information
|
||||
|
||||
@ -888,7 +890,7 @@ void DatabaseSnapshot::dumpAttachment(DumpRecord& record, const Attachment* atta
|
||||
for (transaction = attachment->att_transactions; transaction;
|
||||
transaction = transaction->tra_next)
|
||||
{
|
||||
for (request = transaction->tra_requests;
|
||||
for (jrd_req* request = transaction->tra_requests;
|
||||
request && (request->req_flags & req_active);
|
||||
request = request->req_caller)
|
||||
{
|
||||
@ -909,12 +911,13 @@ void DatabaseSnapshot::dumpAttachment(DumpRecord& record, const Attachment* atta
|
||||
i != attachment->att_requests.end();
|
||||
++i)
|
||||
{
|
||||
const jrd_req* request = *i;
|
||||
const jrd_req* const request = *i;
|
||||
|
||||
if (!(request->getStatement()->flags &
|
||||
(JrdStatement::FLAG_INTERNAL | JrdStatement::FLAG_SYS_TRIGGER)))
|
||||
(JrdStatement::FLAG_INTERNAL | JrdStatement::FLAG_SYS_TRIGGER)))
|
||||
{
|
||||
putRequest(record, request, writer, fb_utils::genUniqueId());
|
||||
const string plan = OPT_get_plan(tdbb, request, true);
|
||||
putRequest(record, request, writer, fb_utils::genUniqueId(), plan);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1165,7 +1168,7 @@ void DatabaseSnapshot::putTransaction(DumpRecord& record, const jrd_tra* transac
|
||||
|
||||
|
||||
void DatabaseSnapshot::putRequest(DumpRecord& record, const jrd_req* request,
|
||||
Writer& writer, int stat_id)
|
||||
Writer& writer, int stat_id, const string& plan)
|
||||
{
|
||||
fb_assert(request);
|
||||
|
||||
@ -1193,11 +1196,16 @@ void DatabaseSnapshot::putRequest(DumpRecord& record, const jrd_req* request,
|
||||
{
|
||||
record.storeInteger(f_mon_stmt_state, mon_state_idle);
|
||||
}
|
||||
|
||||
const JrdStatement* const statement = request->getStatement();
|
||||
|
||||
// sql text
|
||||
if (request->getStatement()->sqlText)
|
||||
{
|
||||
record.storeString(f_mon_stmt_sql_text, *request->getStatement()->sqlText);
|
||||
}
|
||||
if (statement->sqlText)
|
||||
record.storeString(f_mon_stmt_sql_text, *statement->sqlText);
|
||||
|
||||
// explained plan
|
||||
if (plan.hasData())
|
||||
record.storeString(f_mon_stmt_expl_plan, plan);
|
||||
|
||||
// statistics
|
||||
record.storeGlobalId(f_mon_stmt_stat_id, getGlobalId(stat_id));
|
||||
|
@ -353,15 +353,15 @@ protected:
|
||||
DatabaseSnapshot(thread_db*, MemoryPool&);
|
||||
|
||||
private:
|
||||
static void dumpData(Database*, int);
|
||||
static void dumpAttachment(DumpRecord&, const Attachment*, Writer&);
|
||||
static void dumpData(thread_db*, int);
|
||||
static void dumpAttachment(thread_db*, DumpRecord&, const Attachment*, Writer&);
|
||||
|
||||
static SINT64 getGlobalId(int);
|
||||
|
||||
static void putDatabase(DumpRecord&, const Database*, Writer&, int, int);
|
||||
static void putAttachment(DumpRecord&, const Attachment*, Writer&, int);
|
||||
static void putTransaction(DumpRecord&, const jrd_tra*, Writer&, int);
|
||||
static void putRequest(DumpRecord&, const jrd_req*, Writer&, int);
|
||||
static void putRequest(DumpRecord&, const jrd_req*, Writer&, int, const Firebird::string&);
|
||||
static void putCall(DumpRecord&, const jrd_req*, Writer&, int);
|
||||
static void putStatistics(DumpRecord&, const RuntimeStatistics&, Writer&, int, int);
|
||||
static void putContextVars(DumpRecord&, const Firebird::StringMap&, Writer&, int, bool);
|
||||
|
@ -190,3 +190,4 @@
|
||||
FIELD(fld_map_to , nam_map_to , dtype_text , MAX_SQL_IDENTIFIER_LEN , dsc_text_type_metadata , NULL , true)
|
||||
|
||||
FIELD(fld_gen_increment , nam_gen_increment , dtype_long , sizeof(SLONG) , 0 , NULL , false)
|
||||
FIELD(fld_plan , nam_plan , dtype_blob , BLOB_SIZE , isc_blob_text , NULL , true)
|
||||
|
@ -151,6 +151,7 @@ NAME("RDB$PAGES", nam_pages)
|
||||
NAME("RDB$PAGE_NUMBER", nam_p_number)
|
||||
NAME("RDB$PAGE_SEQUENCE", nam_p_sequence)
|
||||
NAME("RDB$PAGE_TYPE", nam_p_type)
|
||||
NAME("RDB$PLAN", nam_plan)
|
||||
NAME("RDB$PROCEDURE_PARAMETERS", nam_proc_parameters)
|
||||
NAME("RDB$PARAMETER_NAME", nam_prm_name)
|
||||
NAME("RDB$PARAMETER_NUMBER", nam_prm_number)
|
||||
@ -291,6 +292,7 @@ NAME("MON$CREATION_DATE", nam_mon_created)
|
||||
NAME("MON$CRYPT_PAGE", nam_mon_crypt_page)
|
||||
NAME("MON$DATABASE", nam_mon_database)
|
||||
NAME("MON$DATABASE_NAME", nam_mon_db_name)
|
||||
NAME("MON$EXPLANED_PLAN", nam_mon_expl_plan)
|
||||
NAME("MON$FORCED_WRITES", nam_mon_forced_writes)
|
||||
NAME("MON$GARBAGE_COLLECTION", nam_mon_gc)
|
||||
NAME("MON$IO_STATS", nam_mon_io_stats)
|
||||
|
@ -535,6 +535,7 @@ RELATION(nam_mon_statements, rel_mon_statements, ODS_11_1, rel_virtual)
|
||||
FIELD(f_mon_stmt_timestamp, nam_mon_timestamp, fld_time, 0, ODS_11_1)
|
||||
FIELD(f_mon_stmt_sql_text, nam_mon_sql_text, fld_source, 0, ODS_11_1)
|
||||
FIELD(f_mon_stmt_stat_id, nam_mon_stat_id, fld_stat_id, 0, ODS_11_1)
|
||||
FIELD(f_mon_stmt_expl_plan, nam_mon_expl_plan, fld_source, 0, ODS_11_1)
|
||||
END_RELATION
|
||||
|
||||
// Relation 37 (MON$CALL_STACK)
|
||||
|
Loading…
Reference in New Issue
Block a user