diff --git a/src/dsql/DsqlRequests.cpp b/src/dsql/DsqlRequests.cpp index b9d0b2f4cac..21f5c87ce93 100644 --- a/src/dsql/DsqlRequests.cpp +++ b/src/dsql/DsqlRequests.cpp @@ -177,6 +177,8 @@ void DsqlRequest::destroy(thread_db* tdbb, DsqlRequest* dsqlRequest) { childStatement->addFlags(DsqlStatement::FLAG_ORPHAN); childStatement->setParentRequest(nullptr); + childStatement->setParentDbKey(nullptr); + childStatement->setParentRecVersion(nullptr); // hvlad: lines below is commented out as // - child is already unlinked from its parent request diff --git a/src/dsql/dsql.cpp b/src/dsql/dsql.cpp index 35476271490..8894a6c4c45 100644 --- a/src/dsql/dsql.cpp +++ b/src/dsql/dsql.cpp @@ -620,7 +620,11 @@ static RefPtr prepareStatement(thread_db* tdbb, dsql_dbb* databas if (!isInternalRequest && dsqlStatement->mustBeReplicated()) dsqlStatement->setOrgText(text, textLength); - if (isStatementCacheActive && dsqlStatement->isDml()) + const bool basedOnCursor = + (dsqlStatement->getType() & (DsqlStatement::TYPE_UPDATE_CURSOR | + DsqlStatement::TYPE_DELETE_CURSOR)); + + if (isStatementCacheActive && dsqlStatement->isDml() && !basedOnCursor) { database->dbb_statement_cache->putStatement(tdbb, textStr, clientDialect, isInternalRequest, dsqlStatement);