summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Paquier2024-07-23 07:54:51 +0000
committerMichael Paquier2024-07-23 07:54:51 +0000
commitffb0603929617f39d449e942abe96cdba36e7545 (patch)
treed2c4086871cf93d0d0c5accaa84b935b53666680
parent65504b747f3c217dfa91297db6ea219924a3fa8a (diff)
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/[email protected] Backpatch-through: 17
-rw-r--r--src/backend/access/transam/slru.c15
-rw-r--r--src/include/access/slru.h7
2 files changed, 18 insertions, 4 deletions
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 77b05cc0a74..248aa1a6553 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -72,6 +72,21 @@
#include "storage/shmem.h"
#include "utils/guc_hooks.h"
+/*
+ * Converts segment number to the filename of the segment.
+ *
+ * "path" should point to a buffer at least MAXPGPATH characters long.
+ *
+ * If ctl->long_segment_names is true, segno can be in the range [0, 2^60-1].
+ * The resulting file name is made of 15 characters, e.g. dir/123456789ABCDEF.
+ *
+ * If ctl->long_segment_names is false, segno can be in the range [0, 2^24-1].
+ * The resulting file name is made of 4 to 6 characters, as of:
+ *
+ * dir/1234 for [0, 2^16-1]
+ * dir/12345 for [2^16, 2^20-1]
+ * dir/123456 for [2^20, 2^24-1]
+ */
static inline int
SlruFileName(SlruCtl ctl, char *path, int64 segno)
{
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 8a8d1918733..97e612cd100 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -134,10 +134,9 @@ typedef struct SlruCtlData
bits16 bank_mask;
/*
- * If true, use long segment filenames formed from lower 48 bits of the
- * segment number, e.g. pg_xact/000000001234. Otherwise, use short
- * filenames formed from lower 16 bits of the segment number e.g.
- * pg_xact/1234.
+ * If true, use long segment file names. Otherwise, use short file names.
+ *
+ * For details about the file name format, see SlruFileName().
*/
bool long_segment_names;