Skip to content

Commit 35282da

Browse files
committed
Backported CORE-6015: Segfault when using expression index with complex expression
1 parent e36f15c commit 35282da

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

src/common/classes/auto.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,39 @@ class AutoSetRestore
139139
T oldValue;
140140
};
141141

142+
143+
template <typename T>
144+
class AutoSetRestoreFlag
145+
{
146+
public:
147+
AutoSetRestoreFlag(T* aValue, T newBit, bool set)
148+
: value(aValue),
149+
bit(newBit),
150+
oldValue((*value) & bit)
151+
{
152+
if (set)
153+
*value |= bit;
154+
else
155+
*value &= ~bit;
156+
}
157+
158+
~AutoSetRestoreFlag()
159+
{
160+
*value &= ~bit;
161+
*value |= oldValue;
162+
}
163+
164+
private:
165+
// copying is prohibited
166+
AutoSetRestoreFlag(const AutoSetRestoreFlag&);
167+
AutoSetRestoreFlag& operator =(const AutoSetRestoreFlag&);
168+
169+
T* value;
170+
T bit;
171+
T oldValue;
172+
};
173+
174+
142175
template <typename T, typename T2>
143176
class AutoSetRestore2
144177
{

src/jrd/idx.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,9 @@ void IDX_garbage_collect(thread_db* tdbb,
774774
insertion.iib_relation = rpb->rpb_relation;
775775
insertion.iib_key = &key1;
776776

777+
Attachment* att = tdbb->getAttachment();
778+
AutoSetRestoreFlag<ULONG> gc(&att->att_flags, ATT_no_cleanup, true);
779+
777780
WIN window(get_root_page(tdbb, rpb->rpb_relation));
778781

779782
index_root_page* root = (index_root_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_root);

0 commit comments

Comments
 (0)