From 6e58bd721cffec7aeffe2abb87dbb3350f9ad3a6 Mon Sep 17 00:00:00 2001 From: dimitr Date: Thu, 11 May 2023 11:31:24 +0300 Subject: [PATCH] Fixed index expression recursion errors after my recent changes --- src/jrd/btr.cpp | 2 ++ src/jrd/btr.h | 16 ++++++++++++++++ src/jrd/idx.cpp | 10 ++++------ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/jrd/btr.cpp b/src/jrd/btr.cpp index 0f67193282..c92dd51eaf 100644 --- a/src/jrd/btr.cpp +++ b/src/jrd/btr.cpp @@ -503,6 +503,7 @@ dsc* IndexExpression::evaluate(Record* record) const return result; } +// IndexKey class idx_e IndexKey::compose(Record* record) { @@ -669,6 +670,7 @@ idx_e IndexKey::compose(Record* record) return idx_e_ok; } + void BTR_all(thread_db* tdbb, jrd_rel* relation, IndexDescList& idxList, RelationPages* relPages) { /************************************** diff --git a/src/jrd/btr.h b/src/jrd/btr.h index 304f278f52..4eb5fc9b24 100644 --- a/src/jrd/btr.h +++ b/src/jrd/btr.h @@ -333,6 +333,11 @@ class IndexCondition { public: IndexCondition(thread_db* tdbb, index_desc* idx); + + IndexCondition(const IndexCondition& other) + : m_tdbb(other.m_tdbb), m_condition(other.m_condition), m_request(other.m_request) + {} + ~IndexCondition(); bool evaluate(Record* record) const; @@ -347,6 +352,11 @@ class IndexExpression { public: IndexExpression(thread_db* tdbb, index_desc* idx); + + IndexExpression(const IndexExpression& other) + : m_tdbb(other.m_tdbb), m_expression(other.m_expression), m_request(other.m_request) + {} + ~IndexExpression(); dsc* evaluate(Record* record) const; @@ -376,6 +386,12 @@ public: fb_assert(m_segments && m_segments <= idx->idx_count); } + IndexKey(const IndexKey& other) + : m_tdbb(other.m_tdbb), m_relation(other.m_relation), m_index(other.m_index), + m_keyType(other.m_keyType), m_segments(other.m_segments), m_expression(other.m_expression) + { + } + idx_e compose(Record* record); operator temporary_key*() diff --git a/src/jrd/idx.cpp b/src/jrd/idx.cpp index 0e37286aa3..90c7a48e8d 100644 --- a/src/jrd/idx.cpp +++ b/src/jrd/idx.cpp @@ -1143,8 +1143,7 @@ void IDX_garbage_collect(thread_db* tdbb, record_param* rpb, RecordStack& going, IndexErrorContext context(rpb->rpb_relation, &idx); IndexCondition condition(tdbb, &idx); - IndexKey key1(tdbb, rpb->rpb_relation, &idx); - IndexKey key2(tdbb, rpb->rpb_relation, &idx); + IndexKey key1(tdbb, rpb->rpb_relation, &idx), key2(key1); for (RecordStack::iterator stack1(going); stack1.hasData(); ++stack1) { @@ -1181,6 +1180,7 @@ void IDX_garbage_collect(thread_db* tdbb, record_param* rpb, RecordStack& going, if (key1 == key2) break; } + if (stack2.hasData()) continue; @@ -1263,8 +1263,7 @@ void IDX_modify(thread_db* tdbb, IndexErrorContext context(new_rpb->rpb_relation, &idx); idx_e error_code; - IndexKey newKey(tdbb, new_rpb->rpb_relation, &idx); - IndexKey orgKey(tdbb, org_rpb->rpb_relation, &idx); + IndexKey newKey(tdbb, new_rpb->rpb_relation, &idx), orgKey(newKey); if ( (error_code = newKey.compose(new_rpb->rpb_record)) ) { @@ -1340,8 +1339,7 @@ void IDX_modify_check_constraints(thread_db* tdbb, IndexErrorContext context(new_rpb->rpb_relation, &idx); idx_e error_code; - IndexKey newKey(tdbb, new_rpb->rpb_relation, &idx); - IndexKey orgKey(tdbb, org_rpb->rpb_relation, &idx); + IndexKey newKey(tdbb, new_rpb->rpb_relation, &idx), orgKey(newKey); if ( (error_code = newKey.compose(new_rpb->rpb_record)) ) {