summaryrefslogtreecommitdiff
path: root/src/backend/replication
diff options
context:
space:
mode:
authorNathan Bossart2024-02-16 20:05:36 +0000
committerNathan Bossart2024-02-16 20:05:36 +0000
commit3b42bdb47169c617cb79123c407a19d16458b49a (patch)
tree90b3448bf3d59ab3bdc5996f2bb43fc83bcfe458 /src/backend/replication
parent6b80394781c8de17fe7cae6996476088af3c319f (diff)
Use new overflow-safe integer comparison functions.
Commit 6b80394781 introduced integer comparison functions designed to be as efficient as possible while avoiding overflow. This commit makes use of these functions in many of the in-tree qsort() comparators to help ensure transitivity. Many of these comparator functions should also see a small performance boost. Author: Mats Kindahl Reviewed-by: Andres Freund, Fabrízio de Royes Mello Discussion: https://postgr.es/m/CA%2B14426g2Wa9QuUpmakwPxXFWG_1FaY0AsApkvcTBy-YfS6uaw%40mail.gmail.com
Diffstat (limited to 'src/backend/replication')
-rw-r--r--src/backend/replication/logical/reorderbuffer.c7
-rw-r--r--src/backend/replication/syncrep.c8
2 files changed, 4 insertions, 11 deletions
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index bbf0966182f..5446df3c647 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -91,6 +91,7 @@
#include "access/xact.h"
#include "access/xlog_internal.h"
#include "catalog/catalog.h"
+#include "common/int.h"
#include "lib/binaryheap.h"
#include "miscadmin.h"
#include "pgstat.h"
@@ -5119,11 +5120,7 @@ file_sort_by_lsn(const ListCell *a_p, const ListCell *b_p)
RewriteMappingFile *a = (RewriteMappingFile *) lfirst(a_p);
RewriteMappingFile *b = (RewriteMappingFile *) lfirst(b_p);
- if (a->lsn < b->lsn)
- return -1;
- else if (a->lsn > b->lsn)
- return 1;
- return 0;
+ return pg_cmp_u64(a->lsn, b->lsn);
}
/*
diff --git a/src/backend/replication/syncrep.c b/src/backend/replication/syncrep.c
index 2e6493aaaa4..bfcd8fa13e9 100644
--- a/src/backend/replication/syncrep.c
+++ b/src/backend/replication/syncrep.c
@@ -75,6 +75,7 @@
#include <unistd.h>
#include "access/xact.h"
+#include "common/int.h"
#include "miscadmin.h"
#include "pgstat.h"
#include "replication/syncrep.h"
@@ -698,12 +699,7 @@ cmp_lsn(const void *a, const void *b)
XLogRecPtr lsn1 = *((const XLogRecPtr *) a);
XLogRecPtr lsn2 = *((const XLogRecPtr *) b);
- if (lsn1 > lsn2)
- return -1;
- else if (lsn1 == lsn2)
- return 0;
- else
- return 1;
+ return pg_cmp_u64(lsn2, lsn1);
}
/*