Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit ffb0603

Browse files
committed
Improve comments in slru.{c,h} about segment name format
slru.h described incorrectly how SLRU segment names are formatted depending on the segment number and if long or short segment names are used. This commit closes the gap with a better description, fitting with the reality. Reported-by: Noah Misch Author: Aleksander Alekseev Discussion: https://postgr.es/m/20240626002747.dc.nmisch@google.com Backpatch-through: 17
1 parent 65504b7 commit ffb0603

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/backend/access/transam/slru.c

+15
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,21 @@
7272
#include "storage/shmem.h"
7373
#include "utils/guc_hooks.h"
7474

75+
/*
76+
* Converts segment number to the filename of the segment.
77+
*
78+
* "path" should point to a buffer at least MAXPGPATH characters long.
79+
*
80+
* If ctl->long_segment_names is true, segno can be in the range [0, 2^60-1].
81+
* The resulting file name is made of 15 characters, e.g. dir/123456789ABCDEF.
82+
*
83+
* If ctl->long_segment_names is false, segno can be in the range [0, 2^24-1].
84+
* The resulting file name is made of 4 to 6 characters, as of:
85+
*
86+
* dir/1234 for [0, 2^16-1]
87+
* dir/12345 for [2^16, 2^20-1]
88+
* dir/123456 for [2^20, 2^24-1]
89+
*/
7590
static inline int
7691
SlruFileName(SlruCtl ctl, char *path, int64 segno)
7792
{

src/include/access/slru.h

+3-4
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,9 @@ typedef struct SlruCtlData
134134
bits16 bank_mask;
135135

136136
/*
137-
* If true, use long segment filenames formed from lower 48 bits of the
138-
* segment number, e.g. pg_xact/000000001234. Otherwise, use short
139-
* filenames formed from lower 16 bits of the segment number e.g.
140-
* pg_xact/1234.
137+
* If true, use long segment file names. Otherwise, use short file names.
138+
*
139+
* For details about the file name format, see SlruFileName().
141140
*/
142141
bool long_segment_names;
143142

0 commit comments

Comments
 (0)