pgsql: Remove useless casts to Pointer

2025-12-02 Thread Peter Eisentraut
Remove useless casts to Pointer in arguments of memcpy() and memmove() calls Reviewed-by: Chao Li Reviewed-by: Bertrand Drouvot Discussion: https://www.postgresql.org/message-id/4154950a-47ae-4223-bd01-1235cc50e933%40eisentraut.org Branch -- master Details --- https://git.postgresql.

pgsql: Use more appropriate DatumGet* function

2025-12-02 Thread Peter Eisentraut
Use more appropriate DatumGet* function Use DatumGetCString() instead of DatumGetPointer() for returning a C string. Right now, they are the same, but that doesn't always have to be so. Reviewed-by: Chao Li Reviewed-by: Bertrand Drouvot Discussion: https://www.postgresql.org/message-id/415495

pgsql: Fix shadow variable warning in subscriptioncmds.c.

2025-12-02 Thread Amit Kapila
Fix shadow variable warning in subscriptioncmds.c. Author: Shlok Kyal Author: Peter Smith Reviewed-by: Chao Li Reviewed-by: Vignesh C Discussion: https://postgr.es/m/CAHut+PsF8R0Bt4J3c92+T2F0mun0rRfK=-gh+ibv2s-o8ah...@mail.gmail.com Branch -- master Details --- https://git.postgresq

pgsql: Use LW_SHARED in dsa.c where possible.

2025-12-02 Thread Nathan Bossart
Use LW_SHARED in dsa.c where possible. Both dsa_get_total_size() and dsa_get_total_size_from_handle() take an exclusive lock just to read a variable. This commit reduces the lock level to LW_SHARED in those functions. Reviewed-by: Sami Imseih Discussion: https://postgr.es/m/aS8fMzWs9e8iHxk2%40n

pgsql: Fix amcheck's handling of half-dead B-tree pages

2025-12-02 Thread Heikki Linnakangas
Fix amcheck's handling of half-dead B-tree pages amcheck incorrectly reported the following error if there were any half-dead pages in the index: ERROR: mismatch between parent key and child high key in index "amchecktest_id_idx" It's expected that a half-dead page does not have a downlink in t

pgsql: Fix amcheck's handling of half-dead B-tree pages

2025-12-02 Thread Heikki Linnakangas
Fix amcheck's handling of half-dead B-tree pages amcheck incorrectly reported the following error if there were any half-dead pages in the index: ERROR: mismatch between parent key and child high key in index "amchecktest_id_idx" It's expected that a half-dead page does not have a downlink in t

pgsql: Fix amcheck's handling of incomplete root splits in B-tree

2025-12-02 Thread Heikki Linnakangas
Fix amcheck's handling of incomplete root splits in B-tree When the root page is being split, it's normal that root page according to the metapage is not marked BTP_ROOT. Fix bogus error in amcheck about that case. Reviewed-by: Peter Geoghegan Discussion: https://www.postgresql.org/message-id/a

pgsql: Add a test for half-dead pages in B-tree indexes

2025-12-02 Thread Heikki Linnakangas
Add a test for half-dead pages in B-tree indexes To increase our test coverage in general, and because I will use this in the next commit to test a bug we currently have in amcheck. Reviewed-by: Peter Geoghegan Discussion: https://www.postgresql.org/message-id/33e39552-6a2a-46f3-8b34-3f9f80044.

pgsql: Fix amcheck's handling of incomplete root splits in B-tree

2025-12-02 Thread Heikki Linnakangas
Fix amcheck's handling of incomplete root splits in B-tree When the root page is being split, it's normal that root page according to the metapage is not marked BTP_ROOT. Fix bogus error in amcheck about that case. Reviewed-by: Peter Geoghegan Discussion: https://www.postgresql.org/message-id/a

pgsql: Fix amcheck's handling of half-dead B-tree pages

2025-12-02 Thread Heikki Linnakangas
Fix amcheck's handling of half-dead B-tree pages amcheck incorrectly reported the following error if there were any half-dead pages in the index: ERROR: mismatch between parent key and child high key in index "amchecktest_id_idx" It's expected that a half-dead page does not have a downlink in t

pgsql: Fix amcheck's handling of incomplete root splits in B-tree

2025-12-02 Thread Heikki Linnakangas
Fix amcheck's handling of incomplete root splits in B-tree When the root page is being split, it's normal that root page according to the metapage is not marked BTP_ROOT. Fix bogus error in amcheck about that case. Reviewed-by: Peter Geoghegan Discussion: https://www.postgresql.org/message-id/a

pgsql: Fix amcheck's handling of incomplete root splits in B-tree

2025-12-02 Thread Heikki Linnakangas
Fix amcheck's handling of incomplete root splits in B-tree When the root page is being split, it's normal that root page according to the metapage is not marked BTP_ROOT. Fix bogus error in amcheck about that case. Reviewed-by: Peter Geoghegan Discussion: https://www.postgresql.org/message-id/a

pgsql: Fix amcheck's handling of half-dead B-tree pages

2025-12-02 Thread Heikki Linnakangas
Fix amcheck's handling of half-dead B-tree pages amcheck incorrectly reported the following error if there were any half-dead pages in the index: ERROR: mismatch between parent key and child high key in index "amchecktest_id_idx" It's expected that a half-dead page does not have a downlink in t

pgsql: Add a test for incomplete splits in B-tree indexes

2025-12-02 Thread Heikki Linnakangas
Add a test for incomplete splits in B-tree indexes To increase our test coverage in general, and because I will add onto this in the next commit to also test amcheck with incomplete splits. This is copied from the similar test we had for GIN indexes. B-tree's incomplete splits work similarly to G

pgsql: Fix amcheck's handling of half-dead B-tree pages

2025-12-02 Thread Heikki Linnakangas
Fix amcheck's handling of half-dead B-tree pages amcheck incorrectly reported the following error if there were any half-dead pages in the index: ERROR: mismatch between parent key and child high key in index "amchecktest_id_idx" It's expected that a half-dead page does not have a downlink in t

pgsql: Fix amcheck's handling of half-dead B-tree pages

2025-12-02 Thread Heikki Linnakangas
Fix amcheck's handling of half-dead B-tree pages amcheck incorrectly reported the following error if there were any half-dead pages in the index: ERROR: mismatch between parent key and child high key in index "amchecktest_id_idx" It's expected that a half-dead page does not have a downlink in t

pgsql: Fix amcheck's handling of incomplete root splits in B-tree

2025-12-02 Thread Heikki Linnakangas
Fix amcheck's handling of incomplete root splits in B-tree When the root page is being split, it's normal that root page according to the metapage is not marked BTP_ROOT. Fix bogus error in amcheck about that case. Reviewed-by: Peter Geoghegan Discussion: https://www.postgresql.org/message-id/a

pgsql: Fix amcheck's handling of incomplete root splits in B-tree

2025-12-02 Thread Heikki Linnakangas
Fix amcheck's handling of incomplete root splits in B-tree When the root page is being split, it's normal that root page according to the metapage is not marked BTP_ROOT. Fix bogus error in amcheck about that case. Reviewed-by: Peter Geoghegan Discussion: https://www.postgresql.org/message-id/a

pgsql: Show size of DSAs and dshashes in pg_dsm_registry_allocations.

2025-12-02 Thread Nathan Bossart
Show size of DSAs and dshashes in pg_dsm_registry_allocations. Presently, this view reports NULL for the size of DSAs and dshash tables because 1) the current backend might not be attached to them and 2) the registry doesn't save the pointers to the dsa_area or dshash_table in local memory. Also,

pgsql: Remove doc and code comments about ON CONFLICT deficiencies

2025-12-02 Thread Álvaro Herrera
Remove doc and code comments about ON CONFLICT deficiencies They have been fixed, so we don't need this text anymore. This reverts commit 8b18ed6dfbb8. Author: Mihail Nikalayeu Discussion: https://postgr.es/m/CADzfLwWo+FV9WSeOah9F1r=4haa6eay1hnvyyy_wfzijek+...@mail.gmail.com Branch -- mas

pgsql: Avoid use of NOTICE to wait for snapshot invalidation

2025-12-02 Thread Álvaro Herrera
Avoid use of NOTICE to wait for snapshot invalidation This idea (implemented in commits and bc32a12e0db2 and 9e8fa05d3412) of using notices to detect that a session is sleeping was unreliable, so simplify the concurrency controller session to just look at pg_stat_activity for a process sleeping on

pgsql: Fix ON CONFLICT with REINDEX CONCURRENTLY and partitions

2025-12-02 Thread Álvaro Herrera
Fix ON CONFLICT with REINDEX CONCURRENTLY and partitions When planning queries with ON CONFLICT on partitioned tables, the indexes to consider as arbiters for each partition are determined based on those found in the parent table. However, it's possible for an index on a partition to be reindexed

pgsql: Remove useless casting to same type

2025-12-02 Thread Peter Eisentraut
Remove useless casting to same type This removes some casts where the input already has the same type as the type specified by the cast. Their presence could cause risks of hiding actual type mismatches in the future or silently discarding qualifiers. It also improves readability. Same kind of

pgsql: Simplify hash_xlog_split_allocate_page()

2025-12-02 Thread Peter Eisentraut
Simplify hash_xlog_split_allocate_page() Instead of complicated pointer arithmetic, overlay a uint32 array and just access the array members. That's safe thanks to XLogRecGetBlockData() returning a MAXALIGNed buffer. Reviewed-by: Bertrand Drouvot Reviewed-by: Jacob Champion Discussion: https: