agora inbox for [email protected]
help / color / mirror / Atom feed[PATCH v29 01/11] Add a syntax to create Incrementally Maintainable Materialized Views
178+ messages / 2 participants
[nested] [flat]
* [PATCH v29 01/11] Add a syntax to create Incrementally Maintainable Materialized Views
@ 2019-12-20 01:05 Yugo Nagata <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Yugo Nagata @ 2019-12-20 01:05 UTC (permalink / raw)
Allow to create Incrementally Maintainable Materialized View (IMMV)
by using INCREMENTAL option in CREATE MATERIALIZED VIEW command
as follow:
CREATE [INCREMANTAL] MATERIALIZED VIEW xxxxx AS SELECT ....;
---
src/backend/parser/gram.y | 32 +++++++++++++++++++++-----------
src/include/nodes/primnodes.h | 1 +
src/include/parser/kwlist.h | 1 +
3 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 7d2032885e..33c647b0c7 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -465,6 +465,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
%type <range> OptTempTableName
%type <into> into_clause create_as_target create_mv_target
+%type <boolean> incremental
%type <defelt> createfunc_opt_item common_func_opt_item dostmt_opt_item
%type <fun_param> func_arg func_arg_with_default table_func_column aggr_arg
@@ -718,7 +719,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
HANDLER HAVING HEADER_P HOLD HOUR_P
IDENTITY_P IF_P ILIKE IMMEDIATE IMMUTABLE IMPLICIT_P IMPORT_P IN_P INCLUDE
- INCLUDING INCREMENT INDENT INDEX INDEXES INHERIT INHERITS INITIALLY INLINE_P
+ INCLUDING INCREMENT INCREMENTAL INDENT INDEX INDEXES INHERIT INHERITS INITIALLY INLINE_P
INNER_P INOUT INPUT_P INSENSITIVE INSERT INSTEAD INT_P INTEGER
INTERSECT INTERVAL INTO INVOKER IS ISNULL ISOLATION
@@ -4652,32 +4653,34 @@ opt_with_data:
*****************************************************************************/
CreateMatViewStmt:
- CREATE OptNoLog MATERIALIZED VIEW create_mv_target AS SelectStmt opt_with_data
+ CREATE OptNoLog incremental MATERIALIZED VIEW create_mv_target AS SelectStmt opt_with_data
{
CreateTableAsStmt *ctas = makeNode(CreateTableAsStmt);
- ctas->query = $7;
- ctas->into = $5;
+ ctas->query = $8;
+ ctas->into = $6;
ctas->objtype = OBJECT_MATVIEW;
ctas->is_select_into = false;
ctas->if_not_exists = false;
/* cram additional flags into the IntoClause */
- $5->rel->relpersistence = $2;
- $5->skipData = !($8);
+ $6->rel->relpersistence = $2;
+ $6->skipData = !($9);
+ $6->ivm = $3;
$$ = (Node *) ctas;
}
- | CREATE OptNoLog MATERIALIZED VIEW IF_P NOT EXISTS create_mv_target AS SelectStmt opt_with_data
+ | CREATE OptNoLog incremental MATERIALIZED VIEW IF_P NOT EXISTS create_mv_target AS SelectStmt opt_with_data
{
CreateTableAsStmt *ctas = makeNode(CreateTableAsStmt);
- ctas->query = $10;
- ctas->into = $8;
+ ctas->query = $11;
+ ctas->into = $9;
ctas->objtype = OBJECT_MATVIEW;
ctas->is_select_into = false;
ctas->if_not_exists = true;
/* cram additional flags into the IntoClause */
- $8->rel->relpersistence = $2;
- $8->skipData = !($11);
+ $9->rel->relpersistence = $2;
+ $9->skipData = !($12);
+ $9->ivm = $3;
$$ = (Node *) ctas;
}
;
@@ -4694,9 +4697,14 @@ create_mv_target:
$$->tableSpaceName = $5;
$$->viewQuery = NULL; /* filled at analysis time */
$$->skipData = false; /* might get changed later */
+ $$->ivm = false;
}
;
+incremental: INCREMENTAL { $$ = true; }
+ | /*EMPTY*/ { $$ = false; }
+ ;
+
OptNoLog: UNLOGGED { $$ = RELPERSISTENCE_UNLOGGED; }
| /*EMPTY*/ { $$ = RELPERSISTENCE_PERMANENT; }
;
@@ -17141,6 +17149,7 @@ unreserved_keyword:
| INCLUDE
| INCLUDING
| INCREMENT
+ | INCREMENTAL
| INDENT
| INDEX
| INDEXES
@@ -17709,6 +17718,7 @@ bare_label_keyword:
| INCLUDE
| INCLUDING
| INCREMENT
+ | INCREMENTAL
| INDENT
| INDEX
| INDEXES
diff --git a/src/include/nodes/primnodes.h b/src/include/nodes/primnodes.h
index 60d72a876b..cecb968b36 100644
--- a/src/include/nodes/primnodes.h
+++ b/src/include/nodes/primnodes.h
@@ -146,6 +146,7 @@ typedef struct IntoClause
/* materialized view's SELECT query */
Node *viewQuery pg_node_attr(query_jumble_ignore);
bool skipData; /* true for WITH NO DATA */
+ bool ivm; /* true for WITH IVM */
} IntoClause;
diff --git a/src/include/parser/kwlist.h b/src/include/parser/kwlist.h
index 5984dcfa4b..d60eb98d65 100644
--- a/src/include/parser/kwlist.h
+++ b/src/include/parser/kwlist.h
@@ -207,6 +207,7 @@ PG_KEYWORD("in", IN_P, RESERVED_KEYWORD, BARE_LABEL)
PG_KEYWORD("include", INCLUDE, UNRESERVED_KEYWORD, BARE_LABEL)
PG_KEYWORD("including", INCLUDING, UNRESERVED_KEYWORD, BARE_LABEL)
PG_KEYWORD("increment", INCREMENT, UNRESERVED_KEYWORD, BARE_LABEL)
+PG_KEYWORD("incremental", INCREMENTAL, UNRESERVED_KEYWORD, BARE_LABEL)
PG_KEYWORD("indent", INDENT, UNRESERVED_KEYWORD, BARE_LABEL)
PG_KEYWORD("index", INDEX, UNRESERVED_KEYWORD, BARE_LABEL)
PG_KEYWORD("indexes", INDEXES, UNRESERVED_KEYWORD, BARE_LABEL)
--
2.25.1
--Multipart=_Mon__28_Aug_2023_11_52_52_+0900_hj6L5h176QaSGtg7
Content-Type: text/x-diff;
name="v29-0002-Add-relisivm-column-to-pg_class-system-catalog.patch"
Content-Disposition: attachment;
filename="v29-0002-Add-relisivm-column-to-pg_class-system-catalog.patch"
Content-Transfer-Encoding: 7bit
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel
@ 2025-10-31 15:51 Álvaro Herrera <[email protected]>
0 siblings, 0 replies; 178+ messages in thread
From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw)
---
src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++---
src/bin/pg_ctl/pg_ctl.c | 12 ++++++------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index f59c293d875..52e7c9212a2 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/pg_prng.h"
#include "common/restricted_token.h"
+#include "datatype/timestamp.h"
#include "fe_utils/recovery_gen.h"
#include "fe_utils/simple_list.h"
#include "fe_utils/string_utils.h"
@@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname,
static void get_publisher_databases(struct CreateSubscriberOptions *opt,
bool dbnamespecified);
-#define USEC_PER_SEC 1000000
#define WAIT_INTERVAL 1 /* 1 second */
static const char *progname;
@@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions
}
/* Keep waiting */
- pg_usleep(WAIT_INTERVAL * USEC_PER_SEC);
-
+ pg_usleep(WAIT_INTERVAL * USECS_PER_SEC);
timer += WAIT_INTERVAL;
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 8a405ff122c..b270c0c0d82 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -26,6 +26,7 @@
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
+#include "datatype/timestamp.h"
#include "getopt_long.h"
#include "utils/pidfile.h"
@@ -68,9 +69,7 @@ typedef enum
#define DEFAULT_WAIT 60
-#define USEC_PER_SEC 1000000
-
-#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */
+#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */
static bool do_wait = true;
static int wait_seconds = DEFAULT_WAIT;
@@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
{
int i;
+ static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0);
for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++)
{
char **optlines;
@@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint)
print_msg(".");
}
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
/* out of patience; report that postmaster is still starting up */
@@ -738,7 +738,7 @@ wait_for_postmaster_stop(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
@@ -771,7 +771,7 @@ wait_for_postmaster_promote(void)
if (cnt % WAITS_PER_SEC == 0)
print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
+ pg_usleep(USECS_PER_SEC / WAITS_PER_SEC);
}
return false; /* timeout reached */
}
--
2.47.3
--iqvkb7rmsfgsymxy
Content-Type: text/x-diff; charset=utf-8
Content-Disposition: attachment;
filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch"
^ permalink raw reply [nested|flat] 178+ messages in thread
end of thread, other threads:[~2025-10-31 15:51 UTC | newest]
Thread overview: 178+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-12-20 01:05 [PATCH v29 01/11] Add a syntax to create Incrementally Maintainable Materialized Views 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]>
2025-10-31 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