pgsql: Add pg_iswalpha() and related functions.

2025-10-17 Thread Jeff Davis
Add pg_iswalpha() and related functions. Per-character pg_locale_t APIs. Useful for tsearch parsing and potentially other places. Significant overlap with the regc_wc_isalpha() and related functions in regc_pg_locale.c, but this change leaves those intact for now. Discussion: https://postgr.es/

pgsql: Fix lookup code for REINDEX INDEX.

2025-10-17 Thread Nathan Bossart
Fix lookup code for REINDEX INDEX. This commit adjusts RangeVarCallbackForReindexIndex() to handle an extremely unlikely race condition involving concurrent OID reuse. In short, if REINDEX INDEX is executed at the same time that the index is re-created with the same name and OID but a different pa

Re: pgsql: Move gramparse.h to src/backend/parser

2025-10-17 Thread Tom Lane
John Naylor writes: > On Wed, Oct 15, 2025 at 2:49 PM Anton A. Melnikov > wrote: >> Maybe backpatch [2] to all supported versions not just 16+? > That only changed src/backend/common.mk, so that's not going to affect > contrib. I looked, and contrib/contrib-global.mk doesn't have any > extra *.b

pgsql: Fix reset of incorrect hash iterator in GROUPING SETS queries

2025-10-17 Thread David Rowley
Fix reset of incorrect hash iterator in GROUPING SETS queries This fixes an unlikely issue when fetching GROUPING SET results from their internally stored hash tables. It was possible in rare cases that the hash iterator would be set up incorrectly which could result in a crash. This was introdu

pgsql: bufmgr: fewer calls to BufferDescriptorGetContentLock

2025-10-17 Thread Andres Freund
bufmgr: fewer calls to BufferDescriptorGetContentLock We're planning to merge buffer content locks into BufferDesc.state. To reduce the size of that patch, centralize calls to BufferDescriptorGetContentLock(). The biggest part of the change is in assertions, by introducing BufferIsLockedByMe[InMo

pgsql: Improve ReadRecentBuffer() scalability

2025-10-17 Thread Andres Freund
Improve ReadRecentBuffer() scalability While testing a new potential use for ReadRecentBuffer(), Andres reported that it scales badly when called concurrently for the same buffer by many backends. Instead of a naive (but wrong) coding with PinBuffer(), it used the spinlock, so that it could be ca

pgsql: Fix incorrect message-printing in win32security.c.

2025-10-17 Thread Tom Lane
Fix incorrect message-printing in win32security.c. log_error() would probably fail completely if used, and would certainly print garbage for anything that needed to be interpolated into the message, because it was failing to use the correct printing subroutine for a va_list argument. This bug lik

pgsql: pgbench: Fix assertion failure with retriable errors in pipeline

2025-10-17 Thread Fujii Masao
pgbench: Fix assertion failure with retriable errors in pipeline mode. When running pgbench with --verbose-errors option and a custom script that triggered retriable errors (e.g., serialization errors) in pipeline mode, an assertion failure could occur: Assertion failed: (sql_script[st->use_f

pgsql: Fix redefinition of typedef RangeVar.

2025-10-17 Thread Nathan Bossart
Fix redefinition of typedef RangeVar. Commit c8af5019be added a forward declaration for this typedef that caused redefinitions, which are not valid in C99. Per buildfarm members longfin and sifaka. Discussion: https://postgr.es/m/aO_fzfnKVXMd_RUM%40nathan Backpatch-through: 18 only Branch -

pgsql: Fix EvalPlanQual handling of foreign/custom joins in ExecScanFet

2025-10-17 Thread Etsuro Fujita
Fix EvalPlanQual handling of foreign/custom joins in ExecScanFetch. If inside an EPQ recheck, ExecScanFetch would run the recheck method function for foreign/custom joins even if they aren't descendant nodes in the EPQ recheck plan tree, which is problematic at least in the foreign-join case, beca

pgsql: plpython: Remove support for major version conflict detection

2025-10-17 Thread Peter Eisentraut
plpython: Remove support for major version conflict detection This essentially reverts commit 866566a690b, which installed safeguards against loading plpython2 and plpython3 into the same process. We don't support plpython2 anymore, so this is obsolete. The Python and PL/Python initialization no

pgsql: Use SOCK_ERRNO[_SET] in fe-secure-gssapi.c.

2025-10-17 Thread Tom Lane
Use SOCK_ERRNO[_SET] in fe-secure-gssapi.c. On Windows, this code did not handle error conditions correctly at all, since it looked at "errno" which is not used for socket-related errors on that platform. This resulted, for example, in failure to connect to a PostgreSQL server with GSSAPI enabled

pgsql: Fix version number calculation for data folder flush in pg_combi

2025-10-17 Thread Michael Paquier
Fix version number calculation for data folder flush in pg_combinebackup The version number calculated by read_pg_version_file() is multiplied once by 1, to be able to do comparisons based on PG_VERSION_NUM or equivalents with a minor version included. However, the version number given sync_p

pgsql: pg_createsubscriber: Use new routine to retrieve data of PG_VERS

2025-10-17 Thread Michael Paquier
pg_createsubscriber: Use new routine to retrieve data of PG_VERSION pg_createsubscriber is documented as requiring the same major version as the target clusters. Attempting to use this tool on a cluster where the control file version read does not match with the version compiled with would lead t

pgsql: Fix access-to-already-freed-memory issue in pgoutput.

2025-10-17 Thread Masahiko Sawada
Fix access-to-already-freed-memory issue in pgoutput. While pgoutput caches relation synchronization information in RelationSyncCache that resides in CacheMemoryContext, each entry's information (such as row filter expressions and column lists) is stored in the entry's private memory context (entr

pgsql: Generate EUC_CN mappings from gb18030-2022.ucm

2025-10-17 Thread John Naylor
Generate EUC_CN mappings from gb18030-2022.ucm In the wake of cfa6cd292, EUC_CN was the only encoding that used gb-18030-2000.xml to generate the .map files. Since EUC_CN is a subset of GB18030, we can easily use the same UCM file. This allows deleting the XML file from our repository. Author: Ch

pgsql: injection_points: Enable entry count in its variable-sized stats

2025-10-17 Thread Michael Paquier
injection_points: Enable entry count in its variable-sized stats This serves as coverage for the tracking of entry count added by 7bd2975fa92b as built-in variable-sized stats kinds have no need for it, at least not yet. A new function, called injection_points_stats_count(), is added to the modul

pgsql: Fix incorrect and inconsistent comments in tableam.h and heapam.

2025-10-17 Thread Fujii Masao
Fix incorrect and inconsistent comments in tableam.h and heapam.c. This commit corrects several issues in function comments: * The parameter "rel" was incorrectly referred to as "relation" in the comments for table_tuple_delete(), table_tuple_update(), and table_tuple_lock(). * In table_tuple_

pgsql: test_bitmapset: Simplify code of the module

2025-10-17 Thread Michael Paquier
test_bitmapset: Simplify code of the module Two macros are added in this module, to cut duplicated patterns: - PG_ARG_GETBITMAPSET(), for input argument handling, with knowledge about NULL. - PG_RETURN_BITMAPSET_AS_TEXT(), that generates a text result from a Bitmapset. These changes limit the cod

pgsql: Add planner_setup_hook and planner_shutdown_hook.

2025-10-17 Thread Robert Haas
Add planner_setup_hook and planner_shutdown_hook. These hooks allow plugins to get control at the earliest point at which the PlannerGlobal object is fully initialized, and then just before it gets destroyed. This is useful in combination with the extendable plan state facilities (see extendplan.h

pgsql: Remove block information from description of some WAL records fo

2025-10-17 Thread Michael Paquier
Remove block information from description of some WAL records for GIN The WAL records XLOG_GIN_INSERT and XLOG_GIN_VACUUM_DATA_LEAF_PAGE included some information about the blocks added to the record. This information is already provided by XLogRecGetBlockRefInfo() with much more details about th

pgsql: test_bitmapset: Expand more the test coverage

2025-10-17 Thread Michael Paquier
test_bitmapset: Expand more the test coverage This commit expands the set of tests added by 00c3d87a5cab, to bring the coverage of bitmapset.c close to 100% by addressing a lot of corner cases (most of these relate to word counts and reallocations). Some of the functions of this module also have

pgsql: Fix privilege checks for pg_prewarm() on indexes.

2025-10-17 Thread Nathan Bossart
Fix privilege checks for pg_prewarm() on indexes. pg_prewarm() currently checks for SELECT privileges on the target relation. However, indexes do not have access rights of their own, so a role may be denied permission to prewarm an index despite having the SELECT privilege on its parent table. T

pgsql: Don't include execnodes.h in brin.h or gin.h

2025-10-17 Thread Álvaro Herrera
Don't include execnodes.h in brin.h or gin.h These headers don't need execnodes.h for anything. I think they never have. Discussion: https://postgr.es/m/[email protected] Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/1b6f61bd89889f70465600

pgsql: pg_createsubscriber: Fix matching check in TAP test

2025-10-17 Thread Michael Paquier
pg_createsubscriber: Fix matching check in TAP test 040_pg_createsubscriber has been calling safe_psql(), that returns the result of a SQL query, with ok() without checking the result generated (in this case 't', for a number of publications). The outcome of the tests is currently not impacted by

pgsql: Replace defunct URL with stable archive.org URL in rbtree.c

2025-10-17 Thread Daniel Gustafsson
Replace defunct URL with stable archive.org URL in rbtree.c The URL for "Sorting and Searching Algorithms: A Cookbook" by Thomas Niemann has started returning 404, and since we refer to the page for license terms this replaces the now defunct link with one to the copy on archive.org. Author: Chao

pgsql: Remove duplicated log related to slot creation in pg_createsubsc

2025-10-17 Thread Michael Paquier
Remove duplicated log related to slot creation in pg_createsubscriber The creation of a replication slot done in a specific database on a publisher was logged twice, with the second log not mentioning the database where the slot creation happened. This commit removes the information logged after

pgsql: Fix access-to-already-freed-memory issue in pgoutput.

2025-10-17 Thread Masahiko Sawada
Fix access-to-already-freed-memory issue in pgoutput. While pgoutput caches relation synchronization information in RelationSyncCache that resides in CacheMemoryContext, each entry's information (such as row filter expressions and column lists) is stored in the entry's private memory context (entr

pgsql: Remove partColsUpdated.

2025-10-17 Thread Nathan Bossart
Remove partColsUpdated. This information appears to have been unused since commit c5b7ba4e67. We could not find any references in third-party code, either. Reviewed-by: Chao Li Reviewed-by: Tom Lane Reviewed-by: Michael Paquier Discussion: https://postgr.es/m/aO_CyFRpbVMtgJWM%40nathan Branch

pgsql: Fix internal error from CollateExpr in SQL/JSON DEFAULT expressi

2025-10-17 Thread Amit Langote
Fix internal error from CollateExpr in SQL/JSON DEFAULT expressions SQL/JSON functions such as JSON_VALUE could fail with "unrecognized node type" errors when a DEFAULT clause contained an explicit COLLATE expression. That happened because assign_collations_walker() could invoke exprSetCollation()

pgsql: Fix EvalPlanQual handling of foreign/custom joins in ExecScanFet

2025-10-17 Thread Etsuro Fujita
Fix EvalPlanQual handling of foreign/custom joins in ExecScanFetch. If inside an EPQ recheck, ExecScanFetch would run the recheck method function for foreign/custom joins even if they aren't descendant nodes in the EPQ recheck plan tree, which is problematic at least in the foreign-join case, beca

pgsql: pg_createsubscriber: Add log message when no publications exist

2025-10-17 Thread Masahiko Sawada
pg_createsubscriber: Add log message when no publications exist to drop. When specifying --clean=publication to pg_createsubscriber, it drops all existing publications with a log message "dropping all existing publications in database "testdb"". Add a new log message "no publications found" when t

pgsql: Fix incorrect message-printing in win32security.c.

2025-10-17 Thread Tom Lane
Fix incorrect message-printing in win32security.c. log_error() would probably fail completely if used, and would certainly print garbage for anything that needed to be interpolated into the message, because it was failing to use the correct printing subroutine for a va_list argument. This bug lik

pgsql: Remove overzealous _bt_killitems assertion.

2025-10-17 Thread Peter Geoghegan
Remove overzealous _bt_killitems assertion. An assertion in _bt_killitems expected the scan's currPos state to contain a valid LSN, saved from when currPos's page was initially read. The assertion failed to account for the fact that even logged relations can have leaf pages with an invalid LSN whe

pgsql: Fix reset of incorrect hash iterator in GROUPING SETS queries

2025-10-17 Thread David Rowley
Fix reset of incorrect hash iterator in GROUPING SETS queries This fixes an unlikely issue when fetching GROUPING SET results from their internally stored hash tables. It was possible in rare cases that the hash iterator would be set up incorrectly which could result in a crash. This was introdu

pgsql: Improve TAP tests by replacing ok() with better Test::More funct

2025-10-17 Thread Tom Lane
Improve TAP tests by replacing ok() with better Test::More functions Transpose the changes made by commit fabb33b35 in 002_pg_dump.pl into its recently-created clone 006_pg_dump_compress.pl. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/a6113dc1dae009a3d9a634d2fcc

pgsql: Remove state.tmp when failing to save a replication slot

2025-10-17 Thread Michael Paquier
Remove state.tmp when failing to save a replication slot An error happening while a slot data is saved on disk in SaveSlotToPath() could cause a state.tmp file (temporary file holding the slot state data, renamed to its permanent name at the end of the function) to remain around after it has been

pgsql: Fix StatisticsObjIsVisibleExt() for pg_temp.

2025-10-17 Thread Noah Misch
Fix StatisticsObjIsVisibleExt() for pg_temp. Neighbor get_statistics_object_oid() ignores objects in pg_temp, as has been the standard for non-relation, non-type namespace searches since CVE-2007-2138. Hence, most operations that name a statistics object correctly decline to map an unqualified na

pgsql: Avoid uninitialized-variable warnings from older compilers.

2025-10-17 Thread Tom Lane
Avoid uninitialized-variable warnings from older compilers. Some of the buildfarm is still unhappy with WinGetFuncArgInPartition even after 2273fa32b. While it seems to be just very old compilers, we can suppress the warnings and arguably make the code more readable by not initializing these vari

pgsql: Fix privilege checks for pg_prewarm() on indexes.

2025-10-17 Thread Nathan Bossart
Fix privilege checks for pg_prewarm() on indexes. pg_prewarm() currently checks for SELECT privileges on the target relation. However, indexes do not have access rights of their own, so a role may be denied permission to prewarm an index despite having the SELECT privilege on its parent table. T

pgsql: Fix privilege checks for pg_prewarm() on indexes.

2025-10-17 Thread Nathan Bossart
Fix privilege checks for pg_prewarm() on indexes. pg_prewarm() currently checks for SELECT privileges on the target relation. However, indexes do not have access rights of their own, so a role may be denied permission to prewarm an index despite having the SELECT privilege on its parent table. T

pgsql: Fix privilege checks for pg_prewarm() on indexes.

2025-10-17 Thread Nathan Bossart
Fix privilege checks for pg_prewarm() on indexes. pg_prewarm() currently checks for SELECT privileges on the target relation. However, indexes do not have access rights of their own, so a role may be denied permission to prewarm an index despite having the SELECT privilege on its parent table. T

pgsql: Fix privilege checks for pg_prewarm() on indexes.

2025-10-17 Thread Nathan Bossart
Fix privilege checks for pg_prewarm() on indexes. pg_prewarm() currently checks for SELECT privileges on the target relation. However, indexes do not have access rights of their own, so a role may be denied permission to prewarm an index despite having the SELECT privilege on its parent table. T

pgsql: Fix privilege checks for pg_prewarm() on indexes.

2025-10-17 Thread Nathan Bossart
Fix privilege checks for pg_prewarm() on indexes. pg_prewarm() currently checks for SELECT privileges on the target relation. However, indexes do not have access rights of their own, so a role may be denied permission to prewarm an index despite having the SELECT privilege on its parent table. T

pgsql: Bump XLOG_PAGE_MAGIC after xl_heap_prune change

2025-10-17 Thread Melanie Plageman
Bump XLOG_PAGE_MAGIC after xl_heap_prune change add323da40a6 altered xl_heap_prune, changing the WAL format, but neglected to bump XLOG_PAGE_MAGIC. Do so now. Author: Melanie Plageman Reported-by: Kirill Reshke Reported-by: Michael Paquier Discussion: https://postgr.es/m/aO3Gw6hCAZFUd5ab%40paq

pgsql: Use SOCK_ERRNO[_SET] in fe-secure-gssapi.c.

2025-10-17 Thread Tom Lane
Use SOCK_ERRNO[_SET] in fe-secure-gssapi.c. On Windows, this code did not handle error conditions correctly at all, since it looked at "errno" which is not used for socket-related errors on that platform. This resulted, for example, in failure to connect to a PostgreSQL server with GSSAPI enabled

pgsql: Remove unused data_bufsz from DecodedBkpBlock struct.

2025-10-17 Thread Masahiko Sawada
Remove unused data_bufsz from DecodedBkpBlock struct. Author: Mikhail Gribkov Reviewed-by: Nazir Bilal Yavuz Discussion: https://postgr.es/m/CAMEv5_sxuaiAfSy1ZyN%3D7UGbHg3C10cwHhEk8nXEjiCsBVs4vQ%40mail.gmail.com Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/fd5

pgsql: Improve description of some WAL records for GIN

2025-10-17 Thread Michael Paquier
Improve description of some WAL records for GIN The following information is added in the description of some GIN records: - In INSERT_LISTPAGE, the number of tuples and the right link block. - In UPDATE_META_PAGE, the number of tuples, the previous tail block, and the right link block. - In SPLIT

pgsql: bufmgr: Fix valgrind checking for buffers pinned in StrategyGetB

2025-10-17 Thread Andres Freund
bufmgr: Fix valgrind checking for buffers pinned in StrategyGetBuffer() In 5e899859287 I made StrategyGetBuffer() pin buffers with a single CAS, instead of using PinBuffer_Locked(). Unfortunately I missed that PinBuffer_Locked() marked the page as defined for valgrind. Fix this oversight by centr

pgsql: Fix update-po for the PGXS case

2025-10-17 Thread Álvaro Herrera
Fix update-po for the PGXS case The original formulation failed to take into account the fact that for the PGXS case, the source dir is not $(top_srcdir), so it ended up not doing anything. Handle it explicitly. Author: Ryo Matsumura Reviewed-by: Bryan Green Backpatch-through: 13 Discussion:

pgsql: Fix update-po for the PGXS case

2025-10-17 Thread Álvaro Herrera
Fix update-po for the PGXS case The original formulation failed to take into account the fact that for the PGXS case, the source dir is not $(top_srcdir), so it ended up not doing anything. Handle it explicitly. Author: Ryo Matsumura Reviewed-by: Bryan Green Backpatch-through: 13 Discussion:

pgsql: Fix hashjoin memory balancing logic

2025-10-17 Thread Tomas Vondra
Fix hashjoin memory balancing logic Commit a1b4f289beec improved the hashjoin sizing to also consider the memory used by BufFiles for batches. The code however had multiple issues, making it ineffective or not working as expected in some cases. * The amount of memory needed by buffers was calcula

pgsql: Fix hashjoin memory balancing logic

2025-10-17 Thread Tomas Vondra
Fix hashjoin memory balancing logic Commit a1b4f289beec improved the hashjoin sizing to also consider the memory used by BufFiles for batches. The code however had multiple issues, making it ineffective or not working as expected in some cases. * The amount of memory needed by buffers was calcula

pgsql: Add more TAP test coverage for pg_dump.

2025-10-17 Thread Tom Lane
Add more TAP test coverage for pg_dump. Add a test case to cover pg_dump with --compress=none. This brings the coverage of compress_none.c up from about 64% to 90%, in particular covering the new code added in a previous patch. Include compression of toc.dat in manually-compressed test cases. We

pgsql: Use SOCK_ERRNO[_SET] in fe-secure-gssapi.c.

2025-10-17 Thread Tom Lane
Use SOCK_ERRNO[_SET] in fe-secure-gssapi.c. On Windows, this code did not handle error conditions correctly at all, since it looked at "errno" which is not used for socket-related errors on that platform. This resulted, for example, in failure to connect to a PostgreSQL server with GSSAPI enabled

pgsql: Doc: clarify n_distinct_inherited setting

2025-10-17 Thread David Rowley
Doc: clarify n_distinct_inherited setting There was some confusion around how to adjust the n_distinct estimates for partitioned tables. Here we try and clarify that n_distinct_inherited needs to be adjusted rather than n_distinct. Also fix some slightly misleading text which was talking about t

pgsql: pg_createsubscriber: Fix matching check in TAP test

2025-10-17 Thread Michael Paquier
pg_createsubscriber: Fix matching check in TAP test 040_pg_createsubscriber has been calling safe_psql(), that returns the result of a SQL query, with ok() without checking the result generated (in this case 't', for a number of publications). The outcome of the tests is currently not impacted by

pgsql: Use SOCK_ERRNO[_SET] in fe-secure-gssapi.c.

2025-10-17 Thread Tom Lane
Use SOCK_ERRNO[_SET] in fe-secure-gssapi.c. On Windows, this code did not handle error conditions correctly at all, since it looked at "errno" which is not used for socket-related errors on that platform. This resulted, for example, in failure to connect to a PostgreSQL server with GSSAPI enabled

pgsql: Avoid warnings in tests when openssl binary isn't available

2025-10-17 Thread Daniel Gustafsson
Avoid warnings in tests when openssl binary isn't available The SSL tests for pg_stat_ssl tries to exactly match the serial from the certificate by extracting it with the openssl binary. If that fails due to the binary not being available, a fallback match is used, but the attempt to execute a mis

pgsql: Make some use of anonymous unions [DSM registry].

2025-10-17 Thread Nathan Bossart
Make some use of anonymous unions [DSM registry]. Make some use of anonymous unions, which are allowed as of C11, as examples and encouragement for future code, and to test compilers. This commit changes the DSMRegistryEntry struct. Reviewed-by: Peter Eisentraut Discussion: https://postgr.es/m/

pgsql: Stop creating constraints during DETACH CONCURRENTLY

2025-10-17 Thread Álvaro Herrera
Stop creating constraints during DETACH CONCURRENTLY Commit 71f4c8c6f74b (which implemented DETACH CONCURRENTLY) added code to create a separate table constraint when a table is detached concurrently, identical to the partition constraint, on the theory that such a constraint was needed in case th

pgsql: Englishify comment wording

2025-10-17 Thread David Rowley
Englishify comment wording Switch to using the English word here rather than using a verbified function name. The full word still fits within a single comment line, so it's probably better just to use that instead of trying to shorten it, which might cause confusion. Author: Rafia Sabih Discuss

pgsql: Fix typo in pgstat_relation.c header comment

2025-10-17 Thread David Rowley
Fix typo in pgstat_relation.c header comment Looks like a copy and paste error from pgstat_function.c Author: Bertrand Drouvot Discussion: https://postgr.es/m/[email protected] Branch -- master Details --- https://git.postgresql.org/pg/commitdif

pgsql: Fix incorrect message-printing in win32security.c.

2025-10-17 Thread Tom Lane
Fix incorrect message-printing in win32security.c. log_error() would probably fail completely if used, and would certainly print garbage for anything that needed to be interpolated into the message, because it was failing to use the correct printing subroutine for a va_list argument. This bug lik

pgsql: Fix StatisticsObjIsVisibleExt() for pg_temp.

2025-10-17 Thread Noah Misch
Fix StatisticsObjIsVisibleExt() for pg_temp. Neighbor get_statistics_object_oid() ignores objects in pg_temp, as has been the standard for non-relation, non-type namespace searches since CVE-2007-2138. Hence, most operations that name a statistics object correctly decline to map an unqualified na

pgsql: Keep track of what RTIs a Result node is scanning.

2025-10-17 Thread Robert Haas
Keep track of what RTIs a Result node is scanning. Result nodes now include an RTI set, which is only non-NULL when they have no subplan, and is taken from the relid set of the RelOptInfo that the Result is generating. ExplainPreScanNode now takes notice of these RTIs, which means that a few thing

pgsql: Stop creating constraints during DETACH CONCURRENTLY

2025-10-17 Thread Álvaro Herrera
Stop creating constraints during DETACH CONCURRENTLY Commit 71f4c8c6f74b (which implemented DETACH CONCURRENTLY) added code to create a separate table constraint when a table is detached concurrently, identical to the partition constraint, on the theory that such a constraint was needed in case th

pgsql: Fix EvalPlanQual handling of foreign/custom joins in ExecScanFet

2025-10-17 Thread Etsuro Fujita
Fix EvalPlanQual handling of foreign/custom joins in ExecScanFetch. If inside an EPQ recheck, ExecScanFetch would run the recheck method function for foreign/custom joins even if they aren't descendant nodes in the EPQ recheck plan tree, which is problematic at least in the foreign-join case, beca

pgsql: Remove overzealous _bt_killitems assertion.

2025-10-17 Thread Peter Geoghegan
Remove overzealous _bt_killitems assertion. An assertion in _bt_killitems expected the scan's currPos state to contain a valid LSN, saved from when currPos's page was initially read. The assertion failed to account for the fact that even logged relations can have leaf pages with an invalid LSN whe

pgsql: Doc: clarify n_distinct_inherited setting

2025-10-17 Thread David Rowley
Doc: clarify n_distinct_inherited setting There was some confusion around how to adjust the n_distinct estimates for partitioned tables. Here we try and clarify that n_distinct_inherited needs to be adjusted rather than n_distinct. Also fix some slightly misleading text which was talking about t

pgsql: Remove overzealous _bt_killitems assertion.

2025-10-17 Thread Peter Geoghegan
Remove overzealous _bt_killitems assertion. An assertion in _bt_killitems expected the scan's currPos state to contain a valid LSN, saved from when currPos's page was initially read. The assertion failed to account for the fact that even logged relations can have leaf pages with an invalid LSN whe

pgsql: Improve TAP tests by replacing ok() with better Test::More funct

2025-10-17 Thread Michael Paquier
Improve TAP tests by replacing ok() with better Test::More functions The TAP tests whose ok() calls are changed in this commit were relying on perl operators, rather than equivalents available in Test::More. For example, rather than the following: ok($data =~ qr/expr/m, "expr matching"); ok($data

pgsql: doc: Clarify when backend_xmin in pg_stat_replication can be NUL

2025-10-17 Thread Fujii Masao
doc: Clarify when backend_xmin in pg_stat_replication can be NULL. Improve the documentation of pg_stat_replication to explain when the backend_xmin column becomes NULL. This happens when a replication slot is used (the xmin is then shown in pg_replication_slots) or when hot_standby_feedback is di

pgsql: Fix access-to-already-freed-memory issue in pgoutput.

2025-10-17 Thread Masahiko Sawada
Fix access-to-already-freed-memory issue in pgoutput. While pgoutput caches relation synchronization information in RelationSyncCache that resides in CacheMemoryContext, each entry's information (such as row filter expressions and column lists) is stored in the entry's private memory context (entr

pgsql: Make some use of anonymous unions [reorderbuffer xact_time]

2025-10-17 Thread Peter Eisentraut
Make some use of anonymous unions [reorderbuffer xact_time] Make some use of anonymous unions, which are allowed as of C11, as examples and encouragement for future code, and to test compilers. This commit changes the ReorderBufferTXN struct. Reviewed-by: Chao Li Discussion: https://www.postgr

pgsql: Remove unused parameter from find_window_run_conditions()

2025-10-17 Thread David Rowley
Remove unused parameter from find_window_run_conditions() ... and check_and_push_window_quals(). Similar to 4be9024d5, but it seems there was yet another unused parameter. Author: Matheus Alcantara Discussion: https://postgr.es/m/[email protected] Branch -- master Detai