@@ -1244,7 +1244,7 @@ DeclareCursorNode* DeclareCursorNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
12441244 cursorNumber = dsqlScratch->cursorNumber ++;
12451245 dsqlScratch->cursors .push (this );
12461246
1247- dsqlScratch->putDebugCursor (cursorNumber, dsqlName);
1247+ dsqlScratch->putDebugDeclaredCursor (cursorNumber, dsqlName);
12481248
12491249 ++dsqlScratch->scopeLevel ;
12501250
@@ -1303,7 +1303,7 @@ DeclareCursorNode* DeclareCursorNode::pass2(thread_db* tdbb, CompilerScratch* cs
13031303 ExprNode::doPass2 (tdbb, csb, refs.getAddress ());
13041304
13051305 MetaName cursorName;
1306- csb->csb_dbg_info ->curIndexToName .get (cursorNumber, cursorName);
1306+ csb->csb_dbg_info ->declaredCursorIndexToName .get (cursorNumber, cursorName);
13071307
13081308 // Finish up processing of record selection expressions.
13091309
@@ -4881,6 +4881,9 @@ DmlNode* ForNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb,
48814881{
48824882 ForNode* node = FB_NEW_POOL (pool) ForNode (pool);
48834883
4884+ if (auto cursorName = csb->csb_dbg_info ->forCursorOffsetToName .get (csb->csb_blr_reader .getOffset () - 1 ))
4885+ csb->csb_forCursorNames .put (node, *cursorName);
4886+
48844887 if (csb->csb_blr_reader .peekByte () == blr_marks)
48854888 node->marks |= PAR_marks (csb);
48864889
@@ -4929,9 +4932,6 @@ ForNode* ForNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
49294932 dsqlCursor->rse = node->rse ;
49304933 dsqlCursor->cursorNumber = dsqlScratch->cursorNumber ++;
49314934 dsqlScratch->cursors .push (dsqlCursor);
4932-
4933- // ASF: We cannot write this cursor name in debug info, as dsqlScratch->cursorNumber is
4934- // decremented below. But for now we don't need it.
49354935 }
49364936 else
49374937 node->rse = dsqlSelect->dsqlPass (dsqlScratch)->dsqlRse ;
@@ -5001,6 +5001,9 @@ void ForNode::genBlr(DsqlCompilerScratch* dsqlScratch)
50015001
50025002 // Generate FOR loop
50035003
5004+ if (dsqlCursor)
5005+ dsqlScratch->putDebugForCursor (dsqlCursor->dsqlName );
5006+
50045007 dsqlScratch->appendUChar (blr_for);
50055008
50065009 if (marks)
@@ -5069,11 +5072,11 @@ StmtNode* ForNode::pass2(thread_db* tdbb, CompilerScratch* csb)
50695072
50705073 RecordSource* const rsb = CMP_post_rse (tdbb, csb, rse.getObject ());
50715074
5075+ MetaName cursorName;
5076+ csb->csb_forCursorNames .get (this , cursorName);
5077+
50725078 cursor = FB_NEW_POOL (*tdbb->getDefaultPool ())
5073- Cursor (csb, rsb, rse, !(marks & MARK_AVOID_COUNTERS), line, column);
5074- // ASF: We cannot define the name of the cursor here, but this is not a problem,
5075- // as implicit cursors are always positioned in a valid record, and the name is
5076- // only used to raise isc_cursor_not_positioned.
5079+ Cursor (csb, rsb, rse, !(marks & MARK_AVOID_COUNTERS), line, column, cursorName);
50775080
50785081 csb->csb_fors .add (cursor);
50795082
0 commit comments