From 9d4d2d255e8057365c6c0a8904bee5db5f97b4a1 Mon Sep 17 00:00:00 2001
From: Michael Paquier <michael@otacoo.com>
Date: Wed, 11 Feb 2015 16:36:15 -0800
Subject: [PATCH 2/2] Switch client binaries to use precise timestamp routine
 on Windows

The following client binaries are updated:
- pg_basebackup
- pg_resetxlog
- pg_test_fsync

Patch and report from Asif Naheem.
---
 contrib/pg_test_fsync/pg_test_fsync.c | 8 ++++++++
 src/bin/pg_basebackup/pg_basebackup.c | 8 ++++++++
 src/bin/pg_resetxlog/pg_resetxlog.c   | 8 ++++++++
 3 files changed, 24 insertions(+)

diff --git a/contrib/pg_test_fsync/pg_test_fsync.c b/contrib/pg_test_fsync/pg_test_fsync.c
index c842762..269bd08 100644
--- a/contrib/pg_test_fsync/pg_test_fsync.c
+++ b/contrib/pg_test_fsync/pg_test_fsync.c
@@ -98,6 +98,14 @@ main(int argc, char *argv[])
 {
 	progname = get_progname(argv[0]);
 
+#if defined(WIN32) && !defined(HAVE_GETTIMEOFDAY)
+	/*
+	 * Attempt upgrade to more precise function to retrieve timestamp
+	 * information.
+	 */
+	pgwin32_upgrade_gettimeofday();
+#endif
+
 	handle_args(argc, argv);
 
 	/* Prevent leaving behind the test file */
diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c
index fbf7106..cf215f0 100644
--- a/src/bin/pg_basebackup/pg_basebackup.c
+++ b/src/bin/pg_basebackup/pg_basebackup.c
@@ -1955,6 +1955,14 @@ main(int argc, char **argv)
 	progname = get_progname(argv[0]);
 	set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_basebackup"));
 
+#if defined(WIN32) && !defined(HAVE_GETTIMEOFDAY)
+	/*
+	 * Attempt upgrade to more precise function to retrieve timestamp
+	 * information.
+	 */
+	pgwin32_upgrade_gettimeofday();
+#endif
+
 	if (argc > 1)
 	{
 		if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
diff --git a/src/bin/pg_resetxlog/pg_resetxlog.c b/src/bin/pg_resetxlog/pg_resetxlog.c
index a16089f..a862d71 100644
--- a/src/bin/pg_resetxlog/pg_resetxlog.c
+++ b/src/bin/pg_resetxlog/pg_resetxlog.c
@@ -99,6 +99,14 @@ main(int argc, char *argv[])
 
 	progname = get_progname(argv[0]);
 
+#if defined(WIN32) && !defined(HAVE_GETTIMEOFDAY)
+	/*
+	 * Attempt upgrade to more precise function to retrieve timestamp
+	 * information.
+	 */
+	pgwin32_upgrade_gettimeofday();
+#endif
+
 	if (argc > 1)
 	{
 		if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
-- 
1.9.2.msysgit.0

