agora inbox for [email protected]help / color / mirror / Atom feed
[PATCH v3 3/3] Replace matview WITH OLD DATA 89+ messages / 2 participants [nested] [flat]
* [PATCH v3 3/3] Replace matview WITH OLD DATA @ 2024-07-26 21:33 Erik Wienhold <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Erik Wienhold @ 2024-07-26 21:33 UTC (permalink / raw) --- .../sgml/ref/create_materialized_view.sgml | 16 +++++++++-- src/backend/commands/createas.c | 26 +++++++++++------ src/backend/parser/gram.y | 16 +++++++++++ src/include/nodes/primnodes.h | 1 + src/test/regress/expected/matview.out | 28 +++++++++++++++++++ src/test/regress/sql/matview.sql | 15 ++++++++++ 6 files changed, 90 insertions(+), 12 deletions(-) diff --git a/doc/src/sgml/ref/create_materialized_view.sgml b/doc/src/sgml/ref/create_materialized_view.sgml index b5a8e3441a..65633b8bfa 100644 --- a/doc/src/sgml/ref/create_materialized_view.sgml +++ b/doc/src/sgml/ref/create_materialized_view.sgml @@ -27,7 +27,7 @@ CREATE [ OR REPLACE ] MATERIALIZED VIEW [ IF NOT EXISTS ] <replaceable>table_nam [ WITH ( <replaceable class="parameter">storage_parameter</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] ) ] [ TABLESPACE <replaceable class="parameter">tablespace_name</replaceable> ] AS <replaceable>query</replaceable> - [ WITH [ NO ] DATA ] + [ WITH [ NO | OLD ] DATA ] </synopsis> </refsynopsisdiv> @@ -37,7 +37,8 @@ CREATE [ OR REPLACE ] MATERIALIZED VIEW [ IF NOT EXISTS ] <replaceable>table_nam <para> <command>CREATE MATERIALIZED VIEW</command> defines a materialized view of a query. The query is executed and used to populate the view at the time - the command is issued (unless <command>WITH NO DATA</command> is used) and may be + the command is issued (unless <command>WITH NO DATA</command> or + <command>WITH OLD DATA</command> is used) and may be refreshed later using <command>REFRESH MATERIALIZED VIEW</command>. </para> @@ -160,7 +161,7 @@ CREATE [ OR REPLACE ] MATERIALIZED VIEW [ IF NOT EXISTS ] <replaceable>table_nam </varlistentry> <varlistentry> - <term><literal>WITH [ NO ] DATA</literal></term> + <term><literal>WITH [ NO | OLD ] DATA</literal></term> <listitem> <para> This clause specifies whether or not the materialized view should be @@ -168,6 +169,15 @@ CREATE [ OR REPLACE ] MATERIALIZED VIEW [ IF NOT EXISTS ] <replaceable>table_nam flagged as unscannable and cannot be queried until <command>REFRESH MATERIALIZED VIEW</command> is used. </para> + + <para> + The form <command>WITH OLD DATA</command> keeps the already stored data + when replacing an existing materialized view to keep it populated. For + newly created materialized views, this has the same effect as + <command>WITH DATA</command>. Use this form if you want to use + <command>REFRESH MATERIALIZED VIEW CONCURRENTLY</command> as it requires + a populated materialized view. + </para> </listitem> </varlistentry> diff --git a/src/backend/commands/createas.c b/src/backend/commands/createas.c index e4ed3748f9..96e7b81966 100644 --- a/src/backend/commands/createas.c +++ b/src/backend/commands/createas.c @@ -331,18 +331,26 @@ ExecCreateTableAs(ParseState *pstate, CreateTableAsStmt *stmt, /* An existing materialized view can be replaced. */ if (is_matview && into->replace) { - RefreshMatViewStmt *refresh; - /* Change the relation to match the new query and other options. */ - (void) create_ctas_nodata(query->targetList, into); + address = create_ctas_nodata(query->targetList, into); - /* Refresh the materialized view with a fake statement. */ - refresh = makeNode(RefreshMatViewStmt); - refresh->relation = into->rel; - refresh->skipData = into->skipData; - refresh->concurrent = false; + /* + * Refresh the materialized view with a fake statement unless we + * must keep the old data. + */ + if (!into->keepData) + { + RefreshMatViewStmt *refresh; + + refresh = makeNode(RefreshMatViewStmt); + refresh->relation = into->rel; + refresh->skipData = into->skipData; + refresh->concurrent = false; + + address = ExecRefreshMatView(refresh, NULL, NULL); + } - return ExecRefreshMatView(refresh, NULL, NULL); + return address; } return InvalidObjectAddress; diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index 4b939ea7ca..e45ebb24f8 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -4808,6 +4808,22 @@ CreateMatViewStmt: $7->replace = true; $$ = (Node *) ctas; } + | CREATE OR REPLACE OptNoLog MATERIALIZED VIEW create_mv_target AS SelectStmt WITH OLD DATA_P + { + CreateTableAsStmt *ctas = makeNode(CreateTableAsStmt); + + ctas->query = $9; + ctas->into = $7; + ctas->objtype = OBJECT_MATVIEW; + ctas->is_select_into = false; + ctas->if_not_exists = false; + /* cram additional flags into the IntoClause */ + $7->rel->relpersistence = $4; + $7->skipData = false; + $7->keepData = true; + $7->replace = true; + $$ = (Node *) ctas; + } ; create_mv_target: diff --git a/src/include/nodes/primnodes.h b/src/include/nodes/primnodes.h index 4b0ee5d10d..ae84cb522e 100644 --- a/src/include/nodes/primnodes.h +++ b/src/include/nodes/primnodes.h @@ -168,6 +168,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 keepData; /* true for WITH OLD DATA */ bool replace; /* replace existing matview? */ } IntoClause; diff --git a/src/test/regress/expected/matview.out b/src/test/regress/expected/matview.out index cefd0d442c..47dfd88bff 100644 --- a/src/test/regress/expected/matview.out +++ b/src/test/regress/expected/matview.out @@ -751,6 +751,23 @@ SELECT * FROM mvtest_replace; 3 (1 row) +-- replace query but keep old data +CREATE OR REPLACE MATERIALIZED VIEW mvtest_replace AS + SELECT 5 AS a + WITH OLD DATA; +SELECT * FROM mvtest_replace; + a +--- + 3 +(1 row) + +REFRESH MATERIALIZED VIEW mvtest_replace; +SELECT * FROM mvtest_replace; + a +--- + 5 +(1 row) + -- add column CREATE OR REPLACE MATERIALIZED VIEW mvtest_replace AS SELECT 4 AS a, 1 b; @@ -905,3 +922,14 @@ ERROR: syntax error at or near "NOT" LINE 1: CREATE OR REPLACE MATERIALIZED VIEW IF NOT EXISTS mvtest_rep... ^ DROP MATERIALIZED VIEW mvtest_replace; +-- Create new matview WITH OLD DATA. This populates the new matview as if +-- WITH DATA had been specified. +CREATE OR REPLACE MATERIALIZED VIEW mvtest_replace AS + SELECT 17 AS a + WITH OLD DATA; +SELECT * FROM mvtest_replace; + a +---- + 17 +(1 row) + diff --git a/src/test/regress/sql/matview.sql b/src/test/regress/sql/matview.sql index c12f0243c9..b268237c24 100644 --- a/src/test/regress/sql/matview.sql +++ b/src/test/regress/sql/matview.sql @@ -338,6 +338,14 @@ SELECT * FROM mvtest_replace; -- error: not populated REFRESH MATERIALIZED VIEW mvtest_replace; SELECT * FROM mvtest_replace; +-- replace query but keep old data +CREATE OR REPLACE MATERIALIZED VIEW mvtest_replace AS + SELECT 5 AS a + WITH OLD DATA; +SELECT * FROM mvtest_replace; +REFRESH MATERIALIZED VIEW mvtest_replace; +SELECT * FROM mvtest_replace; + -- add column CREATE OR REPLACE MATERIALIZED VIEW mvtest_replace AS SELECT 4 AS a, 1 b; @@ -422,3 +430,10 @@ CREATE OR REPLACE MATERIALIZED VIEW IF NOT EXISTS mvtest_replace AS SELECT 1 AS a; DROP MATERIALIZED VIEW mvtest_replace; + +-- Create new matview WITH OLD DATA. This populates the new matview as if +-- WITH DATA had been specified. +CREATE OR REPLACE MATERIALIZED VIEW mvtest_replace AS + SELECT 17 AS a + WITH OLD DATA; +SELECT * FROM mvtest_replace; -- 2.46.0 --muysnh7l3kienazz-- ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
* [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel @ 2025-10-31 15:51 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 89+ messages in thread From: Álvaro Herrera @ 2025-10-31 15:51 UTC (permalink / raw) --- src/bin/pg_basebackup/pg_createsubscriber.c | 5 ++--- src/bin/pg_ctl/pg_ctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index f59c293d875..52e7c9212a2 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -23,6 +23,7 @@ #include "common/logging.h" #include "common/pg_prng.h" #include "common/restricted_token.h" +#include "datatype/timestamp.h" #include "fe_utils/recovery_gen.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" @@ -129,7 +130,6 @@ static void drop_existing_subscription(PGconn *conn, const char *subname, static void get_publisher_databases(struct CreateSubscriberOptions *opt, bool dbnamespecified); -#define USEC_PER_SEC 1000000 #define WAIT_INTERVAL 1 /* 1 second */ static const char *progname; @@ -1610,8 +1610,7 @@ wait_for_end_recovery(const char *conninfo, const struct CreateSubscriberOptions } /* Keep waiting */ - pg_usleep(WAIT_INTERVAL * USEC_PER_SEC); - + pg_usleep(WAIT_INTERVAL * USECS_PER_SEC); timer += WAIT_INTERVAL; } diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 8a405ff122c..b270c0c0d82 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -26,6 +26,7 @@ #include "common/file_perm.h" #include "common/logging.h" #include "common/string.h" +#include "datatype/timestamp.h" #include "getopt_long.h" #include "utils/pidfile.h" @@ -68,9 +69,7 @@ typedef enum #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 /* should divide USECS_PER_SEC evenly */ static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; @@ -594,6 +593,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) { int i; + static_assert(USECS_PER_SEC % WAITS_PER_SEC == 0); for (i = 0; i < wait_seconds * WAITS_PER_SEC; i++) { char **optlines; @@ -699,7 +699,7 @@ wait_for_postmaster_start(pid_t pm_pid, bool do_checkpoint) print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } /* out of patience; report that postmaster is still starting up */ @@ -738,7 +738,7 @@ wait_for_postmaster_stop(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } @@ -771,7 +771,7 @@ wait_for_postmaster_promote(void) if (cnt % WAITS_PER_SEC == 0) print_msg("."); - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } return false; /* timeout reached */ } -- 2.47.3 --iqvkb7rmsfgsymxy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0002-Remove-WaitPMResult-enum-in-pg_createsubscriber.patch" ^ permalink raw reply [nested|flat] 89+ messages in thread
end of thread, other threads:[~2025-10-31 15:51 UTC | newest] Thread overview: 89+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2024-07-26 21:33 [PATCH v3 3/3] Replace matview WITH OLD DATA Erik Wienhold <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 15:51 [PATCH 1/2] pg_ctl: use USECS_PER_SEC from datatype/timestamp.h instead of reinventing the wheel Álvaro Herrera <[email protected]> 2025-10-31 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