pgsql: aio: Fix configuration reload in IO workers.

2025-07-11 Thread Thomas Munro
aio: Fix configuration reload in IO workers. method_worker.c installed SignalHandlerForConfigReload, but it failed to actually process reload requests. That hasn't yet produced any concrete problem reports in terms of GUC changes it should have cared about in v18, but it was inconsistent. It did

pgsql: aio: Fix configuration reload in IO workers.

2025-07-11 Thread Thomas Munro
aio: Fix configuration reload in IO workers. method_worker.c installed SignalHandlerForConfigReload, but it failed to actually process reload requests. That hasn't yet produced any concrete problem reports in terms of GUC changes it should have cared about in v18, but it was inconsistent. It did

pgsql: aio: Regularize IO worker internal naming.

2025-07-11 Thread Thomas Munro
aio: Regularize IO worker internal naming. Adopt PgAioXXX convention for pgaio module type names. Rename a function that didn't use a pgaio_worker_ submodule prefix. Rename the internal submit function's arguments to match the indirectly relevant function pointer declaration and nearby examples.

pgsql: aio: Remove obsolete IO worker ID references.

2025-07-11 Thread Thomas Munro
aio: Remove obsolete IO worker ID references. In an ancient ancestor of this code, the postmaster assigned IDs to IO workers. Now it tracks them in an unordered array and doesn't know their IDs, so it might be confusing to readers that it still referred to their indexes as IDs. No change in beha

pgsql: aio: Remove obsolete IO worker ID references.

2025-07-11 Thread Thomas Munro
aio: Remove obsolete IO worker ID references. In an ancient ancestor of this code, the postmaster assigned IDs to IO workers. Now it tracks them in an unordered array and doesn't know their IDs, so it might be confusing to readers that it still referred to their indexes as IDs. No change in beha

pgsql: aio: Regularize IO worker internal naming.

2025-07-11 Thread Thomas Munro
aio: Regularize IO worker internal naming. Adopt PgAioXXX convention for pgaio module type names. Rename a function that didn't use a pgaio_worker_ submodule prefix. Rename the internal submit function's arguments to match the indirectly relevant function pointer declaration and nearby examples.

pgsql: Fix stale idle flag when IO workers exit.

2025-07-11 Thread Thomas Munro
Fix stale idle flag when IO workers exit. Otherwise we could choose a worker that has exited and crash while trying to wake it up. Back-patch to 18. Reported-by: Tomas Vondra Reported-by: Andres Freund Discussion: https://postgr.es/m/t5aqjhkj6xdkido535pds7fk5z4finoxra4zypefjqnlieevbg%40357aaf

pgsql: Fix stale idle flag when IO workers exit.

2025-07-11 Thread Thomas Munro
Fix stale idle flag when IO workers exit. Otherwise we could choose a worker that has exited and crash while trying to wake it up. Back-patch to 18. Reported-by: Tomas Vondra Reported-by: Andres Freund Discussion: https://postgr.es/m/t5aqjhkj6xdkido535pds7fk5z4finoxra4zypefjqnlieevbg%40357aaf

pgsql: Introduce file_copy_method setting.

2025-04-10 Thread Thomas Munro
Introduce file_copy_method setting. It can be set to either COPY (the default) or CLONE if the system supports it. CLONE causes callers of copydir(), currently CREATE DATABASE ... STRATEGY=FILE_COPY and ALTER DATABASE ... SET TABLESPACE = ..., to use copy_file_range (Linux, FreeBSD) or copyfile (

pgsql: Fix typo in docs.

2025-04-10 Thread Thomas Munro
Fix typo in docs. Typo in previous commit. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/7ea21f4ee2721be4239657e74c2ae8f88fb5a3ef Modified Files -- doc/src/sgml/ref/alter_database.sgml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)

pgsql: Support buffer forwarding in StartReadBuffers().

2025-03-25 Thread Thomas Munro
Support buffer forwarding in StartReadBuffers(). StartReadBuffers() reports a short read when it finds a cached block that ends a range needing I/O by updating the caller's *nblocks. It doesn't want to have to unpin the trailing hit that it knows the caller wants, so the v17 version used sleight

pgsql: libpq: Deprecate pg_int64.

2025-03-25 Thread Thomas Munro
libpq: Deprecate pg_int64. Previously we used pg_int64 in three function prototypes in libpq. It was added by commit 461ef73f to expose the platform-dependent type used for int64 in the C89 era. As of commit 962da900 it is defined as standard int64_t, and the dust seems to have settled. Let's j

pgsql: Fix ps display for IO workers.

2025-03-21 Thread Thomas Munro
Fix ps display for IO workers. This code must have missed a memo about the backend type description being supplied automatically these days, and was duplicating that information. Before: "io worker io worker: N" After: "io worker N" Branch -- master Details --- https://git.postgresql.o

pgsql: Support buffer forwarding in read_stream.c.

2025-03-20 Thread Thomas Munro
Support buffer forwarding in read_stream.c. In preparation for a follow-up change to the buffer manager, teach read_stream.c to manage buffers "forwarded" from one StartReadBuffers() call to the next after a short read. This involves a small amount of extra book-keeping, and opens the way for low

pgsql: Fix compiler warning for commit 434dbf69.

2025-03-18 Thread Thomas Munro
Fix compiler warning for commit 434dbf69. Reported-by: Tom Lane Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/0b53c08677a6515786bde9d4471b42ef7289759e Modified Files -- src/interfaces/libpq/fe-auth-oauth-curl.c | 2 +- 1 file changed, 1 insertion(+),

pgsql: oauth: Improve validator docs on interruptibility

2025-03-18 Thread Thomas Munro
oauth: Improve validator docs on interruptibility Andres pointed out that EINTR handling is inadequate for real-world use cases. Direct module writers to our wait APIs instead. Author: Jacob Champion Discussion: https://postgr.es/m/p4bd7mn6dxr2zdak74abocyltpfdxif4pxqzixqpxpetjwt34h%40qc6jgfmodd

pgsql: oauth: Disallow synchronous DNS in libcurl

2025-03-18 Thread Thomas Munro
oauth: Disallow synchronous DNS in libcurl There is concern that a blocking DNS lookup in libpq could stall a backend process (say, via FDW). Since there's currently no strong evidence that synchronous DNS is a popular option, disallow it entirely rather than warning at configure time. We can revi

pgsql: oauth: Simplify copy of PGoauthBearerRequest

2025-03-18 Thread Thomas Munro
oauth: Simplify copy of PGoauthBearerRequest Follow-up to 03366b61d. Since there are no more const members in the PGoauthBearerRequest struct, the previous memcpy() can be replaced with simple assignment. Author: Jacob Champion Discussion: https://postgr.es/m/p4bd7mn6dxr2zdak74abocyltpfdxif4pxq

pgsql: oauth: Fix postcondition for set_timer on macOS

2025-03-18 Thread Thomas Munro
oauth: Fix postcondition for set_timer on macOS On macOS, readding an EVFILT_TIMER to a kqueue does not appear to clear out previously queued timer events, so checks for timer expiration do not work correctly during token retrieval. Switching to IPv4-only communication exposes the problem, because

pgsql: oauth: Use IPv4-only issuer in oauth_validator tests

2025-03-18 Thread Thomas Munro
Jacob Champion Reported-by: Thomas Munro Discussion: https://postgr.es/m/CAOYmi%2Bn4EDOOUL27_OqYT2-F2rS6S%2B3mK-ppWb2Ec92UEoUbYA%40mail.gmail.com Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/8d9d5843b55f47d24031165f99b07d41715b93e9 Modified Files -

pgsql: Introduce io_max_combine_limit.

2025-03-18 Thread Thomas Munro
Introduce io_max_combine_limit. The existing io_combine_limit can be changed by users. The new io_max_combine_limit is fixed at server startup time, and functions as a silent clamp on the user setting. That in itself is probably quite useful, but the primary motivation is: aio_init.c allocates

pgsql: Increase io_combine_limit range to 1MB.

2025-03-18 Thread Thomas Munro
Increase io_combine_limit range to 1MB. The default of 128kB is unchanged, but the upper limit is changed from 32 blocks to 128 blocks, unless the operating system's IOV_MAX is too low. Some other RDBMSes seem to cap their multi-block buffer pool I/O around this number, and it seems useful to all

pgsql: Simplify distance heuristics in read_stream.c.

2025-03-15 Thread Thomas Munro
Simplify distance heuristics in read_stream.c. Make the distance control heuristics simpler and more aggressive in preparation for asynchronous I/O. The v17 version of read_stream.c made a conservative choice to limit the look-ahead distance when streaming sequential blocks, because it couldn't b

pgsql: Improve read_stream.c advice for dense streams.

2025-03-14 Thread Thomas Munro
Improve read_stream.c advice for dense streams. read_stream.c tries not to issue read-ahead advice when it thinks the kernel's own read-ahead should be active, ie when using buffered I/O and reading sequential blocks. It previously gave up too easily, and issued advice only for the first read of

pgsql: Respect changing pin limits in read_stream.c.

2025-03-14 Thread Thomas Munro
Respect changing pin limits in read_stream.c. To avoid pinning too much of the buffer pool at once, read_stream.c previously used LimitAdditionalPins(). The coding was naive, and only considered the available buffers at stream construction time. This commit checks before each StartReadBuffers()

pgsql: Improve buffer manager API for backend pin limits.

2025-03-13 Thread Thomas Munro
Improve buffer manager API for backend pin limits. Previously the support functions assumed that the caller needed one pin to make progress, and could optionally use some more, allowing enough for every connection to do the same. Add a couple more functions for callers that want to know: * what

pgsql: Fix read_stream.c for changing io_combine_limit.

2025-03-12 Thread Thomas Munro
Fix read_stream.c for changing io_combine_limit. In a couple of places, read_stream.c assumed that io_combine_limit would be stable during the lifetime of a stream. That is not true in at least one unusual case: streams held by CURSORs where you could change the GUC between FETCH commands, with u

pgsql: Fix read_stream.c for changing io_combine_limit.

2025-03-12 Thread Thomas Munro
Fix read_stream.c for changing io_combine_limit. In a couple of places, read_stream.c assumed that io_combine_limit would be stable during the lifetime of a stream. That is not true in at least one unusual case: streams held by CURSORs where you could change the GUC between FETCH commands, with u

pgsql: ci: Use a RAM disk for NetBSD and OpenBSD.

2025-03-03 Thread Thomas Munro
ci: Use a RAM disk for NetBSD and OpenBSD. Put the RAM disk setup for all three *BSD CI tasks into a common script, replacing the old FreeBSD-specific one from commit 0265e5c1. This makes them run 3 times and a bit over 2 times faster, respectively. NetBSD and FreeBSD now share the same one-line

pgsql: Work around OAuth/EVFILT_TIMER quirk on NetBSD.

2025-02-28 Thread Thomas Munro
Work around OAuth/EVFILT_TIMER quirk on NetBSD. NetBSD's EVFILT_TIMER doesn't like zero timeouts, as introduced by commit b3f0be788. Steal the workaround from the same problem on Linux from a few lines up: round zero up to one. Do this only for NetBSD, as the other systems with the kevent() API

pgsql: Remove arbitrary cap on read_stream.c buffer queue.

2025-02-26 Thread Thomas Munro
Remove arbitrary cap on read_stream.c buffer queue. Previously the internal queue of buffers was capped at max_ios * 4, though not less than io_combine_limit, at allocation time. That was done in the first version based on conservative theories about resource usage and heuristics pending later wo

pgsql: Fix explicit valgrind interaction in read_stream.c.

2025-02-20 Thread Thomas Munro
Fix explicit valgrind interaction in read_stream.c. This is a back-patch of commits 2a8a0067 and 2509b857 into REL_17_STABLE. It's doesn't fix any known live bug in PostgreSQL v17 itself, but an extension could in theory have used the per-buffer data feature and seen spurious errors under Valgrin

pgsql: Fix typo in 2a8a0067.

2025-02-17 Thread Thomas Munro
Fix typo in 2a8a0067. Builds configured with Valgrind but without assertions would fail due to a typo in the recent change. This should be included when back-patching 2a8a0067 into v17. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/2509b857cc1067be628291864289f27

pgsql: Fix explicit valgrind interaction in read_stream.c.

2025-02-14 Thread Thomas Munro
Fix explicit valgrind interaction in read_stream.c. By calling wipe_mem() on per-buffer data memory that has been released, we are also telling Valgrind that the memory is "noaccess". We need to set it to "undefined" before giving it to the registered callback to fill in, when a slot is reused.

pgsql: Remove obsolete comment.

2025-02-13 Thread Thomas Munro
Remove obsolete comment. Commit 755a4c10d19d prevented StartReadBuffers() from crossing md.c segment boundaries in one operation, but a comment about that possibility remained. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/9e17ac997f921c9de99125a97a0f34ae50f5c498

pgsql: Fix latch event policy that hid socket events.

2025-01-19 Thread Thomas Munro
Fix latch event policy that hid socket events. If a WaitEventSetWait() caller asks for multiple events, an already set latch would previously prevent other events from being reported at the same time. Now, we'll also poll the kernel for other events that would fit in the caller's output buffer wi

pgsql: Fix latch event policy that hid socket events.

2025-01-19 Thread Thomas Munro
Fix latch event policy that hid socket events. If a WaitEventSetWait() caller asks for multiple events, an already set latch would previously prevent other events from being reported at the same time. Now, we'll also poll the kernel for other events that would fit in the caller's output buffer wi

pgsql: Fix latch event policy that hid socket events.

2025-01-19 Thread Thomas Munro
Fix latch event policy that hid socket events. If a WaitEventSetWait() caller asks for multiple events, an already set latch would previously prevent other events from being reported at the same time. Now, we'll also poll the kernel for other events that would fit in the caller's output buffer wi

pgsql: Provide 64-bit ftruncate() and lseek() on Windows.

2025-01-08 Thread Thomas Munro
Provide 64-bit ftruncate() and lseek() on Windows. Change our ftruncate() macro to use the 64-bit variant of chsize(), and add a new macro to redirect lseek() to _lseeki64(). Back-patch to all supported releases, in preparation for a bug fix. Tested-by: Davinder Singh Discussion: https://postg

pgsql: Fix off_t overflow in pg_basebackup on Windows.

2025-01-08 Thread Thomas Munro
Fix off_t overflow in pg_basebackup on Windows. walmethods.c used off_t to navigate around a pg_wal.tar file that could exceed 2GB, which doesn't work on Windows and would fail with misleading errors. Use pgoff_t instead. Back-patch to all supported branches. Author: Davinder Singh Reported-by

pgsql: Fix off_t overflow in pg_basebackup on Windows.

2025-01-08 Thread Thomas Munro
Fix off_t overflow in pg_basebackup on Windows. walmethods.c used off_t to navigate around a pg_wal.tar file that could exceed 2GB, which doesn't work on Windows and would fail with misleading errors. Use pgoff_t instead. Back-patch to all supported branches. Author: Davinder Singh Reported-by

pgsql: Fix off_t overflow in pg_basebackup on Windows.

2025-01-08 Thread Thomas Munro
Fix off_t overflow in pg_basebackup on Windows. walmethods.c used off_t to navigate around a pg_wal.tar file that could exceed 2GB, which doesn't work on Windows and would fail with misleading errors. Use pgoff_t instead. Back-patch to all supported branches. Author: Davinder Singh Reported-by

pgsql: Fix off_t overflow in pg_basebackup on Windows.

2025-01-08 Thread Thomas Munro
Fix off_t overflow in pg_basebackup on Windows. walmethods.c used off_t to navigate around a pg_wal.tar file that could exceed 2GB, which doesn't work on Windows and would fail with misleading errors. Use pgoff_t instead. Back-patch to all supported branches. Author: Davinder Singh Reported-by

pgsql: Fix off_t overflow in pg_basebackup on Windows.

2025-01-08 Thread Thomas Munro
Fix off_t overflow in pg_basebackup on Windows. walmethods.c used off_t to navigate around a pg_wal.tar file that could exceed 2GB, which doesn't work on Windows and would fail with misleading errors. Use pgoff_t instead. Back-patch to all supported branches. Author: Davinder Singh Reported-by

pgsql: Fix off_t overflow in pg_basebackup on Windows.

2025-01-08 Thread Thomas Munro
Fix off_t overflow in pg_basebackup on Windows. walmethods.c used off_t to navigate around a pg_wal.tar file that could exceed 2GB, which doesn't work on Windows and would fail with misleading errors. Use pgoff_t instead. Back-patch to all supported branches. Author: Davinder Singh Reported-by

pgsql: Provide 64-bit ftruncate() and lseek() on Windows.

2025-01-08 Thread Thomas Munro
Provide 64-bit ftruncate() and lseek() on Windows. Change our ftruncate() macro to use the 64-bit variant of chsize(), and add a new macro to redirect lseek() to _lseeki64(). Back-patch to all supported releases, in preparation for a bug fix. Tested-by: Davinder Singh Discussion: https://postg

pgsql: Provide 64-bit ftruncate() and lseek() on Windows.

2025-01-08 Thread Thomas Munro
Provide 64-bit ftruncate() and lseek() on Windows. Change our ftruncate() macro to use the 64-bit variant of chsize(), and add a new macro to redirect lseek() to _lseeki64(). Back-patch to all supported releases, in preparation for a bug fix. Tested-by: Davinder Singh Discussion: https://postg

pgsql: Provide 64-bit ftruncate() and lseek() on Windows.

2025-01-08 Thread Thomas Munro
Provide 64-bit ftruncate() and lseek() on Windows. Change our ftruncate() macro to use the 64-bit variant of chsize(), and add a new macro to redirect lseek() to _lseeki64(). Back-patch to all supported releases, in preparation for a bug fix. Tested-by: Davinder Singh Discussion: https://postg

pgsql: Provide 64-bit ftruncate() and lseek() on Windows.

2025-01-08 Thread Thomas Munro
Provide 64-bit ftruncate() and lseek() on Windows. Change our ftruncate() macro to use the 64-bit variant of chsize(), and add a new macro to redirect lseek() to _lseeki64(). Back-patch to all supported releases, in preparation for a bug fix. Tested-by: Davinder Singh Discussion: https://postg

pgsql: Provide 64-bit ftruncate() and lseek() on Windows.

2025-01-08 Thread Thomas Munro
Provide 64-bit ftruncate() and lseek() on Windows. Change our ftruncate() macro to use the 64-bit variant of chsize(), and add a new macro to redirect lseek() to _lseeki64(). Back-patch to all supported releases, in preparation for a bug fix. Tested-by: Davinder Singh Discussion: https://postg

pgsql: Back-patch b1ffe3ff into REL_13_STABLE.

2025-01-08 Thread Thomas Munro
Back-patch b1ffe3ff into REL_13_STABLE. This is a cherry pick of 4c8e00ae from the 14 branch into the 13 branch. It avoids an assertion failure when ForwardSyncRequest() tries to allocate memory while trying to compact the queue, if run in a critical section. RelationTruncate() gained a critical

pgsql: Fix C error reported by Oracle compiler.

2025-01-07 Thread Thomas Munro
Fix C error reported by Oracle compiler. Commit 66aaabe7 (branches 13 - 17 only) was not acceptable to the Oracle Developer Studio compiler on build farm animal wrasse. It accidentally used a C++ style return statement to wrap a void function. None of the usual compilers complained, but it is ri

pgsql: Fix C error reported by Oracle compiler.

2025-01-07 Thread Thomas Munro
Fix C error reported by Oracle compiler. Commit 66aaabe7 (branches 13 - 17 only) was not acceptable to the Oracle Developer Studio compiler on build farm animal wrasse. It accidentally used a C++ style return statement to wrap a void function. None of the usual compilers complained, but it is ri

pgsql: Fix C error reported by Oracle compiler.

2025-01-07 Thread Thomas Munro
Fix C error reported by Oracle compiler. Commit 66aaabe7 (branches 13 - 17 only) was not acceptable to the Oracle Developer Studio compiler on build farm animal wrasse. It accidentally used a C++ style return statement to wrap a void function. None of the usual compilers complained, but it is ri

pgsql: Fix C error reported by Oracle compiler.

2025-01-07 Thread Thomas Munro
Fix C error reported by Oracle compiler. Commit 66aaabe7 (branches 13 - 17 only) was not acceptable to the Oracle Developer Studio compiler on build farm animal wrasse. It accidentally used a C++ style return statement to wrap a void function. None of the usual compilers complained, but it is ri

pgsql: Fix C error reported by Oracle compiler.

2025-01-07 Thread Thomas Munro
Fix C error reported by Oracle compiler. Commit 66aaabe7 (branches 13 - 17 only) was not acceptable to the Oracle Developer Studio compiler on build farm animal wrasse. It accidentally used a C++ style return statement to wrap a void function. None of the usual compilers complained, but it is ri

pgsql: Restore smgrtruncate() prototype in back-branches.

2025-01-07 Thread Thomas Munro
Restore smgrtruncate() prototype in back-branches. It's possible that external code is calling smgrtruncate(). Any external callers might like to consider the recent changes to RelationTruncate(), but commit 38c579b0 should not have changed the function prototype in the back-branches, per ABI sta

pgsql: Restore smgrtruncate() prototype in back-branches.

2025-01-07 Thread Thomas Munro
Restore smgrtruncate() prototype in back-branches. It's possible that external code is calling smgrtruncate(). Any external callers might like to consider the recent changes to RelationTruncate(), but commit 38c579b0 should not have changed the function prototype in the back-branches, per ABI sta

pgsql: Restore smgrtruncate() prototype in back-branches.

2025-01-07 Thread Thomas Munro
Restore smgrtruncate() prototype in back-branches. It's possible that external code is calling smgrtruncate(). Any external callers might like to consider the recent changes to RelationTruncate(), but commit 38c579b0 should not have changed the function prototype in the back-branches, per ABI sta

pgsql: Restore smgrtruncate() prototype in back-branches.

2025-01-07 Thread Thomas Munro
Restore smgrtruncate() prototype in back-branches. It's possible that external code is calling smgrtruncate(). Any external callers might like to consider the recent changes to RelationTruncate(), but commit 38c579b0 should not have changed the function prototype in the back-branches, per ABI sta

pgsql: Restore smgrtruncate() prototype in back-branches.

2025-01-07 Thread Thomas Munro
Restore smgrtruncate() prototype in back-branches. It's possible that external code is calling smgrtruncate(). Any external callers might like to consider the recent changes to RelationTruncate(), but commit 38c579b0 should not have changed the function prototype in the back-branches, per ABI sta

pgsql: Fix meson detection of a couple of 64 bit builtins.

2025-01-07 Thread Thomas Munro
Fix meson detection of a couple of 64 bit builtins. A couple of checks were missed by commit 962da900, so we would fail to detect the features. Reported-by: Юрий Соколов Discussion: https://postgr.es/m/42C25E2A-6519-4549-9F47-6B0686E83836%40postgrespro.ru Branch -- master Details ---

pgsql: Fix corruption when relation truncation fails.

2024-12-20 Thread Thomas Munro
Fix corruption when relation truncation fails. RelationTruncate() does three things, while holding an AccessExclusiveLock and preventing checkpoints: 1. Logs the truncation. 2. Drops buffers, even if they're dirty. 3. Truncates some number of files. Step 2 could previously be canceled if it had

pgsql: Fix corruption when relation truncation fails.

2024-12-20 Thread Thomas Munro
Fix corruption when relation truncation fails. RelationTruncate() does three things, while holding an AccessExclusiveLock and preventing checkpoints: 1. Logs the truncation. 2. Drops buffers, even if they're dirty. 3. Truncates some number of files. Step 2 could previously be canceled if it had

pgsql: Fix corruption when relation truncation fails.

2024-12-20 Thread Thomas Munro
Fix corruption when relation truncation fails. RelationTruncate() does three things, while holding an AccessExclusiveLock and preventing checkpoints: 1. Logs the truncation. 2. Drops buffers, even if they're dirty. 3. Truncates some number of files. Step 2 could previously be canceled if it had

pgsql: Fix corruption when relation truncation fails.

2024-12-20 Thread Thomas Munro
Fix corruption when relation truncation fails. RelationTruncate() does three things, while holding an AccessExclusiveLock and preventing checkpoints: 1. Logs the truncation. 2. Drops buffers, even if they're dirty. 3. Truncates some number of files. Step 2 could previously be canceled if it had

pgsql: Fix corruption when relation truncation fails.

2024-12-20 Thread Thomas Munro
Fix corruption when relation truncation fails. RelationTruncate() does three things, while holding an AccessExclusiveLock and preventing checkpoints: 1. Logs the truncation. 2. Drops buffers, even if they're dirty. 3. Truncates some number of files. Step 2 could previously be canceled if it had

pgsql: Fix corruption when relation truncation fails.

2024-12-20 Thread Thomas Munro
Fix corruption when relation truncation fails. RelationTruncate() does three things, while holding an AccessExclusiveLock and preventing checkpoints: 1. Logs the truncation. 2. Drops buffers, even if they're dirty. 3. Truncates some number of files. Step 2 could previously be canceled if it had

pgsql: Fix warnings about declaration of environ on MinGW.

2024-12-14 Thread Thomas Munro
Fix warnings about declaration of environ on MinGW. POSIX says that the global variable environ shouldn't be declared in a header, and that you have to declare it yourself. MinGW declares it in with some macrology that messes up our declarations. Visual Studio doesn't warn (there are clues that

pgsql: Remove EXTENSION_DONT_CHECK_SIZE from md.c.

2024-12-14 Thread Thomas Munro
Remove EXTENSION_DONT_CHECK_SIZE from md.c. Commits 7bb3102c and 3eb77eba removed the only user of the EXTENSION_DONT_CHECK_SIZE flag, which had previously been required to checkpoint truncated relations. Since 7bb3102c, segments have been opened directly for synchronization without calling _mdfd

pgsql: Fix printf format string warning on MinGW.

2024-12-05 Thread Thomas Munro
Fix printf format string warning on MinGW. Commit 517bf2d91 changed a printf format string to placate MinGW, which at the time warned about "%lld". Current MinGW is now warning about the replacement "%I64d". Reverting the change clears the warning on the MinGW CI task, and hopefully it will clea

pgsql: Fix header inclusion order in c.h.

2024-12-04 Thread Thomas Munro
Fix header inclusion order in c.h. Commit 962da900a added #include to postgres_ext.h, which broke c.h's header ordering rule. The system headers on some systems would then lock down off_t's size in private macros, before they'd had a chance to see our definition of _FILE_OFFSET_BITS (and presuma

pgsql: Use and for c.h integers.

2024-12-03 Thread Thomas Munro
Use and for c.h integers. Redefine our exact width types with standard C99 types and macros, including int64_t, INT64_MAX, INT64_C(), PRId64 etc. We were already using types in a few places. One complication is that Windows' uses format strings like "%I64d", "%I32", "%I" for PRI*64, PRI*32,

pgsql: RelationTruncate() must set DELAY_CHKPT_START.

2024-12-02 Thread Thomas Munro
rrent checkpoint, the sync request queued by that operation must be processed by that checkpoint, rather than being left for the following one. This is a refinement of commit 412ad7a5563. Back-patch to all supported releases, like that commit. Author: Robert Haas Reported-by: Thomas Munro Discu

pgsql: RelationTruncate() must set DELAY_CHKPT_START.

2024-12-02 Thread Thomas Munro
rrent checkpoint, the sync request queued by that operation must be processed by that checkpoint, rather than being left for the following one. This is a refinement of commit 412ad7a5563. Back-patch to all supported releases, like that commit. Author: Robert Haas Reported-by: Thomas Munro Discu

pgsql: RelationTruncate() must set DELAY_CHKPT_START.

2024-12-02 Thread Thomas Munro
rrent checkpoint, the sync request queued by that operation must be processed by that checkpoint, rather than being left for the following one. This is a refinement of commit 412ad7a5563. Back-patch to all supported releases, like that commit. Author: Robert Haas Reported-by: Thomas Munro Discu

pgsql: RelationTruncate() must set DELAY_CHKPT_START.

2024-12-02 Thread Thomas Munro
rrent checkpoint, the sync request queued by that operation must be processed by that checkpoint, rather than being left for the following one. This is a refinement of commit 412ad7a5563. Back-patch to all supported releases, like that commit. Author: Robert Haas Reported-by: Thomas Munro Discu

pgsql: RelationTruncate() must set DELAY_CHKPT_START.

2024-12-02 Thread Thomas Munro
rrent checkpoint, the sync request queued by that operation must be processed by that checkpoint, rather than being left for the following one. This is a refinement of commit 412ad7a5563. Back-patch to all supported releases, like that commit. Author: Robert Haas Reported-by: Thomas Munro Discu

pgsql: RelationTruncate() must set DELAY_CHKPT_START.

2024-12-02 Thread Thomas Munro
rrent checkpoint, the sync request queued by that operation must be processed by that checkpoint, rather than being left for the following one. This is a refinement of commit 412ad7a5563. Back-patch to all supported releases, like that commit. Author: Robert Haas Reported-by: Thomas Munro Discu

pgsql: Fix MinGW %d vs %lu warnings in back branches.

2024-11-28 Thread Thomas Munro
Fix MinGW %d vs %lu warnings in back branches. Commit 352f6f2d used %d instead of %lu to format DWORD (unsigned long) with psprintf(). The _WIN32_WINNT value recently changed for MinGW in REL_15_STABLE (commit d700e8d7), so the code was suddenly being compiled, with warnings from gcc. The warnin

pgsql: Fix MinGW %d vs %lu warnings in back branches.

2024-11-28 Thread Thomas Munro
Fix MinGW %d vs %lu warnings in back branches. Commit 352f6f2d used %d instead of %lu to format DWORD (unsigned long) with psprintf(). The _WIN32_WINNT value recently changed for MinGW in REL_15_STABLE (commit d700e8d7), so the code was suddenly being compiled, with warnings from gcc. The warnin

pgsql: Fix MinGW %d vs %lu warnings in back branches.

2024-11-28 Thread Thomas Munro
Fix MinGW %d vs %lu warnings in back branches. Commit 352f6f2d used %d instead of %lu to format DWORD (unsigned long) with psprintf(). The _WIN32_WINNT value recently changed for MinGW in REL_15_STABLE (commit d700e8d7), so the code was suddenly being compiled, with warnings from gcc. The warnin

pgsql: Skip SectionMemoryManager.h in cpluspluscheck.

2024-11-27 Thread Thomas Munro
Skip SectionMemoryManager.h in cpluspluscheck. Commit 9044fc1d45a0 skipped SectionMemoryManager.h in headerscheck, and by extension also cpluspluscheck, because it's C++ and would fail both tests. That worked in master and REL_17_STABLE due to 7b8e2ae2fd3b, but older branches have a separate cplu

pgsql: Skip SectionMemoryManager.h in cpluspluscheck.

2024-11-27 Thread Thomas Munro
Skip SectionMemoryManager.h in cpluspluscheck. Commit 9044fc1d45a0 skipped SectionMemoryManager.h in headerscheck, and by extension also cpluspluscheck, because it's C++ and would fail both tests. That worked in master and REL_17_STABLE due to 7b8e2ae2fd3b, but older branches have a separate cplu

pgsql: Skip SectionMemoryManager.h in cpluspluscheck.

2024-11-27 Thread Thomas Munro
Skip SectionMemoryManager.h in cpluspluscheck. Commit 9044fc1d45a0 skipped SectionMemoryManager.h in headerscheck, and by extension also cpluspluscheck, because it's C++ and would fail both tests. That worked in master and REL_17_STABLE due to 7b8e2ae2fd3b, but older branches have a separate cplu

pgsql: Skip SectionMemoryManager.h in cpluspluscheck.

2024-11-27 Thread Thomas Munro
Skip SectionMemoryManager.h in cpluspluscheck. Commit 9044fc1d45a0 skipped SectionMemoryManager.h in headerscheck, and by extension also cpluspluscheck, because it's C++ and would fail both tests. That worked in master and REL_17_STABLE due to 7b8e2ae2fd3b, but older branches have a separate cplu

pgsql: Require sizeof(bool) == 1.

2024-11-27 Thread Thomas Munro
Require sizeof(bool) == 1. The C standard says that sizeof(bool) is implementation-defined, but we know of no current systems where it is not 1. The last known systems seem to have been Apple macOS/PowerPC 10.5 and Microsoft Visual C++ 4, both long defunct. PostgreSQL has always required sizeof(

pgsql: Require ucrt if using MinGW.

2024-11-27 Thread Thomas Munro
Require ucrt if using MinGW. Historically we tolerated the absence of various C runtime library features for the benefit of the MinGW tool chain, because it used ancient msvcrt.dll for a long period of time. It now uses ucrt by default (like Windows 10+, Visual Studio 2015+), and that's the only

pgsql: Remove configure check for _configthreadlocale().

2024-11-27 Thread Thomas Munro
Remove configure check for _configthreadlocale(). All modern Windows systems have _configthreadlocale(). It was first introduced in msvcr80.dll from Visual Studio 2005. Historically, MinGW was stuck on even older msvcrt.dll, but added its own dummy implementation of the function when using msvcr

pgsql: Revert "Blind attempt to fix _configthreadlocale() failures on M

2024-11-27 Thread Thomas Munro
Revert "Blind attempt to fix _configthreadlocale() failures on MinGW." This reverts commit 2cf91ccb73ce888c44e3751548fb7c77e87335f2. When using the old msvcrt.dll, MinGW would supply its own dummy version of _configthreadlocale() that just returns -1 if you try to use it. For a time we tolerated

pgsql: If a C23 compiler is detected, try asking for C17.

2024-11-26 Thread Thomas Munro
If a C23 compiler is detected, try asking for C17. Branches before 16 can't be compiled with a C23 compiler (see deprecation warnings silenced by commit f9a56e72, and non-back-patchable changes made in 16 by commit 1c27d16e). Test __STDC_VERSION__, and if it's above C17 then try appending -std=gn

pgsql: If a C23 compiler is detected, try asking for C17.

2024-11-26 Thread Thomas Munro
If a C23 compiler is detected, try asking for C17. Branches before 16 can't be compiled with a C23 compiler (see deprecation warnings silenced by commit f9a56e72, and non-back-patchable changes made in 16 by commit 1c27d16e). Test __STDC_VERSION__, and if it's above C17 then try appending -std=gn

pgsql: If a C23 compiler is detected, try asking for C17.

2024-11-26 Thread Thomas Munro
If a C23 compiler is detected, try asking for C17. Branches before 16 can't be compiled with a C23 compiler (see deprecation warnings silenced by commit f9a56e72, and non-back-patchable changes made in 16 by commit 1c27d16e). Test __STDC_VERSION__, and if it's above C17 then try appending -std=gn

pgsql: If a C23 compiler is detected, try asking for C17.

2024-11-26 Thread Thomas Munro
If a C23 compiler is detected, try asking for C17. Branches before 16 can't be compiled with a C23 compiler (see deprecation warnings silenced by commit f9a56e72, and non-back-patchable changes made in 16 by commit 1c27d16e). Test __STDC_VERSION__, and if it's above C17 then try appending -std=gn

pgsql: If a C23 compiler is detected, try asking for C17.

2024-11-26 Thread Thomas Munro
If a C23 compiler is detected, try asking for C17. Branches before 16 can't be compiled with a C23 compiler (see deprecation warnings silenced by commit f9a56e72, and non-back-patchable changes made in 16 by commit 1c27d16e). Test __STDC_VERSION__, and if it's above C17 then try appending -std=gn

pgsql: If a C23 compiler is detected, try asking for C17.

2024-11-26 Thread Thomas Munro
If a C23 compiler is detected, try asking for C17. Branches before 16 can't be compiled with a C23 compiler (see deprecation warnings silenced by commit f9a56e72, and non-back-patchable changes made in 16 by commit 1c27d16e). Test __STDC_VERSION__, and if it's above C17 then try appending -std=gn

pgsql: If a C23 compiler is detected, try asking for C17.

2024-11-26 Thread Thomas Munro
If a C23 compiler is detected, try asking for C17. Branches before 16 can't be compiled with a C23 compiler (see deprecation warnings silenced by commit f9a56e72, and non-back-patchable changes made in 16 by commit 1c27d16e). Test __STDC_VERSION__, and if it's above C17 then try appending -std=gn

pgsql: If a C23 compiler is detected, try asking for C17.

2024-11-26 Thread Thomas Munro
If a C23 compiler is detected, try asking for C17. Branches before 16 can't be compiled with a C23 compiler (see deprecation warnings silenced by commit f9a56e72, and non-back-patchable changes made in 16 by commit 1c27d16e). Test __STDC_VERSION__, and if it's above C17 then try appending -std=gn

pgsql: If a C23 compiler is detected, try asking for C17.

2024-11-26 Thread Thomas Munro
If a C23 compiler is detected, try asking for C17. Branches before 16 can't be compiled with a C23 compiler (see deprecation warnings silenced by commit f9a56e72, and non-back-patchable changes made in 16 by commit 1c27d16e). Test __STDC_VERSION__, and if it's above C17 then try appending -std=gn

pgsql: If a C23 compiler is detected, try asking for C17.

2024-11-26 Thread Thomas Munro
If a C23 compiler is detected, try asking for C17. Branches before 16 can't be compiled with a C23 compiler (see deprecation warnings silenced by commit f9a56e72, and non-back-patchable changes made in 16 by commit 1c27d16e). Test __STDC_VERSION__, and if it's above C17 then try appending -std=gn

  1   2   3   4   5   6   7   8   9   10   >