Skip to content

Commit 99299e5

Browse files
committed
Asserts and comments per @dyemanov request
1 parent 2ff68e9 commit 99299e5

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/jrd/Monitoring.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,21 +626,31 @@ MonitoringSnapshot::MonitoringSnapshot(thread_db* tdbb, MemoryPool& pool)
626626
{
627627
if (dbb->getEncodedOdsVersion() >= ODS_13_1)
628628
{
629+
// The code below requires that rel_mon_compiled_statements put
630+
// into dump before rel_mon_statements, see also dumpAttachment()
631+
629632
FB_UINT64 stmtId;
630633
StmtBlobs stmtBlobs;
631634
dsc desc;
632635

633636
if ((rid == rel_mon_compiled_statements) && EVL_field(nullptr, record, f_mon_cmp_stmt_id, &desc))
634637
{
638+
fb_assert(desc.dsc_dtype == dtype_int64);
635639
stmtId = *(FB_UINT64*) desc.dsc_address;
636640

637641
if (EVL_field(nullptr, record, f_mon_cmp_stmt_sql_text, &desc))
642+
{
643+
fb_assert(desc.isBlob());
638644
stmtBlobs.text = *reinterpret_cast<bid*>(desc.dsc_address);
645+
}
639646
else
640647
stmtBlobs.text.clear();
641648

642649
if (EVL_field(nullptr, record, f_mon_cmp_stmt_expl_plan, &desc))
650+
{
651+
fb_assert(desc.isBlob());
643652
stmtBlobs.plan = *reinterpret_cast<bid*>(desc.dsc_address);
653+
}
644654
else
645655
stmtBlobs.plan.clear();
646656

@@ -649,6 +659,7 @@ MonitoringSnapshot::MonitoringSnapshot(thread_db* tdbb, MemoryPool& pool)
649659
}
650660
else if ((rid == rel_mon_statements) && EVL_field(nullptr, record, f_mon_stmt_cmp_stmt_id, &desc))
651661
{
662+
fb_assert(desc.dsc_dtype == dtype_int64);
652663
stmtId = *(FB_UINT64*) desc.dsc_address;
653664

654665
if (blobsMap.get(stmtId, stmtBlobs))
@@ -657,14 +668,19 @@ MonitoringSnapshot::MonitoringSnapshot(thread_db* tdbb, MemoryPool& pool)
657668
{
658669
record->clearNull(f_mon_stmt_sql_text);
659670
if (EVL_field(nullptr, record, f_mon_stmt_sql_text, &desc))
671+
{
672+
fb_assert(desc.isBlob());
660673
*reinterpret_cast<bid*>(desc.dsc_address) = stmtBlobs.text;
674+
}
661675
}
662-
663676
if (!stmtBlobs.plan.isEmpty())
664677
{
665678
record->clearNull(f_mon_stmt_expl_plan);
666679
if (EVL_field(nullptr, record, f_mon_stmt_expl_plan, &desc))
680+
{
681+
fb_assert(desc.isBlob());
667682
*reinterpret_cast<bid*>(desc.dsc_address) = stmtBlobs.plan;
683+
}
668684
}
669685
}
670686
}
@@ -1564,7 +1580,7 @@ void Monitoring::dumpAttachment(thread_db* tdbb, Attachment* attachment, ULONG g
15641580

15651581
if (dbb->getEncodedOdsVersion() >= ODS_13_1)
15661582
{
1567-
// Statement information
1583+
// Statement information, must be put into dump before requests
15681584

15691585
for (const auto statement : attachment->att_statements)
15701586
{

0 commit comments

Comments
 (0)