pgsql: Fix min_dynamic_shared_memory on Windows.

2023-10-21 Thread Thomas Munro
Fix min_dynamic_shared_memory on Windows. When min_dynamic_shared_memory is set above 0, we try to find space in a pre-allocated region of the main shared memory area instead of calling dsm_impl_XXX() routines to allocate more. The dsm_pin_segment() and dsm_unpin_segment() routines had a bug:

pgsql: Fix min_dynamic_shared_memory on Windows.

2023-10-21 Thread Thomas Munro
Fix min_dynamic_shared_memory on Windows. When min_dynamic_shared_memory is set above 0, we try to find space in a pre-allocated region of the main shared memory area instead of calling dsm_impl_XXX() routines to allocate more. The dsm_pin_segment() and dsm_unpin_segment() routines had a bug:

pgsql: jit: Changes for LLVM 17.

2023-10-18 Thread Thomas Munro
Andres Freund Reviewed-by: Thomas Munro Discussion: https://postgr.es/m/CA%2BhUKG%2BWXznXCyTgCADd%3DHWkP9Qksa6chd7L%3DGCnZo-MBgg9Lg%40mail.gmail.com Branch -- REL_12_STABLE Details --- https://git.postgresql.org/pg/commitdiff/7da915e33abf54ce126d68baead4c1871b302c1c Modified

pgsql: jit: Changes for LLVM 17.

2023-10-18 Thread Thomas Munro
Andres Freund Reviewed-by: Thomas Munro Discussion: https://postgr.es/m/CA%2BhUKG%2BWXznXCyTgCADd%3DHWkP9Qksa6chd7L%3DGCnZo-MBgg9Lg%40mail.gmail.com Branch -- REL_13_STABLE Details --- https://git.postgresql.org/pg/commitdiff/53c4dabe18d3de365a96ccf8c7493a9ffd4b6dcf Modified

pgsql: jit: Changes for LLVM 17.

2023-10-18 Thread Thomas Munro
Andres Freund Reviewed-by: Thomas Munro Discussion: https://postgr.es/m/CA%2BhUKG%2BWXznXCyTgCADd%3DHWkP9Qksa6chd7L%3DGCnZo-MBgg9Lg%40mail.gmail.com Branch -- REL_14_STABLE Details --- https://git.postgresql.org/pg/commitdiff/0a8b7d5c11266ba5291d0aafc0ff4f92ab1cc041 Modified

pgsql: jit: Changes for LLVM 17.

2023-10-18 Thread Thomas Munro
Andres Freund Reviewed-by: Thomas Munro Discussion: https://postgr.es/m/CA%2BhUKG%2BWXznXCyTgCADd%3DHWkP9Qksa6chd7L%3DGCnZo-MBgg9Lg%40mail.gmail.com Branch -- REL_15_STABLE Details --- https://git.postgresql.org/pg/commitdiff/b60e3ac7603dfae3f810418b1fb5856d9fc7a328 Modified

pgsql: jit: Changes for LLVM 17.

2023-10-18 Thread Thomas Munro
Andres Freund Reviewed-by: Thomas Munro Discussion: https://postgr.es/m/CA%2BhUKG%2BWXznXCyTgCADd%3DHWkP9Qksa6chd7L%3DGCnZo-MBgg9Lg%40mail.gmail.com Branch -- REL_16_STABLE Details --- https://git.postgresql.org/pg/commitdiff/774185056834eef7702f6afb37731c583fa51a1a Modified

pgsql: jit: Changes for LLVM 17.

2023-10-18 Thread Thomas Munro
Andres Freund Reviewed-by: Thomas Munro Discussion: https://postgr.es/m/CA%2BhUKG%2BWXznXCyTgCADd%3DHWkP9Qksa6chd7L%3DGCnZo-MBgg9Lg%40mail.gmail.com Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/76200e5ee469e4a9db5f9514b9d0c6a31b496bff Modified Files

pgsql: jit: Supply LLVMGlobalGetValueType() for LLVM < 8.

2023-10-18 Thread Thomas Munro
jit: Supply LLVMGlobalGetValueType() for LLVM < 8. Commit 37d5babb used this C API function while adding support for LLVM 16 and opaque pointers, but it's not available in LLVM 7 and older. Provide it in our own llvmjit_wrap.cpp. It just calls a C++ function that pre-dates LLVM 3.9, our minimum

pgsql: jit: Supply LLVMGlobalGetValueType() for LLVM < 8.

2023-10-18 Thread Thomas Munro
jit: Supply LLVMGlobalGetValueType() for LLVM < 8. Commit 37d5babb used this C API function while adding support for LLVM 16 and opaque pointers, but it's not available in LLVM 7 and older. Provide it in our own llvmjit_wrap.cpp. It just calls a C++ function that pre-dates LLVM 3.9, our minimum

pgsql: jit: Supply LLVMGlobalGetValueType() for LLVM < 8.

2023-10-18 Thread Thomas Munro
jit: Supply LLVMGlobalGetValueType() for LLVM < 8. Commit 37d5babb used this C API function while adding support for LLVM 16 and opaque pointers, but it's not available in LLVM 7 and older. Provide it in our own llvmjit_wrap.cpp. It just calls a C++ function that pre-dates LLVM 3.9, our minimum

pgsql: jit: Supply LLVMGlobalGetValueType() for LLVM < 8.

2023-10-18 Thread Thomas Munro
jit: Supply LLVMGlobalGetValueType() for LLVM < 8. Commit 37d5babb used this C API function while adding support for LLVM 16 and opaque pointers, but it's not available in LLVM 7 and older. Provide it in our own llvmjit_wrap.cpp. It just calls a C++ function that pre-dates LLVM 3.9, our minimum

pgsql: jit: Supply LLVMGlobalGetValueType() for LLVM < 8.

2023-10-18 Thread Thomas Munro
jit: Supply LLVMGlobalGetValueType() for LLVM < 8. Commit 37d5babb used this C API function while adding support for LLVM 16 and opaque pointers, but it's not available in LLVM 7 and older. Provide it in our own llvmjit_wrap.cpp. It just calls a C++ function that pre-dates LLVM 3.9, our minimum

pgsql: jit: Supply LLVMGlobalGetValueType() for LLVM < 8.

2023-10-18 Thread Thomas Munro
jit: Supply LLVMGlobalGetValueType() for LLVM < 8. Commit 37d5babb used this C API function while adding support for LLVM 16 and opaque pointers, but it's not available in LLVM 7 and older. Provide it in our own llvmjit_wrap.cpp. It just calls a C++ function that pre-dates LLVM 3.9, our minimum

pgsql: jit: Support opaque pointers in LLVM 16.

2023-10-18 Thread Thomas Munro
jit: Support opaque pointers in LLVM 16. Remove use of LLVMGetElementType() and provide the type of all pointers to LLVMBuildXXX() functions when emitting IR, as required by modern LLVM versions[1]. * For LLVM <= 14, we'll still use the old LLVMBuildXXX() functions. * For LLVM == 15, we'll

pgsql: jit: Support opaque pointers in LLVM 16.

2023-10-18 Thread Thomas Munro
jit: Support opaque pointers in LLVM 16. Remove use of LLVMGetElementType() and provide the type of all pointers to LLVMBuildXXX() functions when emitting IR, as required by modern LLVM versions[1]. * For LLVM <= 14, we'll still use the old LLVMBuildXXX() functions. * For LLVM == 15, we'll

pgsql: jit: Support opaque pointers in LLVM 16.

2023-10-18 Thread Thomas Munro
jit: Support opaque pointers in LLVM 16. Remove use of LLVMGetElementType() and provide the type of all pointers to LLVMBuildXXX() functions when emitting IR, as required by modern LLVM versions[1]. * For LLVM <= 14, we'll still use the old LLVMBuildXXX() functions. * For LLVM == 15, we'll

pgsql: jit: Support opaque pointers in LLVM 16.

2023-10-18 Thread Thomas Munro
jit: Support opaque pointers in LLVM 16. Remove use of LLVMGetElementType() and provide the type of all pointers to LLVMBuildXXX() functions when emitting IR, as required by modern LLVM versions[1]. * For LLVM <= 14, we'll still use the old LLVMBuildXXX() functions. * For LLVM == 15, we'll

pgsql: jit: Support opaque pointers in LLVM 16.

2023-10-18 Thread Thomas Munro
jit: Support opaque pointers in LLVM 16. Remove use of LLVMGetElementType() and provide the type of all pointers to LLVMBuildXXX() functions when emitting IR, as required by modern LLVM versions[1]. * For LLVM <= 14, we'll still use the old LLVMBuildXXX() functions. * For LLVM == 15, we'll

pgsql: jit: Support opaque pointers in LLVM 16.

2023-10-18 Thread Thomas Munro
jit: Support opaque pointers in LLVM 16. Remove use of LLVMGetElementType() and provide the type of all pointers to LLVMBuildXXX() functions when emitting IR, as required by modern LLVM versions[1]. * For LLVM <= 14, we'll still use the old LLVMBuildXXX() functions. * For LLVM == 15, we'll

pgsql: Try to handle torn reads of pg_control in frontend.

2023-10-15 Thread Thomas Munro
Try to handle torn reads of pg_control in frontend. Some of our src/bin tools read the control file without any kind of interlocking against concurrent writes from the server. At least ext4 and ntfs can expose partially modified contents when you do that. For now, we'll try to tolerate this by

pgsql: Try to handle torn reads of pg_control in frontend.

2023-10-15 Thread Thomas Munro
Try to handle torn reads of pg_control in frontend. Some of our src/bin tools read the control file without any kind of interlocking against concurrent writes from the server. At least ext4 and ntfs can expose partially modified contents when you do that. For now, we'll try to tolerate this by

pgsql: Try to handle torn reads of pg_control in frontend.

2023-10-15 Thread Thomas Munro
Try to handle torn reads of pg_control in frontend. Some of our src/bin tools read the control file without any kind of interlocking against concurrent writes from the server. At least ext4 and ntfs can expose partially modified contents when you do that. For now, we'll try to tolerate this by

pgsql: Try to handle torn reads of pg_control in frontend.

2023-10-15 Thread Thomas Munro
Try to handle torn reads of pg_control in frontend. Some of our src/bin tools read the control file without any kind of interlocking against concurrent writes from the server. At least ext4 and ntfs can expose partially modified contents when you do that. For now, we'll try to tolerate this by

pgsql: Try to handle torn reads of pg_control in frontend.

2023-10-15 Thread Thomas Munro
Try to handle torn reads of pg_control in frontend. Some of our src/bin tools read the control file without any kind of interlocking against concurrent writes from the server. At least ext4 and ntfs can expose partially modified contents when you do that. For now, we'll try to tolerate this by

pgsql: Try to handle torn reads of pg_control in frontend.

2023-10-15 Thread Thomas Munro
Try to handle torn reads of pg_control in frontend. Some of our src/bin tools read the control file without any kind of interlocking against concurrent writes from the server. At least ext4 and ntfs can expose partially modified contents when you do that. For now, we'll try to tolerate this by

Re: pgsql: Rename 005_login_trigger.pl to 006_login_trigger.pl

2023-10-15 Thread Thomas Munro
On Mon, Oct 16, 2023 at 2:04 PM Alexander Korotkov wrote: > Rename 005_login_trigger.pl to 006_login_trigger.pl > > In order to avoid numbering collision with 005_sspi.pl. Hi Alexander, Usually I notice if someone steals my TAP script number because there is git conflict in eg

pgsql: Fix comment from commit 22655aa231.

2023-10-15 Thread Thomas Munro
Fix comment from commit 22655aa231. Per automated complaint from BF animal koel this needed to be re-indented, but there was also a typo. Back-patch to 16. Branch -- REL_16_STABLE Details --- https://git.postgresql.org/pg/commitdiff/3090213690bd69dd46dae865a2021982e7309208 Modified

pgsql: Fix comment from commit 22655aa231.

2023-10-15 Thread Thomas Munro
Fix comment from commit 22655aa231. Per automated complaint from BF animal koel this needed to be re-indented, but there was also a typo. Back-patch to 16. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/01529c7040088db2718628d0814058598152bd39 Modified Files

pgsql: Acquire ControlFileLock in relevant SQL functions.

2023-10-15 Thread Thomas Munro
Acquire ControlFileLock in relevant SQL functions. Commit dc7d70ea added functions that read the control file, but didn't acquire ControlFileLock. With unlucky timing, file systems that have weak interlocking like ext4 and ntfs could expose partially overwritten contents, and the checksum would

pgsql: Acquire ControlFileLock in relevant SQL functions.

2023-10-15 Thread Thomas Munro
Acquire ControlFileLock in relevant SQL functions. Commit dc7d70ea added functions that read the control file, but didn't acquire ControlFileLock. With unlucky timing, file systems that have weak interlocking like ext4 and ntfs could expose partially overwritten contents, and the checksum would

pgsql: Acquire ControlFileLock in relevant SQL functions.

2023-10-15 Thread Thomas Munro
Acquire ControlFileLock in relevant SQL functions. Commit dc7d70ea added functions that read the control file, but didn't acquire ControlFileLock. With unlucky timing, file systems that have weak interlocking like ext4 and ntfs could expose partially overwritten contents, and the checksum would

pgsql: Acquire ControlFileLock in relevant SQL functions.

2023-10-15 Thread Thomas Munro
Acquire ControlFileLock in relevant SQL functions. Commit dc7d70ea added functions that read the control file, but didn't acquire ControlFileLock. With unlucky timing, file systems that have weak interlocking like ext4 and ntfs could expose partially overwritten contents, and the checksum would

pgsql: Acquire ControlFileLock in relevant SQL functions.

2023-10-15 Thread Thomas Munro
Acquire ControlFileLock in relevant SQL functions. Commit dc7d70ea added functions that read the control file, but didn't acquire ControlFileLock. With unlucky timing, file systems that have weak interlocking like ext4 and ntfs could expose partially overwritten contents, and the checksum would

pgsql: Acquire ControlFileLock in relevant SQL functions.

2023-10-15 Thread Thomas Munro
Acquire ControlFileLock in relevant SQL functions. Commit dc7d70ea added functions that read the control file, but didn't acquire ControlFileLock. With unlucky timing, file systems that have weak interlocking like ext4 and ntfs could expose partially overwritten contents, and the checksum would

pgsql: Acquire ControlFileLock in relevant SQL functions.

2023-10-15 Thread Thomas Munro
Acquire ControlFileLock in relevant SQL functions. Commit dc7d70ea added functions that read the control file, but didn't acquire ControlFileLock. With unlucky timing, file systems that have weak interlocking like ext4 and ntfs could expose partially overwritten contents, and the checksum would

pgsql: Add wait events for checkpoint delay mechanism.

2023-10-12 Thread Thomas Munro
Add wait events for checkpoint delay mechanism. When MyProc->delayChkptFlags is set to temporarily block phase transitions in a concurrent checkpoint, the checkpointer enters a sleep-poll loop to wait for the flag to be cleared. We should show that as a wait event in the pg_stat_activity view.

pgsql: Fix edge-case for xl_tot_len broken by bae868ca.

2023-09-25 Thread Thomas Munro
Fix edge-case for xl_tot_len broken by bae868ca. bae868ca removed a check that was still needed. If you had an xl_tot_len at the end of a page that was too small for a record header, but not big enough to span onto the next page, we'd immediately perform the CRC check using a bogus large length.

pgsql: Fix edge-case for xl_tot_len broken by bae868ca.

2023-09-25 Thread Thomas Munro
Fix edge-case for xl_tot_len broken by bae868ca. bae868ca removed a check that was still needed. If you had an xl_tot_len at the end of a page that was too small for a record header, but not big enough to span onto the next page, we'd immediately perform the CRC check using a bogus large length.

pgsql: Fix edge-case for xl_tot_len broken by bae868ca.

2023-09-25 Thread Thomas Munro
Fix edge-case for xl_tot_len broken by bae868ca. bae868ca removed a check that was still needed. If you had an xl_tot_len at the end of a page that was too small for a record header, but not big enough to span onto the next page, we'd immediately perform the CRC check using a bogus large length.

pgsql: Fix edge-case for xl_tot_len broken by bae868ca.

2023-09-25 Thread Thomas Munro
Fix edge-case for xl_tot_len broken by bae868ca. bae868ca removed a check that was still needed. If you had an xl_tot_len at the end of a page that was too small for a record header, but not big enough to span onto the next page, we'd immediately perform the CRC check using a bogus large length.

pgsql: Fix edge-case for xl_tot_len broken by bae868ca.

2023-09-25 Thread Thomas Munro
Fix edge-case for xl_tot_len broken by bae868ca. bae868ca removed a check that was still needed. If you had an xl_tot_len at the end of a page that was too small for a record header, but not big enough to span onto the next page, we'd immediately perform the CRC check using a bogus large length.

pgsql: Fix edge-case for xl_tot_len broken by bae868ca.

2023-09-25 Thread Thomas Munro
Fix edge-case for xl_tot_len broken by bae868ca. bae868ca removed a check that was still needed. If you had an xl_tot_len at the end of a page that was too small for a record header, but not big enough to span onto the next page, we'd immediately perform the CRC check using a bogus large length.

pgsql: Don't use Perl pack('Q') in 039_end_of_wal.pl.

2023-09-22 Thread Thomas Munro
Don't use Perl pack('Q') in 039_end_of_wal.pl. 'Q' for 64 bit integers turns out not to work on 32 bit Perl, as revealed by the build farm. Use 'II' instead, and deal with endianness. Back-patch to 12, like bae868ca. Discussion: https://postgr.es/m/ZQ4r1vHcryBsSi_V%40paquier.xyz Branch --

pgsql: Don't use Perl pack('Q') in 039_end_of_wal.pl.

2023-09-22 Thread Thomas Munro
Don't use Perl pack('Q') in 039_end_of_wal.pl. 'Q' for 64 bit integers turns out not to work on 32 bit Perl, as revealed by the build farm. Use 'II' instead, and deal with endianness. Back-patch to 12, like bae868ca. Discussion: https://postgr.es/m/ZQ4r1vHcryBsSi_V%40paquier.xyz Branch --

pgsql: Don't use Perl pack('Q') in 039_end_of_wal.pl.

2023-09-22 Thread Thomas Munro
Don't use Perl pack('Q') in 039_end_of_wal.pl. 'Q' for 64 bit integers turns out not to work on 32 bit Perl, as revealed by the build farm. Use 'II' instead, and deal with endianness. Back-patch to 12, like bae868ca. Discussion: https://postgr.es/m/ZQ4r1vHcryBsSi_V%40paquier.xyz Branch --

pgsql: Don't use Perl pack('Q') in 039_end_of_wal.pl.

2023-09-22 Thread Thomas Munro
Don't use Perl pack('Q') in 039_end_of_wal.pl. 'Q' for 64 bit integers turns out not to work on 32 bit Perl, as revealed by the build farm. Use 'II' instead, and deal with endianness. Back-patch to 12, like bae868ca. Discussion: https://postgr.es/m/ZQ4r1vHcryBsSi_V%40paquier.xyz Branch --

pgsql: Don't use Perl pack('Q') in 039_end_of_wal.pl.

2023-09-22 Thread Thomas Munro
Don't use Perl pack('Q') in 039_end_of_wal.pl. 'Q' for 64 bit integers turns out not to work on 32 bit Perl, as revealed by the build farm. Use 'II' instead, and deal with endianness. Back-patch to 12, like bae868ca. Discussion: https://postgr.es/m/ZQ4r1vHcryBsSi_V%40paquier.xyz Branch --

pgsql: Don't use Perl pack('Q') in 039_end_of_wal.pl.

2023-09-22 Thread Thomas Munro
Don't use Perl pack('Q') in 039_end_of_wal.pl. 'Q' for 64 bit integers turns out not to work on 32 bit Perl, as revealed by the build farm. Use 'II' instead, and deal with endianness. Back-patch to 12, like bae868ca. Discussion: https://postgr.es/m/ZQ4r1vHcryBsSi_V%40paquier.xyz Branch --

pgsql: Don't trust unvalidated xl_tot_len.

2023-09-22 Thread Thomas Munro
ing, but changing that is left for later work. Also included is a new TAP test to exercise various cases of end-of-WAL detection by writing contrived data into the WAL from Perl. Back-patch to 12. We decided not to put this change into the final release of 11. Author: Thomas Munro Author: Mich

pgsql: Don't trust unvalidated xl_tot_len.

2023-09-22 Thread Thomas Munro
ing, but changing that is left for later work. Also included is a new TAP test to exercise various cases of end-of-WAL detection by writing contrived data into the WAL from Perl. Back-patch to 12. We decided not to put this change into the final release of 11. Author: Thomas Munro Author: Mich

pgsql: Don't trust unvalidated xl_tot_len.

2023-09-22 Thread Thomas Munro
ing, but changing that is left for later work. Also included is a new TAP test to exercise various cases of end-of-WAL detection by writing contrived data into the WAL from Perl. Back-patch to 12. We decided not to put this change into the final release of 11. Author: Thomas Munro Author: Mich

pgsql: Don't trust unvalidated xl_tot_len.

2023-09-22 Thread Thomas Munro
ing, but changing that is left for later work. Also included is a new TAP test to exercise various cases of end-of-WAL detection by writing contrived data into the WAL from Perl. Back-patch to 12. We decided not to put this change into the final release of 11. Author: Thomas Munro Author: Mich

pgsql: Don't trust unvalidated xl_tot_len.

2023-09-22 Thread Thomas Munro
ing, but changing that is left for later work. Also included is a new TAP test to exercise various cases of end-of-WAL detection by writing contrived data into the WAL from Perl. Back-patch to 12. We decided not to put this change into the final release of 11. Author: Thomas Munro Author: Mich

pgsql: Don't trust unvalidated xl_tot_len.

2023-09-22 Thread Thomas Munro
ing, but changing that is left for later work. Also included is a new TAP test to exercise various cases of end-of-WAL detection by writing contrived data into the WAL from Perl. Back-patch to 12. We decided not to put this change into the final release of 11. Author: Thomas Munro Author: Mich

pgsql: Fix exception safety bug in typcache.c.

2023-09-12 Thread Thomas Munro
Fix exception safety bug in typcache.c. If an out-of-memory error was thrown at an unfortunate time, ensure_record_cache_typmod_slot_exists() could leak memory and leave behind a global state that produced an infinite loop on the next call. Fix by merging RecordCacheArray and

pgsql: Fix exception safety bug in typcache.c.

2023-09-12 Thread Thomas Munro
Fix exception safety bug in typcache.c. If an out-of-memory error was thrown at an unfortunate time, ensure_record_cache_typmod_slot_exists() could leak memory and leave behind a global state that produced an infinite loop on the next call. Fix by merging RecordCacheArray and

pgsql: Fix exception safety bug in typcache.c.

2023-09-12 Thread Thomas Munro
Fix exception safety bug in typcache.c. If an out-of-memory error was thrown at an unfortunate time, ensure_record_cache_typmod_slot_exists() could leak memory and leave behind a global state that produced an infinite loop on the next call. Fix by merging RecordCacheArray and

pgsql: Fix exception safety bug in typcache.c.

2023-09-12 Thread Thomas Munro
Fix exception safety bug in typcache.c. If an out-of-memory error was thrown at an unfortunate time, ensure_record_cache_typmod_slot_exists() could leak memory and leave behind a global state that produced an infinite loop on the next call. Fix by merging RecordCacheArray and

pgsql: Fix exception safety bug in typcache.c.

2023-09-12 Thread Thomas Munro
Fix exception safety bug in typcache.c. If an out-of-memory error was thrown at an unfortunate time, ensure_record_cache_typmod_slot_exists() could leak memory and leave behind a global state that produced an infinite loop on the next call. Fix by merging RecordCacheArray and

pgsql: Fix exception safety bug in typcache.c.

2023-09-12 Thread Thomas Munro
Fix exception safety bug in typcache.c. If an out-of-memory error was thrown at an unfortunate time, ensure_record_cache_typmod_slot_exists() could leak memory and leave behind a global state that produced an infinite loop on the next call. Fix by merging RecordCacheArray and

pgsql: Fix exception safety bug in typcache.c.

2023-09-12 Thread Thomas Munro
Fix exception safety bug in typcache.c. If an out-of-memory error was thrown at an unfortunate time, ensure_record_cache_typmod_slot_exists() could leak memory and leave behind a global state that produced an infinite loop on the next call. Fix by merging RecordCacheArray and

pgsql: Teach WaitEventSetWait() to report multiple events on Windows.

2023-09-08 Thread Thomas Munro
Teach WaitEventSetWait() to report multiple events on Windows. The WAIT_USE_WIN32 implementation of WaitEventSetWait() previously reported at most one event per call, because that's what the underlying WaitForMultipleObjects() call does. We can make the behavior match the three Unix

pgsql: Remove some more "snapshot too old" vestiges.

2023-09-07 Thread Thomas Munro
Remove some more "snapshot too old" vestiges. Commit f691f5b8 removed the logic, but left behind some now-useless Snapshot arguments to various AM-internal functions, and missed a couple of comments. Reported-by: Peter Geoghegan Discussion:

pgsql: Fix instability in 031_recovery_conflict.pl.

2023-09-06 Thread Thomas Munro
Fix instability in 031_recovery_conflict.pl. Where the test wants a VACUUM command to generate WAL that would conflict with a session on the standby, it could transiently fail to do so if it couldn't acquire a cleanup lock conditionally at that moment on the primary. VACUUM FREEZE will wait, so

pgsql: Fix recovery conflict SIGUSR1 handling.

2023-09-06 Thread Thomas Munro
Fix recovery conflict SIGUSR1 handling. We shouldn't be doing non-trivial work in signal handlers in general, and in this case the handler could reach unsafe code and corrupt state. It also clobbered its own "reason" code. Move all recovery conflict decision logic into the next

pgsql: Disable 031_recovery_conflict.pl in 15 and 16.

2023-09-06 Thread Thomas Munro
Disable 031_recovery_conflict.pl in 15 and 16. This test fails due to known bugs in the test and the server. Those will be fixed in master shortly and possibly back-patched a bit later, but in the meantime it is unhelpful for package maintainers if the tests randomly fail, and it's not a good

pgsql: Disable 031_recovery_conflict.pl in 15 and 16.

2023-09-06 Thread Thomas Munro
Disable 031_recovery_conflict.pl in 15 and 16. This test fails due to known bugs in the test and the server. Those will be fixed in master shortly and possibly back-patched a bit later, but in the meantime it is unhelpful for package maintainers if the tests randomly fail, and it's not a good

pgsql: Remove the "snapshot too old" feature.

2023-09-05 Thread Thomas Munro
Remove the "snapshot too old" feature. Remove the old_snapshot_threshold setting and mechanism for producing the error "snapshot too old", originally added by commit 848ef42b. Unfortunately it had a number of known problems in terms of correctness and performance, mostly reported by Andres in the

pgsql: Rename hook functions for debug_io_direct to match variable name

2023-08-24 Thread Thomas Munro
Rename hook functions for debug_io_direct to match variable name. Commit 319bae9a renamed the GUC. Rename the check and assign functions to match, and alphabetize. Back-patch to 16. Author: Peter Eisentraut Discussion: https://postgr.es/m/2769341e-fa28-c2ee-3e4b-53fdcaaf2271%40eisentraut.org

pgsql: Rename hook functions for debug_io_direct to match variable name

2023-08-24 Thread Thomas Munro
Rename hook functions for debug_io_direct to match variable name. Commit 319bae9a renamed the GUC. Rename the check and assign functions to match, and alphabetize. Back-patch to 16. Author: Peter Eisentraut Discussion: https://postgr.es/m/2769341e-fa28-c2ee-3e4b-53fdcaaf2271%40eisentraut.org

pgsql: ExtendBufferedWhat -> BufferManagerRelation.

2023-08-22 Thread Thomas Munro
ExtendBufferedWhat -> BufferManagerRelation. Commit 31966b15 invented a way for functions dealing with relation extension to accept a Relation in online code and an SMgrRelation in recovery code. It seems highly likely that future bufmgr.c interfaces will face the same problem, and need to do

pgsql: ExtendBufferedWhat -> BufferManagerRelation.

2023-08-22 Thread Thomas Munro
ExtendBufferedWhat -> BufferManagerRelation. Commit 31966b15 invented a way for functions dealing with relation extension to accept a Relation in online code and an SMgrRelation in recovery code. It seems highly likely that future bufmgr.c interfaces will face the same problem, and need to do

Re: pgsql: Split out tiebreaker comparisons from comparetup_* functions

2023-08-18 Thread Thomas Munro
On Fri, Aug 18, 2023 at 12:48 AM John Naylor wrote: > On Thu, Aug 17, 2023 at 11:41 AM John Naylor > wrote: > > On Wed, Aug 16, 2023 at 5:17 PM John Naylor > > wrote: > > > > > > Split out tiebreaker comparisons from comparetup_* functions > > > > Hammerkop is getting OOM errors with this

pgsql: Don't probe extra libraries for fdatasync.

2023-08-16 Thread Thomas Munro
Don't probe extra libraries for fdatasync. Commit d2e15083 got rid of the main configure probe and HAVE_FDATASYNC macro, but we still searched -lrt and -lposix4 for old Solaris systems. It's in the C library on modern Solaris, as on other supported systems. Reviewed-by: Peter Eisentraut

pgsql: Remove traces of Sun -lposix4.

2023-08-16 Thread Thomas Munro
Remove traces of Sun -lposix4. This was a library on ancient Solaris systems, which was eventually replaced by -lrt, itself now redundant on that OS. Reviewed-by: Peter Eisentraut Reviewed-by: Tristan Partin Discussion:

pgsql: Invalidate smgr_targblock in smgrrelease().

2023-08-16 Thread Thomas Munro
Invalidate smgr_targblock in smgrrelease(). In rare circumstances involving relfilenode reuse, it might have been possible for smgr_targblock to finish up pointing past the end. Oversight in b74e94dc. Back-patch to 15. Reviewed-by: Heikki Linnakangas Discussion:

pgsql: Invalidate smgr_targblock in smgrrelease().

2023-08-16 Thread Thomas Munro
Invalidate smgr_targblock in smgrrelease(). In rare circumstances involving relfilenode reuse, it might have been possible for smgr_targblock to finish up pointing past the end. Oversight in b74e94dc. Back-patch to 15. Reviewed-by: Heikki Linnakangas Discussion:

pgsql: Invalidate smgr_targblock in smgrrelease().

2023-08-16 Thread Thomas Munro
Invalidate smgr_targblock in smgrrelease(). In rare circumstances involving relfilenode reuse, it might have been possible for smgr_targblock to finish up pointing past the end. Oversight in b74e94dc. Back-patch to 15. Reviewed-by: Heikki Linnakangas Discussion:

pgsql: De-pessimize ConditionVariableCancelSleep().

2023-08-14 Thread Thomas Munro
De-pessimize ConditionVariableCancelSleep(). Commit b91dd9de was concerned with a theoretical problem with our non-atomic condition variable operations. If you stop sleeping, and then cancel the sleep in a separate step, you might be signaled in between, and that could be lost. That doesn't

pgsql: De-pessimize ConditionVariableCancelSleep().

2023-08-14 Thread Thomas Munro
De-pessimize ConditionVariableCancelSleep(). Commit b91dd9de was concerned with a theoretical problem with our non-atomic condition variable operations. If you stop sleeping, and then cancel the sleep in a separate step, you might be signaled in between, and that could be lost. That doesn't

pgsql: Remove wal_sync_method=fsync_writethrough on Windows.

2023-07-13 Thread Thomas Munro
Remove wal_sync_method=fsync_writethrough on Windows. The "fsync" level already flushes drive write caches on Windows (as does "fdatasync"), so it only confuses matters to have an apparently higher level that isn't actually different at all. That leaves "fsync_writethrough" only for macOS, where

pgsql: Doc: Adjust libpq docs about thread safety.

2023-07-11 Thread Thomas Munro
Doc: Adjust libpq docs about thread safety. Describe the situation now that --disable-thread-safety is gone. Author: Heikki Linnakangas Discussion: https://postgr.es/m/CA%2BhUKGLtmexrpMtxBRLCVePqV_dtWG-ZsEbyPrYc%2BNBB2TkNsw%40mail.gmail.com Branch -- master Details ---

pgsql: Remove --disable-thread-safety and related code.

2023-07-11 Thread Thomas Munro
Remove --disable-thread-safety and related code. All supported computers have either POSIX or Windows threads, and we no longer have any automated testing of --disable-thread-safety. We define a vestigial ENABLE_THREAD_SAFETY macro to 1 in ecpg_config.h in case it is useful, but we no longer

pgsql: Don't expose Windows' mbstowcs_l() and wcstombs_l().

2023-07-10 Thread Thomas Munro
Don't expose Windows' mbstowcs_l() and wcstombs_l(). Windows has similar functions with leading underscores. Previously, we provided the rename via a macro in win32_port.h. In fact its functions are not always good replacements for the Unix functions, since they can't deal with UTF-8. They are

pgsql: Rename port/thread.c to port/user.c.

2023-07-09 Thread Thomas Munro
Rename port/thread.c to port/user.c. Historically this module dealt with thread-safety of system interfaces, but now all that's left is wrapper code for user name and home directory lookup. Arguably the Windows variants of this logic could be moved in here too, to justify its presence under

pgsql: Remove obsolete comment and code from fe-auth.c.

2023-07-08 Thread Thomas Munro
Remove obsolete comment and code from fe-auth.c. We don't use getpwuid() anymore (see commit e757cdd6), so we don't need locking around pg_get_user_name(). Reviewed-by: Andres Freund Reviewed-by: Peter Eisentraut Reviewed-by: Heikki Linnakangas Discussion:

pgsql: All supported systems have locale_t.

2023-07-08 Thread Thomas Munro
All supported systems have locale_t. locale_t is defined by POSIX.1-2008 and SUSv4, and available on all targeted systems. For Windows, win32_port.h redirects to a partial implementation called _locale_t. We can now remove a lot of compile-time tests for HAVE_LOCALE_T, and associated comments

pgsql: Re-bin segment when memory pages are freed.

2023-07-03 Thread Thomas Munro
be called whenever free pages are returned to the segment's free page map. Back-patch to all supported releases. Author: Dongming Liu Reviewed-by: Robert Haas (earlier version) Reviewed-by: Thomas Munro Discussion: https://postgr.es/m/CAL1p7e8LzB2LSeAXo2pXCW4%2BRya9s0sJ3G_ReKOU%3DAjSUWjHWQ

pgsql: Re-bin segment when memory pages are freed.

2023-07-03 Thread Thomas Munro
be called whenever free pages are returned to the segment's free page map. Back-patch to all supported releases. Author: Dongming Liu Reviewed-by: Robert Haas (earlier version) Reviewed-by: Thomas Munro Discussion: https://postgr.es/m/CAL1p7e8LzB2LSeAXo2pXCW4%2BRya9s0sJ3G_ReKOU%3DAjSUWjHWQ

pgsql: Re-bin segment when memory pages are freed.

2023-07-03 Thread Thomas Munro
be called whenever free pages are returned to the segment's free page map. Back-patch to all supported releases. Author: Dongming Liu Reviewed-by: Robert Haas (earlier version) Reviewed-by: Thomas Munro Discussion: https://postgr.es/m/CAL1p7e8LzB2LSeAXo2pXCW4%2BRya9s0sJ3G_ReKOU%3DAjSUWjHWQ

pgsql: Re-bin segment when memory pages are freed.

2023-07-03 Thread Thomas Munro
be called whenever free pages are returned to the segment's free page map. Back-patch to all supported releases. Author: Dongming Liu Reviewed-by: Robert Haas (earlier version) Reviewed-by: Thomas Munro Discussion: https://postgr.es/m/CAL1p7e8LzB2LSeAXo2pXCW4%2BRya9s0sJ3G_ReKOU%3DAjSUWjHWQ

pgsql: Re-bin segment when memory pages are freed.

2023-07-03 Thread Thomas Munro
be called whenever free pages are returned to the segment's free page map. Back-patch to all supported releases. Author: Dongming Liu Reviewed-by: Robert Haas (earlier version) Reviewed-by: Thomas Munro Discussion: https://postgr.es/m/CAL1p7e8LzB2LSeAXo2pXCW4%2BRya9s0sJ3G_ReKOU%3DAjSUWjHWQ

pgsql: Re-bin segment when memory pages are freed.

2023-07-03 Thread Thomas Munro
be called whenever free pages are returned to the segment's free page map. Back-patch to all supported releases. Author: Dongming Liu Reviewed-by: Robert Haas (earlier version) Reviewed-by: Thomas Munro Discussion: https://postgr.es/m/CAL1p7e8LzB2LSeAXo2pXCW4%2BRya9s0sJ3G_ReKOU%3DAjSUWjHWQ

pgsql: Re-bin segment when memory pages are freed.

2023-07-03 Thread Thomas Munro
be called whenever free pages are returned to the segment's free page map. Back-patch to all supported releases. Author: Dongming Liu Reviewed-by: Robert Haas (earlier version) Reviewed-by: Thomas Munro Discussion: https://postgr.es/m/CAL1p7e8LzB2LSeAXo2pXCW4%2BRya9s0sJ3G_ReKOU%3DAjSUWjHWQ

pgsql: Fix race in SSI interaction with bitmap heap scan.

2023-07-03 Thread Thomas Munro
Fix race in SSI interaction with bitmap heap scan. When performing a bitmap heap scan, we don't want to miss concurrent writes that occurred after we observed the heap's rs_nblocks, but before we took predicate locks on index pages. Therefore, we can't skip fetching any heap tuples that are

pgsql: Fix race in SSI interaction with empty btrees.

2023-07-03 Thread Thomas Munro
Fix race in SSI interaction with empty btrees. When predicate-locking btrees, we have a special case for completely empty btrees, since there is no page to lock. This was racy, because, without buffer lock held, a matching key could be inserted between the _bt_search() and the

pgsql: Fix race in SSI interaction with gin fast path.

2023-07-03 Thread Thomas Munro
Fix race in SSI interaction with gin fast path. The ginfast.c code previously checked for conflicts in before locking the relevant buffer, leaving a window where a RW conflict could be missed. Re-order. There was also a place where buffer ID and block number were confused while trying to

pgsql: Fix race in SSI interaction with bitmap heap scan.

2023-07-03 Thread Thomas Munro
Fix race in SSI interaction with bitmap heap scan. When performing a bitmap heap scan, we don't want to miss concurrent writes that occurred after we observed the heap's rs_nblocks, but before we took predicate locks on index pages. Therefore, we can't skip fetching any heap tuples that are

pgsql: Fix race in SSI interaction with empty btrees.

2023-07-03 Thread Thomas Munro
Fix race in SSI interaction with empty btrees. When predicate-locking btrees, we have a special case for completely empty btrees, since there is no page to lock. This was racy, because, without buffer lock held, a matching key could be inserted between the _bt_search() and the

<    1   2   3   4   5   6   7   8   9   10   >