aboutsummaryrefslogtreecommitdiff
path: root/src/backend/replication/logical/relation.c
diff options
context:
space:
mode:
authorNathan Bossart <nathan@postgresql.org>2024-01-04 16:09:34 -0600
committerNathan Bossart <nathan@postgresql.org>2024-01-04 16:09:34 -0600
commit14dd0f27d7cd56ffae9ecdbe324965073d01a9ff (patch)
tree3ae126d6f1e2dab9ce5b1ac788912a374c18c0c7 /src/backend/replication/logical/relation.c
parent5e8674dc83926f52516f847f1a77e8d38e94e143 (diff)
downloadpostgresql-14dd0f27d7cd56ffae9ecdbe324965073d01a9ff.tar.gz
postgresql-14dd0f27d7cd56ffae9ecdbe324965073d01a9ff.zip
Add macros for looping through a List without a ListCell.
Many foreach loops only use the ListCell pointer to retrieve the content of the cell, like so: ListCell *lc; foreach(lc, mylist) { int myint = lfirst_int(lc); ... } This commit adds a few convenience macros that automatically declare the loop variable and retrieve the current cell's contents. This allows us to rewrite the previous loop like this: foreach_int(myint, mylist) { ... } This commit also adjusts a few existing loops in order to add coverage for the new/adjusted macros. There is presently no plan to bulk update all foreach loops, as that could introduce a significant amount of back-patching pain. Instead, these macros are primarily intended for use in new code. Author: Jelte Fennema-Nio Reviewed-by: David Rowley, Alvaro Herrera, Vignesh C, Tom Lane Discussion: https://postgr.es/m/CAGECzQSwXKnxGwW1_Q5JE%2B8Ja20kyAbhBHO04vVrQsLcDciwXA%40mail.gmail.com
Diffstat (limited to 'src/backend/replication/logical/relation.c')
-rw-r--r--src/backend/replication/logical/relation.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/backend/replication/logical/relation.c b/src/backend/replication/logical/relation.c
index 136e2532578..c68e8cfab7a 100644
--- a/src/backend/replication/logical/relation.c
+++ b/src/backend/replication/logical/relation.c
@@ -746,11 +746,9 @@ static Oid
FindUsableIndexForReplicaIdentityFull(Relation localrel, AttrMap *attrmap)
{
List *idxlist = RelationGetIndexList(localrel);
- ListCell *lc;
- foreach(lc, idxlist)
+ foreach_oid(idxoid, idxlist)
{
- Oid idxoid = lfirst_oid(lc);
bool isUsableIdx;
Relation idxRel;
IndexInfo *idxInfo;