Skip to content

Commit f87538c

Browse files
gfphoenix78my-ship-it
authored andcommitted
ORCA: Wrap bms_* function in C++
ORCA uses exception to handle errors, it can't correctly handle long jump. It's a rule to use pg functions in a wrapper to adapt long jump and exceptions in C++.
1 parent 3b44ecd commit f87538c

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

src/backend/gpopt/gpdbwrappers.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,17 @@ gpdb::BmsAddMember(Bitmapset *a, int x)
9393
return nullptr;
9494
}
9595

96+
int
97+
gpdb::BmsNextMember(const Bitmapset *a, int prevbit)
98+
{
99+
GP_WRAP_START;
100+
{
101+
return bms_next_member(a, prevbit);
102+
}
103+
GP_WRAP_END;
104+
return -2;
105+
}
106+
96107
void *
97108
gpdb::CopyObject(void *from)
98109
{

src/backend/gpopt/translate/CPartPruneStepsBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ CPartPruneStepsBuilder::CreatePartPruneInfoForOneLevel(CDXLNode *filterNode)
9090
// partition did survive pruning
9191
pinfo->subplan_map[i] = part_ptr;
9292
pinfo->relid_map[i] = gpdb::RelationGetPartitionDesc(m_relation, true)->oids[i];
93-
pinfo->present_parts = bms_add_member(pinfo->present_parts, i);
93+
pinfo->present_parts = gpdb::BmsAddMember(pinfo->present_parts, i);
9494
++part_ptr;
9595
}
9696
else

src/backend/gpopt/translate/CTranslatorRelcacheToDXL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ CTranslatorRelcacheToDXL::RetrieveExtStatsInfo(CMemoryPool *mp, IMDId *mdid)
413413
CBitSet *keys = GPOS_NEW(mp) CBitSet(mp);
414414

415415
int attno = -1;
416-
while ((attno = bms_next_member(info->keys, attno)) >= 0)
416+
while ((attno = gpdb::BmsNextMember(info->keys, attno)) >= 0)
417417
{
418418
keys->ExchangeSet(attno);
419419
}

src/include/gpopt/gpdbwrappers.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,9 @@ bool AggregateExists(Oid oid);
227227
// add member to Bitmapset
228228
Bitmapset *BmsAddMember(Bitmapset *a, int x);
229229

230+
// next member of Bitmapset
231+
int BmsNextMember(const Bitmapset *a, int prevbit);
232+
230233
// create a copy of an object
231234
void *CopyObject(void *from);
232235

0 commit comments

Comments
 (0)