agora inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH 3/4] Move conversion of a "historic" to MVCC snapshot to a separate function.
246+ messages / 2 participants
[nested] [flat]

* [PATCH 3/4] Move conversion of a "historic" to MVCC snapshot to a separate function.
@ 2025-08-11 13:23 Antonin Houska <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Antonin Houska @ 2025-08-11 13:23 UTC (permalink / raw)

The conversion is now handled by SnapBuildMVCCFromHistoric(). REPACK
CONCURRENTLY will also need it.
---
 src/backend/replication/logical/snapbuild.c | 51 +++++++++++++++++----
 src/backend/utils/time/snapmgr.c            |  3 +-
 src/include/replication/snapbuild.h         |  1 +
 src/include/utils/snapmgr.h                 |  1 +
 4 files changed, 45 insertions(+), 11 deletions(-)

diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c
index 8532bfd27e5..6eaa40f6acf 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -440,10 +440,7 @@ Snapshot
 SnapBuildInitialSnapshot(SnapBuild *builder)
 {
 	Snapshot	snap;
-	TransactionId xid;
 	TransactionId safeXid;
-	TransactionId *newxip;
-	int			newxcnt = 0;
 
 	Assert(XactIsoLevel == XACT_REPEATABLE_READ);
 	Assert(builder->building_full_snapshot);
@@ -485,6 +482,31 @@ SnapBuildInitialSnapshot(SnapBuild *builder)
 
 	MyProc->xmin = snap->xmin;
 
+	/* Convert the historic snapshot to MVCC snapshot. */
+	return SnapBuildMVCCFromHistoric(snap, true);
+}
+
+/*
+ * Turn a historic MVCC snapshot into an ordinary MVCC snapshot.
+ *
+ * Unlike a regular (non-historic) MVCC snapshot, the xip array of this
+ * snapshot contains not only running main transactions, but also their
+ * subtransactions. This difference does has no impact on XidInMVCCSnapshot().
+ *
+ * Pass true for 'in_place' if you don't care about modifying the source
+ * snapshot. If you need a new instance, and one that was allocated as a
+ * single chunk of memory, pass false.
+ */
+Snapshot
+SnapBuildMVCCFromHistoric(Snapshot snapshot, bool in_place)
+{
+	TransactionId xid;
+	TransactionId *oldxip = snapshot->xip;
+	uint32		oldxcnt = snapshot->xcnt;
+	TransactionId *newxip;
+	int			newxcnt = 0;
+	Snapshot	result;
+
 	/* allocate in transaction context */
 	newxip = (TransactionId *)
 		palloc(sizeof(TransactionId) * GetMaxSnapshotXidCount());
@@ -495,7 +517,7 @@ SnapBuildInitialSnapshot(SnapBuild *builder)
 	 * classical snapshot by marking all non-committed transactions as
 	 * in-progress. This can be expensive.
 	 */
-	for (xid = snap->xmin; NormalTransactionIdPrecedes(xid, snap->xmax);)
+	for (xid = snapshot->xmin; NormalTransactionIdPrecedes(xid, snapshot->xmax);)
 	{
 		void	   *test;
 
@@ -503,7 +525,7 @@ SnapBuildInitialSnapshot(SnapBuild *builder)
 		 * Check whether transaction committed using the decoding snapshot
 		 * meaning of ->xip.
 		 */
-		test = bsearch(&xid, snap->xip, snap->xcnt,
+		test = bsearch(&xid, snapshot->xip, snapshot->xcnt,
 					   sizeof(TransactionId), xidComparator);
 
 		if (test == NULL)
@@ -520,11 +542,22 @@ SnapBuildInitialSnapshot(SnapBuild *builder)
 	}
 
 	/* adjust remaining snapshot fields as needed */
-	snap->snapshot_type = SNAPSHOT_MVCC;
-	snap->xcnt = newxcnt;
-	snap->xip = newxip;
+	snapshot->xcnt = newxcnt;
+	snapshot->xip = newxip;
+
+	if (in_place)
+		result = snapshot;
+	else
+	{
+		result = CopySnapshot(snapshot);
+
+		/* Restore the original values so the source is intact. */
+		snapshot->xip = oldxip;
+		snapshot->xcnt = oldxcnt;
+	}
+	result->snapshot_type = SNAPSHOT_MVCC;
 
-	return snap;
+	return result;
 }
 
 /*
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index ea35f30f494..70a6b8902d1 100644
--- a/src/backend/utils/time/snapmgr.c
+++ b/src/backend/utils/time/snapmgr.c
@@ -212,7 +212,6 @@ typedef struct ExportedSnapshot
 static List *exportedSnapshots = NIL;
 
 /* Prototypes for local functions */
-static Snapshot CopySnapshot(Snapshot snapshot);
 static void UnregisterSnapshotNoOwner(Snapshot snapshot);
 static void FreeSnapshot(Snapshot snapshot);
 static void SnapshotResetXmin(void);
@@ -591,7 +590,7 @@ SetTransactionSnapshot(Snapshot sourcesnap, VirtualTransactionId *sourcevxid,
  * The copy is palloc'd in TopTransactionContext and has initial refcounts set
  * to 0.  The returned snapshot has the copied flag set.
  */
-static Snapshot
+Snapshot
 CopySnapshot(Snapshot snapshot)
 {
 	Snapshot	newsnap;
diff --git a/src/include/replication/snapbuild.h b/src/include/replication/snapbuild.h
index 44031dcf6e3..6d4d2d1814c 100644
--- a/src/include/replication/snapbuild.h
+++ b/src/include/replication/snapbuild.h
@@ -73,6 +73,7 @@ extern void FreeSnapshotBuilder(SnapBuild *builder);
 extern void SnapBuildSnapDecRefcount(Snapshot snap);
 
 extern Snapshot SnapBuildInitialSnapshot(SnapBuild *builder);
+extern Snapshot SnapBuildMVCCFromHistoric(Snapshot snapshot, bool in_place);
 extern const char *SnapBuildExportSnapshot(SnapBuild *builder);
 extern void SnapBuildClearExportedSnapshot(void);
 extern void SnapBuildResetExportedSnapshotState(void);
diff --git a/src/include/utils/snapmgr.h b/src/include/utils/snapmgr.h
index d346be71642..147b190210a 100644
--- a/src/include/utils/snapmgr.h
+++ b/src/include/utils/snapmgr.h
@@ -60,6 +60,7 @@ extern Snapshot GetTransactionSnapshot(void);
 extern Snapshot GetLatestSnapshot(void);
 extern void SnapshotSetCommandId(CommandId curcid);
 
+extern Snapshot CopySnapshot(Snapshot snapshot);
 extern Snapshot GetCatalogSnapshot(Oid relid);
 extern Snapshot GetNonHistoricCatalogSnapshot(Oid relid);
 extern void InvalidateCatalogSnapshot(void);
-- 
2.47.1


--=-=-=
Content-Type: text/plain
Content-Disposition: attachment;
 filename=v18-0004-Add-CONCURRENTLY-option-to-REPACK-command.patch



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread

* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 246+ messages in thread

From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  5 ++---
 src/bin/pg_ctl/pg_ctl.c                     | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
 #include "common/logging.h"
 #include "common/pg_prng.h"
 #include "common/restricted_token.h"
+#include "datatype/timestamp.h"
 #include "fe_utils/recovery_gen.h"
 #include "fe_utils/simple_list.h"
 #include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
 static void get_publisher_databases(struct CreateSubscriberOptions *opt,
 									bool dbnamespecified);
 
-#define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
 static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
 		}
 
 		/* Keep waiting */
-		pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+		pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
 		timer += WAIT_INTERVAL;
 	}
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
 #include "common/file_perm.h"
 #include "common/logging.h"
 #include "common/string.h"
+#include "datatype/timestamp.h"
 #include "getopt_long.h"
 #include "utils/pidfile.h"
 
@@ -68,9 +69,7 @@ typedef enum
 
 #define DEFAULT_WAIT	60
 
-#define USEC_PER_SEC	1000000
-
-#define WAITS_PER_SEC	10		/* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC	10		/* should divide USECS_PER_SEC evenly */
 
 static bool do_wait = true;
 static int	wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 {
 	int			i;
 
+	static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
 	for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
 	{
 		char	  **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
 				print_msg(".");
 		}
 
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 
 	/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
 
 		if (cnt % WAITS_PER_SEC == 0)
 			print_msg(".");
-		pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+		pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
 	}
 	return false;				/* timeout reached */
 }
-- 
2.47.3


--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
	filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"



^ permalink  raw  reply  [nested|flat] 246+ messages in thread


end of thread, other threads:[~2025-10-31 15:51 UTC | newest]

Thread overview: 246+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-08-11 13:23 [PATCH 3/4] Move conversion of a "historic" to MVCC snapshot to a separate function. Antonin Houska <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>
2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox