pgsql: Fix incorrect accessing of pfree'd memory in Memoize

2024-03-10 Thread David Rowley
Fix incorrect accessing of pfree'd memory in Memoize For pass-by-reference types, the code added in 0b053e78b, which aimed to resolve a memory leak, was overly aggressive in resetting the per-tuple memory context which could result in pfree'd memory being accessed resulting in failing to find

pgsql: Fix incorrect accessing of pfree'd memory in Memoize

2024-03-10 Thread David Rowley
Fix incorrect accessing of pfree'd memory in Memoize For pass-by-reference types, the code added in 0b053e78b, which aimed to resolve a memory leak, was overly aggressive in resetting the per-tuple memory context which could result in pfree'd memory being accessed resulting in failing to find

pgsql: Fix incorrect accessing of pfree'd memory in Memoize

2024-03-10 Thread David Rowley
Fix incorrect accessing of pfree'd memory in Memoize For pass-by-reference types, the code added in 0b053e78b, which aimed to resolve a memory leak, was overly aggressive in resetting the per-tuple memory context which could result in pfree'd memory being accessed resulting in failing to find

pgsql: Fix incorrect accessing of pfree'd memory in Memoize

2024-03-10 Thread David Rowley
Fix incorrect accessing of pfree'd memory in Memoize For pass-by-reference types, the code added in 0b053e78b, which aimed to resolve a memory leak, was overly aggressive in resetting the per-tuple memory context which could result in pfree'd memory being accessed resulting in failing to find

pgsql: Doc: Warn about two_phase when altering a subscription's slot na

2024-03-10 Thread Amit Kapila
Doc: Warn about two_phase when altering a subscription's slot name. We expect the 'two_phase' and 'failover' properties to match between the slot on the publisher and a subscription option on the subscriber. Otherwise, the slot on the publisher may behave differently from what the subscription's

pgsql: Backpatch missing check_stack_depth() to some recursive function

2024-03-10 Thread Alexander Korotkov
Backpatch missing check_stack_depth() to some recursive functions Backpatch changes from d57b7cc333, 75bcba6cbd to all supported branches per proposal of Egor Chindyaskin. Discussion: https://postgr.es/m/DE5FD776-A8CD-4378-BCFA-3BF30F1F6D60%40mail.ru Branch -- REL_15_STABLE Details ---

pgsql: Backpatch missing check_stack_depth() to some recursive function

2024-03-10 Thread Alexander Korotkov
Backpatch missing check_stack_depth() to some recursive functions Backpatch changes from d57b7cc333, 75bcba6cbd to all supported branches per proposal of Egor Chindyaskin. Discussion: https://postgr.es/m/DE5FD776-A8CD-4378-BCFA-3BF30F1F6D60%40mail.ru Branch -- REL_16_STABLE Details ---

pgsql: Backpatch missing check_stack_depth() to some recursive function

2024-03-10 Thread Alexander Korotkov
Backpatch missing check_stack_depth() to some recursive functions Backpatch changes from d57b7cc333, 75bcba6cbd to all supported branches per proposal of Egor Chindyaskin. Discussion: https://postgr.es/m/DE5FD776-A8CD-4378-BCFA-3BF30F1F6D60%40mail.ru Branch -- REL_14_STABLE Details ---

pgsql: Backpatch missing check_stack_depth() to some recursive function

2024-03-10 Thread Alexander Korotkov
Backpatch missing check_stack_depth() to some recursive functions Backpatch changes from d57b7cc333, 75bcba6cbd to all supported branches per proposal of Egor Chindyaskin. Discussion: https://postgr.es/m/DE5FD776-A8CD-4378-BCFA-3BF30F1F6D60%40mail.ru Branch -- REL_13_STABLE Details ---

pgsql: Backpatch missing check_stack_depth() to some recursive function

2024-03-10 Thread Alexander Korotkov
Backpatch missing check_stack_depth() to some recursive functions Backpatch changes from d57b7cc333, 75bcba6cbd to all supported branches per proposal of Egor Chindyaskin. Discussion: https://postgr.es/m/DE5FD776-A8CD-4378-BCFA-3BF30F1F6D60%40mail.ru Branch -- REL_12_STABLE Details ---

pgsql: Improve consistency of replication slot statistics

2024-03-10 Thread Michael Paquier
Improve consistency of replication slot statistics The replication slot stats stored in shared memory rely on an internal index number. Both pgstat_reset_replslot() and pgstat_fetch_replslot() lacked some LWLock protections with ReplicationSlotControlLock while operating on these index numbers.

pgsql: Add some checkpoint and redo LSNs to a couple of recovery errors

2024-03-10 Thread Michael Paquier
Add some checkpoint and redo LSNs to a couple of recovery errors Two FATALs and one PANIC gain details about the LSNs they fail at: - When restoring from a backup_label, the FATAL log generated when not finding the checkpoint record now reports its LSN. - When restoring from a backup_label, the

pgsql: Improve support for ExplainOneQuery() hook

2024-03-10 Thread Michael Paquier
Improve support for ExplainOneQuery() hook There is a hook called ExplainOneQuery_hook that gives modules the possibility to plug into this code path, but, like utility.c for utility statement execution, there is no corresponding "standard" routine in the case of EXPLAIN executed for one Query.

pgsql: Fix deparsing of Consts in postgres_fdw ORDER BY

2024-03-10 Thread David Rowley
Fix deparsing of Consts in postgres_fdw ORDER BY For UNION ALL queries where a union child query contained a foreign table, if the targetlist of that query contained a constant, and the top-level query performed an ORDER BY which contained the column for the constant value, then postgres_fdw

pgsql: Fix deparsing of Consts in postgres_fdw ORDER BY

2024-03-10 Thread David Rowley
Fix deparsing of Consts in postgres_fdw ORDER BY For UNION ALL queries where a union child query contained a foreign table, if the targetlist of that query contained a constant, and the top-level query performed an ORDER BY which contained the column for the constant value, then postgres_fdw

pgsql: Fix deparsing of Consts in postgres_fdw ORDER BY

2024-03-10 Thread David Rowley
Fix deparsing of Consts in postgres_fdw ORDER BY For UNION ALL queries where a union child query contained a foreign table, if the targetlist of that query contained a constant, and the top-level query performed an ORDER BY which contained the column for the constant value, then postgres_fdw

pgsql: Fix deparsing of Consts in postgres_fdw ORDER BY

2024-03-10 Thread David Rowley
Fix deparsing of Consts in postgres_fdw ORDER BY For UNION ALL queries where a union child query contained a foreign table, if the targetlist of that query contained a constant, and the top-level query performed an ORDER BY which contained the column for the constant value, then postgres_fdw

pgsql: Fix deparsing of Consts in postgres_fdw ORDER BY

2024-03-10 Thread David Rowley
Fix deparsing of Consts in postgres_fdw ORDER BY For UNION ALL queries where a union child query contained a foreign table, if the targetlist of that query contained a constant, and the top-level query performed an ORDER BY which contained the column for the constant value, then postgres_fdw

pgsql: Fix deparsing of Consts in postgres_fdw ORDER BY

2024-03-10 Thread David Rowley
Fix deparsing of Consts in postgres_fdw ORDER BY For UNION ALL queries where a union child query contained a foreign table, if the targetlist of that query contained a constant, and the top-level query performed an ORDER BY which contained the column for the constant value, then postgres_fdw