From 60dc5dd571319070439748ee7670f79c68d4af32 Mon Sep 17 00:00:00 2001 From: hvlad Date: Tue, 8 Mar 2011 09:05:28 +0000 Subject: [PATCH] Additional patch for CORE-3362 : Cursors should ignore changes made by the same statement Better (i hope) fix for implicit cursors stability in PSQL --- src/dsql/StmtNodes.cpp | 12 +++++++----- src/dsql/StmtNodes.h | 2 -- src/jrd/exe.h | 2 -- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/dsql/StmtNodes.cpp b/src/dsql/StmtNodes.cpp index 57a63120cf..92ad8fc27e 100644 --- a/src/dsql/StmtNodes.cpp +++ b/src/dsql/StmtNodes.cpp @@ -3681,8 +3681,6 @@ static RegisterNode regForNode(blr_for); DmlNode* ForNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, UCHAR blrOp) { ForNode* node = FB_NEW(pool) ForNode(pool); - csb->csb_for_nodes++; - node->needSavePoint = (csb->csb_for_nodes > 1); if (csb->csb_blr_reader.peekByte() == (UCHAR) blr_stall) node->stall = PAR_parse_stmt(tdbb, csb); @@ -3834,7 +3832,9 @@ const StmtNode* ForNode::execute(thread_db* tdbb, jrd_req* request, ExeState* /* switch (request->req_operation) { case jrd_req::req_evaluate: - if (needSavePoint && (transaction != sysTransaction)) + *request->getImpure(impureOffset) = 0; + if (transaction != sysTransaction && + transaction->tra_save_point && transaction->tra_save_point->sav_verb_actions) { VIO_start_save_point(tdbb, transaction); const Savepoint* save_point = transaction->tra_save_point; @@ -3874,9 +3874,10 @@ const StmtNode* ForNode::execute(thread_db* tdbb, jrd_req* request, ExeState* /* } default: - if (needSavePoint && (transaction != sysTransaction)) + { + const SLONG sav_number = *request->getImpure(impureOffset); + if (sav_number) { - const SLONG sav_number = *request->getImpure(impureOffset); for (const Savepoint* save_point = transaction->tra_save_point; save_point && sav_number <= save_point->sav_number; save_point = transaction->tra_save_point) @@ -3886,6 +3887,7 @@ const StmtNode* ForNode::execute(thread_db* tdbb, jrd_req* request, ExeState* /* } cursor->close(tdbb); return parentStmt; + } } fb_assert(false); // unreachable code diff --git a/src/dsql/StmtNodes.h b/src/dsql/StmtNodes.h index c56d0271e5..e7d9747070 100644 --- a/src/dsql/StmtNodes.h +++ b/src/dsql/StmtNodes.h @@ -707,7 +707,6 @@ public: dsqlCursor(NULL), dsqlLabel(NULL), dsqlForceSingular(false), - needSavePoint(false), stall(NULL), rse(NULL), statement(NULL), @@ -731,7 +730,6 @@ public: dsql_nod* dsqlCursor; dsql_nod* dsqlLabel; bool dsqlForceSingular; - bool needSavePoint; NestConst stall; NestConst rse; NestConst statement; diff --git a/src/jrd/exe.h b/src/jrd/exe.h index 7cd65076ba..62d6dc078e 100644 --- a/src/jrd/exe.h +++ b/src/jrd/exe.h @@ -426,7 +426,6 @@ class CompilerScratch : public pool_alloc csb_map_field_info(p), csb_map_item_info(p), csb_domain_validation(domain_validation), - csb_for_nodes(0), csb_rpt(p, len) {} @@ -512,7 +511,6 @@ public: USHORT csb_view_stream; bool csb_validate_expr; USHORT csb_remap_variable; - int csb_for_nodes; struct csb_repeat {