pgsql: doc: Avoid too prominent use of "backup" on pg_dump man page

2024-07-30 Thread Peter Eisentraut
doc: Avoid too prominent use of "backup" on pg_dump man page Some users inadvertently rely on pg_dump as their primary backup tool, when better solutions exist. The pg_dump man page is arguably misleading in that it starts with "pg_dump is a utility for backing up a PostgreSQL database." This t

pgsql: Make building with LTO work on macOS

2024-07-30 Thread Peter Eisentraut
Make building with LTO work on macOS When building with -flto, the backend binary must keep many otherwise unused symbols to make them available to dynamically loaded modules / extensions. This has been done via -Wl,--export-dynamic on many platforms for years. This flag is not supported by the

pgsql: Fix random failure in 021_twophase.

2024-07-30 Thread Amit Kapila
Fix random failure in 021_twophase. After disabling the subscription, the failed test was changing the two_phase option for the subscription. We can't change the two_phase option for a subscription till the corresponding apply worker is active. The check to ensure that the replication apply worker

pgsql: Relax check for return value from second call of pg_strnxfrm().

2024-07-30 Thread Jeff Davis
Relax check for return value from second call of pg_strnxfrm(). strxfrm() is not guaranteed to return the exact number of bytes needed to store the result; it may return a higher value. Discussion: https://postgr.es/m/32f85d88d1f64395abfe5a10dd97a62a4d3474ce.ca...@j-davis.com Reviewed-by: Heikki

pgsql: Relax check for return value from second call of pg_strnxfrm().

2024-07-30 Thread Jeff Davis
Relax check for return value from second call of pg_strnxfrm(). strxfrm() is not guaranteed to return the exact number of bytes needed to store the result; it may return a higher value. Discussion: https://postgr.es/m/32f85d88d1f64395abfe5a10dd97a62a4d3474ce.ca...@j-davis.com Reviewed-by: Heikki

pgsql: Relax check for return value from second call of pg_strnxfrm().

2024-07-30 Thread Jeff Davis
Relax check for return value from second call of pg_strnxfrm(). strxfrm() is not guaranteed to return the exact number of bytes needed to store the result; it may return a higher value. Discussion: https://postgr.es/m/32f85d88d1f64395abfe5a10dd97a62a4d3474ce.ca...@j-davis.com Reviewed-by: Heikki

pgsql: Refactor getWeights to write to caller-supplied buffer

2024-07-30 Thread Heikki Linnakangas
Refactor getWeights to write to caller-supplied buffer This gets rid of the static result buffer. Reviewed-by: Robert Haas Discussion: https://www.postgresql.org/message-id/7f86e06a-98c5-4ce3-8ec9-3885c8de0...@iki.fi Branch -- master Details --- https://git.postgresql.org/pg/commitdiff

pgsql: Replace static buf with palloc in str_time()

2024-07-30 Thread Heikki Linnakangas
Replace static buf with palloc in str_time() The function is used only once in the startup process, so the leak into current memory context is harmless. This is a tiny step in making the server thread-safe. Reviewed-by: Robert Haas Discussion: https://www.postgresql.org/message-id/7f86e06a-98c5

pgsql: Replace static buf with a stack-allocated one in ReadControlFile

2024-07-30 Thread Heikki Linnakangas
Replace static buf with a stack-allocated one in ReadControlFile It's only used very locally within the function. Reviewed-by: Robert Haas Discussion: https://www.postgresql.org/message-id/7f86e06a-98c5-4ce3-8ec9-3885c8de0...@iki.fi Branch -- master Details --- https://git.postgresql.o

pgsql: Replace static bufs with a StringInfo in cash_words()

2024-07-30 Thread Heikki Linnakangas
Replace static bufs with a StringInfo in cash_words() For clarity. The code was correct, and the buffer was large enough, but string manipulation with no bounds checking is scary. This incurs an extra palloc+pfree to every call, but in quick performance testing, it doesn't seem to be significant.

pgsql: Replace static buf with a stack-allocated one in 'seg' extension

2024-07-30 Thread Heikki Linnakangas
Replace static buf with a stack-allocated one in 'seg' extension The buffer is used only locally within the function. Also, the initialization to '0' characters was unnecessary, the initial content were always overwritten with sprintf(). I don't understand why it was done that way, but it's been l

pgsql: Remove leftover function declaration

2024-07-30 Thread Heikki Linnakangas
Remove leftover function declaration Commit 9d9b9d46f3 removed the function (or rather, moved it to a different source file and renamed it to SendCancelRequest), but forgot the declaration in the header file. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/47c98035c

pgsql: Preserve tz when converting to jsonb timestamptz

2024-07-30 Thread Andrew Dunstan
Preserve tz when converting to jsonb timestamptz This removes an inconsistency in the treatment of different datatypes by the jsonpath timestamp_tz() function. Conversions from data types that are not timestamp-aware, such as date and timestamp, are now treated consistently with conversion from th

pgsql: Preserve tz when converting to jsonb timestamptz

2024-07-30 Thread Andrew Dunstan
Preserve tz when converting to jsonb timestamptz This removes an inconsistency in the treatment of different datatypes by the jsonpath timestamp_tz() function. Conversions from data types that are not timestamp-aware, such as date and timestamp, are now treated consistently with conversion from th

pgsql: Remove spinlocks and atomics from meson_options.txt.

2024-07-30 Thread Thomas Munro
Remove spinlocks and atomics from meson_options.txt. Commits e2562667 and 81385261 removed the configure equivalents, but forgot to remove these options from meson_options.txt. Revealed by the fact that build farm animals rorqual and francolin didn't fail, despite being configured to set those op

Re: pgsql: Remove --disable-spinlocks.

2024-07-30 Thread Thomas Munro
On Tue, Jul 30, 2024 at 11:09 PM Heikki Linnakangas wrote: > The SpinLockSemaArray field should be completely completely, nut just > the #ifndef guard around it. Looks like I had that right in the first version, but got confused while rebasing over a conflict. Fixed, thanks!

pgsql: Remove useless member of BackendParameters.

2024-07-30 Thread Thomas Munro
Remove useless member of BackendParameters. Oversight in e2562667, which stopped using SpinlockSemaArray but forgot to remove it from the array. Reported-by: Heikki Linnakangas Discussion: https://postgr.es/m/310f4005-91d7-42b2-ac70-92624260dd28%40iki.fi Branch -- master Details --- ht

Re: pgsql: Remove --disable-spinlocks.

2024-07-30 Thread Heikki Linnakangas
On 30/07/2024 14:03, Thomas Munro wrote: Remove --disable-spinlocks. Sorry, spotted this only now: --- a/src/backend/postmaster/launch_backend.c +++ b/src/backend/postmaster/launch_backend.c @@ -108,9 +108,7 @@ typedef struct #ifdef USE_INJECTION_POINTS struct InjectionPointsCtl *ActiveI

pgsql: Remove --disable-spinlocks.

2024-07-30 Thread Thomas Munro
Remove --disable-spinlocks. A later change will require atomic support, so it wouldn't make sense for a hypothetical new system not to be able to implement spinlocks. Reviewed-by: Heikki Linnakangas Reviewed-by: Tom Lane (concept, not the patch) Reviewed-by: Andres Freund (concept, not the pat

pgsql: Require compiler barrier support.

2024-07-30 Thread Thomas Munro
Require compiler barrier support. Previously we had a fallback implementation of pg_compiler_barrier() that called an empty function across a translation unit boundary so the compiler couldn't see what it did. That shouldn't be needed on any current systems, and might not even work with a link ti

pgsql: Remove --disable-atomics, require 32 bit atomics.

2024-07-30 Thread Thomas Munro
Remove --disable-atomics, require 32 bit atomics. Modern versions of all relevant architectures and tool chains have atomics support. Since edadeb07, there is no remaining reason to carry code that simulates atomic flags and uint32 imperfectly with spinlocks. 64 bit atomics are still emulated wit

pgsql: Require memory barrier support.

2024-07-30 Thread Thomas Munro
Require memory barrier support. Previously we had a fallback implementation that made a harmless system call, based on the assumption that system calls must contain a memory barrier. That shouldn't be reached on any current system, and it seems highly likely that we can easily find out how to req

pgsql: pg_createsubscriber: Remove obsolete comment

2024-07-30 Thread Peter Eisentraut
pg_createsubscriber: Remove obsolete comment This comment should have been removed by commit b9639138262. There is no replication slot check on the primary anymore. Author: Euler Taveira Discussion: https://www.postgresql.org/message-id/697d692f-f9d3-41f6-9f0e-29a4fb18e...@app.fastmail.com Br

pgsql: pg_createsubscriber: Remove obsolete comment

2024-07-30 Thread Peter Eisentraut
pg_createsubscriber: Remove obsolete comment This comment should have been removed by commit b9639138262. There is no replication slot check on the primary anymore. Author: Euler Taveira Discussion: https://www.postgresql.org/message-id/697d692f-f9d3-41f6-9f0e-29a4fb18e...@app.fastmail.com Br

pgsql: Stabilize xid_wraparound tests

2024-07-30 Thread Andrew Dunstan
Stabilize xid_wraparound tests The tests had a race condition if autovacuum was set to off. Instead we create all the tables we are interested in with autovacuum disabled, so they are only ever touched when in danger of wraparound. Discussion: https://postgr.es/m/3e2cbd24-f45e-4b2b-ba83-8149214f

pgsql: Stabilize xid_wraparound tests

2024-07-30 Thread Andrew Dunstan
Stabilize xid_wraparound tests The tests had a race condition if autovacuum was set to off. Instead we create all the tables we are interested in with autovacuum disabled, so they are only ever touched when in danger of wraparound. Discussion: https://postgr.es/m/3e2cbd24-f45e-4b2b-ba83-8149214f

pgsql: pg_createsubscriber: Fix an unpredictable recovery wait time.

2024-07-30 Thread Amit Kapila
pg_createsubscriber: Fix an unpredictable recovery wait time. The problem is that the tool is using the LSN returned by pg_create_logical_replication_slot() as recovery_target_lsn. This LSN is ahead of the current WAL position and the recovery waits until the publisher writes a WAL record to reach

pgsql: pg_createsubscriber: Fix an unpredictable recovery wait time.

2024-07-30 Thread Amit Kapila
pg_createsubscriber: Fix an unpredictable recovery wait time. The problem is that the tool is using the LSN returned by pg_create_logical_replication_slot() as recovery_target_lsn. This LSN is ahead of the current WAL position and the recovery waits until the publisher writes a WAL record to reach

pgsql: Disallow setting MAX_PARTITION_BUFFERS to less than 2

2024-07-30 Thread David Rowley
Disallow setting MAX_PARTITION_BUFFERS to less than 2 Add some comments to mention that this value must be at least 2 and also add a StaticAssertDecl to cause compilation failure if anyone tries to build with an invalid value. The multiInsertBuffers list must have at least two elements due to how

pgsql: Make collation not depend on setlocale().

2024-07-30 Thread Jeff Davis
Make collation not depend on setlocale(). Now that the result of pg_newlocale_from_collation() is always non-NULL, then we can move the collate_is_c and ctype_is_c flags into pg_locale_t. That simplifies the logic in lc_collate_is_c() and lc_ctype_is_c(), removing the dependence on setlocale(). T