pgsql: postgres_fdw and dblink should check if backend has MyProcPort

2025-08-08 Thread Peter Eisentraut
postgres_fdw and dblink should check if backend has MyProcPort

before checking ->has_scram_keys.  MyProcPort is NULL in background
workers.  So this could crash for example if a background worker
accessed a suitable configured foreign table.

Author: Alexander Pyhalov 
Reviewed-by: Peter Eisentraut 
Reviewed-by: Matheus Alcantara 
Discussion: 
https://www.postgresql.org/message-id/flat/27b29a35-9b96-46a9-bc1a-914140869dac%40gmail.com

Branch
--
REL_18_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/762fed90bfee248ca090a96fe883e063ba035088

Modified Files
--
contrib/dblink/dblink.c   | 8 
contrib/postgres_fdw/connection.c | 8 
2 files changed, 8 insertions(+), 8 deletions(-)



pgsql: postgres_fdw and dblink should check if backend has MyProcPort

2025-08-08 Thread Peter Eisentraut
postgres_fdw and dblink should check if backend has MyProcPort

before checking ->has_scram_keys.  MyProcPort is NULL in background
workers.  So this could crash for example if a background worker
accessed a suitable configured foreign table.

Author: Alexander Pyhalov 
Reviewed-by: Peter Eisentraut 
Reviewed-by: Matheus Alcantara 
Discussion: 
https://www.postgresql.org/message-id/flat/27b29a35-9b96-46a9-bc1a-914140869dac%40gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/138750dde4a8b939a30a6d650c6c8146192b39cb

Modified Files
--
contrib/dblink/dblink.c   | 8 
contrib/postgres_fdw/connection.c | 8 
2 files changed, 8 insertions(+), 8 deletions(-)



pgsql: First-draft release notes for 17.6.

2025-08-08 Thread Tom Lane
First-draft release notes for 17.6.

As usual, the release notes for other branches will be made by cutting
these down, but put them up for community review first.

Branch
--
REL_17_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/b70d9de77f337828ca3a0a3064a6827b1ce68977

Modified Files
--
doc/src/sgml/release-17.sgml | 1652 ++
1 file changed, 1652 insertions(+)



pgsql: Fix incorrect lack of Datum conversion in _int_matchsel()

2025-08-08 Thread Peter Eisentraut
Fix incorrect lack of Datum conversion in _int_matchsel()

The code used

return (Selectivity) 0.0;

where

PG_RETURN_FLOAT8(0.0);

would be correct.

On 64-bit systems, these are pretty much equivalent, but on 32-bit
systems, PG_RETURN_FLOAT8() correctly produces a pointer, but the old
wrong code would return a null pointer, possibly leading to a crash
elsewhere.

We think this code is actually not reachable because bqarr_in won't
accept an empty query, and there is no other function that will
create query_int values.  But better be safe and not let such
incorrect code lie around.

Reviewed-by: Tom Lane 
Discussion: 
https://www.postgresql.org/message-id/flat/8246d7ff-f4b7-4363-913e-827dadfeb145%40eisentraut.org

Branch
--
REL_17_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/276cdd4cc37845b31fb9048c4f32eeb33ae60e1a

Modified Files
--
contrib/intarray/_int_selfuncs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



pgsql: Fix incorrect lack of Datum conversion in _int_matchsel()

2025-08-08 Thread Peter Eisentraut
Fix incorrect lack of Datum conversion in _int_matchsel()

The code used

return (Selectivity) 0.0;

where

PG_RETURN_FLOAT8(0.0);

would be correct.

On 64-bit systems, these are pretty much equivalent, but on 32-bit
systems, PG_RETURN_FLOAT8() correctly produces a pointer, but the old
wrong code would return a null pointer, possibly leading to a crash
elsewhere.

We think this code is actually not reachable because bqarr_in won't
accept an empty query, and there is no other function that will
create query_int values.  But better be safe and not let such
incorrect code lie around.

Reviewed-by: Tom Lane 
Discussion: 
https://www.postgresql.org/message-id/flat/8246d7ff-f4b7-4363-913e-827dadfeb145%40eisentraut.org

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/fd2ab03fea23ad6183fe694e750c901c6ff38479

Modified Files
--
contrib/intarray/_int_selfuncs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



pgsql: Fix incorrect lack of Datum conversion in _int_matchsel()

2025-08-08 Thread Peter Eisentraut
Fix incorrect lack of Datum conversion in _int_matchsel()

The code used

return (Selectivity) 0.0;

where

PG_RETURN_FLOAT8(0.0);

would be correct.

On 64-bit systems, these are pretty much equivalent, but on 32-bit
systems, PG_RETURN_FLOAT8() correctly produces a pointer, but the old
wrong code would return a null pointer, possibly leading to a crash
elsewhere.

We think this code is actually not reachable because bqarr_in won't
accept an empty query, and there is no other function that will
create query_int values.  But better be safe and not let such
incorrect code lie around.

Reviewed-by: Tom Lane 
Discussion: 
https://www.postgresql.org/message-id/flat/8246d7ff-f4b7-4363-913e-827dadfeb145%40eisentraut.org

Branch
--
REL_13_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/387883f68c851e716476975229c539c938d1f206

Modified Files
--
contrib/intarray/_int_selfuncs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



pgsql: Fix incorrect lack of Datum conversion in _int_matchsel()

2025-08-08 Thread Peter Eisentraut
Fix incorrect lack of Datum conversion in _int_matchsel()

The code used

return (Selectivity) 0.0;

where

PG_RETURN_FLOAT8(0.0);

would be correct.

On 64-bit systems, these are pretty much equivalent, but on 32-bit
systems, PG_RETURN_FLOAT8() correctly produces a pointer, but the old
wrong code would return a null pointer, possibly leading to a crash
elsewhere.

We think this code is actually not reachable because bqarr_in won't
accept an empty query, and there is no other function that will
create query_int values.  But better be safe and not let such
incorrect code lie around.

Reviewed-by: Tom Lane 
Discussion: 
https://www.postgresql.org/message-id/flat/8246d7ff-f4b7-4363-913e-827dadfeb145%40eisentraut.org

Branch
--
REL_14_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/64dec8060c84b9b08c85fe5a757f10a4480ec484

Modified Files
--
contrib/intarray/_int_selfuncs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



pgsql: oauth: Remove stale events from the kqueue multiplexer

2025-08-08 Thread Jacob Champion
oauth: Remove stale events from the kqueue multiplexer

If a socket is added to the kqueue, becomes readable/writable, and
subsequently becomes non-readable/writable again, the kqueue itself will
remain readable until either the socket registration is removed, or the
stale event is cleared via a call to kevent().

In many simple cases, Curl itself will remove the socket registration
quickly, but in real-world usage, this is not guaranteed to happen. The
kqueue can then remain stuck in a permanently readable state until the
request ends, which results in pointless wakeups for the client and
wasted CPU time.

Implement comb_multiplexer() to call kevent() and unstick any stale
events that would cause unnecessary callbacks. This is called right
after drive_request(), before we return control to the client to wait.

Suggested-by: Thomas Munro 
Co-authored-by: Thomas Munro 
Reviewed-by: Thomas Munro 
Backpatch-through: 18
Discussion: 
https://postgr.es/m/caoymi+ndzxjhawj9_jrsyf8umtocadamofjeggskw-ky7au...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/ff5b0824b3b0c58bbb322719628c42b7a4751dd9

Modified Files
--
src/interfaces/libpq-oauth/oauth-curl.c | 67 ++---
1 file changed, 61 insertions(+), 6 deletions(-)



pgsql: oauth: Remove stale events from the kqueue multiplexer

2025-08-08 Thread Jacob Champion
oauth: Remove stale events from the kqueue multiplexer

If a socket is added to the kqueue, becomes readable/writable, and
subsequently becomes non-readable/writable again, the kqueue itself will
remain readable until either the socket registration is removed, or the
stale event is cleared via a call to kevent().

In many simple cases, Curl itself will remove the socket registration
quickly, but in real-world usage, this is not guaranteed to happen. The
kqueue can then remain stuck in a permanently readable state until the
request ends, which results in pointless wakeups for the client and
wasted CPU time.

Implement comb_multiplexer() to call kevent() and unstick any stale
events that would cause unnecessary callbacks. This is called right
after drive_request(), before we return control to the client to wait.

Suggested-by: Thomas Munro 
Co-authored-by: Thomas Munro 
Reviewed-by: Thomas Munro 
Backpatch-through: 18
Discussion: 
https://postgr.es/m/caoymi+ndzxjhawj9_jrsyf8umtocadamofjeggskw-ky7au...@mail.gmail.com

Branch
--
REL_18_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/ff181d1f876f32da332238879c3834a3e7825a46

Modified Files
--
src/interfaces/libpq-oauth/oauth-curl.c | 67 ++---
1 file changed, 61 insertions(+), 6 deletions(-)



pgsql: oauth: Remove expired timers from the multiplexer

2025-08-08 Thread Jacob Champion
oauth: Remove expired timers from the multiplexer

In a case similar to the previous commit, an expired timer can remain
permanently readable if Curl does not remove the timeout itself. Since
that removal isn't guaranteed to happen in real-world situations,
implement drain_timer_events() to reset the timer before calling into
drive_request().

Moving to drain_timer_events() happens to fix a logic bug in the
previous caller of timer_expired(), which treated an error condition as
if the timer were expired instead of bailing out.

The previous implementation of timer_expired() gave differing results
for epoll and kqueue if the timer was reset. (For epoll, a reset timer
was considered to be expired, and for kqueue it was not.) This didn't
previously cause problems, since timer_expired() was only called while
the timer was known to be set, but both implementations now use the
kqueue logic.

Reviewed-by: Thomas Munro 
Backpatch-through: 18
Discussion: 
https://postgr.es/m/caoymi+ndzxjhawj9_jrsyf8umtocadamofjeggskw-ky7au...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/1749a12f0d2005ba23236089f0a32e6c6c1533f0

Modified Files
--
src/interfaces/libpq-oauth/oauth-curl.c | 108 
1 file changed, 68 insertions(+), 40 deletions(-)



pgsql: oauth: Add unit tests for multiplexer handling

2025-08-08 Thread Jacob Champion
oauth: Add unit tests for multiplexer handling

To better record the internal behaviors of oauth-curl.c, add a unit test
suite for the socket and timer handling code. This is all based on TAP
and driven by our existing Test::More infrastructure.

Reviewed-by: Dagfinn Ilmari Mannsåker 
Discussion: 
https://postgr.es/m/caoymi+ndzxjhawj9_jrsyf8umtocadamofjeggskw-ky7au...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/1443b6c0eaa2b464affc0c3aacb3c3bf09efcd6d

Modified Files
--
src/interfaces/libpq-oauth/Makefile  |  14 +
src/interfaces/libpq-oauth/meson.build   |  35 ++
src/interfaces/libpq-oauth/t/001_oauth.pl|  24 ++
src/interfaces/libpq-oauth/test-oauth-curl.c | 527 +++
4 files changed, 600 insertions(+)



pgsql: oauth: Ensure unused socket registrations are removed

2025-08-08 Thread Jacob Champion
oauth: Ensure unused socket registrations are removed

If Curl needs to switch the direction of a socket's registration (e.g.
from CURL_POLL_IN to CURL_POLL_OUT), it expects the old registration to
be discarded. For epoll, this happened via EPOLL_CTL_MOD, but for
kqueue, the old registration would remain if it was not explicitly
removed by Curl.

Explicitly remove the opposite-direction event during registrations. (If
that event doesn't exist, we'll just get an ENOENT, which will be
ignored by the same code that handles CURL_POLL_REMOVE.) A few
assertions are also added to strengthen the relationship between the
number of events added, the number of events pulled off the queue, and
the lengths of the kevent arrays.

Reviewed-by: Thomas Munro 
Backpatch-through: 18
Discussion: 
https://postgr.es/m/caoymi+ndzxjhawj9_jrsyf8umtocadamofjeggskw-ky7au...@mail.gmail.com

Branch
--
REL_18_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/16b0c48583a5043f46d75cde99d8a3ffbd9c7c98

Modified Files
--
src/interfaces/libpq-oauth/oauth-curl.c | 22 ++
1 file changed, 14 insertions(+), 8 deletions(-)



pgsql: oauth: Remove expired timers from the multiplexer

2025-08-08 Thread Jacob Champion
oauth: Remove expired timers from the multiplexer

In a case similar to the previous commit, an expired timer can remain
permanently readable if Curl does not remove the timeout itself. Since
that removal isn't guaranteed to happen in real-world situations,
implement drain_timer_events() to reset the timer before calling into
drive_request().

Moving to drain_timer_events() happens to fix a logic bug in the
previous caller of timer_expired(), which treated an error condition as
if the timer were expired instead of bailing out.

The previous implementation of timer_expired() gave differing results
for epoll and kqueue if the timer was reset. (For epoll, a reset timer
was considered to be expired, and for kqueue it was not.) This didn't
previously cause problems, since timer_expired() was only called while
the timer was known to be set, but both implementations now use the
kqueue logic.

Reviewed-by: Thomas Munro 
Backpatch-through: 18
Discussion: 
https://postgr.es/m/caoymi+ndzxjhawj9_jrsyf8umtocadamofjeggskw-ky7au...@mail.gmail.com

Branch
--
REL_18_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/e507e08acf63ffa6777424f53cec24e6a1363571

Modified Files
--
src/interfaces/libpq-oauth/oauth-curl.c | 108 
1 file changed, 68 insertions(+), 40 deletions(-)



pgsql: oauth: Track total call count during a client flow

2025-08-08 Thread Jacob Champion
oauth: Track total call count during a client flow

Tracking down the bugs that led to the addition of comb_multiplexer()
and drain_timer_events() was difficult, because an inefficient flow is
not visibly different from one that is working properly. To help
maintainers notice when something has gone wrong, track the number of
calls into the flow as part of debug mode, and print the total when the
flow finishes.

A new test makes sure the total count is less than 100. (We expect
something on the order of 10.) This isn't foolproof, but it is able to
catch several regressions in the logic of the prior two commits, and
future work to add TLS support to the oauth_validator test server should
strengthen it as well.

Backpatch-through: 18
Discussion: 
https://postgr.es/m/caoymi+ndzxjhawj9_jrsyf8umtocadamofjeggskw-ky7au...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/3e311664e4974ea0eef708d54256aacbb0239c95

Modified Files
--
src/interfaces/libpq-oauth/oauth-curl.c  | 22 +
src/test/modules/oauth_validator/t/001_server.pl | 31 +++-
2 files changed, 52 insertions(+), 1 deletion(-)



pgsql: oauth: Track total call count during a client flow

2025-08-08 Thread Jacob Champion
oauth: Track total call count during a client flow

Tracking down the bugs that led to the addition of comb_multiplexer()
and drain_timer_events() was difficult, because an inefficient flow is
not visibly different from one that is working properly. To help
maintainers notice when something has gone wrong, track the number of
calls into the flow as part of debug mode, and print the total when the
flow finishes.

A new test makes sure the total count is less than 100. (We expect
something on the order of 10.) This isn't foolproof, but it is able to
catch several regressions in the logic of the prior two commits, and
future work to add TLS support to the oauth_validator test server should
strengthen it as well.

Backpatch-through: 18
Discussion: 
https://postgr.es/m/caoymi+ndzxjhawj9_jrsyf8umtocadamofjeggskw-ky7au...@mail.gmail.com

Branch
--
REL_18_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/41aac1483a6ce61c0a721c590caf838eae47

Modified Files
--
src/interfaces/libpq-oauth/oauth-curl.c  | 22 +
src/test/modules/oauth_validator/t/001_server.pl | 31 +++-
2 files changed, 52 insertions(+), 1 deletion(-)



pgsql: oauth: Ensure unused socket registrations are removed

2025-08-08 Thread Jacob Champion
oauth: Ensure unused socket registrations are removed

If Curl needs to switch the direction of a socket's registration (e.g.
from CURL_POLL_IN to CURL_POLL_OUT), it expects the old registration to
be discarded. For epoll, this happened via EPOLL_CTL_MOD, but for
kqueue, the old registration would remain if it was not explicitly
removed by Curl.

Explicitly remove the opposite-direction event during registrations. (If
that event doesn't exist, we'll just get an ENOENT, which will be
ignored by the same code that handles CURL_POLL_REMOVE.) A few
assertions are also added to strengthen the relationship between the
number of events added, the number of events pulled off the queue, and
the lengths of the kevent arrays.

Reviewed-by: Thomas Munro 
Backpatch-through: 18
Discussion: 
https://postgr.es/m/caoymi+ndzxjhawj9_jrsyf8umtocadamofjeggskw-ky7au...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/3d9c03429a82c199a77563ae5d57c4c9cefa3d41

Modified Files
--
src/interfaces/libpq-oauth/oauth-curl.c | 22 ++
1 file changed, 14 insertions(+), 8 deletions(-)



pgsql: pg_upgrade: Add missing newline in output, another one

2025-08-08 Thread Peter Eisentraut
pg_upgrade: Add missing newline in output, another one

This came from the backport of commit f295494d338, but older branches
require the explicit newline in messages (see commit 7652353d87a).

Branch
--
REL_15_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/18d2d8ae42af4d3a73b6ae067dead8663f92afb8

Modified Files
--
src/bin/pg_upgrade/check.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



pgsql: pg_upgrade: Add missing newline in output, another one

2025-08-08 Thread Peter Eisentraut
pg_upgrade: Add missing newline in output, another one

This came from the backport of commit f295494d338, but older branches
require the explicit newline in messages (see commit 7652353d87a).

Branch
--
REL_14_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/bef2c2a4ebefe5023368c7423ff8e06c98f6d32a

Modified Files
--
src/bin/pg_upgrade/check.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



pgsql: Mop-up for Datum conversion cleanups.

2025-08-08 Thread Tom Lane
Mop-up for Datum conversion cleanups.

Fix a couple more places where an explicit Datum conversion
is needed (not clear how we missed these in ff89e182d and
previous commits).

Replace the minority usage "(Datum) NULL" with "(Datum) 0".
The former depends on the assumption that Datum is the same
width as Pointer, the latter doesn't.  Anyway consistency
is a good thing.

This is, I believe, the last of the notational mop-up needed
before we can consider changing Datum to uint64 everywhere.
It's also important cleanup for more aggressive ideas such
as making Datum a struct.

Discussion: https://postgr.es/m/1749799.1752797...@sss.pgh.pa.us
Discussion: 
https://postgr.es/m/8246d7ff-f4b7-4363-913e-827dadfeb...@eisentraut.org

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/665c3dbba497b795c4ee46145777bc4eb89c78a1

Modified Files
--
contrib/ltree/_ltree_gist.c | 2 +-
src/backend/catalog/pg_aggregate.c  | 2 +-
src/backend/catalog/pg_constraint.c | 2 +-
src/backend/catalog/pg_conversion.c | 2 +-
src/backend/catalog/pg_namespace.c  | 2 +-
src/backend/catalog/pg_operator.c   | 4 ++--
src/backend/catalog/pg_type.c   | 2 +-
src/backend/executor/spi.c  | 2 +-
src/backend/nodes/readfuncs.c   | 2 +-
src/backend/utils/adt/jsonfuncs.c   | 6 +++---
src/backend/utils/adt/rangetypes.c  | 4 ++--
src/include/access/htup_details.h   | 2 +-
src/include/access/itup.h   | 2 +-
13 files changed, 17 insertions(+), 17 deletions(-)



pgsql: Fix rare bug in read_stream.c's split IO handling.

2025-08-08 Thread Thomas Munro
Fix rare bug in read_stream.c's split IO handling.

The internal queue of buffers could become corrupted in a rare edge case
that failed to invalidate an entry, causing a stale buffer to be
"forwarded" to StartReadBuffers().  This is a simple fix for the
immediate problem.

A small API change might be able to remove this and related fragility
entirely, but that will have to wait a bit.

Defect in commit ed0b87ca.

Bug: 19006
Backpatch-through: 18
Reported-by: Alexander Lakhin 
Reviewed-by: Tom Lane 
Reviewed-by: Michael Paquier 
Reviewed-by: Xuneng Zhou 
Discussion: https://postgr.es/m/19006-80fcaaf69000377e%40postgresql.org

Branch
--
REL_18_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/9110d81641696b95ea55f3a15dd0907ec0743529

Modified Files
--
src/backend/storage/aio/read_stream.c | 34 ++
1 file changed, 34 insertions(+)



Re: pgsql: oauth: Add unit tests for multiplexer handling

2025-08-08 Thread Jacob Champion
On Fri, Aug 8, 2025 at 9:07 AM Jacob Champion  wrote:
>
> oauth: Add unit tests for multiplexer handling

Hmm, this has broken a couple of animals. Investigating.

--Jacob




pgsql: Remove useless/superfluous Datum conversions

2025-08-08 Thread Peter Eisentraut
Remove useless/superfluous Datum conversions

Remove useless DatumGetFoo() and FooGetDatum() calls.  These are
places where no conversion from or to Datum was actually happening.

We think these extra calls covered here were harmless.  Some actual
bugs that were discovered during this process have been committed
separately (80c758a2e1d, 2242b26ce47).

Reviewed-by: Tom Lane 
Discussion: 
https://www.postgresql.org/message-id/flat/8246d7ff-f4b7-4363-913e-827dadfeb145%40eisentraut.org

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/dcfc0f891273eeeb85ce6e723decf5cc37f9b1c3

Modified Files
--
src/backend/commands/alter.c| 2 +-
src/backend/executor/execExprInterp.c   | 6 +++---
src/backend/rewrite/rewriteDefine.c | 5 ++---
src/backend/statistics/extended_stats.c | 2 +-
src/backend/tsearch/ts_parse.c  | 4 ++--
src/backend/utils/activity/pgstat.c | 2 +-
src/backend/utils/adt/json.c| 2 +-
src/backend/utils/adt/multirangetypes.c | 7 +++
src/backend/utils/adt/rangetypes.c  | 4 ++--
src/backend/utils/adt/varlena.c | 5 ++---
src/backend/utils/cache/relcache.c  | 2 +-
11 files changed, 19 insertions(+), 22 deletions(-)



pgsql: Add missing Datum conversions

2025-08-08 Thread Peter Eisentraut
Add missing Datum conversions

Add various missing conversions from and to Datum.  The previous code
mostly relied on implicit conversions or its own explicit casts
instead of using the correct DatumGet*() or *GetDatum() functions.

We think these omissions are harmless.  Some actual bugs that were
discovered during this process have been committed
separately (80c758a2e1d, fd2ab03fea2).

Reviewed-by: Tom Lane 
Discussion: 
https://www.postgresql.org/message-id/flat/8246d7ff-f4b7-4363-913e-827dadfeb145%40eisentraut.org

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/ff89e182d42048380dba32fee1b491893c7b4bec

Modified Files
--
contrib/btree_gist/btree_enum.c |  4 ++--
contrib/btree_gist/btree_numeric.c  |  2 +-
contrib/btree_gist/btree_utils_num.c| 22 +++---
contrib/intarray/_int_op.c  |  2 +-
contrib/pageinspect/heapfuncs.c |  2 +-
contrib/pgrowlocks/pgrowlocks.c |  4 ++--
contrib/seg/seg.c   |  4 ++--
src/backend/access/brin/brin.c  |  4 ++--
src/backend/access/brin/brin_bloom.c|  2 +-
src/backend/access/brin/brin_minmax.c   | 10 +-
src/backend/access/brin/brin_minmax_multi.c |  6 +++---
src/backend/access/common/heaptuple.c   |  2 +-
src/backend/access/common/toast_internals.c |  4 ++--
src/backend/catalog/objectaddress.c |  4 ++--
src/backend/catalog/pg_proc.c   |  2 +-
src/backend/catalog/pg_publication.c|  2 +-
src/backend/catalog/pg_shdepend.c   | 12 ++--
src/backend/commands/event_trigger.c|  4 ++--
src/backend/commands/subscriptioncmds.c |  8 
src/backend/commands/tablecmds.c|  2 +-
src/backend/commands/trigger.c  |  2 +-
src/backend/commands/tsearchcmds.c  |  8 
src/backend/commands/user.c |  6 +++---
src/backend/executor/execExprInterp.c   |  2 +-
src/backend/statistics/attribute_stats.c|  6 +++---
src/backend/storage/aio/aio_funcs.c |  2 +-
src/backend/storage/buffer/bufmgr.c |  4 ++--
src/backend/storage/ipc/shmem.c |  2 +-
src/backend/storage/lmgr/lock.c |  4 ++--
src/backend/utils/adt/datum.c   |  6 +++---
src/backend/utils/adt/jsonpath_exec.c   |  2 +-
src/backend/utils/adt/lockfuncs.c   |  8 
src/backend/utils/adt/multirangetypes.c | 12 ++--
src/backend/utils/adt/rangetypes.c  |  8 
src/backend/utils/adt/rangetypes_spgist.c   |  2 +-
src/backend/utils/adt/rowtypes.c|  4 ++--
src/backend/utils/adt/waitfuncs.c   |  2 +-
src/backend/utils/cache/attoptcache.c   |  2 +-
src/backend/utils/cache/lsyscache.c |  2 +-
src/backend/utils/cache/relcache.c  |  2 +-
src/backend/utils/cache/syscache.c  |  6 +++---
src/backend/utils/sort/sortsupport.c|  2 +-
src/backend/utils/sort/tuplesortvariants.c  |  6 +++---
src/pl/plperl/plperl.c  | 10 +-
src/test/regress/regress.c  |  2 +-
45 files changed, 107 insertions(+), 107 deletions(-)



pgsql: Fix incorrect lack of Datum conversion in _int_matchsel()

2025-08-08 Thread Peter Eisentraut
Fix incorrect lack of Datum conversion in _int_matchsel()

The code used

return (Selectivity) 0.0;

where

PG_RETURN_FLOAT8(0.0);

would be correct.

On 64-bit systems, these are pretty much equivalent, but on 32-bit
systems, PG_RETURN_FLOAT8() correctly produces a pointer, but the old
wrong code would return a null pointer, possibly leading to a crash
elsewhere.

We think this code is actually not reachable because bqarr_in won't
accept an empty query, and there is no other function that will
create query_int values.  But better be safe and not let such
incorrect code lie around.

Reviewed-by: Tom Lane 
Discussion: 
https://www.postgresql.org/message-id/flat/8246d7ff-f4b7-4363-913e-827dadfeb145%40eisentraut.org

Branch
--
REL_16_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/a3906b44c5b920cd7beb569a097660f487adf883

Modified Files
--
contrib/intarray/_int_selfuncs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



Re: pgsql: oauth: Add unit tests for multiplexer handling

2025-08-08 Thread Jacob Champion
On Fri, Aug 8, 2025 at 9:46 AM Jacob Champion
 wrote:
> Is the buildfarm client trying to build that directory explicitly?

Ah, yeah:

> foreach my $testdir (
>glob(
>"$pgsql/src/test/modules/*
> $pgsql/src/interfaces/*
> $pgsql/src/tools/*"
>)
>  )

Before this commit, there was no t/ directory to get caught by the
buildfarm. We've had to work around this in past, it looks like:

> next if $testname =~ /ssl/ && !$using_ssl;

Thinking...

--Jacob




Re: pgsql: oauth: Add unit tests for multiplexer handling

2025-08-08 Thread Jacob Champion
On Fri, Aug 8, 2025 at 9:42 AM Tom Lane  wrote:
> At least on sifaka, oauth_tests should not be getting built at all,
> because it doesn't use --with-libcurl nor have access to that library.
> The link failure is unsurprising given that you're trying to build it
> anyway.

src/interfaces/libpq-oauth/Makefile is supposed to be skipped if
with_libcurl isn't there, though? Otherwise we'd fail to build the
`all` target, too.

Is the buildfarm client trying to build that directory explicitly?

--Jacob




Re: pgsql: oauth: Add unit tests for multiplexer handling

2025-08-08 Thread Jacob Champion
On Fri, Aug 8, 2025 at 10:01 AM Tom Lane  wrote:
> Yeah, that's a horrid kluge.  The makefiles themselves ought to
> short-circuit building the test program.  I think the issue is that
> we apply that short-circuit at the next makefile level up --- can
> we do it in src/interfaces/libpq-oauth/Makefile itself?

I'm working on an ifeq test to do that, but some Meson animals are
also reporting issues:

/usr/bin/ld: test-oauth-curl.o: undefined reference to symbol
'floor@@GLIBC_2.2.5'
/usr/bin/ld: /lib/x86_64-linux-gnu/libm.so.6: error adding symbols:
DSO missing from command line
clang: error: linker command failed with exit code 1 (use -v to see invocation)

This is not fully baked enough. I'll revert the test commit for now;
today is not the day to make other people fight a red farm.

--Jacob




Re: pgsql: oauth: Add unit tests for multiplexer handling

2025-08-08 Thread Tom Lane
Jacob Champion  writes:
> Before this commit, there was no t/ directory to get caught by the
> buildfarm. We've had to work around this in past, it looks like:
>> next if $testname =~ /ssl/ && !$using_ssl;

Yeah, that's a horrid kluge.  The makefiles themselves ought to
short-circuit building the test program.  I think the issue is that
we apply that short-circuit at the next makefile level up --- can
we do it in src/interfaces/libpq-oauth/Makefile itself?

regards, tom lane




Re: pgsql: oauth: Add unit tests for multiplexer handling

2025-08-08 Thread Tom Lane
Jacob Champion  writes:
> Hmm, this has broken a couple of animals. Investigating.

At least on sifaka, oauth_tests should not be getting built at all,
because it doesn't use --with-libcurl nor have access to that library.
The link failure is unsurprising given that you're trying to build it
anyway.

regards, tom lane




pgsql: Revert "oauth: Add unit tests for multiplexer handling"

2025-08-08 Thread Jacob Champion
Revert "oauth: Add unit tests for multiplexer handling"

Commit 1443b6c0e introduced buildfarm breakage for Autoconf animals,
which expect to be able to run `make installcheck` on the libpq-oauth
directory even if libcurl support is disabled. Some other Meson animals
complained of a missing -lm link as well.

Since this is the day before a freeze, revert for now and come back
later.

Discussion: 
https://postgr.es/m/CAOYmi%2BnCkoh3zB%2BGkZad44%3DFNskwUg6F1kmuxqQZzng7Zgj5tw%40mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/ebaaf386adb133010c2024256521b993c5e53e98

Modified Files
--
src/interfaces/libpq-oauth/Makefile  |  14 -
src/interfaces/libpq-oauth/meson.build   |  35 --
src/interfaces/libpq-oauth/t/001_oauth.pl|  24 --
src/interfaces/libpq-oauth/test-oauth-curl.c | 527 ---
4 files changed, 600 deletions(-)



Re: pgsql: oauth: Add unit tests for multiplexer handling

2025-08-08 Thread Tom Lane
Jacob Champion  writes:
> So when I go for a followup next week... I could
> 1) wrap just the installcheck and check targets in ifeq
> 2) wrap the `all` target in addition to the above
> 3) wrap everything after the Makefile.global inclusion
> Any preferences?

I think it'd be advisable to keep the "clean" target doing its thing.
But I agree with disabling 'all', 'check', 'installcheck'.

regards, tom lane




Re: pgsql: oauth: Add unit tests for multiplexer handling

2025-08-08 Thread Jacob Champion
On Fri, Aug 8, 2025 at 10:05 AM Jacob Champion
 wrote:
>
> I'll revert the test commit for now;
> today is not the day to make other people fight a red farm.

Reverted.

So when I go for a followup next week... I could
1) wrap just the installcheck and check targets in ifeq
2) wrap the `all` target in addition to the above
3) wrap everything after the Makefile.global inclusion

Any preferences?

--Jacob




pgsql: Fix incorrect lack of Datum conversion in _int_matchsel()

2025-08-08 Thread Peter Eisentraut
Fix incorrect lack of Datum conversion in _int_matchsel()

The code used

return (Selectivity) 0.0;

where

PG_RETURN_FLOAT8(0.0);

would be correct.

On 64-bit systems, these are pretty much equivalent, but on 32-bit
systems, PG_RETURN_FLOAT8() correctly produces a pointer, but the old
wrong code would return a null pointer, possibly leading to a crash
elsewhere.

We think this code is actually not reachable because bqarr_in won't
accept an empty query, and there is no other function that will
create query_int values.  But better be safe and not let such
incorrect code lie around.

Reviewed-by: Tom Lane 
Discussion: 
https://www.postgresql.org/message-id/flat/8246d7ff-f4b7-4363-913e-827dadfeb145%40eisentraut.org

Branch
--
REL_18_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/992a18f5161cf36147eedaf7ac1d0af8a89646dc

Modified Files
--
contrib/intarray/_int_selfuncs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



pgsql: Fix incorrect lack of Datum conversion in _int_matchsel()

2025-08-08 Thread Peter Eisentraut
Fix incorrect lack of Datum conversion in _int_matchsel()

The code used

return (Selectivity) 0.0;

where

PG_RETURN_FLOAT8(0.0);

would be correct.

On 64-bit systems, these are pretty much equivalent, but on 32-bit
systems, PG_RETURN_FLOAT8() correctly produces a pointer, but the old
wrong code would return a null pointer, possibly leading to a crash
elsewhere.

We think this code is actually not reachable because bqarr_in won't
accept an empty query, and there is no other function that will
create query_int values.  But better be safe and not let such
incorrect code lie around.

Reviewed-by: Tom Lane 
Discussion: 
https://www.postgresql.org/message-id/flat/8246d7ff-f4b7-4363-913e-827dadfeb145%40eisentraut.org

Branch
--
REL_15_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/f0d55b68ef920b5ed22c3788a5dfc15fe1f70be7

Modified Files
--
contrib/intarray/_int_selfuncs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



pgsql: Remove obsolete comment.

2025-08-08 Thread Thomas Munro
Remove obsolete comment.

Remove a comment about potential for AIO in StartReadBuffersImpl(),
because that change happened.

Branch
--
REL_18_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/4cd9d5fc158d31afd07485e8497b7f33d3f20c6c

Modified Files
--
src/backend/storage/buffer/bufmgr.c | 5 -
1 file changed, 5 deletions(-)



pgsql: Remove obsolete comment.

2025-08-08 Thread Thomas Munro
Remove obsolete comment.

Remove a comment about potential for AIO in StartReadBuffersImpl(),
because that change happened.

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/b5cd74612c26ec3f96dfe3689acd634db9385d2e

Modified Files
--
src/backend/storage/buffer/bufmgr.c | 5 -
1 file changed, 5 deletions(-)



pgsql: Fix oversight in FindTriggerIncompatibleWithInheritance.

2025-08-08 Thread Etsuro Fujita
Fix oversight in FindTriggerIncompatibleWithInheritance.

This function is called from ATExecAttachPartition/ATExecAddInherit,
which prevent tables with row-level triggers with transition tables from
becoming partitions or inheritance children, to check if there is such a
trigger on the given table, but failed to check if a found trigger is
row-level, causing the caller functions to needlessly prevent a table
with only a statement-level trigger with transition tables from becoming
a partition or inheritance child.  Repair.

Oversight in commit 501ed02cf.

Author: Etsuro Fujita 
Discussion: 
https://postgr.es/m/CAPmGK167mXzwzzmJ_0YZ3EZrbwiCxtM1vogH_8drqsE6PtxRYw%40mail.gmail.com
Backpatch-through: 13

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/9e63f83a7e7f8211581bfe9e9d05b72695261f4f

Modified Files
--
src/backend/commands/trigger.c |  2 ++
src/test/regress/expected/triggers.out |  8 
src/test/regress/sql/triggers.sql  | 10 ++
3 files changed, 20 insertions(+)



pgsql: Fix oversight in FindTriggerIncompatibleWithInheritance.

2025-08-08 Thread Etsuro Fujita
Fix oversight in FindTriggerIncompatibleWithInheritance.

This function is called from ATExecAttachPartition/ATExecAddInherit,
which prevent tables with row-level triggers with transition tables from
becoming partitions or inheritance children, to check if there is such a
trigger on the given table, but failed to check if a found trigger is
row-level, causing the caller functions to needlessly prevent a table
with only a statement-level trigger with transition tables from becoming
a partition or inheritance child.  Repair.

Oversight in commit 501ed02cf.

Author: Etsuro Fujita 
Discussion: 
https://postgr.es/m/CAPmGK167mXzwzzmJ_0YZ3EZrbwiCxtM1vogH_8drqsE6PtxRYw%40mail.gmail.com
Backpatch-through: 13

Branch
--
REL_14_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/73eb6afa13605d9bb619752180b739fd3c4ba168

Modified Files
--
src/backend/commands/trigger.c |  2 ++
src/test/regress/expected/triggers.out |  8 
src/test/regress/sql/triggers.sql  | 10 ++
3 files changed, 20 insertions(+)



pgsql: Fix oversight in FindTriggerIncompatibleWithInheritance.

2025-08-08 Thread Etsuro Fujita
Fix oversight in FindTriggerIncompatibleWithInheritance.

This function is called from ATExecAttachPartition/ATExecAddInherit,
which prevent tables with row-level triggers with transition tables from
becoming partitions or inheritance children, to check if there is such a
trigger on the given table, but failed to check if a found trigger is
row-level, causing the caller functions to needlessly prevent a table
with only a statement-level trigger with transition tables from becoming
a partition or inheritance child.  Repair.

Oversight in commit 501ed02cf.

Author: Etsuro Fujita 
Discussion: 
https://postgr.es/m/CAPmGK167mXzwzzmJ_0YZ3EZrbwiCxtM1vogH_8drqsE6PtxRYw%40mail.gmail.com
Backpatch-through: 13

Branch
--
REL_18_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/bba6a6fafc8ae5d2e364b713568068941a929d5f

Modified Files
--
src/backend/commands/trigger.c |  2 ++
src/test/regress/expected/triggers.out |  8 
src/test/regress/sql/triggers.sql  | 10 ++
3 files changed, 20 insertions(+)



pgsql: Fix oversight in FindTriggerIncompatibleWithInheritance.

2025-08-08 Thread Etsuro Fujita
Fix oversight in FindTriggerIncompatibleWithInheritance.

This function is called from ATExecAttachPartition/ATExecAddInherit,
which prevent tables with row-level triggers with transition tables from
becoming partitions or inheritance children, to check if there is such a
trigger on the given table, but failed to check if a found trigger is
row-level, causing the caller functions to needlessly prevent a table
with only a statement-level trigger with transition tables from becoming
a partition or inheritance child.  Repair.

Oversight in commit 501ed02cf.

Author: Etsuro Fujita 
Discussion: 
https://postgr.es/m/CAPmGK167mXzwzzmJ_0YZ3EZrbwiCxtM1vogH_8drqsE6PtxRYw%40mail.gmail.com
Backpatch-through: 13

Branch
--
REL_15_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/f39a7f32aefcd424bdbe001f08718eaad5170d6b

Modified Files
--
src/backend/commands/trigger.c |  2 ++
src/test/regress/expected/triggers.out |  8 
src/test/regress/sql/triggers.sql  | 10 ++
3 files changed, 20 insertions(+)



pgsql: Fix oversight in FindTriggerIncompatibleWithInheritance.

2025-08-08 Thread Etsuro Fujita
Fix oversight in FindTriggerIncompatibleWithInheritance.

This function is called from ATExecAttachPartition/ATExecAddInherit,
which prevent tables with row-level triggers with transition tables from
becoming partitions or inheritance children, to check if there is such a
trigger on the given table, but failed to check if a found trigger is
row-level, causing the caller functions to needlessly prevent a table
with only a statement-level trigger with transition tables from becoming
a partition or inheritance child.  Repair.

Oversight in commit 501ed02cf.

Author: Etsuro Fujita 
Discussion: 
https://postgr.es/m/CAPmGK167mXzwzzmJ_0YZ3EZrbwiCxtM1vogH_8drqsE6PtxRYw%40mail.gmail.com
Backpatch-through: 13

Branch
--
REL_16_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/3863c6fb696cf57718483a3bf0abbf05e382abe1

Modified Files
--
src/backend/commands/trigger.c |  2 ++
src/test/regress/expected/triggers.out |  8 
src/test/regress/sql/triggers.sql  | 10 ++
3 files changed, 20 insertions(+)



pgsql: Fix oversight in FindTriggerIncompatibleWithInheritance.

2025-08-08 Thread Etsuro Fujita
Fix oversight in FindTriggerIncompatibleWithInheritance.

This function is called from ATExecAttachPartition/ATExecAddInherit,
which prevent tables with row-level triggers with transition tables from
becoming partitions or inheritance children, to check if there is such a
trigger on the given table, but failed to check if a found trigger is
row-level, causing the caller functions to needlessly prevent a table
with only a statement-level trigger with transition tables from becoming
a partition or inheritance child.  Repair.

Oversight in commit 501ed02cf.

Author: Etsuro Fujita 
Discussion: 
https://postgr.es/m/CAPmGK167mXzwzzmJ_0YZ3EZrbwiCxtM1vogH_8drqsE6PtxRYw%40mail.gmail.com
Backpatch-through: 13

Branch
--
REL_17_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/e028ce911ad21e23ca39555e01a2d6c41c76aa79

Modified Files
--
src/backend/commands/trigger.c |  2 ++
src/test/regress/expected/triggers.out |  8 
src/test/regress/sql/triggers.sql  | 10 ++
3 files changed, 20 insertions(+)



pgsql: Fix oversight in FindTriggerIncompatibleWithInheritance.

2025-08-08 Thread Etsuro Fujita
Fix oversight in FindTriggerIncompatibleWithInheritance.

This function is called from ATExecAttachPartition/ATExecAddInherit,
which prevent tables with row-level triggers with transition tables from
becoming partitions or inheritance children, to check if there is such a
trigger on the given table, but failed to check if a found trigger is
row-level, causing the caller functions to needlessly prevent a table
with only a statement-level trigger with transition tables from becoming
a partition or inheritance child.  Repair.

Oversight in commit 501ed02cf.

Author: Etsuro Fujita 
Discussion: 
https://postgr.es/m/CAPmGK167mXzwzzmJ_0YZ3EZrbwiCxtM1vogH_8drqsE6PtxRYw%40mail.gmail.com
Backpatch-through: 13

Branch
--
REL_13_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/afdb4cde14948cdeb83701f457ecbfc4522c1a06

Modified Files
--
src/backend/commands/trigger.c |  2 ++
src/test/regress/expected/triggers.out |  8 
src/test/regress/sql/triggers.sql  | 10 ++
3 files changed, 20 insertions(+)



pgsql: Fix rare bug in read_stream.c's split IO handling.

2025-08-08 Thread Thomas Munro
Fix rare bug in read_stream.c's split IO handling.

The internal queue of buffers could become corrupted in a rare edge case
that failed to invalidate an entry, causing a stale buffer to be
"forwarded" to StartReadBuffers().  This is a simple fix for the
immediate problem.

A small API change might be able to remove this and related fragility
entirely, but that will have to wait a bit.

Defect in commit ed0b87ca.

Bug: 19006
Backpatch-through: 18
Reported-by: Alexander Lakhin 
Reviewed-by: Tom Lane 
Reviewed-by: Michael Paquier 
Reviewed-by: Xuneng Zhou 
Discussion: https://postgr.es/m/19006-80fcaaf69000377e%40postgresql.org

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/b421223172a28db2e724d5e35304097fe68a1e38

Modified Files
--
src/backend/storage/aio/read_stream.c | 34 ++
1 file changed, 34 insertions(+)