pgsql: Fix typo

2026-03-24 Thread Peter Eisentraut
Fix typo Mistake in commit e2f289e5b9b: SOFT_ERROR_OCCURRED was called with the wrong fcinfo field. Reported-by: Jianghua Yang Reviewed-by: Nathan Bossart Discussion: https://www.postgresql.org/message-id/flat/CAAZLFmSGti716gWeY%3DDCZ9TTVOixnHZ4_4V4tDzoeE86D64vOA%40mail.gmail.com Branch -

pgsql: pg_createsubscriber: Add -l/--logdir option to redirect output t

2026-03-24 Thread Amit Kapila
pg_createsubscriber: Add -l/--logdir option to redirect output to files. This commit introduces a -l (or --logdir) argument to pg_createsubscriber, allowing users to specify a directory for log files. When enabled, a timestamped subdirectory is created within the specified log directory, containi

pgsql: Remove isolation test lock-stats

2026-03-24 Thread Michael Paquier
Remove isolation test lock-stats This test is proving to be unstable in the CI for Windows, at least. The origin of the issue is that the deadlock_timeout requests may not be processed, causing the lock stats to not be updated. This could be mitigated by making the hardcoded sleep longer, however

pgsql: Fix poorly-sized buffers in astreamer compression modules.

2026-03-24 Thread Tom Lane
Fix poorly-sized buffers in astreamer compression modules. astreamer_gzip.c and astreamer_lz4.c left their decompression output buffers at StringInfo's default allocation, merely 1kB. This results in a lot of ping-ponging between the decompressor and the next astreamer filter. This patch increase

pgsql: Remove read_archive_file()'s "count" parameter.

2026-03-24 Thread Tom Lane
Remove read_archive_file()'s "count" parameter. Instead, always try to fill the allocated buffer completely. The previous coding apparently intended (though it's undocumented) to read only small amounts of data until we are able to identify the WAL segment size and begin filtering out unwanted seg

pgsql: Don't include storage/lock.h in so many headers

2026-03-24 Thread Álvaro Herrera
Don't include storage/lock.h in so many headers Since storage/locktags.h was added by commit 322bab79744d, many headers can be made leaner by depending on that instead of on storage/lock.h, which has many other dependencies. (In fact, some of these changes were possible even before that.) Author

pgsql: Refactor to remove ForeignServerName().

2026-03-24 Thread Jeff Davis
Refactor to remove ForeignServerName(). Callers either have a ForeignServer object or can readily construct one. Discussion: https://postgr.es/m/CAExHW5vV5znEvecX=ra2-v7ubj9-m6qvddzub78m-txbyd1...@mail.gmail.com Suggested-by: Ashutosh Bapat Branch -- master Details --- https://git.pos

pgsql: GetSubscription(): use per-object memory context.

2026-03-24 Thread Jeff Davis
GetSubscription(): use per-object memory context. Constructing a Subcription object uses a number of small or temporary allocations. Use a per-object memory context for easy cleanup. Get rid of FreeSubscription() which did not free all the allocations anyway. Also get rid of the PG_TRY()/PG_CATCH

pgsql: get_memoize_path: Don't exit quickly when PGS_NESTLOOP_PLAIN is

2026-03-24 Thread Robert Haas
get_memoize_path: Don't exit quickly when PGS_NESTLOOP_PLAIN is unset. This function exits early in the case where the number of inner rows is estimated to be less than 2, on the theory that in that case a Nested Loop with inner Memoize must lose to a plain Nested Loop. But since commit 4020b370f2

pgsql: WAL log VM setting during vacuum phase I in XLOG_HEAP2_PRUNE_VAC

2026-03-24 Thread Melanie Plageman
WAL log VM setting during vacuum phase I in XLOG_HEAP2_PRUNE_VACUUM_SCAN Vacuum no longer emits a separate WAL record for each page set all-visible or all-frozen during phase I. Instead, visibility map updates are now included in the XLOG_HEAP2_PRUNE_VACUUM_SCAN record that is already emitted for

pgsql: Refactor handling of x86 CPUID instructions

2026-03-24 Thread John Naylor
Refactor handling of x86 CPUID instructions Introduce two helpers for CPUID, pg_cpuid and pg_cpuid_subleaf that wrap the platform specific __get_cpuid/__cpuid and __get_cpuid_count/__cpuidex functions. Additionally, use macros to specify registers names (e.g. EAX) for clarity, instead of numeric

pgsql: Use GlobalVisState in vacuum to determine page level visibility

2026-03-24 Thread Melanie Plageman
Use GlobalVisState in vacuum to determine page level visibility During vacuum's first and third phases, we examine tuples' visibility to determine if we can set the page all-visible in the visibility map. Previously, this check compared tuple xmins against a single XID chosen at the start of vacu

pgsql: Fix dereference in a couple of GUC check hooks

2026-03-24 Thread Álvaro Herrera
Fix dereference in a couple of GUC check hooks check_backtrace_functions() and check_archive_directory() were doing an empty-string check this way: *newval[0] == '\0' which, because of operator precedence, is interpreted as *(newval[0]) instead of (*newval)[0] -- but these variables are pointe

pgsql: Keep newest live XID up-to-date even if page not all-visible

2026-03-24 Thread Melanie Plageman
Keep newest live XID up-to-date even if page not all-visible During pruning, we keep track of the newest xmin of live tuples on the page visible to all running and future transactions so that we can use it later as the snapshot conflict horizon when setting the VM if the page turns out to be all-v

pgsql: Avoid including clog.h in proc.h

2026-03-24 Thread Álvaro Herrera
Avoid including clog.h in proc.h The number of .c files that must include access/clog.h can currently be counted on one's fingers and miss only one (assuming one has the usual number of hands). However, due to indirect inclusion via proc.h, there's a lot of files that are pointlessly including it

pgsql: WAL log VM setting for empty pages in XLOG_HEAP2_PRUNE_VACUUM_SC

2026-03-24 Thread Melanie Plageman
WAL log VM setting for empty pages in XLOG_HEAP2_PRUNE_VACUUM_SCAN As part of removing XLOG_HEAP2_VISIBLE records, phase I of VACUUM now marks empty pages all-visible and all-frozen in a XLOG_HEAP2_PRUNE_VACUUM_SCAN record. This has no real independent benefit, but empty pages were the last user

pgsql: Remove XLOG_HEAP2_VISIBLE entirely

2026-03-24 Thread Melanie Plageman
Remove XLOG_HEAP2_VISIBLE entirely There are no remaining users that emit XLOG_HEAP2_VISIBLE records, so it can be removed. This includes deleting the xl_heap_visible struct and all functions responsible for emitting or replaying XLOG_HEAP2_VISIBLE records. Bumps XLOG_PAGE_MAGIC because we remove

pgsql: Fix copy-paste error in test_ginpostinglist

2026-03-24 Thread John Naylor
Fix copy-paste error in test_ginpostinglist The check for a mismatch on the second decoded item pointer was an exact copy of the first item pointer check, comparing orig_itemptrs[0] with decoded_itemptrs[0] instead of orig_itemptrs[1] with decoded_itemptrs[1]. The error message also reported (0,

pgsql: Fix copy-paste error in test_ginpostinglist

2026-03-24 Thread John Naylor
Fix copy-paste error in test_ginpostinglist The check for a mismatch on the second decoded item pointer was an exact copy of the first item pointer check, comparing orig_itemptrs[0] with decoded_itemptrs[0] instead of orig_itemptrs[1] with decoded_itemptrs[1]. The error message also reported (0,

pgsql: Fix copy-paste error in test_ginpostinglist

2026-03-24 Thread John Naylor
Fix copy-paste error in test_ginpostinglist The check for a mismatch on the second decoded item pointer was an exact copy of the first item pointer check, comparing orig_itemptrs[0] with decoded_itemptrs[0] instead of orig_itemptrs[1] with decoded_itemptrs[1]. The error message also reported (0,

pgsql: Fix copy-paste error in test_ginpostinglist

2026-03-24 Thread John Naylor
Fix copy-paste error in test_ginpostinglist The check for a mismatch on the second decoded item pointer was an exact copy of the first item pointer check, comparing orig_itemptrs[0] with decoded_itemptrs[0] instead of orig_itemptrs[1] with decoded_itemptrs[1]. The error message also reported (0,

pgsql: Fix copy-paste error in test_ginpostinglist

2026-03-24 Thread John Naylor
Fix copy-paste error in test_ginpostinglist The check for a mismatch on the second decoded item pointer was an exact copy of the first item pointer check, comparing orig_itemptrs[0] with decoded_itemptrs[0] instead of orig_itemptrs[1] with decoded_itemptrs[1]. The error message also reported (0,

pgsql: Fix copy-paste error in test_ginpostinglist

2026-03-24 Thread John Naylor
Fix copy-paste error in test_ginpostinglist The check for a mismatch on the second decoded item pointer was an exact copy of the first item pointer check, comparing orig_itemptrs[0] with decoded_itemptrs[0] instead of orig_itemptrs[1] with decoded_itemptrs[1]. The error message also reported (0,

pgsql: Prevent spurious "indexes on virtual generated columns are not s

2026-03-24 Thread Robert Haas
Prevent spurious "indexes on virtual generated columns are not supported". Both of the checks in DefineIndex() that can produce this error message have a guard against negative attribute numbers, but lack a guard to ensure that attno is non-zero. As a result, we can index off the beginning of the

pgsql: Prevent spurious "indexes on virtual generated columns are not s

2026-03-24 Thread Robert Haas
Prevent spurious "indexes on virtual generated columns are not supported". Both of the checks in DefineIndex() that can produce this error message have a guard against negative attribute numbers, but lack a guard to ensure that attno is non-zero. As a result, we can index off the beginning of the

pgsql: Make many cast functions error safe

2026-03-24 Thread Peter Eisentraut
Make many cast functions error safe This adjusts many C functions underlying casts to support soft errors. This is in preparation for a future feature where conversion errors in casts can be caught. This patch covers cast functions that can be adjusted easily by changing ereport to ereturn or mak

pgsql: Further improve commentary about ChangeVarNodesWalkExpression()

2026-03-24 Thread Alexander Korotkov
Further improve commentary about ChangeVarNodesWalkExpression() The updated comment explains why we use ChangeVarNodes_walker() instead of expression_tree_walker(), and provides a bit more detail about the differences in processing top-level Query and subqueries. Author: Alexander Korotkov Revie

pgsql: Further improve commentary about ChangeVarNodesWalkExpression()

2026-03-24 Thread Alexander Korotkov
Further improve commentary about ChangeVarNodesWalkExpression() The updated comment explains why we use ChangeVarNodes_walker() instead of expression_tree_walker(), and provides a bit more detail about the differences in processing top-level Query and subqueries. Author: Alexander Korotkov Revie

pgsql: Report detailed errors from XLogFindNextRecord() failures.

2026-03-24 Thread Fujii Masao
Report detailed errors from XLogFindNextRecord() failures. Previously, XLogFindNextRecord() did not return detailed error information when it failed to find a valid WAL record. As a result, callers such as the WAL summarizer, pg_waldump, and pg_walinspect could only report generic errors (e.g., "c

pgsql: Fix accidentally casting away const

2026-03-24 Thread Peter Eisentraut
Fix accidentally casting away const Recently introduced in commit 4b5ba0c4ca5. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/6bc7449eac31ca573572000a10660d5995a4f96a Modified Files -- src/bin/pg_dump/pg_dump.c | 2 +- 1 file changed, 1 insertion(+), 1

pgsql: Bounds-check access to TupleDescAttr with an Assert.

2026-03-24 Thread Robert Haas
Bounds-check access to TupleDescAttr with an Assert. The second argument to TupleDescAttr should always be at least zero and less than natts; otherwise, we index outside of the attribute array. Assert that this is the case. Various violations, or possible violations, of this rule that are current

pgsql: Add a test for creating an index on a whole-row expression.

2026-03-24 Thread Robert Haas
Add a test for creating an index on a whole-row expression. Surprisingly, we have no existing test for this. Had this test been present before commit 570e2fcc041a55ba8991a640cc3f3f0e122feac3 the Assert added in commit c98ad086ad9b1ca9dbb2725f246298fa8450d82f would have caught the bug. Reviewed-by

pgsql: test_bloomfilter: Fix error message.

2026-03-24 Thread Nathan Bossart
test_bloomfilter: Fix error message. The error message in question uses the wrong format specifier and variable. This has been wrong for a while, but since it's in a test module and wasn't noticed until just now, no back-patch. Oversight in commit 51bc271790. Author: Jianghua Yang Discussion: