pgsql: Increase BAS_BULKREAD based on effective_io_concurrency

2025-04-07 Thread Andres Freund
Increase BAS_BULKREAD based on effective_io_concurrency Before, BAS_BULKREAD was always of size 256kB. With the default io_combine_limit of 16, that only allowed 1-2 IOs to be in flight - insufficient even on very low latency storage. We don't just want to increase the size to a much larger hardc

pgsql: Add pg_buffercache_evict_{relation,all} functions

2025-04-07 Thread Andres Freund
Add pg_buffercache_evict_{relation,all} functions In addition to the added functions, the pg_buffercache_evict() function now shows whether the buffer was flushed. pg_buffercache_evict_relation(): Evicts all shared buffers in a relation at once. pg_buffercache_evict_all(): Evicts all shared buffe

pgsql: Speedup child EquivalenceMember lookup in planner

2025-04-07 Thread David Rowley
Speedup child EquivalenceMember lookup in planner When planning queries to partitioned tables, we clone all EquivalenceMembers belonging to the partitioned table into em_is_child EquivalenceMembers for each non-pruned partition. For partitioned tables with large numbers of partitions, this meant

pgsql: aio: Make AIO more compatible with valgrind

2025-04-07 Thread Andres Freund
aio: Make AIO more compatible with valgrind In some edge cases valgrind flags issues with the memory referenced by IOs. All of the cases addressed in this change are false positives. Most of the false positives are caused by UnpinBuffer[NoOwner] marking buffer data as inaccessible. This happens e

Re: pgsql: Transfer statistics during pg_upgrade.

2025-04-07 Thread David Rowley
On Thu, 20 Feb 2025 at 22:29, Jeff Davis wrote: > Add support to pg_dump for dumping stats, and use that during > pg_upgrade so that statistics are transferred during upgrade. In most > cases this removes the need for a costly re-analyze after upgrade. I was surprised to see when I did pg_dump -T

pgsql: Stabilize 035_standby_logical_decoding.pl.

2025-04-07 Thread Amit Kapila
Stabilize 035_standby_logical_decoding.pl. Some tests try to invalidate logical slots on the standby server by running VACUUM on the primary. The problem is that xl_running_xacts was getting generated and replayed before the VACUUM command, leading to the advancement of the active slot's catalog_x

pgsql: Stabilize 035_standby_logical_decoding.pl.

2025-04-07 Thread Amit Kapila
Stabilize 035_standby_logical_decoding.pl. Some tests try to invalidate logical slots on the standby server by running VACUUM on the primary. The problem is that xl_running_xacts was getting generated and replayed before the VACUUM command, leading to the advancement of the active slot's catalog_x

pgsql: Fix PG 17 [NOT] NULL optimization bug for domains

2025-04-07 Thread Bruce Momjian
Fix PG 17 [NOT] NULL optimization bug for domains A PG 17 optimization allowed columns with NOT NULL constraints to skip table scans for IS NULL queries, and to skip IS NOT NULL checks for IS NOT NULL queries. This didn't work for domain types, since domain types don't follow the IS NULL/IS NOT N

pgsql: Fix PG 17 [NOT] NULL optimization bug for domains

2025-04-07 Thread Bruce Momjian
Fix PG 17 [NOT] NULL optimization bug for domains A PG 17 optimization allowed columns with NOT NULL constraints to skip table scans for IS NULL queries, and to skip IS NOT NULL checks for IS NOT NULL queries. This didn't work for domain types, since domain types don't follow the IS NULL/IS NOT N

pgsql: Add support for basic NUMA awareness

2025-04-07 Thread Tomas Vondra
Add support for basic NUMA awareness Add basic NUMA awareness routines, using a minimal src/port/pg_numa.c portability wrapper and an optional build dependency, enabled by --with-libnuma configure option. For now this is Linux-only, other platforms may be supported later. A built-in SQL function

pgsql: Add pg_buffercache_numa view with NUMA node info

2025-04-07 Thread Tomas Vondra
Add pg_buffercache_numa view with NUMA node info Introduces a new view pg_buffercache_numa, showing NUMA memory nodes for individual buffers. For each buffer the view returns an entry for each memory page, with the associated NUMA node. The database blocks and OS memory pages may have different s

pgsql: Introduce pg_shmem_allocations_numa view

2025-04-07 Thread Tomas Vondra
Introduce pg_shmem_allocations_numa view Introduce new pg_shmem_alloctions_numa view with information about how shared memory is distributed across NUMA nodes. For each shared memory segment, the view returns one row for each NUMA node backing it, with the total amount of memory allocated from tha

pgsql: Use specific collation where needed in new test

2025-04-07 Thread Álvaro Herrera
Use specific collation where needed in new test Oversight in commit a379061a22a8. Per Czech buildfarm members jay and hippopotamus. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/17bcf4f5450430f67b744c225566c9e0e6413e95 Modified Files -- src/test/regr

pgsql: Fix some issues in contrib/spi/refint.c.

2025-04-07 Thread Tom Lane
Fix some issues in contrib/spi/refint.c. check_foreign_key incorrectly used a single cache entry for its saved plans for a 'c' (cascade) trigger, although there are two different queries to execute depending on whether it fires for an update or a delete. This caused the wrong things to be done if

pgsql: localbuf: Add Valgrind buffer access instrumentation

2025-04-07 Thread Andres Freund
localbuf: Add Valgrind buffer access instrumentation This mirrors 1e0dfd166b3 (+ 46ef520b9566), for temporary table buffers. This is mainly interesting right now because the AIO work currently triggers spurious valgrind errors, and the fix for that is cleaner if temp buffers behave the same as sha

Re: pgsql: Allow NOT NULL constraints to be added as NOT VALID

2025-04-07 Thread Andres Freund
Hi, On 2025-04-07 17:20:21 +, Álvaro Herrera wrote: > Allow NOT NULL constraints to be added as NOT VALID Looks like the test results aren't quite stable across collations: https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=jay&dt=2025-04-07%2017%3A56%3A49 https://buildfarm.postgresql.o

pgsql: doc: Fix a typo in pg_recvlogical documentation.

2025-04-07 Thread Masahiko Sawada
doc: Fix a typo in pg_recvlogical documentation. Oversight in cf2655a9029a. Author: Zhijie Hou Discussion: https://postgr.es/m/os3pr01mb5718dd1466e2b9043448ae5094...@os3pr01mb5718.jpnprd01.prod.outlook.com Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/a13d49014

pgsql: Follow-up fixes for SHA-2 patch (commit 749a9e20c).

2025-04-07 Thread Tom Lane
Follow-up fixes for SHA-2 patch (commit 749a9e20c). This changes the check for valid characters in the salt string to only allow plain ASCII letters and digits. The previous coding was locale-dependent which doesn't really seem like a great idea here; moreover it could not work correctly in multi

pgsql: Allow NOT NULL constraints to be added as NOT VALID

2025-04-07 Thread Álvaro Herrera
Allow NOT NULL constraints to be added as NOT VALID This allows them to be added without scanning the table, and validating them afterwards without holding access exclusive lock on the table after any violating rows have been deleted or fixed. Doing ALTER TABLE ... SET NOT NULL for a column that

pgsql: Clean up error messages from 1495eff7bdb

2025-04-07 Thread Andrew Dunstan
Clean up error messages from 1495eff7bdb Quote file names, and mostly avoid hard coded file names. Along the way make a few other minor improvements. Discussion: https://postgr.es/m/20250407.152721.1397761902317499205.horikyota@gmail.com Branch -- master Details --- https://git.pos

pgsql: Add local-address escape "%L" to log_line_prefix.

2025-04-07 Thread Tom Lane
Add local-address escape "%L" to log_line_prefix. This escape shows the numeric server IP address that the client has connected to. Unix-socket connections will show "[local]". Non-client processes (e.g. background processes) will show "[none]". We expect that this option will be of interest to

pgsql: Revert "Use workaround of __builtin_setjmp only on MINGW on MSVC

2025-04-07 Thread Andrew Dunstan
Revert "Use workaround of __builtin_setjmp only on MINGW on MSVCRT" This reverts commit c313fa4602defe1be947370ab5b217ca163a1e3c. This is found to cause issues on x86_64 Windows even when using UCRT. Discussion: https://postgr.es/m/3312149.1744001...@sss.pgh.pa.us Branch -- master Details

Re: pgsql: Convert 'x IN (VALUES ...)' to 'x = ANY ...' then appropriate

2025-04-07 Thread Melanie Plageman
On Mon, Apr 7, 2025 at 5:15 AM David Rowley wrote: > Are these failures from patches applied to master prior to 3ba2cdaa? Yea, my email was held in moderation for days. I guess cross-posting is flagged. I thought I saw people regularly cc pgsql-hackers when replying to pgsql-committers, but I g

Re: pgsql: Convert 'x IN (VALUES ...)' to 'x = ANY ...' then appropriate

2025-04-07 Thread Alexander Korotkov
Hi, David! On Mon, Apr 7, 2025 at 12:15 PM David Rowley wrote: > > On Mon, 7 Apr 2025 at 19:39, Melanie Plageman > wrote: > > +++ > > C:/cirrus/build/testrun/pg_upgrade/002_pg_upgrade/data/results/subselect.out > > 2025-04-04 14:47:20.358393500 + > > @@ -2769,15 +2769,16 @@ > > EXPLAIN (C

pgsql: read_stream: Fix overflow hazard with large shared buffers

2025-04-07 Thread Andres Freund
read_stream: Fix overflow hazard with large shared buffers If the limit returned by GetAdditionalPinLimit() is large, the buffer_limit variable in read_stream_start_pending_read() can overflow. While the code is careful to limit buffer_limit PG_INT16_MAX, we subsequently add the number of forwarde

pgsql: Remove GUC_NOT_IN_SAMPLE from enable_self_join_elimination

2025-04-07 Thread Alexander Korotkov
Remove GUC_NOT_IN_SAMPLE from enable_self_join_elimination fc069a3a6319 implements Self-Join Elimination (SJE) and provides a new GUC variable: enable_self_join_elimination. This new GUC variable was marked as GUC_NOT_IN_SAMPLE. However, enable_self_join_elimination is documented and is not diff

pgsql: psql: Clarify help message for WATCH_INTERVAL

2025-04-07 Thread Daniel Gustafsson
psql: Clarify help message for WATCH_INTERVAL The help message for WATCH_INTERVAL was hard to interpret and didn't follow the style of other messages, this updates it to nake it fit in better and be easier to interpret. Author: Daniel Gustafsson Reported-by: Kyotaro Horiguchi Reviewed-by: David

Re: pgsql: Convert 'x IN (VALUES ...)' to 'x = ANY ...' then appropriate

2025-04-07 Thread David Rowley
On Mon, 7 Apr 2025 at 19:39, Melanie Plageman wrote: > +++ > C:/cirrus/build/testrun/pg_upgrade/002_pg_upgrade/data/results/subselect.out > 2025-04-04 14:47:20.358393500 + > @@ -2769,15 +2769,16 @@ > EXPLAIN (COSTS OFF) > SELECT c.oid,c.relname FROM pg_class c JOIN pg_am a USING (oid) > WH

Re: pgsql: Convert 'x IN (VALUES ...)' to 'x = ANY ...' then appropriate

2025-04-07 Thread Alexander Korotkov
On Fri, Apr 4, 2025 at 6:47 PM Melanie Plageman wrote: > > On Fri, Apr 4, 2025 at 9:17 AM Alexander Korotkov > wrote: > > > > Convert 'x IN (VALUES ...)' to 'x = ANY ...' then appropriate > > > > This commit implements the automatic conversion of 'x IN (VALUES ...)' into > > ScalarArrayOpExpr. T

Re: pgsql: Convert 'x IN (VALUES ...)' to 'x = ANY ...' then appropriate

2025-04-07 Thread Melanie Plageman
On Fri, Apr 4, 2025 at 9:17 AM Alexander Korotkov wrote: > > Convert 'x IN (VALUES ...)' to 'x = ANY ...' then appropriate > > This commit implements the automatic conversion of 'x IN (VALUES ...)' into > ScalarArrayOpExpr. That simplifies the query tree, eliminating the appearance > of an unnece

pgsql: Fix grammar in log message of pg_restore.c

2025-04-07 Thread Michael Paquier
Fix grammar in log message of pg_restore.c Introduced by 1495eff7bdb0. Author: Kyotaro Horiguchi Discussion: https://postgr.es/m/20250407.151359.72428746612514925.horikyota@gmail.com Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/d6f118444db320d13b70e7fbb8ea