agora inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH v28 05/11] Add Incremental View Maintenance support to psql
177+ messages / 2 participants
[nested] [flat]

* [PATCH v28 05/11] Add Incremental View Maintenance support to psql
@ 2019-12-20 01:21  Yugo Nagata <[email protected]>
  0 siblings, 0 replies; 177+ messages in thread

From: Yugo Nagata @ 2019-12-20 01:21 UTC (permalink / raw)

Add tab completion and meta-command output for IVM.
---
 src/bin/psql/describe.c     | 32 +++++++++++++++++++++++++++++++-
 src/bin/psql/tab-complete.c | 14 +++++++++-----
 2 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 9325a46b8f..f555af7c95 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -1575,6 +1575,7 @@ describeOneTableDetails(const char *schemaname,
 		char		relpersistence;
 		char		relreplident;
 		char	   *relam;
+		bool		isivm;
 	}			tableinfo;
 	bool		show_column_details = false;
 
@@ -1587,7 +1588,26 @@ describeOneTableDetails(const char *schemaname,
 	initPQExpBuffer(&tmpbuf);
 
 	/* Get general table info */
-	if (pset.sversion >= 120000)
+	if (pset.sversion >= 170000)
+	{
+		printfPQExpBuffer(&buf,
+						  "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
+						  "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, "
+						  "false AS relhasoids, c.relispartition, %s, c.reltablespace, "
+						  "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, "
+						  "c.relpersistence, c.relreplident, am.amname, "
+						  "c.relisivm\n"
+						  "FROM pg_catalog.pg_class c\n "
+						  "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
+						  "LEFT JOIN pg_catalog.pg_am am ON (c.relam = am.oid)\n"
+						  "WHERE c.oid = '%s';",
+						  (verbose ?
+						   "pg_catalog.array_to_string(c.reloptions || "
+						   "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
+						   : "''"),
+						  oid);
+	}
+	else if (pset.sversion >= 120000)
 	{
 		printfPQExpBuffer(&buf,
 						  "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
@@ -1707,6 +1727,10 @@ describeOneTableDetails(const char *schemaname,
 			(char *) NULL : pg_strdup(PQgetvalue(res, 0, 14));
 	else
 		tableinfo.relam = NULL;
+	if (pset.sversion >= 170000)
+		tableinfo.isivm = strcmp(PQgetvalue(res, 0, 15), "t") == 0;
+	else
+		tableinfo.isivm = false;
 	PQclear(res);
 	res = NULL;
 
@@ -3508,6 +3532,12 @@ describeOneTableDetails(const char *schemaname,
 			printfPQExpBuffer(&buf, _("Access method: %s"), tableinfo.relam);
 			printTableAddFooter(&cont, buf.data);
 		}
+
+		/* Incremental view maintance info */
+		if (verbose && tableinfo.relkind == RELKIND_MATVIEW && tableinfo.isivm)
+		{
+			printTableAddFooter(&cont, _("Incremental view maintenance: yes"));
+		}
 	}
 
 	/* reloptions, if verbose */
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 677847e434..6ec195b2e9 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -1240,6 +1240,7 @@ static const pgsql_thing_t words_after_create[] = {
 	{"FOREIGN TABLE", NULL, NULL, NULL},
 	{"FUNCTION", NULL, NULL, Query_for_list_of_functions},
 	{"GROUP", Query_for_list_of_roles},
+	{"INCREMENTAL MATERIALIZED VIEW", NULL, NULL, &Query_for_list_of_matviews, NULL, THING_NO_DROP | THING_NO_ALTER},
 	{"INDEX", NULL, NULL, &Query_for_list_of_indexes},
 	{"LANGUAGE", Query_for_list_of_languages},
 	{"LARGE OBJECT", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP},
@@ -3187,7 +3188,7 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH("SEQUENCE", "TABLE", "VIEW");
 	/* Complete "CREATE UNLOGGED" with TABLE or MATVIEW */
 	else if (TailMatches("CREATE", "UNLOGGED"))
-		COMPLETE_WITH("TABLE", "MATERIALIZED VIEW");
+		COMPLETE_WITH("TABLE", "MATERIALIZED VIEW", "INCREMENTAL MATERIALIZED VIEW");
 	/* Complete PARTITION BY with RANGE ( or LIST ( or ... */
 	else if (TailMatches("PARTITION", "BY"))
 		COMPLETE_WITH("RANGE (", "LIST (", "HASH (");
@@ -3504,13 +3505,16 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH("SELECT");
 
 /* CREATE MATERIALIZED VIEW */
-	else if (Matches("CREATE", "MATERIALIZED"))
+	else if (Matches("CREATE", "MATERIALIZED") ||
+			 Matches("CREATE", "INCREMENTAL", "MATERIALIZED"))
 		COMPLETE_WITH("VIEW");
-	/* Complete CREATE MATERIALIZED VIEW <name> with AS */
-	else if (Matches("CREATE", "MATERIALIZED", "VIEW", MatchAny))
+	/* Complete CREATE MATERIALIZED VIEW <name> with AS  */
+	else if (Matches("CREATE", "MATERIALIZED", "VIEW", MatchAny) ||
+			 Matches("CREATE", "INCREMENTAL", "MATERIALIZED", "VIEW", MatchAny))
 		COMPLETE_WITH("AS");
 	/* Complete "CREATE MATERIALIZED VIEW <sth> AS with "SELECT" */
-	else if (Matches("CREATE", "MATERIALIZED", "VIEW", MatchAny, "AS"))
+	else if (Matches("CREATE", "MATERIALIZED", "VIEW", MatchAny, "AS") ||
+			 Matches("CREATE", "INCREMENTAL", "MATERIALIZED", "VIEW", MatchAny, "AS"))
 		COMPLETE_WITH("SELECT");
 
 /* CREATE EVENT TRIGGER */
-- 
2.25.1


--Multipart=_Thu__1_Jun_2023_23_59_09_+0900_/G5+8nG46.f1T42K
Content-Type: text/x-diff;
 name="v28-0006-Add-Incremental-View-Maintenance-support.patch"
Content-Disposition: attachment;
 filename="v28-0006-Add-Incremental-View-Maintenance-support.patch"
Content-Transfer-Encoding: 7bit



^ permalink  raw  reply  [nested|flat] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ 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; 177+ 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] 177+ messages in thread


end of thread, other threads:[~2025-10-31 15:51 UTC | newest]

Thread overview: 177+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-12-20 01:21 [PATCH v28 05/11] Add Incremental View Maintenance support to psql Yugo Nagata <[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