Re: pgsql: pg_logicalinspect: Fix possible crash when passing a directory p

2025-03-11 Thread Tom Lane
Masahiko Sawada writes: > On Tue, Mar 11, 2025 at 7:08 PM David Rowley wrote: >> This introduces a new compiler warning for compilers that don't know >> the ereport(ERROR) does not return. > Thank you for the report. Can we generate the warning using some gcc's > warning flags? I'd like to add a

Re: pgsql: pg_logicalinspect: Fix possible crash when passing a directory p

2025-03-11 Thread Masahiko Sawada
On Tue, Mar 11, 2025 at 7:08 PM David Rowley wrote: > > On Wed, 12 Mar 2025 at 05:57, Masahiko Sawada wrote: > > contrib/pg_logicalinspect/pg_logicalinspect.c | 55 --- > > This introduces a new compiler warning for compilers that don't know > the ereport(ERROR) does not return. >

Re: pgsql: Doc: silence A4 PDF build warnings.

2025-03-11 Thread Tom Lane
Peter Geoghegan writes: > On Tue, Mar 11, 2025 at 11:36 PM Tom Lane wrote: >> Per buildfarm. > What buildfarm animal? I didn't see anything about this today. crake and alabio. They're just warnings, so you have to actually go look to notice them. regards, tom lane

Re: pgsql: Doc: silence A4 PDF build warnings.

2025-03-11 Thread Peter Geoghegan
On Tue, Mar 11, 2025 at 11:36 PM Tom Lane wrote: > Per buildfarm. What buildfarm animal? I didn't see anything about this today. Thanks, though. -- Peter Geoghegan

pgsql: Doc: silence A4 PDF build warnings.

2025-03-11 Thread Tom Lane
Doc: silence A4 PDF build warnings. Commit 0fbceae84 put a "&zwsp;" in almost but not quite the correct place to avoid "The contents of fo:block line 1 exceed the available area" warnings. Per buildfarm. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/c872516d8fe5b

Re: pgsql: pg_logicalinspect: Fix possible crash when passing a directory p

2025-03-11 Thread David Rowley
On Wed, 12 Mar 2025 at 05:57, Masahiko Sawada wrote: > contrib/pg_logicalinspect/pg_logicalinspect.c | 55 --- This introduces a new compiler warning for compilers that don't know the ereport(ERROR) does not return. The attached is enough to fix it. David fix_parse_snapshot_fi

pgsql: Improve snapmgr.c comment

2025-03-11 Thread Heikki Linnakangas
Improve snapmgr.c comment Add more details on the different kinds of snapshots, how to use them, and how the active snapshot stack works. Discussion: https://www.postgresql.org/message-id/7c56f180-b9e1-481e-8c1d-efa63de3e...@iki.fi Branch -- master Details --- https://git.postgresql.or

pgsql: Assert that a snapshot is active or registered before it's used

2025-03-11 Thread Heikki Linnakangas
Assert that a snapshot is active or registered before it's used The comment in GetTransactionSnapshot() said that you "should call RegisterSnapshot or PushActiveSnapshot on the returned snap if it is to be used very long". That felt too unclear to me. Make the comment more strongly worded. To enf

pgsql: Doc: improve description of window function processing.

2025-03-11 Thread Tom Lane
Doc: improve description of window function processing. The previous wording talked about a "single pass over the data", which can be read as promising more than intended (to wit, that only one WindowAgg plan node will be used). What we promise is only what the SQL spec requires, namely that the

pgsql: Doc: improve description of window function processing.

2025-03-11 Thread Tom Lane
Doc: improve description of window function processing. The previous wording talked about a "single pass over the data", which can be read as promising more than intended (to wit, that only one WindowAgg plan node will be used). What we promise is only what the SQL spec requires, namely that the

pgsql: Fix snapshot used in logical replication index lookup

2025-03-11 Thread Heikki Linnakangas
Fix snapshot used in logical replication index lookup The function calls GetLatestSnapshot() to acquire a fresh snapshot, makes it active, and was meant to pass it to table_tuple_lock(), but instead called GetLatestSnapshot() again to acquire yet another snapshot. It was harmless because the heap

pgsql: Fix some performance issues in GIN query startup.

2025-03-11 Thread Tom Lane
Fix some performance issues in GIN query startup. If a GIN index search had a lot of search keys (for example, "jsonbcol ?| array[]" with tens of thousands of array elements), both ginFillScanKey() and startScanKey() took O(N^2) time. Worse, those loops were uncancelable for lack of CHECK_FOR_INTE

pgsql: Doc: improve description of window function processing.

2025-03-11 Thread Tom Lane
Doc: improve description of window function processing. The previous wording talked about a "single pass over the data", which can be read as promising more than intended (to wit, that only one WindowAgg plan node will be used). What we promise is only what the SQL spec requires, namely that the

pgsql: Fix snapshot used in logical replication index lookup

2025-03-11 Thread Heikki Linnakangas
Fix snapshot used in logical replication index lookup The function calls GetLatestSnapshot() to acquire a fresh snapshot, makes it active, and was meant to pass it to table_tuple_lock(), but instead called GetLatestSnapshot() again to acquire yet another snapshot. It was harmless because the heap

pgsql: Fix snapshot used in logical replication index lookup

2025-03-11 Thread Heikki Linnakangas
Fix snapshot used in logical replication index lookup The function calls GetLatestSnapshot() to acquire a fresh snapshot, makes it active, and was meant to pass it to table_tuple_lock(), but instead called GetLatestSnapshot() again to acquire yet another snapshot. It was harmless because the heap

pgsql: Fix a few more redundant calls of GetLatestSnapshot()

2025-03-11 Thread Heikki Linnakangas
Fix a few more redundant calls of GetLatestSnapshot() Commit 2367503177 fixed this in RelationFindReplTupleByIndex(), but I missed two other similar cases. Per report from Ranier Vilela. Discussion: https://www.postgresql.org/message-id/caeudqarut1de45wn87f-gb7xmy_hw6x1dfd3sqdhhxp-rmd...@mail.g

pgsql: Fix some performance issues in GIN query startup.

2025-03-11 Thread Tom Lane
Fix some performance issues in GIN query startup. If a GIN index search had a lot of search keys (for example, "jsonbcol ?| array[]" with tens of thousands of array elements), both ginFillScanKey() and startScanKey() took O(N^2) time. Worse, those loops were uncancelable for lack of CHECK_FOR_INTE

pgsql: Fix a few more redundant calls of GetLatestSnapshot()

2025-03-11 Thread Heikki Linnakangas
Fix a few more redundant calls of GetLatestSnapshot() Commit 2367503177 fixed this in RelationFindReplTupleByIndex(), but I missed two other similar cases. Per report from Ranier Vilela. Discussion: https://www.postgresql.org/message-id/caeudqarut1de45wn87f-gb7xmy_hw6x1dfd3sqdhhxp-rmd...@mail.g

pgsql: Add special case fast-paths for strict functions

2025-03-11 Thread Daniel Gustafsson
Add special case fast-paths for strict functions Many STRICT function calls will have one or two arguments, in which case we can speed up checking for NULL input by avoiding setting up a loop over the arguments. This adds EEOP_FUNCEXPR_STRICT_1 and the corresponding EEOP_FUNCEXPR_STRICT_2 for func

pgsql: Fix snapshot used in logical replication index lookup

2025-03-11 Thread Heikki Linnakangas
Fix snapshot used in logical replication index lookup The function calls GetLatestSnapshot() to acquire a fresh snapshot, makes it active, and was meant to pass it to table_tuple_lock(), but instead called GetLatestSnapshot() again to acquire yet another snapshot. It was harmless because the heap

pgsql: Fix a few more redundant calls of GetLatestSnapshot()

2025-03-11 Thread Heikki Linnakangas
Fix a few more redundant calls of GetLatestSnapshot() Commit 2367503177 fixed this in RelationFindReplTupleByIndex(), but I missed two other similar cases. Per report from Ranier Vilela. Discussion: https://www.postgresql.org/message-id/caeudqarut1de45wn87f-gb7xmy_hw6x1dfd3sqdhhxp-rmd...@mail.g

pgsql: pg_logicalinspect: Fix possible crash when passing a directory p

2025-03-11 Thread Masahiko Sawada
pg_logicalinspect: Fix possible crash when passing a directory path. Previously, pg_logicalinspect functions were too trusting of their input and blindly passed it to SnapBuildRestoreSnapshot(). If the input pointed to a directory, the server could a PANIC error while attempting to fsync_fname() w

pgsql: Move RemoveInheritedConstraint() call slightly earlier

2025-03-11 Thread Peter Eisentraut
Move RemoveInheritedConstraint() call slightly earlier This change is harmless and does not affect the existing intended operation. It is necessary for a subsequent patch operation (NOT ENFORCED foreign keys), where we may need to change the child constraint to enforced. In this case, we would c

pgsql: refactor: re-add ATExecAlterChildConstr()

2025-03-11 Thread Peter Eisentraut
refactor: re-add ATExecAlterChildConstr() ATExecAlterChildConstr() was removed in commit 80d7f990496, but it is needed in some subsequent patches for the NOT ENFORCED feature, to recurse over child constraints. This adds it back in slightly altered form. Author: Amul Sul Reviewed-by: Alexandra

pgsql: pg_logicalinspect: Stabilize isolation tests.

2025-03-11 Thread Masahiko Sawada
pg_logicalinspect: Stabilize isolation tests. The previous isolation tests did not account for the possibility that the background writer or the checkpointer could write a RUNNING_XACTS record, which could cause logical decoding to produce more logical snapshots than expected. This commit modifie

pgsql: Improve EXPLAIN's display of window functions.

2025-03-11 Thread Tom Lane
Improve EXPLAIN's display of window functions. Up to now we just punted on showing the window definitions used in a plan, with window function calls represented as "OVER (?)". To improve that, show the window definition implemented by each WindowAgg plan node, and reference their window names in O

pgsql: nbtree: Make BTMaxItemSize into object-like macro.

2025-03-11 Thread Peter Geoghegan
nbtree: Make BTMaxItemSize into object-like macro. Make nbtree's "1/3 of a page limit" BTMaxItemSize function-like macro (which accepts a "page" argument) into an object-like macro that can be used from code that doesn't have convenient access to an nbtree page. Preparation for an upcoming patch

pgsql: Show index search count in EXPLAIN ANALYZE, take 2.

2025-03-11 Thread Peter Geoghegan
Show index search count in EXPLAIN ANALYZE, take 2. Expose the count of index searches/index descents in EXPLAIN ANALYZE's output for index scan/index-only scan/bitmap index scan nodes. This information is particularly useful with scans that use ScalarArrayOp quals, where the number of index sear

pgsql: Update nls.mk for newly added file

2025-03-11 Thread Peter Eisentraut
Update nls.mk for newly added file Commit f18231e8175 moved some code to a new file, but the new file wasn't added to nls.mk. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/12c5f797ea6a8e96de661e3838410b9775061796 Modified Files -- src/interfaces/ecpg/

pgsql: BRIN: be more strict about required support procs

2025-03-11 Thread Álvaro Herrera
BRIN: be more strict about required support procs With improperly defined operator classes, it's possible to get a Postgres crash because we'd try to invoke a procedure that doesn't exist. This is because the code is being a bit too trusting that the opclass is correctly defined. Add some erepor

pgsql: BRIN: be more strict about required support procs

2025-03-11 Thread Álvaro Herrera
BRIN: be more strict about required support procs With improperly defined operator classes, it's possible to get a Postgres crash because we'd try to invoke a procedure that doesn't exist. This is because the code is being a bit too trusting that the opclass is correctly defined. Add some erepor

pgsql: BRIN: be more strict about required support procs

2025-03-11 Thread Álvaro Herrera
BRIN: be more strict about required support procs With improperly defined operator classes, it's possible to get a Postgres crash because we'd try to invoke a procedure that doesn't exist. This is because the code is being a bit too trusting that the opclass is correctly defined. Add some erepor

pgsql: BRIN: be more strict about required support procs

2025-03-11 Thread Álvaro Herrera
BRIN: be more strict about required support procs With improperly defined operator classes, it's possible to get a Postgres crash because we'd try to invoke a procedure that doesn't exist. This is because the code is being a bit too trusting that the opclass is correctly defined. Add some erepor

pgsql: BRIN: be more strict about required support procs

2025-03-11 Thread Álvaro Herrera
BRIN: be more strict about required support procs With improperly defined operator classes, it's possible to get a Postgres crash because we'd try to invoke a procedure that doesn't exist. This is because the code is being a bit too trusting that the opclass is correctly defined. Add some erepor

pgsql: BRIN: be more strict about required support procs

2025-03-11 Thread Álvaro Herrera
BRIN: be more strict about required support procs With improperly defined operator classes, it's possible to get a Postgres crash because we'd try to invoke a procedure that doesn't exist. This is because the code is being a bit too trusting that the opclass is correctly defined. Add some erepor

Re: pgsql: tests: Fix race condition in postmaster/002_connection_limits

2025-03-11 Thread Andrew Dunstan
On 2025-03-07 Fr 1:22 PM, Andres Freund wrote: tests: Fix race condition in postmaster/002_connection_limits The test occasionally failed due to unexpected connection limit errors being encountered after having waited for FATAL errors on another connection. These spurious failures were caused

pgsql: Replace EEOP_DONE with special steps for return/no return

2025-03-11 Thread Daniel Gustafsson
Replace EEOP_DONE with special steps for return/no return Knowing when the side-effects of an expression is the intended result of the execution, rather than the returnvalue, is important for being able generate more efficient JITed code. This replaces EEOP_DONE with two new steps: EEOP_DONE_RETUR

Re: pgsql: refactor: re-add ATExecAlterChildConstr()

2025-03-11 Thread Álvaro Herrera
On 2025-Mar-11, Peter Eisentraut wrote: > refactor: re-add ATExecAlterChildConstr() > > ATExecAlterChildConstr() was removed in commit 80d7f990496, but it is > needed in some subsequent patches for the NOT ENFORCED feature, to > recurse over child constraints. This adds it back in slightly alter

pgsql: refactor: Split tryAttachPartitionForeignKey()

2025-03-11 Thread Peter Eisentraut
refactor: Split tryAttachPartitionForeignKey() Split tryAttachPartitionForeignKey() into three functions: AttachPartitionForeignKey(), RemoveInheritedConstraint(), and DropForeignKeyConstraintTriggers(), so they can be reused in some subsequent patches for the NOT ENFORCED feature. Author: Amul S