Skip to content

Commit 4bac960

Browse files
Harmonize heapam and tableam parameter names.
Make sure that function declarations use names that exactly match the corresponding names from function definitions. Having parameter names that are reliably consistent in this way will make it easier to reason about groups of related C functions from the same translation unit as a module. It will also make certain refactoring tasks easier. Like other recent commits that cleaned up function parameter names, this commit was written with help from clang-tidy. Later commits will do the same for other parts of the codebase. Author: Peter Geoghegan <pg@bowt.ie> Reviewed-By: David Rowley <dgrowleyml@gmail.com> Discussion: https://postgr.es/m/CAH2-WznJt9CMM9KJTMjJh_zbL5hD9oX44qdJ4aqZtjFi-zA3Tg@mail.gmail.com
1 parent cb8ff7e commit 4bac960

File tree

14 files changed

+90
-89
lines changed

14 files changed

+90
-89
lines changed

src/backend/access/common/heaptuple.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -420,13 +420,13 @@ heap_attisnull(HeapTuple tup, int attnum, TupleDesc tupleDesc)
420420
* ----------------
421421
*/
422422
Datum
423-
nocachegetattr(HeapTuple tuple,
423+
nocachegetattr(HeapTuple tup,
424424
int attnum,
425425
TupleDesc tupleDesc)
426426
{
427-
HeapTupleHeader tup = tuple->t_data;
427+
HeapTupleHeader td = tup->t_data;
428428
char *tp; /* ptr to data part of tuple */
429-
bits8 *bp = tup->t_bits; /* ptr to null bitmap in tuple */
429+
bits8 *bp = td->t_bits; /* ptr to null bitmap in tuple */
430430
bool slow = false; /* do we have to walk attrs? */
431431
int off; /* current offset within data */
432432

@@ -441,7 +441,7 @@ nocachegetattr(HeapTuple tuple,
441441

442442
attnum--;
443443

444-
if (!HeapTupleNoNulls(tuple))
444+
if (!HeapTupleNoNulls(tup))
445445
{
446446
/*
447447
* there's a null somewhere in the tuple
@@ -470,7 +470,7 @@ nocachegetattr(HeapTuple tuple,
470470
}
471471
}
472472

473-
tp = (char *) tup + tup->t_hoff;
473+
tp = (char *) td + td->t_hoff;
474474

475475
if (!slow)
476476
{
@@ -489,7 +489,7 @@ nocachegetattr(HeapTuple tuple,
489489
* target. If there aren't any, it's safe to cheaply initialize the
490490
* cached offsets for these attrs.
491491
*/
492-
if (HeapTupleHasVarWidth(tuple))
492+
if (HeapTupleHasVarWidth(tup))
493493
{
494494
int j;
495495

@@ -565,7 +565,7 @@ nocachegetattr(HeapTuple tuple,
565565
{
566566
Form_pg_attribute att = TupleDescAttr(tupleDesc, i);
567567

568-
if (HeapTupleHasNulls(tuple) && att_isnull(i, bp))
568+
if (HeapTupleHasNulls(tup) && att_isnull(i, bp))
569569
{
570570
usecache = false;
571571
continue; /* this cannot be the target att */

src/backend/access/heap/heapam.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ static bool ConditionalMultiXactIdWait(MultiXactId multi, MultiXactStatus status
108108
static void index_delete_sort(TM_IndexDeleteOp *delstate);
109109
static int bottomup_sort_and_shrink(TM_IndexDeleteOp *delstate);
110110
static XLogRecPtr log_heap_new_cid(Relation relation, HeapTuple tup);
111-
static HeapTuple ExtractReplicaIdentity(Relation rel, HeapTuple tup, bool key_required,
111+
static HeapTuple ExtractReplicaIdentity(Relation relation, HeapTuple tp, bool key_required,
112112
bool *copy);
113113

114114

src/backend/access/heap/heapam_visibility.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1763,30 +1763,30 @@ HeapTupleSatisfiesHistoricMVCC(HeapTuple htup, Snapshot snapshot,
17631763
* if so, the indicated buffer is marked dirty.
17641764
*/
17651765
bool
1766-
HeapTupleSatisfiesVisibility(HeapTuple tup, Snapshot snapshot, Buffer buffer)
1766+
HeapTupleSatisfiesVisibility(HeapTuple htup, Snapshot snapshot, Buffer buffer)
17671767
{
17681768
switch (snapshot->snapshot_type)
17691769
{
17701770
case SNAPSHOT_MVCC:
1771-
return HeapTupleSatisfiesMVCC(tup, snapshot, buffer);
1771+
return HeapTupleSatisfiesMVCC(htup, snapshot, buffer);
17721772
break;
17731773
case SNAPSHOT_SELF:
1774-
return HeapTupleSatisfiesSelf(tup, snapshot, buffer);
1774+
return HeapTupleSatisfiesSelf(htup, snapshot, buffer);
17751775
break;
17761776
case SNAPSHOT_ANY:
1777-
return HeapTupleSatisfiesAny(tup, snapshot, buffer);
1777+
return HeapTupleSatisfiesAny(htup, snapshot, buffer);
17781778
break;
17791779
case SNAPSHOT_TOAST:
1780-
return HeapTupleSatisfiesToast(tup, snapshot, buffer);
1780+
return HeapTupleSatisfiesToast(htup, snapshot, buffer);
17811781
break;
17821782
case SNAPSHOT_DIRTY:
1783-
return HeapTupleSatisfiesDirty(tup, snapshot, buffer);
1783+
return HeapTupleSatisfiesDirty(htup, snapshot, buffer);
17841784
break;
17851785
case SNAPSHOT_HISTORIC_MVCC:
1786-
return HeapTupleSatisfiesHistoricMVCC(tup, snapshot, buffer);
1786+
return HeapTupleSatisfiesHistoricMVCC(htup, snapshot, buffer);
17871787
break;
17881788
case SNAPSHOT_NON_VACUUMABLE:
1789-
return HeapTupleSatisfiesNonVacuumable(tup, snapshot, buffer);
1789+
return HeapTupleSatisfiesNonVacuumable(htup, snapshot, buffer);
17901790
break;
17911791
}
17921792

src/backend/access/heap/visibilitymap.c

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static void vm_extend(Relation rel, BlockNumber vm_nblocks);
137137
* any I/O. Returns true if any bits have been cleared and false otherwise.
138138
*/
139139
bool
140-
visibilitymap_clear(Relation rel, BlockNumber heapBlk, Buffer buf, uint8 flags)
140+
visibilitymap_clear(Relation rel, BlockNumber heapBlk, Buffer vmbuf, uint8 flags)
141141
{
142142
BlockNumber mapBlock = HEAPBLK_TO_MAPBLOCK(heapBlk);
143143
int mapByte = HEAPBLK_TO_MAPBYTE(heapBlk);
@@ -152,21 +152,21 @@ visibilitymap_clear(Relation rel, BlockNumber heapBlk, Buffer buf, uint8 flags)
152152
elog(DEBUG1, "vm_clear %s %d", RelationGetRelationName(rel), heapBlk);
153153
#endif
154154

155-
if (!BufferIsValid(buf) || BufferGetBlockNumber(buf) != mapBlock)
155+
if (!BufferIsValid(vmbuf) || BufferGetBlockNumber(vmbuf) != mapBlock)
156156
elog(ERROR, "wrong buffer passed to visibilitymap_clear");
157157

158-
LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE);
159-
map = PageGetContents(BufferGetPage(buf));
158+
LockBuffer(vmbuf, BUFFER_LOCK_EXCLUSIVE);
159+
map = PageGetContents(BufferGetPage(vmbuf));
160160

161161
if (map[mapByte] & mask)
162162
{
163163
map[mapByte] &= ~mask;
164164

165-
MarkBufferDirty(buf);
165+
MarkBufferDirty(vmbuf);
166166
cleared = true;
167167
}
168168

169-
LockBuffer(buf, BUFFER_LOCK_UNLOCK);
169+
LockBuffer(vmbuf, BUFFER_LOCK_UNLOCK);
170170

171171
return cleared;
172172
}
@@ -180,43 +180,43 @@ visibilitymap_clear(Relation rel, BlockNumber heapBlk, Buffer buf, uint8 flags)
180180
* shouldn't hold a lock on the heap page while doing that. Then, call
181181
* visibilitymap_set to actually set the bit.
182182
*
183-
* On entry, *buf should be InvalidBuffer or a valid buffer returned by
183+
* On entry, *vmbuf should be InvalidBuffer or a valid buffer returned by
184184
* an earlier call to visibilitymap_pin or visibilitymap_get_status on the same
185-
* relation. On return, *buf is a valid buffer with the map page containing
185+
* relation. On return, *vmbuf is a valid buffer with the map page containing
186186
* the bit for heapBlk.
187187
*
188188
* If the page doesn't exist in the map file yet, it is extended.
189189
*/
190190
void
191-
visibilitymap_pin(Relation rel, BlockNumber heapBlk, Buffer *buf)
191+
visibilitymap_pin(Relation rel, BlockNumber heapBlk, Buffer *vmbuf)
192192
{
193193
BlockNumber mapBlock = HEAPBLK_TO_MAPBLOCK(heapBlk);
194194

195195
/* Reuse the old pinned buffer if possible */
196-
if (BufferIsValid(*buf))
196+
if (BufferIsValid(*vmbuf))
197197
{
198-
if (BufferGetBlockNumber(*buf) == mapBlock)
198+
if (BufferGetBlockNumber(*vmbuf) == mapBlock)
199199
return;
200200

201-
ReleaseBuffer(*buf);
201+
ReleaseBuffer(*vmbuf);
202202
}
203-
*buf = vm_readbuf(rel, mapBlock, true);
203+
*vmbuf = vm_readbuf(rel, mapBlock, true);
204204
}
205205

206206
/*
207207
* visibilitymap_pin_ok - do we already have the correct page pinned?
208208
*
209-
* On entry, buf should be InvalidBuffer or a valid buffer returned by
209+
* On entry, vmbuf should be InvalidBuffer or a valid buffer returned by
210210
* an earlier call to visibilitymap_pin or visibilitymap_get_status on the same
211211
* relation. The return value indicates whether the buffer covers the
212212
* given heapBlk.
213213
*/
214214
bool
215-
visibilitymap_pin_ok(BlockNumber heapBlk, Buffer buf)
215+
visibilitymap_pin_ok(BlockNumber heapBlk, Buffer vmbuf)
216216
{
217217
BlockNumber mapBlock = HEAPBLK_TO_MAPBLOCK(heapBlk);
218218

219-
return BufferIsValid(buf) && BufferGetBlockNumber(buf) == mapBlock;
219+
return BufferIsValid(vmbuf) && BufferGetBlockNumber(vmbuf) == mapBlock;
220220
}
221221

222222
/*
@@ -314,11 +314,11 @@ visibilitymap_set(Relation rel, BlockNumber heapBlk, Buffer heapBuf,
314314
* Are all tuples on heapBlk visible to all or are marked frozen, according
315315
* to the visibility map?
316316
*
317-
* On entry, *buf should be InvalidBuffer or a valid buffer returned by an
317+
* On entry, *vmbuf should be InvalidBuffer or a valid buffer returned by an
318318
* earlier call to visibilitymap_pin or visibilitymap_get_status on the same
319-
* relation. On return, *buf is a valid buffer with the map page containing
319+
* relation. On return, *vmbuf is a valid buffer with the map page containing
320320
* the bit for heapBlk, or InvalidBuffer. The caller is responsible for
321-
* releasing *buf after it's done testing and setting bits.
321+
* releasing *vmbuf after it's done testing and setting bits.
322322
*
323323
* NOTE: This function is typically called without a lock on the heap page,
324324
* so somebody else could change the bit just after we look at it. In fact,
@@ -328,7 +328,7 @@ visibilitymap_set(Relation rel, BlockNumber heapBlk, Buffer heapBuf,
328328
* all concurrency issues!
329329
*/
330330
uint8
331-
visibilitymap_get_status(Relation rel, BlockNumber heapBlk, Buffer *buf)
331+
visibilitymap_get_status(Relation rel, BlockNumber heapBlk, Buffer *vmbuf)
332332
{
333333
BlockNumber mapBlock = HEAPBLK_TO_MAPBLOCK(heapBlk);
334334
uint32 mapByte = HEAPBLK_TO_MAPBYTE(heapBlk);
@@ -341,23 +341,23 @@ visibilitymap_get_status(Relation rel, BlockNumber heapBlk, Buffer *buf)
341341
#endif
342342

343343
/* Reuse the old pinned buffer if possible */
344-
if (BufferIsValid(*buf))
344+
if (BufferIsValid(*vmbuf))
345345
{
346-
if (BufferGetBlockNumber(*buf) != mapBlock)
346+
if (BufferGetBlockNumber(*vmbuf) != mapBlock)
347347
{
348-
ReleaseBuffer(*buf);
349-
*buf = InvalidBuffer;
348+
ReleaseBuffer(*vmbuf);
349+
*vmbuf = InvalidBuffer;
350350
}
351351
}
352352

353-
if (!BufferIsValid(*buf))
353+
if (!BufferIsValid(*vmbuf))
354354
{
355-
*buf = vm_readbuf(rel, mapBlock, false);
356-
if (!BufferIsValid(*buf))
355+
*vmbuf = vm_readbuf(rel, mapBlock, false);
356+
if (!BufferIsValid(*vmbuf))
357357
return false;
358358
}
359359

360-
map = PageGetContents(BufferGetPage(*buf));
360+
map = PageGetContents(BufferGetPage(*vmbuf));
361361

362362
/*
363363
* A single byte read is atomic. There could be memory-ordering effects

src/backend/access/table/tableam.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,19 +172,18 @@ table_parallelscan_initialize(Relation rel, ParallelTableScanDesc pscan,
172172
}
173173

174174
TableScanDesc
175-
table_beginscan_parallel(Relation relation, ParallelTableScanDesc parallel_scan)
175+
table_beginscan_parallel(Relation relation, ParallelTableScanDesc pscan)
176176
{
177177
Snapshot snapshot;
178178
uint32 flags = SO_TYPE_SEQSCAN |
179179
SO_ALLOW_STRAT | SO_ALLOW_SYNC | SO_ALLOW_PAGEMODE;
180180

181-
Assert(RelationGetRelid(relation) == parallel_scan->phs_relid);
181+
Assert(RelationGetRelid(relation) == pscan->phs_relid);
182182

183-
if (!parallel_scan->phs_snapshot_any)
183+
if (!pscan->phs_snapshot_any)
184184
{
185185
/* Snapshot was serialized -- restore it */
186-
snapshot = RestoreSnapshot((char *) parallel_scan +
187-
parallel_scan->phs_snapshot_off);
186+
snapshot = RestoreSnapshot((char *) pscan + pscan->phs_snapshot_off);
188187
RegisterSnapshot(snapshot);
189188
flags |= SO_TEMP_SNAPSHOT;
190189
}
@@ -195,7 +194,7 @@ table_beginscan_parallel(Relation relation, ParallelTableScanDesc parallel_scan)
195194
}
196195

197196
return relation->rd_tableam->scan_begin(relation, snapshot, 0, NULL,
198-
parallel_scan, flags);
197+
pscan, flags);
199198
}
200199

201200

src/backend/access/transam/multixact.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,14 +1214,14 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
12141214
* range, that is, greater to or equal than oldestMultiXactId, and less than
12151215
* nextMXact. Otherwise, an error is raised.
12161216
*
1217-
* onlyLock must be set to true if caller is certain that the given multi
1217+
* isLockOnly must be set to true if caller is certain that the given multi
12181218
* is used only to lock tuples; can be false without loss of correctness,
12191219
* but passing a true means we can return quickly without checking for
12201220
* old updates.
12211221
*/
12221222
int
12231223
GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
1224-
bool from_pgupgrade, bool onlyLock)
1224+
bool from_pgupgrade, bool isLockOnly)
12251225
{
12261226
int pageno;
12271227
int prev_pageno;
@@ -1263,7 +1263,7 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
12631263
* we can skip checking if the value is older than our oldest visible
12641264
* multi. It cannot possibly still be running.
12651265
*/
1266-
if (onlyLock &&
1266+
if (isLockOnly &&
12671267
MultiXactIdPrecedes(multi, OldestVisibleMXactId[MyBackendId]))
12681268
{
12691269
debug_elog2(DEBUG2, "GetMembers: a locker-only multi is too old");

src/include/access/heapam.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ extern TableScanDesc heap_beginscan(Relation relation, Snapshot snapshot,
118118
int nkeys, ScanKey key,
119119
ParallelTableScanDesc parallel_scan,
120120
uint32 flags);
121-
extern void heap_setscanlimits(TableScanDesc scan, BlockNumber startBlk,
121+
extern void heap_setscanlimits(TableScanDesc sscan, BlockNumber startBlk,
122122
BlockNumber numBlks);
123-
extern void heapgetpage(TableScanDesc scan, BlockNumber page);
124-
extern void heap_rescan(TableScanDesc scan, ScanKey key, bool set_params,
123+
extern void heapgetpage(TableScanDesc sscan, BlockNumber page);
124+
extern void heap_rescan(TableScanDesc sscan, ScanKey key, bool set_params,
125125
bool allow_strat, bool allow_sync, bool allow_pagemode);
126-
extern void heap_endscan(TableScanDesc scan);
127-
extern HeapTuple heap_getnext(TableScanDesc scan, ScanDirection direction);
126+
extern void heap_endscan(TableScanDesc sscan);
127+
extern HeapTuple heap_getnext(TableScanDesc sscan, ScanDirection direction);
128128
extern bool heap_getnextslot(TableScanDesc sscan,
129129
ScanDirection direction, struct TupleTableSlot *slot);
130130
extern void heap_set_tidrange(TableScanDesc sscan, ItemPointer mintid,
@@ -138,7 +138,7 @@ extern bool heap_hot_search_buffer(ItemPointer tid, Relation relation,
138138
Buffer buffer, Snapshot snapshot, HeapTuple heapTuple,
139139
bool *all_dead, bool first_call);
140140

141-
extern void heap_get_latest_tid(TableScanDesc scan, ItemPointer tid);
141+
extern void heap_get_latest_tid(TableScanDesc sscan, ItemPointer tid);
142142

143143
extern BulkInsertState GetBulkInsertState(void);
144144
extern void FreeBulkInsertState(BulkInsertState);
@@ -160,7 +160,7 @@ extern TM_Result heap_update(Relation relation, ItemPointer otid,
160160
struct TM_FailureData *tmfd, LockTupleMode *lockmode);
161161
extern TM_Result heap_lock_tuple(Relation relation, HeapTuple tuple,
162162
CommandId cid, LockTupleMode mode, LockWaitPolicy wait_policy,
163-
bool follow_update,
163+
bool follow_updates,
164164
Buffer *buffer, struct TM_FailureData *tmfd);
165165

166166
extern void heap_inplace_update(Relation relation, HeapTuple tuple);
@@ -187,7 +187,7 @@ extern void heap_page_prune_opt(Relation relation, Buffer buffer);
187187
extern int heap_page_prune(Relation relation, Buffer buffer,
188188
struct GlobalVisState *vistest,
189189
TransactionId old_snap_xmin,
190-
TimestampTz old_snap_ts_ts,
190+
TimestampTz old_snap_ts,
191191
int *nnewlpdead,
192192
OffsetNumber *off_loc);
193193
extern void heap_page_prune_execute(Buffer buffer,
@@ -202,13 +202,13 @@ extern void heap_vacuum_rel(Relation rel,
202202
struct VacuumParams *params, BufferAccessStrategy bstrategy);
203203

204204
/* in heap/heapam_visibility.c */
205-
extern bool HeapTupleSatisfiesVisibility(HeapTuple stup, Snapshot snapshot,
205+
extern bool HeapTupleSatisfiesVisibility(HeapTuple htup, Snapshot snapshot,
206206
Buffer buffer);
207-
extern TM_Result HeapTupleSatisfiesUpdate(HeapTuple stup, CommandId curcid,
207+
extern TM_Result HeapTupleSatisfiesUpdate(HeapTuple htup, CommandId curcid,
208208
Buffer buffer);
209-
extern HTSV_Result HeapTupleSatisfiesVacuum(HeapTuple stup, TransactionId OldestXmin,
209+
extern HTSV_Result HeapTupleSatisfiesVacuum(HeapTuple htup, TransactionId OldestXmin,
210210
Buffer buffer);
211-
extern HTSV_Result HeapTupleSatisfiesVacuumHorizon(HeapTuple stup, Buffer buffer,
211+
extern HTSV_Result HeapTupleSatisfiesVacuumHorizon(HeapTuple htup, Buffer buffer,
212212
TransactionId *dead_after);
213213
extern void HeapTupleSetHintBits(HeapTupleHeader tuple, Buffer buffer,
214214
uint16 infomask, TransactionId xid);
@@ -227,7 +227,7 @@ extern bool ResolveCminCmaxDuringDecoding(struct HTAB *tuplecid_data,
227227
HeapTuple htup,
228228
Buffer buffer,
229229
CommandId *cmin, CommandId *cmax);
230-
extern void HeapCheckForSerializableConflictOut(bool valid, Relation relation, HeapTuple tuple,
230+
extern void HeapCheckForSerializableConflictOut(bool visible, Relation relation, HeapTuple tuple,
231231
Buffer buffer, Snapshot snapshot);
232232

233233
#endif /* HEAPAM_H */

src/include/access/heapam_xlog.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,8 @@ extern bool heap_prepare_freeze_tuple(HeapTupleHeader tuple,
414414
TransactionId *relfrozenxid_out,
415415
MultiXactId *relminmxid_out);
416416
extern void heap_execute_freeze_tuple(HeapTupleHeader tuple,
417-
xl_heap_freeze_tuple *xlrec_tp);
417+
xl_heap_freeze_tuple *frz);
418418
extern XLogRecPtr log_heap_visible(RelFileLocator rlocator, Buffer heap_buffer,
419-
Buffer vm_buffer, TransactionId cutoff_xid, uint8 flags);
419+
Buffer vm_buffer, TransactionId cutoff_xid, uint8 vmflags);
420420

421421
#endif /* HEAPAM_XLOG_H */

src/include/access/htup_details.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ extern void heap_fill_tuple(TupleDesc tupleDesc,
699699
uint16 *infomask, bits8 *bit);
700700
extern bool heap_attisnull(HeapTuple tup, int attnum, TupleDesc tupleDesc);
701701
extern Datum nocachegetattr(HeapTuple tup, int attnum,
702-
TupleDesc att);
702+
TupleDesc tupleDesc);
703703
extern Datum heap_getsysattr(HeapTuple tup, int attnum, TupleDesc tupleDesc,
704704
bool *isnull);
705705
extern Datum getmissingattr(TupleDesc tupleDesc,

0 commit comments

Comments
 (0)