summaryrefslogtreecommitdiff
path: root/contrib/file_fdw/file_fdw.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2023-03-02 11:34:29 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2023-03-02 11:34:29 -0500
commit462bb7f12851c215dfc21a88ae0ed4bf7fcb36a3 (patch)
tree1ab5f6429f5833fd548c1eb079d6129339acb077 /contrib/file_fdw/file_fdw.c
parent2f80c95740f88e9e3e04ee0c2063e55a497315b4 (diff)
Remove bms_first_member().
This function has been semi-deprecated ever since we invented bms_next_member(). Its habit of scribbling on the input bitmapset isn't great, plus for sufficiently large bitmapsets it would take O(N^2) time to complete a loop. Now we have the additional problem that reducing the input to empty while leaving it still accessible would violate a planned invariant. So let's just get rid of it, after updating the few extant callers to use bms_next_member(). Patch by me; thanks to Nathan Bossart and Richard Guo for review. Discussion: https://postgr.es/m/1159933.1677621588@sss.pgh.pa.us
Diffstat (limited to 'contrib/file_fdw/file_fdw.c')
-rw-r--r--contrib/file_fdw/file_fdw.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/contrib/file_fdw/file_fdw.c b/contrib/file_fdw/file_fdw.c
index 8ccc1675488..2d2b0b6a6b9 100644
--- a/contrib/file_fdw/file_fdw.c
+++ b/contrib/file_fdw/file_fdw.c
@@ -858,7 +858,7 @@ check_selective_binary_conversion(RelOptInfo *baserel,
ListCell *lc;
Relation rel;
TupleDesc tupleDesc;
- AttrNumber attnum;
+ int attidx;
Bitmapset *attrs_used = NULL;
bool has_wholerow = false;
int numattrs;
@@ -901,10 +901,11 @@ check_selective_binary_conversion(RelOptInfo *baserel,
rel = table_open(foreigntableid, AccessShareLock);
tupleDesc = RelationGetDescr(rel);
- while ((attnum = bms_first_member(attrs_used)) >= 0)
+ attidx = -1;
+ while ((attidx = bms_next_member(attrs_used, attidx)) >= 0)
{
- /* Adjust for system attributes. */
- attnum += FirstLowInvalidHeapAttributeNumber;
+ /* attidx is zero-based, attnum is the normal attribute number */
+ AttrNumber attnum = attidx + FirstLowInvalidHeapAttributeNumber;
if (attnum == 0)
{