assert-that-RELSEG_SIZE-is-sane.patch
text/x-diff
Filename: assert-that-RELSEG_SIZE-is-sane.patch
Type: text/x-diff
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
| File | + | − |
|---|---|---|
| src/backend/access/transam/xlog.c | 10 | 0 |
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index eceab341255..2e1da5c714b 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -39,6 +39,7 @@
#include "postgres.h"
#include <ctype.h>
+#include <limits.h>
#include <math.h>
#include <time.h>
#include <fcntl.h>
@@ -202,6 +203,15 @@ const struct config_enum_entry archive_mode_options[] = {
{NULL, 0, false}
};
+/*
+ * RELSEG_SIZE must fit into BlockNumber; but since we expose its value
+ * as an integer GUC, it actually needs to fit in signed int. It's worth
+ * having a cross-check for this since configure's --with-segsize options
+ * could let people select insane values.
+ */
+StaticAssertDecl(RELSEG_SIZE > 0 && RELSEG_SIZE <= INT_MAX,
+ "RELSEG_SIZE must fit in an integer");
+
/*
* Statistics for current checkpoint are collected in this global struct.
* Because only the checkpointer or a stand-alone backend can perform