pgsql: Fix untranslatable string concatenation in pg_upgrade

2025-02-24 Thread Michael Paquier
Fix untranslatable string concatenation in pg_upgrade Oversight in 1aab6805919b. Author: Kyotaro Horiguchi Discussion: https://postgr.es/m/20250225.140953.1271748916018759840.horikyota@gmail.com Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/560a842d639f28497

pgsql: Expand virtual generated columns in the planner

2025-02-24 Thread Richard Guo
Expand virtual generated columns in the planner Commit 83ea6c540 added support for virtual generated columns that are computed on read. All Var nodes in the query that reference virtual generated columns must be replaced with the corresponding generation expressions. Currently, this replacement

pgsql: Eliminate code duplication in replace_rte_variables callbacks

2025-02-24 Thread Richard Guo
Eliminate code duplication in replace_rte_variables callbacks The callback functions ReplaceVarsFromTargetList_callback and pullup_replace_vars_callback are both used to replace Vars in an expression tree that reference a particular RTE with items from a targetlist, and they both need to expand wh

pgsql: Doc: Fix pg_copy_logical_replication_slot description.

2025-02-24 Thread Amit Kapila
Doc: Fix pg_copy_logical_replication_slot description. This commit documents that the failover option is not copied when using the pg_copy_logical_replication_slot function. In passing, we modify the comments in the function clarifying the reason for this behavior. Reported-by: Author: Hou Zhij

pgsql: Missing doc update for f3dae2ae58.

2025-02-24 Thread Jeff Davis
Missing doc update for f3dae2ae58. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/15601fa21a5509b83a871c39ab98671f560da905 Modified Files -- doc/src/sgml/func.sgml | 8 1 file changed, 8 deletions(-)

pgsql: Do not use in-place updates for statistics import.

2025-02-24 Thread Jeff Davis
Do not use in-place updates for statistics import. The use of in-place updates was originally there to follow the precedent of ANALYZE and to reduce the potential for bloat on pg_class. Per discussion, it's not worth the risks. Reported-by: Andres Freund Discussion: https://postgr.es/m/cpdanvzy

pgsql: psql: Add pipeline status to prompt and some state variables

2025-02-24 Thread Michael Paquier
psql: Add pipeline status to prompt and some state variables This commit adds %P to psql prompts, able to report the status of a pipeline depending on PQpipelineStatus(): on, off or abort. The following variables are added to report the state of an ongoing pipeline: - PIPELINE_SYNC_COUNT: reports

pgsql: Fix bug in cbc127917 to handle nested Append correctly

2025-02-24 Thread Amit Langote
Fix bug in cbc127917 to handle nested Append correctly A non-leaf partition with a subplan that is an Append node was omitted from PlannedStmt.unprunableRelids because it was mistakenly included in PlannerGlobal.prunableRelids due to the way PartitionedRelPruneInfo.leafpart_rti_map[] is constructe

pgsql: Fix assertion when decoding XLOG_PARAMETER_CHANGE on promoted pr

2025-02-24 Thread Masahiko Sawada
Fix assertion when decoding XLOG_PARAMETER_CHANGE on promoted primary. When a standby replays an XLOG_PARAMETER_CHANGE record that lowers wal_level below logical, we invalidate all logical slots in hot standby mode. However, if this record was replayed while not in hot standby mode, logical slots

pgsql: Fix assertion when decoding XLOG_PARAMETER_CHANGE on promoted pr

2025-02-24 Thread Masahiko Sawada
Fix assertion when decoding XLOG_PARAMETER_CHANGE on promoted primary. When a standby replays an XLOG_PARAMETER_CHANGE record that lowers wal_level below logical, we invalidate all logical slots in hot standby mode. However, if this record was replayed while not in hot standby mode, logical slots

pgsql: Fix assertion when decoding XLOG_PARAMETER_CHANGE on promoted pr

2025-02-24 Thread Masahiko Sawada
Fix assertion when decoding XLOG_PARAMETER_CHANGE on promoted primary. When a standby replays an XLOG_PARAMETER_CHANGE record that lowers wal_level below logical, we invalidate all logical slots in hot standby mode. However, if this record was replayed while not in hot standby mode, logical slots

pgsql: oauth: Fix incorrect const markers in struct

2025-02-24 Thread Daniel Gustafsson
oauth: Fix incorrect const markers in struct Two members in PGoauthBearerRequest were incorrectly marked as const. While in there, align the name of the struct with the typedef as per project style. Reported-by: Tom Lane Discussion: https://postgr.es/m/912516.1740329...@sss.pgh.pa.us Branch ---

pgsql: oauth: Rename macro to avoid collisions on Windows

2025-02-24 Thread Daniel Gustafsson
oauth: Rename macro to avoid collisions on Windows Our json parsing defined the macros OPTIONAL and REQUIRED to decorate the structs with for increased readability. This however collides with macros in the header on Windows. ../src/interfaces/libpq/fe-auth-oauth-curl.c:398:9: warning: "OPTIONAL"

pgsql: Delay extraction of TIDBitmap per page offsets

2025-02-24 Thread Melanie Plageman
Delay extraction of TIDBitmap per page offsets Pages from the bitmap created by the TIDBitmap API can be exact or lossy. The TIDBitmap API extracts the tuple offsets from exact pages into an array for the convenience of the caller. This was done in tbm_private|shared_iterate() right after advanci

pgsql: Add lossy indicator to TBMIterateResult

2025-02-24 Thread Melanie Plageman
Add lossy indicator to TBMIterateResult TBMIterateResult->ntuples is -1 when the page in the bitmap is lossy. Add an explicit lossy indicator so that we can move ntuples out of the TBMIterateResult in a future commit. Discussion: https://postgr.es/m/CA%2BhUKGLHbKP3jwJ6_%2BhnGi37Pw3BD5j2amjV3oSk7

pgsql: Fix comment for MAX_BACKENDS.

2025-02-24 Thread Nathan Bossart
Fix comment for MAX_BACKENDS. This comment mentions that we check that the configured number of backends does not exceed MAX_BACKENDS in RegisterBackgroundWorker() and relevant GUC check hooks, neither of which has those checks anymore. To fix, adjust this comment to say that we do the check in I

pgsql: libpq: Trace all NegotiateProtocolVersion fields

2025-02-24 Thread Robert Haas
libpq: Trace all NegotiateProtocolVersion fields Previously, the names of the unsupported protocol options were not traced. Since NegotiateProtocolVersion has not really been used yet, that has not mattered much, but we hope to use it eventually, so let's fix this. Author: Jelte Fennema-Nio Disc

pgsql: libpq: Add PQfullProtocolVersion to exports.txt

2025-02-24 Thread Robert Haas
libpq: Add PQfullProtocolVersion to exports.txt This is necessary to be able to actually use the function on Windows; bug introduced in commit cdb6b0fdb0b2face270406905d31f8f513b015cc. Author: Jelte Fennema-Nio Discussion: https://postgr.es/m/cageczqtfc_o+hxqao5_-xg4r3efvstefueqzsvheyyldba-...@

pgsql: Fix confusion about data type of pg_class.relpages and relallvis

2025-02-24 Thread Tom Lane
Fix confusion about data type of pg_class.relpages and relallvisible. Although they're exposed as int4 in pg_class, relpages and relallvisible are really of type BlockNumber, that is uint32. Correct type puns in relation_statistics_update() and remove inappropriate range-checks. The type puns are

Re: pgsql: Trial fix for old cross-version upgrades.

2025-02-24 Thread Jeff Davis
On Sat, 2025-02-22 at 21:48 -0500, Tom Lane wrote: > CREATE INDEX vcharidx ON vchartmp USING GIST ( text(a) ); > > The index column will be given the name "text".  However, it > dumps as > > CREATE INDEX vcharidx ON public.vchartmp USING gist (((a)::text)); Thank you! I dismissed the naming issu

pgsql: pg_amcheck: PQclear query results

2025-02-24 Thread Daniel Gustafsson
pg_amcheck: PQclear query results While the potential memory leak is small, ensure to PQclear the query results before disconnecting. Author: Jiao Shuntian <312199...@qq.com> Reviewed-by: Daniel Gustafsson Discussion: https://postgr.es/m/tencent_f34922c91c41e76c734773e767c9fbdb9...@qq.com Bran

pgsql: Move MAX_BACKENDS to procnumber.h

2025-02-24 Thread Andres Freund
Move MAX_BACKENDS to procnumber.h MAX_BACKENDS influences many things besides postmaster. I e.g. noticed that we don't have static assertions ensuring BUF_REFCOUNT_MASK is big enough for MAX_BACKENDS, adding them would require including postmaster.h in buf_internals.h which doesn't seem right. Wh

pgsql: Add static asserts for MAX_BACKENDS limiting factors

2025-02-24 Thread Andres Freund
Add static asserts for MAX_BACKENDS limiting factors So far the various dependencies were documented in the comment above MAX_BACKENDS, but not checked. Discussion: https://postgr.es/m/CA+COZaBO_s3LfALq=b+hcbhfsoegiapvjrracce4vp9m7cj...@mail.gmail.com Branch -- master Details --- https

pgsql: bufmgr: Make it easier to change number of buffer state bits

2025-02-24 Thread Andres Freund
bufmgr: Make it easier to change number of buffer state bits In an upcoming commit I'd like to change the number of bits for the usage count (the current max is 5, fitting in three bits, but we reserve four bits). Until now that required adjusting a bunch of magic constants, now the constants are

pgsql: Base LWLock limits directly on MAX_BACKENDS

2025-02-24 Thread Andres Freund
Base LWLock limits directly on MAX_BACKENDS Jacob reported that comments for LW_SHARED_MASK referenced a MAX_BACKENDS limit of 2^23-1, but that MAX_BACKENDS is actually limited to 2^18-1. The limit was lowered in 48354581a49c, but the comment in lwlock.c wasn't updated. Instead of just fixing the

pgsql: Silence warning in older versions of Valgrind

2025-02-24 Thread John Naylor
Silence warning in older versions of Valgrind Due to misunderstanding on my part, commit 235328ee4 did not go far enough to silence older versions of Valgrind. For those, it was the bit scan that was problematic, not the subsequent bit-masking operation. To fix, use the unaligned path for the trai

pgsql: Silence warning in older versions of Valgrind

2025-02-24 Thread John Naylor
Silence warning in older versions of Valgrind Due to misunderstanding on my part, commit 235328ee4 did not go far enough to silence older versions of Valgrind. For those, it was the bit scan that was problematic, not the subsequent bit-masking operation. To fix, use the unaligned path for the trai