pgsql: Use palloc_object() and palloc_array(), the last change

2025-12-10 Thread Michael Paquier
Use palloc_object() and palloc_array(), the last change This is the last batch of changes that have been suggested by the author, this part covering the non-trivial changes. Some of the changes suggested have been discarded as they seem to lead to more instructions generated, leaving the parts th

pgsql: pg_buffercache: Fix memory allocation formula

2025-12-10 Thread Michael Paquier
pg_buffercache: Fix memory allocation formula The code over-allocated the memory required for os_page_status, relying on uint64 for its element size instead of an int, hence doubling what was required. This could mean quite a lot of memory if dealing with a lot of NUMA pages. Oversight in ba2a3c

pgsql: pg_buffercache: Fix memory allocation formula

2025-12-10 Thread Michael Paquier
pg_buffercache: Fix memory allocation formula The code over-allocated the memory required for os_page_status, relying on uint64 for its element size instead of an int, hence doubling what was required. This could mean quite a lot of memory if dealing with a lot of NUMA pages. Oversight in ba2a3c

pgsql: Enhance slot synchronization API to respect promotion signal.

2025-12-10 Thread Amit Kapila
Enhance slot synchronization API to respect promotion signal. Previously, during a promotion, only the slot synchronization worker was signaled to shut down. The backend executing slot synchronization via the pg_sync_replication_slots() SQL function was not signaled, allowing it to complete its sy

pgsql: Clarify why _bt_killitems sorts its items array.

2025-12-10 Thread Peter Geoghegan
Clarify why _bt_killitems sorts its items array. Make it clear why _bt_killitems sorts the scan's so->killedItems[] array. Also add an assertion to the _bt_killitems loop (that iterates through this array) to verify it accesses tuples in leaf page order. Follow-up to commit bfb335df58. Author:

pgsql: Fix allocation formula in llvmjit_expr.c

2025-12-10 Thread Michael Paquier
Fix allocation formula in llvmjit_expr.c An array of LLVMBasicBlockRef is allocated with the size used for an element being "LLVMBasicBlockRef *" rather than "LLVMBasicBlockRef". LLVMBasicBlockRef is a type that refers to a pointer, so this did not directly cause a problem because both should have

pgsql: Fix allocation formula in llvmjit_expr.c

2025-12-10 Thread Michael Paquier
Fix allocation formula in llvmjit_expr.c An array of LLVMBasicBlockRef is allocated with the size used for an element being "LLVMBasicBlockRef *" rather than "LLVMBasicBlockRef". LLVMBasicBlockRef is a type that refers to a pointer, so this did not directly cause a problem because both should have

pgsql: Fix allocation formula in llvmjit_expr.c

2025-12-10 Thread Michael Paquier
Fix allocation formula in llvmjit_expr.c An array of LLVMBasicBlockRef is allocated with the size used for an element being "LLVMBasicBlockRef *" rather than "LLVMBasicBlockRef". LLVMBasicBlockRef is a type that refers to a pointer, so this did not directly cause a problem because both should have

pgsql: Fix allocation formula in llvmjit_expr.c

2025-12-10 Thread Michael Paquier
Fix allocation formula in llvmjit_expr.c An array of LLVMBasicBlockRef is allocated with the size used for an element being "LLVMBasicBlockRef *" rather than "LLVMBasicBlockRef". LLVMBasicBlockRef is a type that refers to a pointer, so this did not directly cause a problem because both should have

pgsql: Fix allocation formula in llvmjit_expr.c

2025-12-10 Thread Michael Paquier
Fix allocation formula in llvmjit_expr.c An array of LLVMBasicBlockRef is allocated with the size used for an element being "LLVMBasicBlockRef *" rather than "LLVMBasicBlockRef". LLVMBasicBlockRef is a type that refers to a pointer, so this did not directly cause a problem because both should have

pgsql: Fix allocation formula in llvmjit_expr.c

2025-12-10 Thread Michael Paquier
Fix allocation formula in llvmjit_expr.c An array of LLVMBasicBlockRef is allocated with the size used for an element being "LLVMBasicBlockRef *" rather than "LLVMBasicBlockRef". LLVMBasicBlockRef is a type that refers to a pointer, so this did not directly cause a problem because both should have

Re: pgsql: Widen MultiXactOffset to 64 bits

2025-12-10 Thread Peter Geoghegan
On Wed, Dec 10, 2025 at 5:14 PM Peter Geoghegan wrote: > Noticed a minor issue. This seems to have broken MULTIXACT_DEBUG builds, here: Never mind. Pushed a fix for this myself just now. Thanks -- Peter Geoghegan

pgsql: Fix MULTIXACT_DEBUG builds.

2025-12-10 Thread Peter Geoghegan
Fix MULTIXACT_DEBUG builds. Oversight in commit bd8d9c9b. Discussion: https://postgr.es/m/CAH2-WzmvwVKZ+0Z=rl_+g_aoku8qxwdddcxmtylj02y+nya...@mail.gmail.com Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/473cb1b9512ef8ae5ec3ea42bcebeb7d39e79ce4 Modified Files --

Re: pgsql: Widen MultiXactOffset to 64 bits

2025-12-10 Thread Peter Geoghegan
On Tue, Dec 9, 2025 at 6:57 AM Heikki Linnakangas wrote: > Widen MultiXactOffset to 64 bits Thanks for working on this! Noticed a minor issue. This seems to have broken MULTIXACT_DEBUG builds, here: ../source/src/backend/access/transam/multixact.c:2195:61: error: expected ')' 2195 | de

pgsql: Allow PG_PRINTF_ATTRIBUTE to be different in C and C++ code.

2025-12-10 Thread Tom Lane
Allow PG_PRINTF_ATTRIBUTE to be different in C and C++ code. Although clang claims to be compatible with gcc's printf format archetypes, this appears to be a falsehood: it likes __syslog__ (which gcc does not, on most platforms) and doesn't accept gnu_printf. This means that if you try to use gcc

pgsql: Return TIDs in desc order during backwards scans.

2025-12-10 Thread Peter Geoghegan
Return TIDs in desc order during backwards scans. Always return TIDs in descending order when returning groups of TIDs from an nbtree posting list tuple during nbtree backwards scans. This makes backwards scans tend to require fewer buffer hits, since the scan is less likely to repeatedly pin and

pgsql: Add pg_iswcased().

2025-12-10 Thread Jeff Davis
Add pg_iswcased(). True if character has multiple case forms. Will be a useful multibyte-aware replacement for char_is_cased(). Reviewed-by: Chao Li Reviewed-by: Peter Eisentraut Discussion: https://postgr.es/m/[email protected] Branch -- master D

pgsql: Remove char_tolower() API.

2025-12-10 Thread Jeff Davis
Remove char_tolower() API. It's only useful for an ILIKE optimization for the libc provider using a single-byte encoding and a non-C locale, but it creates significant internal complexity. Reviewed-by: Chao Li Reviewed-by: Peter Eisentraut Discussion: https://postgr.es/m/450ceb6260cad30d7afdf1

pgsql: Fix bogus extra arguments to query_safe in test

2025-12-10 Thread Heikki Linnakangas
Fix bogus extra arguments to query_safe in test The test seemed to incorrectly think that query_safe() takes an argument that describes what the query does, similar to e.g. command_ok(). Until commit bd8d9c9bdf the extra arguments were harmless and were just ignored, but when commit bd8d9c9bdf int

pgsql: Fix bogus extra arguments to query_safe in test

2025-12-10 Thread Heikki Linnakangas
Fix bogus extra arguments to query_safe in test The test seemed to incorrectly think that query_safe() takes an argument that describes what the query does, similar to e.g. command_ok(). Until commit bd8d9c9bdf the extra arguments were harmless and were just ignored, but when commit bd8d9c9bdf int

pgsql: Fix bogus extra arguments to query_safe in test

2025-12-10 Thread Heikki Linnakangas
Fix bogus extra arguments to query_safe in test The test seemed to incorrectly think that query_safe() takes an argument that describes what the query does, similar to e.g. command_ok(). Until commit bd8d9c9bdf the extra arguments were harmless and were just ignored, but when commit bd8d9c9bdf int

pgsql: Improve DDL deparsing test

2025-12-10 Thread Heikki Linnakangas
Improve DDL deparsing test 1. The test initially focuses on the "parent" table, then switches to the "part" table, and goes back to the "parent" table. That seems a little weird, so move the tests around so that all the commands on the "parent" table are done first, followed by the "part" table.

pgsql: Add comment about keeping PD_ALL_VISIBLE and VM in sync

2025-12-10 Thread Melanie Plageman
Add comment about keeping PD_ALL_VISIBLE and VM in sync The comment above heap_xlog_visible() about the critical integrity requirement for PD_ALL_VISIBLE and the visibility map should also be in heap_xlog_prune_freeze() where we set PD_ALL_VISIBLE. Oversight in add323da40a6bf9e Author: Melanie P

pgsql: Simplify vacuum visibility assertion

2025-12-10 Thread Melanie Plageman
Simplify vacuum visibility assertion Phase I vacuum gives the page a once-over after pruning and freezing to check that the values of all_visible and all_frozen agree with the result of heap_page_is_all_visible(). This is meant to keep the logic in phase I for determining visibility in sync with t

pgsql: Fix comment in GetPublicationRelations

2025-12-10 Thread Heikki Linnakangas
Fix comment in GetPublicationRelations This function gets the list of relations associated with the publication but the comment said the opposite. Author: Shlok Kyal Discussion: https://www.postgresql.org/message-id/CANhcyEV3C_CGBeDtjvKjALDJDMH-Uuc9BWfSd=eck8SCXnE=f...@mail.gmail.com Branch --

pgsql: Fix some near-bugs related to ResourceOwner function arguments

2025-12-10 Thread Heikki Linnakangas
Fix some near-bugs related to ResourceOwner function arguments These functions took a ResourceOwner argument, but only checked if it was NULL, and then used CurrentResourceOwner for the actual work. Surely the intention was to use the passed-in resource owner. All current callers passed CurrentRes

pgsql: Fix some near-bugs related to ResourceOwner function arguments

2025-12-10 Thread Heikki Linnakangas
Fix some near-bugs related to ResourceOwner function arguments These functions took a ResourceOwner argument, but only checked if it was NULL, and then used CurrentResourceOwner for the actual work. Surely the intention was to use the passed-in resource owner. All current callers passed CurrentRes

pgsql: Fix some near-bugs related to ResourceOwner function arguments

2025-12-10 Thread Heikki Linnakangas
Fix some near-bugs related to ResourceOwner function arguments These functions took a ResourceOwner argument, but only checked if it was NULL, and then used CurrentResourceOwner for the actual work. Surely the intention was to use the passed-in resource owner. All current callers passed CurrentRes

Re: pgsql: injection_points: Remove portions related to custom pgstats

2025-12-10 Thread Heikki Linnakangas
On 10/12/2025 07:53, Michael Paquier wrote: On Wed, Dec 10, 2025 at 01:05:39PM +0900, Michael Paquier wrote: All that should be now addressed with 1d7b00dc14b8 (down to v17) and 06817fc8a4b7 (HEAD only for nbtree). Let's see what the buildfarm thinks. And crake is now green. Thanks all for t