@@ -1365,6 +1365,19 @@ const StmtNode* EXE_looper(thread_db* tdbb, jrd_req* request, const StmtNode* no
13651365 SINT64 lastPerfCounter = initialPerfCounter;
13661366 const StmtNode* profileNode = nullptr ;
13671367
1368+ const auto profilerCallAfterPsqlLineColumn = [&] {
1369+ const SINT64 currentPerfCounter = fb_utils::query_performance_counter ();
1370+
1371+ if (profileNode)
1372+ {
1373+ attachment->getProfilerManager (tdbb)->afterPsqlLineColumn (request,
1374+ profileNode->line , profileNode->column ,
1375+ currentPerfCounter - lastPerfCounter);
1376+ }
1377+
1378+ return currentPerfCounter;
1379+ };
1380+
13681381 while (node && !(request->req_flags & req_stall))
13691382 {
13701383 try
@@ -1386,16 +1399,7 @@ const StmtNode* EXE_looper(thread_db* tdbb, jrd_req* request, const StmtNode* no
13861399 (!profileNode ||
13871400 !(node->line == profileNode->line && node->column == profileNode->column )))
13881401 {
1389- if (profileNode)
1390- {
1391- const SINT64 currentPerfCounter = fb_utils::query_performance_counter ();
1392-
1393- attachment->getProfilerManager (tdbb)->afterPsqlLineColumn (request,
1394- profileNode->line , profileNode->column ,
1395- currentPerfCounter - lastPerfCounter);
1396-
1397- lastPerfCounter = currentPerfCounter;
1398- }
1402+ lastPerfCounter = profilerCallAfterPsqlLineColumn ();
13991403
14001404 profileNode = node;
14011405
@@ -1408,7 +1412,12 @@ const StmtNode* EXE_looper(thread_db* tdbb, jrd_req* request, const StmtNode* no
14081412 node = node->execute (tdbb, request, &exeState);
14091413
14101414 if (exeState.exit )
1415+ {
1416+ if (attachment->isProfilerActive () && !request->hasInternalStatement ())
1417+ request->req_profiler_time += profilerCallAfterPsqlLineColumn () - initialPerfCounter;
1418+
14111419 return node;
1420+ }
14121421 } // try
14131422 catch (const Firebird::Exception& ex)
14141423 {
@@ -1448,18 +1457,7 @@ const StmtNode* EXE_looper(thread_db* tdbb, jrd_req* request, const StmtNode* no
14481457 } // while()
14491458
14501459 if (attachment->isProfilerActive () && !request->hasInternalStatement ())
1451- {
1452- const SINT64 currentPerfCounter = fb_utils::query_performance_counter ();
1453-
1454- if (profileNode)
1455- {
1456- attachment->getProfilerManager (tdbb)->afterPsqlLineColumn (request,
1457- profileNode->line , profileNode->column ,
1458- currentPerfCounter - lastPerfCounter);
1459- }
1460-
1461- request->req_profiler_time += currentPerfCounter - initialPerfCounter;
1462- }
1460+ request->req_profiler_time += profilerCallAfterPsqlLineColumn () - initialPerfCounter;
14631461
14641462 request->adjustCallerStats ();
14651463
0 commit comments