aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2020-06-24 14:00:37 -0400
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2020-06-24 14:00:37 -0400
commit013d324d51ef55cbfff50d4302261b5199cd3198 (patch)
tree1a1a86b161f3b1f45e8a647083c793d3c8c64015
parentd3d8755180b68b6d0d385e8f6989bfbc969a891a (diff)
downloadpostgresql-013d324d51ef55cbfff50d4302261b5199cd3198.tar.gz
postgresql-013d324d51ef55cbfff50d4302261b5199cd3198.zip
Add parens to ConvertToXSegs macro
The current definition is dangerous. No bugs exist in our code at present, but backpatch to 11 nonetheless where it was introduced. Author: Álvaro Herrera <alvherre@alvh.no-ip.org>
-rw-r--r--src/backend/access/transam/xlog.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index e285ae96c1e..18b4d11bd03 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -744,9 +744,12 @@ static ControlFileData *ControlFile = NULL;
*/
#define UsableBytesInPage (XLOG_BLCKSZ - SizeOfXLogShortPHD)
-/* Convert min_wal_size_mb and max wal_size_mb to equivalent segment count */
+/*
+ * Convert min_wal_size_mb and max wal_size_mb to equivalent segment count.
+ * Rounds down.
+ */
#define ConvertToXSegs(x, segsize) \
- (x / ((segsize) / (1024 * 1024)))
+ ((x) / ((segsize) / (1024 * 1024)))
/* The number of bytes in a WAL segment usable for WAL data. */
static int UsableBytesInSegment;