aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2022-10-17 11:40:19 +0900
committerMichael Paquier <michael@paquier.xyz>2022-10-17 11:40:19 +0900
commit9ebcb5ffdf3a1f49388c38ba5273370f49bf7d19 (patch)
tree1fa72a01c679f53aa2aebb84e687a377b10273cf
parentd4abb0bc5abb5dcb351956aed70f317a6bc494ba (diff)
downloadpostgresql-9ebcb5ffdf3a1f49388c38ba5273370f49bf7d19.tar.gz
postgresql-9ebcb5ffdf3a1f49388c38ba5273370f49bf7d19.zip
Fix calculation related to temporary WAL segment name in basic_archive
The file name used for its temporary destination, before renaming it to the real deal, has been using a microseconds in a timestamp aimed to be originally in milli-seconds. This is harmless as this is aimed at being a safeguard against name collisions (note MyProcPid in the name), but let's be correct with the maths. While on it, add a note in the module's makefile to document why installcheck is not supported. Author: Nathan Bossart Reviewed-by: Bharath Rupireddy Discussion: https://postgr.es/m/20221014044106.GA1673343@nathanxps13 Backpatch-through: 15
-rw-r--r--contrib/basic_archive/Makefile3
-rw-r--r--contrib/basic_archive/basic_archive.c4
2 files changed, 4 insertions, 3 deletions
diff --git a/contrib/basic_archive/Makefile b/contrib/basic_archive/Makefile
index 14d036e1c42..55d299d650c 100644
--- a/contrib/basic_archive/Makefile
+++ b/contrib/basic_archive/Makefile
@@ -5,7 +5,8 @@ PGFILEDESC = "basic_archive - basic archive module"
REGRESS = basic_archive
REGRESS_OPTS = --temp-config $(top_srcdir)/contrib/basic_archive/basic_archive.conf
-
+# Disabled because these tests require "shared_preload_libraries=basic_archive",
+# which typical installcheck users do not have (e.g. buildfarm clients).
NO_INSTALLCHECK = 1
ifdef USE_PGXS
diff --git a/contrib/basic_archive/basic_archive.c b/contrib/basic_archive/basic_archive.c
index 7efeb0d7058..87dd77cdd34 100644
--- a/contrib/basic_archive/basic_archive.c
+++ b/contrib/basic_archive/basic_archive.c
@@ -221,7 +221,7 @@ basic_archive_file_internal(const char *file, const char *path)
char temp[MAXPGPATH + 256];
struct stat st;
struct timeval tv;
- uint64 epoch;
+ uint64 epoch; /* milliseconds */
ereport(DEBUG3,
(errmsg("archiving \"%s\" via basic_archive", file)));
@@ -268,7 +268,7 @@ basic_archive_file_internal(const char *file, const char *path)
*/
gettimeofday(&tv, NULL);
if (pg_mul_u64_overflow((uint64) 1000, (uint64) tv.tv_sec, &epoch) ||
- pg_add_u64_overflow(epoch, (uint64) tv.tv_usec, &epoch))
+ pg_add_u64_overflow(epoch, (uint64) (tv.tv_usec / 1000), &epoch))
elog(ERROR, "could not generate temporary file name for archiving");
snprintf(temp, sizeof(temp), "%s/%s.%s.%d." UINT64_FORMAT,