Robert Haas [Fri, 27 Jun 2025 14:39:40 +0000 (10:39 -0400)]
Move wrap_column into pgpa_output_context
Robert Haas [Fri, 27 Jun 2025 14:24:19 +0000 (10:24 -0400)]
pgindent
Robert Haas [Fri, 27 Jun 2025 14:24:03 +0000 (10:24 -0400)]
Introduce output context object.
Robert Haas [Fri, 27 Jun 2025 14:00:34 +0000 (10:00 -0400)]
add some line wrapping logic
Robert Haas [Thu, 26 Jun 2025 17:59:40 +0000 (13:59 -0400)]
move more code to pgpa_output.c
Robert Haas [Thu, 26 Jun 2025 16:18:31 +0000 (12:18 -0400)]
move debug output routines to a new file
Robert Haas [Wed, 25 Jun 2025 20:08:20 +0000 (16:08 -0400)]
filter join RTIs out of clumped joins to avoid failures
Robert Haas [Wed, 25 Jun 2025 19:39:13 +0000 (15:39 -0400)]
reintroduce range table identifiers
breaks the regression tests in a few places, because join RTIs leak
into clumped joins
Robert Haas [Tue, 24 Jun 2025 16:24:29 +0000 (12:24 -0400)]
more comments
Robert Haas [Tue, 24 Jun 2025 16:22:16 +0000 (12:22 -0400)]
more comments
Robert Haas [Tue, 24 Jun 2025 16:08:47 +0000 (12:08 -0400)]
pgindent
Robert Haas [Tue, 24 Jun 2025 16:08:21 +0000 (12:08 -0400)]
Refactoring.
Robert Haas [Tue, 24 Jun 2025 15:41:14 +0000 (11:41 -0400)]
remove more code not required by the regression tests
Robert Haas [Tue, 24 Jun 2025 15:31:59 +0000 (11:31 -0400)]
remove apparently-unnecessary Result node traversal
add some comments
Robert Haas [Tue, 24 Jun 2025 15:08:23 +0000 (11:08 -0400)]
use pgpa_descend_node more
Robert Haas [Tue, 24 Jun 2025 14:51:45 +0000 (10:51 -0400)]
cleanup, incidental bug fix
Robert Haas [Tue, 24 Jun 2025 14:39:28 +0000 (10:39 -0400)]
fix various things so regression tests pass
Robert Haas [Thu, 12 Jun 2025 20:12:49 +0000 (16:12 -0400)]
fix subplan walking because i never get this right
Robert Haas [Thu, 12 Jun 2025 17:24:25 +0000 (13:24 -0400)]
Couple of bug fixes and tweaks.
I suspect there are residual problems with decomposing joins, but
this is better.
Robert Haas [Thu, 12 Jun 2025 15:35:24 +0000 (11:35 -0400)]
temporary debugging hack
Robert Haas [Thu, 12 Jun 2025 15:20:13 +0000 (11:20 -0400)]
update makefile
Robert Haas [Mon, 9 Jun 2025 19:16:12 +0000 (15:16 -0400)]
remove XXX
Robert Haas [Mon, 9 Jun 2025 19:10:52 +0000 (15:10 -0400)]
output something for GATHER and GATHER_MERGE
Robert Haas [Fri, 6 Jun 2025 19:26:05 +0000 (15:26 -0400)]
tidy up some cosmetics
Robert Haas [Fri, 6 Jun 2025 19:22:13 +0000 (15:22 -0400)]
Look through Gather and Gather Merge nodes.
Robert Haas [Fri, 6 Jun 2025 19:02:27 +0000 (15:02 -0400)]
Insist that a purported scan node must have an RTI.
Robert Haas [Fri, 6 Jun 2025 17:38:47 +0000 (13:38 -0400)]
attempt to fix handling of multiple elided nodes
also add a bunch of comments to pgpa_plan_walker
Robert Haas [Fri, 6 Jun 2025 16:31:55 +0000 (12:31 -0400)]
first elided node -> last elided node
Robert Haas [Thu, 5 Jun 2025 19:21:51 +0000 (15:21 -0400)]
add a comment
Robert Haas [Fri, 30 May 2025 15:28:21 +0000 (11:28 -0400)]
hackity hack elided nodes
Robert Haas [Thu, 29 May 2025 17:49:03 +0000 (13:49 -0400)]
hackity, hack
Robert Haas [Wed, 28 May 2025 20:06:48 +0000 (16:06 -0400)]
hackity hack
Robert Haas [Thu, 22 May 2025 19:33:53 +0000 (15:33 -0400)]
fix a few bugs
Robert Haas [Wed, 21 May 2025 20:17:31 +0000 (16:17 -0400)]
debugging code that shows it doesn't work
this prints out unrolled joins in a fairly raw format, and the result
is we can see we're not unrolling anything
Robert Haas [Wed, 21 May 2025 19:46:14 +0000 (15:46 -0400)]
Remove unused field.
Robert Haas [Wed, 21 May 2025 18:47:51 +0000 (14:47 -0400)]
pgpa_join_strategy renaming
Robert Haas [Wed, 21 May 2025 18:32:16 +0000 (14:32 -0400)]
fix some stuff
Robert Haas [Fri, 25 Apr 2025 20:01:15 +0000 (16:01 -0400)]
Start trying to get a proper treewalk oraganized.
See various XXX things in this commit. There's a bunch of stuff that
isn't right here. But I think it's closer to being right than the old
thing, since I believe we need several coordinated pgpa subsystems to
concurrently walk the tree.
Robert Haas [Thu, 24 Apr 2025 18:38:45 +0000 (14:38 -0400)]
remove junk
Robert Haas [Thu, 24 Apr 2025 18:37:56 +0000 (14:37 -0400)]
pgpa_join.c
Robert Haas [Tue, 22 Apr 2025 20:08:55 +0000 (16:08 -0400)]
pgpa_join.h
This is wrong insofar as the thinking about the ElidedNode case is
not in the comments, and maybe we should actually store the ElidedNode
in the arrays.
Robert Haas [Tue, 22 Apr 2025 16:47:16 +0000 (12:47 -0400)]
Port pg_plan_advice over from the subplanname branch.
Re-add build system integration.
thing
more
Robert Haas [Tue, 22 Apr 2025 18:10:19 +0000 (14:10 -0400)]
Store information about elided nodes in the final plan.
When setrefs.c removes a SubqueryScan, single-child Append, or
single-child MergeAppend from the final Plan tree, the RTI which
would have been scanned by the removed node no longer appears in
the final plan (the actual range table entry is still present,
but it's no longer referenced).
That's fine for the executor, but it can create difficulties for
code that wants to deduce from the final plan what choices were
made during the planing process. For example, a traversal of a
join tree in the final plan might never encounter the RTI of one
of the relationss in the join problem, and might instead encounter
a scan of a child RTI or even one from a different subquery level.
This patch adjusts things so that each time we elide a node during
setrefs processing, we record the plan_node_id of its single surviving
child, the type of the removed node, and the RTIs that the removed
node would have scanned. This information is recorded in a separate
list that can be ignored by the executor and examined only by code
that cares about these details.
This commit also updates pg_overexplain to display these details.
Robert Haas [Fri, 21 Mar 2025 15:06:35 +0000 (11:06 -0400)]
Store information about range-table flattening in the final plan.
During planning, there is one range table per subquery; at the end if
planning, those separate range tables are flattened into a single
range table. Prior to this change, it was impractical for code
examining the final plan to understand which parts of the flattened
range table came from which subquery's range table.
If the only consumer of the final plan is the executor, that is
completely fine. However, if some code wants to examine the final
plan, or what happens when we execute it, and extract information from
it that be used in future planning cycles, it's inconvenient. So,
this commit remembers in the final plan which part of the final range
table came from which subquery's range table.
Additionally, this commit teaches pg_overexplain'e RANGE_TABLE option
to display the subquery name for each range table entry.
Robert Haas [Thu, 5 Dec 2024 20:19:17 +0000 (15:19 -0500)]
Give subplans names that are known while planning that subplan.
Previously, subplans were shown in EXPLAIN output identified by
a number, like "InitPlan 1", and some were identified by a name,
like "CTE foo". Now, each subplan gets a name, which for InitPlans
and SubPlans is based on the type of sublink e.g. expr_1 or any_1,
and these names are guaranteed to be unique across the whole plan.
The numerical portion of the name may be different than it was
previously, because InitPlan 1 meant the first subplan that we
finished planning (which happened to be an InitPlan). This number
couldn't be known at the time we began planning that subplan,
because the query planner might recurse into other subplans which
would then be fully planned before finishing the plan at the outer
level. These new subplan names are assigned when we *start* planning
a subplan, which allows extensions that affect planning to know the
name that will ultimately be assigned while planning is still in
progress.
Some subplans aren't shown as subplans in EXPLAIN output. This
happens when the subquery is a FROM-cluse item or a branch of a
set operation, rather than, for example, an expression that will
be transformed into something render as an InitPlan or SubPlan.
These subplans also get unique names, although those names are not
currently shown in the EXPLAIN output. This means that it's now
possible to use unique, human-readable names to refer to any
subplan within a query; only the topmost query level is nameless.
Robert Haas [Wed, 16 Apr 2025 12:32:00 +0000 (08:32 -0400)]
Assert that RTIs of joined rels are discoverable from join plans.
Every RTI that appears in the joinrel's relid set should be findable
via the outer or inner plan, except for join RTIs which aren't
necessarily preserved in the final plan. This is a requirement if
we want to be able to reliably determine the chosen join order from
the final plan, although it's not sufficient for that goal of itself,
due to further problems created by setrefs-time processing.
Note that this depends on the earlier commit to add a relids field to
Result nodes; without that change, a join tree involving two or more
Result nodes would be fundamentally ambiguous (and even a join tree
involving one could only be interpreted by guessing at its origin).
Robert Haas [Mon, 21 Apr 2025 17:35:28 +0000 (13:35 -0400)]
Consider a Result node's relids in ExplainPreScanNode.
Now that a Result node has a relids set, add the relids that it
carries the set accumulated by ExplainPreScanNode so that we
generate unique relation aliases for all of the referenced relations
when it calls select_rtable_names_for_explain. The effect of this
changes is that a few things get schema-qualified in the regression
test outputs that previously were not. In similar cases not involving
a Result node, we were already schema-qualifying, so this appears to
be an improvement.
XXX. I have broken this out as a separate commit for now; however,
it could be merged with the commit to add 'relids' to 'Result'; or
the patch series could even be rejiggered to present this as the
primary benefit of that change, leaving the EXPLAIN changes as a
secondary benefit, instead of the current organization, which does
the reverse.
Robert Haas [Wed, 9 Apr 2025 14:14:31 +0000 (10:14 -0400)]
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.
Using that information, EXPLAIN now emits, where relevant, a "Replaces" line
that says whether it replaced a scan, a join, or an aggregate; and in the
former two cases, which relations were involved.
Likewise, pg_overexplain's EXPLAIN (RANGE_TABLE) now displays the RTIs
stored in a Result node just as it already does for other RTI-bearing
node types.
Amit Kapila [Mon, 19 May 2025 06:43:06 +0000 (12:13 +0530)]
Don't retreat slot's confirmed_flush LSN.
Prevent moving the confirmed_flush backwards, as this could lead to data
duplication issues caused by replicating already replicated changes.
This can happen when a client acknowledges an LSN it doesn't have to do
anything for, and thus didn't store persistently. After a restart, the
client can send the prior LSN that it stored persistently as an
acknowledgement, but we need to ignore such an LSN to avoid retreating
confirm_flush LSN.
Diagnosed-by: Zhijie Hou <houzj.fnst@fujitsu.com>
Author: shveta malik <shveta.malik@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: Dilip Kumar <dilipbalaut@gmail.com>
Tested-by: Nisha Moond <nisha.moond412@gmail.com>
Backpatch-through: 13
Discussion: https://postgr.es/m/CAJpy0uDZ29P=BYB1JDWMCh-6wXaNqMwG1u1mB4=10Ly0x7HhwQ@mail.gmail.com
Discussion: https://postgr.es/m/OS0PR01MB57164AB5716AF2E477D53F6F9489A@OS0PR01MB5716.jpnprd01.prod.outlook.com
Tom Lane [Mon, 19 May 2025 03:31:44 +0000 (23:31 -0400)]
Doc: add pre-branch task to run src/tools/copyright.pl.
It's common for some files with last year's copyright date
to sneak into the tree between early January (when we normally run
copyright.pl) and feature freeze. Immediately before branching
the new release is an ideal time to fix the stragglers, so add a
note about it to the RELEASE_CHANGES checklist.
Discussion: https://postgr.es/m/CALa6HA4_Wu7-2PV0xv-Q84cT8eG7rTx6bdjUV0Pc=McAwkNMfQ@mail.gmail.com
Michael Paquier [Mon, 19 May 2025 00:46:52 +0000 (09:46 +0900)]
Fix incorrect year in some copyright notices
A couple of new files have been added in the tree with a copyright year
of 2024 while we were already in 2025. These should be marked with
2025, so let's fix them.
Reported-by: Shaik Mohammad Mujeeb <mujeeb.sk.dev@gmail.com>
Discussion: https://postgr.es/m/CALa6HA4_Wu7-2PV0xv-Q84cT8eG7rTx6bdjUV0Pc=McAwkNMfQ@mail.gmail.com
Michael Paquier [Mon, 19 May 2025 00:44:17 +0000 (09:44 +0900)]
ecpg: Add missing newline in meson.build
Noticed while performing a routine sanity check of the files in the
tree. Issue introduced by
28f04984f0c2.
Discussion: https://postgr.es/m/CALa6HA4_Wu7-2PV0xv-Q84cT8eG7rTx6bdjUV0Pc=McAwkNMfQ@mail.gmail.com
Alexander Korotkov [Sun, 18 May 2025 20:49:50 +0000 (23:49 +0300)]
Fix tuple_fraction calculation in generate_orderedappend_paths()
6b94e7a6da adjusted generate_orderedappend_paths() to consider fractional
paths. However, it didn't manage to interpret the tuple_fraction value
correctly. According to the header comment of grouping_planner(), the
tuple_fraction >= 1 specifies the absolute number of expected tuples. That
number must be divided by the expected total number of tuples to get the
actual fraction.
Even though this is a bug fix, we don't backpatch it. The risks of the side
effects of plan changes on stable branches are too high.
Reported-by: Andrei Lepikhov <lepihov@gmail.com>
Discussion: https://postgr.es/m/
3ca271fa-ca5c-458c-8934-
eb148622b270%40gmail.com
Author: Andrei Lepikhov <lepihov@gmail.com>
Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>
Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Tom Lane [Sun, 18 May 2025 16:45:55 +0000 (12:45 -0400)]
Make our usage of memset_s() conform strictly to the C11 standard.
Per the letter of the C11 standard, one must #define
__STDC_WANT_LIB_EXT1__ as 1 before including <string.h> in order to
have access to memset_s(). It appears that many platforms are lenient
about this, because we weren't doing it and yet the code appeared to
work anyway. But we now find that with -std=c11, macOS is strict and
doesn't declare memset_s, leading to compile failures since we try to
use it anyway. (Given the lack of prior reports, perhaps this is new
behavior in the latest SDK? No matter, we're clearly in the wrong.)
In addition to the immediate problem, which could be fixed merely by
adding the needed #define to explicit_bzero.c, it seems possible that
our configure-time probe for memset_s() could fail in case a platform
implements the function in some odd way due to this spec requirement.
This concern can be fixed in largely the same way that we dealt with
strchrnul() in
6da2ba1d8: switch to using a declaration-based
configure probe instead of a does-it-link probe.
Back-patch to v13 where we started using memset_s().
Reported-by: Lakshmi Narayana Velayudam <dev.narayana.v@gmail.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAA4pTnLcKGG78xeOjiBr5yS7ZeE-Rh=FaFQQGOO=nPzA1L8yEA@mail.gmail.com
Backpatch-through: 13
Daniel Gustafsson [Sun, 18 May 2025 08:05:38 +0000 (10:05 +0200)]
Fix function name reference in comment
Ensure that we refer to the function being used, rather than the
name of the resulting function in question.
Author: Paul A Jungwirth <pj@illuminatedcomputing.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/CA+renyVZNiHEv5ceKDjA4j5xC6NT6mRuW33BDERBQMi_90_t6A@mail.gmail.com
Daniel Gustafsson [Fri, 16 May 2025 15:20:07 +0000 (11:20 -0400)]
Align organization wording in copyright statement
This aligns the copyright and legal notice wordig with commit
a233a603bab8 and pgweb commit
2d764dbc083ab8. Backpatch down
to all supported versions.
Author: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Dave Page <dpage@pgadmin.org>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/
744E414E-3F52-404C-97FB-
ED9B3AA37DC8@yesql.se
Backpatch-through: 13
Richard Guo [Thu, 15 May 2025 08:09:04 +0000 (17:09 +0900)]
Fix Assert failure in XMLTABLE parser
In an XMLTABLE expression, columns can be marked NOT NULL, and the
parser internally fabricates an option named "is_not_null" to
represent this. However, the parser also allows users to specify
arbitrary option names. This creates a conflict: a user can
explicitly use "is_not_null" as an option name and assign it a
non-Boolean value, which violates internal assumptions and triggers an
assertion failure.
To fix, this patch checks whether a user-supplied name collides with
the internally reserved option name and raises an error if so.
Additionally, the internal name is renamed to "__pg__is_not_null" to
further reduce the risk of collision with user-defined names.
Reported-by: Евгений Горбанев <gorbanyoves@basealt.ru>
Author: Richard Guo <guofenglinux@gmail.com>
Reviewed-by: Alvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/
6bac9886-65bf-4cec-96bd-
e304159f28db@basealt.ru
Backpatch-through: 15
Richard Guo [Wed, 14 May 2025 00:59:31 +0000 (09:59 +0900)]
Add explicit initialization for all PlannerGlobal fields
When creating a new PlannerGlobal node in standard_planner(), most
fields are explicitly initialized, but a few are not. This doesn't
cause any functional issues, as makeNode() zeroes all fields by
default. However, the inconsistency is undesirable from a clarity and
maintenance perspective.
This patch explicitly initializes the remaining fields to improve
consistency and readability.
Author: Richard Guo <guofenglinux@gmail.com>
Reviewed-by: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/CAMbWs4-TgQHNOiouqGcuHoBqbJjWyx4UxGKxUY3FrF4trGbcPA@mail.gmail.com
Daniel Gustafsson [Tue, 13 May 2025 11:29:14 +0000 (07:29 -0400)]
Fix order of parameters in POD documentation
The documentation for log_check() had the parameters in the wrong
order. Also while there, rename %parameters to %params to better
documentation for similar functions which use %params. Backpatch
down to v14 where this was introduced.
Author: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/
9F503B5-32F2-45D7-A0AE-
952879AD65F1@yesql.se
Backpatch-through: 14
Amit Kapila [Tue, 13 May 2025 04:24:29 +0000 (09:54 +0530)]
Fix the race condition in the test added by
7c99dc587.
After executing ALTER SUBSCRIPTION tap_sub SET PUBLICATION, we did not
wait for the new walsender process to restart. As a result, an INSERT
executed immediately after the ALTER could be decoded and skipped,
considering it is not part of any subscribed publication. And, the old
apply worker could also confirm the LSN of such an INSERT. This could
cause the replication to resume from a point after the INSERT. In such
cases, we miss the expected warning about the missing publication.
To fix this, ensure the walsender has restarted before continuing after
ALTER SUBSCRIPTION.
Reported-by: Tom Lane as per CI
Author: vignesh C <vignesh21@gmail.com>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Discussion: https://postgr.es/m/
1230066.
1745992333@sss.pgh.pa.us
Álvaro Herrera [Sun, 11 May 2025 14:16:45 +0000 (10:16 -0400)]
Add tab-complete for ALTER DOMAIN ADD [CONSTRAINT]
We can add tab-completion with "CHECK (" and "NOT NULL" after ALTER
DOMAIN ADD [CONSTRAINT].
ALTER DOMAIN dom ADD -> CHECK (
ALTER DOMAIN dom ADD -> NOT NULL
ALTER DOMAIN dom ADD -> CONSTRAINT
ALTER DOMAIN dom ADD CONSTRAINT nm -> CHECK (
ALTER DOMAIN dom ADD CONSTRAINT nm -> NOT NULL
Author: jian he <jian.universality@gmail.com>
Author: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Discussion: https://postgr.es/m/CACJufxG_f6LzAT_McC-kKmQWpuWnOYKyNBw8Kv3xzTjPqmeHcA@mail.gmail.com
Álvaro Herrera [Sun, 11 May 2025 13:47:10 +0000 (09:47 -0400)]
Fix comment of tsquerysend()
The comment describes the order in which fields are sent, and it had one
of the fields in the wrong place.
This has been wrong since
e6dbcb72fafa (2008), so backpatch all the way
back.
Author: Emre Hasegeli <emre@hasegeli.com>
Discussion: https://postgr.es/m/CAE2gYzzf38bR_R=izhpMxAmqHXKeM5ajkmukh4mNs_oXfxcMCA@mail.gmail.com
Álvaro Herrera [Sun, 11 May 2025 13:22:12 +0000 (09:22 -0400)]
relcache: Avoid memory leak on tables with no CHECK constraints
As complained about by Valgrind, in commit
a379061a22a8 I failed to
realize that I was causing rd_att->constr->check to become allocated
when no CHECK constraints exist; previously it'd remain NULL. (This was
my bug, not the mentioned commit author's). Fix by making the
allocation conditional, and set ->check to NULL if unallocated.
Reported-by: Yasir <yasir.hussain.shah@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/
202505082025.57ijx3qrbx7u@alvherre.pgsql
Álvaro Herrera [Sun, 11 May 2025 13:15:05 +0000 (09:15 -0400)]
Sort includes in alphabetical order
Added by commit
042a66291b04, no backpatch needed.
Tom Lane [Sun, 11 May 2025 00:22:39 +0000 (20:22 -0400)]
Fix incorrect "return NULL" in BumpAllocLarge().
This must be "return MemoryContextAllocationFailure(context, size, flags)"
instead. The effect of this oversight is that if we got a malloc
failure right here, the code would act as though MCXT_ALLOC_NO_OOM
had been specified, whether it was or not. That would likely lead
to a null-pointer-dereference crash at the unsuspecting call site.
Noted while messing with a patch to improve our Valgrind leak
detection support. Back-patch to v17 where this code came in.
Noah Misch [Sat, 10 May 2025 14:36:27 +0000 (07:36 -0700)]
Remove GLOBALTABLESPACE_OID assert for locked buffers.
Commit
f4ece891fc2f3f96f0571720a1ae30db8030681b added the assertion in
an attempt to catch some defects even after VACUUM FULL or REINDEX.
However, IsCatalogTextUniqueIndexOid(tag.relNumber) always returns false
after a relfilenode change, provoking unintended assertion failures.
Reported-by: Adam Guo <adamguo@amazon.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Bug: #18912
Discussion: https://postgr.es/m/18912-
a41c9bd0e0ad19b1@postgresql.org
Bruce Momjian [Sat, 10 May 2025 03:39:34 +0000 (23:39 -0400)]
doc PG 18 relnotes: mv. hash joins and GROUP BY item to General
Reported-by: David Rowley
Discussion: https://postgr.es/m/CAApHDvqJz+Zf7a6abisqoTGottDSRD+YPx=aQSgCsCKD476vGA@mail.gmail.com
Michael Paquier [Sat, 10 May 2025 03:36:57 +0000 (12:36 +0900)]
aio: Use runtime arguments with injections points in tests
This cleans up the code related to the testing infrastructure of AIO
that used injection points, switching the test code to use the new
facility for injection points added by
371f2db8b05e rather than tweaks
to pass and reset arguments to the callbacks run.
This removes all the dependencies to USE_INJECTION_POINTS in the AIO
code. pgaio_io_call_inj(), pgaio_inj_io_get() and pgaio_inj_cur_handle
are now gone.
Reviewed-by: Greg Burd <greg@burd.me>
Discussion: https://postgr.es/m/Z_y9TtnXubvYAApS@paquier.xyz
Michael Paquier [Fri, 9 May 2025 22:40:25 +0000 (07:40 +0900)]
injection_points: Add support and tests for runtime arguments
This commit provides some test coverage for the runtime arguments of
injection points, for both INJECTION_POINT_CACHED() and
INJECTION_POINT(), as extended in
371f2db8b05e.
The SQL functions injection_points_cached() and injection_points_run()
are extended so as it is possible to pass an optional string value to
them.
Reviewed-by: Greg Burd <greg@burd.me>
Discussion: https://postgr.es/m/Z_y9TtnXubvYAApS@paquier.xyz
Michael Paquier [Fri, 9 May 2025 21:56:26 +0000 (06:56 +0900)]
Add support for runtime arguments in injection points
The macros INJECTION_POINT() and INJECTION_POINT_CACHED() are extended
with an optional argument that can be passed down to the callback
attached when an injection point is run, giving to callbacks the
possibility to manipulate a stack state given by the caller. The
existing callbacks in modules injection_points and test_aio have their
declarations adjusted based on that.
da7226993fd4 (core AIO infrastructure) and
93bc3d75d8e1 (test_aio) and
been relying on a set of workarounds where a static variable called
pgaio_inj_cur_handle is used as runtime argument in the injection point
callbacks used by the AIO tests, in combination with a TRY/CATCH block
to reset the argument value. The infrastructure introduced in this
commit will be reused for the AIO tests, simplifying them.
Reviewed-by: Greg Burd <greg@burd.me>
Discussion: https://postgr.es/m/Z_y9TtnXubvYAApS@paquier.xyz
Bruce Momjian [Fri, 9 May 2025 18:15:54 +0000 (14:15 -0400)]
doc PG 18 relnotes: fix missing parens for crc32c()
Reported-by: Steven Niu
Discussion: https://postgr.es/m/CABBtG=ejqK58cFWpw3etVZfQfhjC-qOqV+9GQWRnLO+p9wYMbw@mail.gmail.com
Tom Lane [Fri, 9 May 2025 16:29:01 +0000 (12:29 -0400)]
Skip RSA-PSS ssl test when using LibreSSL.
Presently, LibreSSL does not have working support for RSA-PSS,
so disable that test. Per discussion at
https://marc.info/?l=libressl&m=
174664225002441&w=2
they do intend to fix this, but it's a ways off yet.
Reported-by: Thomas Munro <thomas.munro@gmail.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/CA+hUKG+fLqyweHqFSBcErueUVT0vDuSNWui-ySz3+d_APmq7dw@mail.gmail.com
Backpatch-through: 15
Tom Lane [Fri, 9 May 2025 15:53:51 +0000 (11:53 -0400)]
Hack one ssl test case to pass with current LibreSSL.
With LibreSSL, our test of error logging for cert chain depths > 0
reports the wrong certificate. This is almost certainly their bug
not ours, so just tweak the test to accept their answer.
No back-patch needed, since this test case wasn't enabled before
e0f373ee4.
Reported-by: Thomas Munro <thomas.munro@gmail.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/CA+hUKG+fLqyweHqFSBcErueUVT0vDuSNWui-ySz3+d_APmq7dw@mail.gmail.com
Tom Lane [Fri, 9 May 2025 15:50:33 +0000 (11:50 -0400)]
Centralize ssl tests' check for whether we're using LibreSSL.
Right now there's only one caller, so that this is merely
an exercise in shoving code from one module to another,
but there will shortly be another one. It seems better to
avoid having two copies of this highly-subject-to-change test.
Back-patch to v15, where we first introduced some tests that
don't work with LibreSSL.
Reported-by: Thomas Munro <thomas.munro@gmail.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/CA+hUKG+fLqyweHqFSBcErueUVT0vDuSNWui-ySz3+d_APmq7dw@mail.gmail.com
Backpatch-through: 15
Peter Eisentraut [Fri, 9 May 2025 06:55:05 +0000 (08:55 +0200)]
doc: Put new options in consistent order on man pages
Heikki Linnakangas [Thu, 8 May 2025 19:01:25 +0000 (22:01 +0300)]
Use 'void *' for arbitrary buffers, 'uint8 *' for byte arrays
A 'void *' argument suggests that the caller might pass an arbitrary
struct, which is appropriate for functions like libc's read/write, or
pq_sendbytes(). 'uint8 *' is more appropriate for byte arrays that
have no structure, like the cancellation keys or SCRAM tokens. Some
places used 'char *', but 'uint8 *' is better because 'char *' is
commonly used for null-terminated strings. Change code around SCRAM,
MD5 authentication, and cancellation key handling to follow these
conventions.
Discussion: https://www.postgresql.org/message-id/
61be9e31-7b7d-49d5-bc11-
721800d89d64@eisentraut.org
Heikki Linnakangas [Thu, 8 May 2025 19:01:20 +0000 (22:01 +0300)]
Use more mundane 'int' type for cancel key lengths in libpq
The documented max length of a cancel key is 256 bytes, so it fits in
uint8. It nevertheless seems weird to not just use 'int', like in
commit
0f1433f053 for the backend.
Discussion: https://www.postgresql.org/message-id/
61be9e31-7b7d-49d5-bc11-
721800d89d64%40eisentraut.org
Bruce Momjian [Thu, 8 May 2025 15:11:08 +0000 (11:11 -0400)]
PG 18 relnotes: adjust RETURNING new/old item
Reported-by: jian he
Discussion: https://postgr.es/m/CACJufxFM1avdwu=OrTx_uMAjTDbFOj1Gp7mnNHOofTVj9QtmRw@mail.gmail.com
Daniel Gustafsson [Thu, 8 May 2025 11:53:16 +0000 (13:53 +0200)]
doc: Fix title markup for AT TIME ZONE and AT LOCAL
The title for AT TIME ZONE and AT LOCAL was accidentally wrapping the
"and" in the <literal> tag. Backpatch to v17 where it was introduced
in
97957fdbaa42.
Author: Noboru Saito <noborusai@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Tatsuo Ishii <ishii@postgresql.org>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/CAAM3qn+7QUWW9R6_YwPKXmky0xGE4n63U3EsxZeWE_QtogeU8g@mail.gmail.com
Backpatch-through: 17
Richard Guo [Thu, 8 May 2025 09:21:32 +0000 (18:21 +0900)]
Track the number of presorted outer pathkeys in MergePath
When creating an explicit Sort node for the outer path of a mergejoin,
we need to determine the number of presorted keys of the outer path to
decide whether explicit incremental sort can be applied. Currently,
this is done by repeatedly calling pathkeys_count_contained_in.
This patch caches the number of presorted outer pathkeys in MergePath,
allowing us to save several calls to pathkeys_count_contained_in. It
can be considered a complement to the changes in commit
828e94c9d.
Reported-by: David Rowley <dgrowleyml@gmail.com>
Author: Richard Guo <guofenglinux@gmail.com>
Reviewed-by: Tender Wang <tndrwang@gmail.com>
Discussion: https://postgr.es/m/CAApHDvqvBireB_w6x8BN5txdvBEHxVgZBt=rUnpf5ww5P_E_ww@mail.gmail.com
Richard Guo [Thu, 8 May 2025 09:20:18 +0000 (18:20 +0900)]
Suppress unnecessary explicit sorting for EPQ mergejoin path
When building a ForeignPath for a joinrel, if there's a possibility
that EvalPlanQual will be executed, we must identify a suitable path
for EPQ checks. If the outer or inner path of the chosen path is a
ForeignPath representing a pushed-down join, we replace it with its
fdw_outerpath to ensure that the EPQ check path consists entirely of
local joins.
If the chosen path is a MergePath, and its outer or inner path is a
ForeignPath that is not already well enough ordered, the MergePath
will have non-NIL outersortkeys or innersortkeys indicating the
desired ordering to be created by an explicit Sort node. If we then
replace the outer or inner path with its corresponding fdw_outerpath,
and that path is already sufficiently ordered, we end up in an
inconsistent state: the MergePath has non-NIL outersortkeys or
innersortkeys, and its input path is already properly ordered. This
inconsistency can result in an Assert failure or the addition of a
redundant Sort node.
To fix, check if the new outer or inner path of a MergePath is already
properly sorted, and set its outersortkeys or innersortkeys to NIL if
so.
Bug: #18902
Reported-by: Nikita Kalinin <n.kalinin@postgrespro.ru>
Author: Richard Guo <guofenglinux@gmail.com>
Reviewed-by: Tender Wang <tndrwang@gmail.com>
Discussion: https://postgr.es/m/18902-
71c1bed2b9f7c46f@postgresql.org
Bruce Momjian [Thu, 8 May 2025 01:11:16 +0000 (21:11 -0400)]
doc PG 18 relnotes: adjust pg_log_backend_memory_contexts()
Reported-by: David Rowley
Discussion: https://postgr.es/m/CAApHDvrGLBqs_Vm9COMY7uBDvUDMKds7RwC20YjEPf+XRTY9XQ@mail.gmail.com
Bruce Momjian [Thu, 8 May 2025 00:36:21 +0000 (20:36 -0400)]
doc PG 18 relnotes: add pg_log_backend_memory_contexts() mention
Now zero-based.
Reported-by: David Rowley
Discussion: https://postgr.es/m/CAApHDvqMfTBdfwc0Z-tHXLnBMKJLYEZDApgUzA7x_PUDZsY3GA@mail.gmail.com
Bruce Momjian [Wed, 7 May 2025 20:56:26 +0000 (16:56 -0400)]
doc PG 18 relnotes: adjust pgbench per-script reporting item
Also run src/tools/add_commit_links.pl for a previous commit.
Reported-by: Yugo Nagata
Discussion: https://postgr.es/m/
20250507195941.
c6e1b48c73f062b727f686a8@sraoss.co.jp
Bruce Momjian [Wed, 7 May 2025 20:39:26 +0000 (16:39 -0400)]
doc PG 18 relnotes: mention GROUP SET fixes
Reported-by: Richard Guo
Discussion: https://postgr.es/m/CAMbWs4_asKPqTCt0h9pp=zHc9vmPcnczbHeF6Xkxn1LhLapcTQ@mail.gmail.com
Nathan Bossart [Wed, 7 May 2025 19:47:36 +0000 (14:47 -0500)]
Remove pg_replication_origin's TOAST table.
A few places that access this catalog don't set up an active
snapshot before potentially accessing its TOAST table. However,
roname (the replication origin name) is the only varlena column, so
this is only a problem if the name requires out-of-line storage.
This commit removes its TOAST table to avoid needing to set up a
snapshot. It also places a limit on replication origin names so
that attempts to set long names will fail with a more user-friendly
error. Those chosen limit of 512 bytes should be sufficient to
avoid "row is too big" errors independent of BLCKSZ, but it should
also be lenient enough for all reasonable use-cases.
Bumps catversion.
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: Euler Taveira <euler@eulerto.com>
Reviewed-by: Nisha Moond <nisha.moond412@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/ZvMSUPOqUU-VNADN%40nathan
Peter Geoghegan [Wed, 7 May 2025 19:20:42 +0000 (15:20 -0400)]
Prevent premature nbtree array advancement.
nbtree array index scans could fail to return matching tuples in rare
cases where the missed tuples cover key space that the scan's arrays
incorrectly indicate has already been read. These cases involved nearby
tuples with NULL values that were evaluated using a skip array key while
in pstate.forcenonrequired mode.
To fix, prevent forcenonrequired mode from prematurely advancing the
scan's array keys beyond key space that the scan has yet to read tuples
from: reset the scan's array keys (to the first elements in the current
scan direction) before the _bt_checkkeys call for pstate.finaltup. That
way _bt_checkkeys starts from a clean slate, which ensures that it will
call _bt_advance_array_keys (while passing it sktrig_required=true).
This reliably restores the invariant that the scan's arrays always
accurately track its progress through the index's key space (at least
when the scan is "between pages").
Oversight in commit
8a510275, which optimized nbtree search scan key
comparisons.
Author: Peter Geoghegan <pg@bowt.ie>
Reviewed-By: Mark Dilger <mark.dilger@enterprisedb.com>
Discussion: https://postgr.es/m/CAH2-WzmodSE+gpTd1CRGU9ez8ytyyDS+Kns2r9NzgUp1s56kpw@mail.gmail.com
Peter Geoghegan [Wed, 7 May 2025 19:17:40 +0000 (15:17 -0400)]
nbtree: tighten up array recheck rules.
Be more conservative when performing a scheduled recheck of an nbtree
scan's array keys once on the next page, having set so->scanBehind: back
out of reading the page (perform another primitive scan instead) when
the next page's high key/finaltup has an untruncated prefix of matching
values and truncated suffix attributes associated with lower-order keys.
In other words, stop assuming that the lower-order keys have been
satisfied by the truncated suffix attributes in this context (only do so
when considering scheduling a recheck within _bt_advance_array_keys).
The new behavior is more logical: if the next page read after setting
so->scanBehind can only contain tuples that are themselves "behind the
scan", that's reason enough to cut our losses. In general, when we set
so->scanBehind, we only expect to perform one recheck on the next page
to make a final decision about whether or not to continue the current
primitive index scan. It seems unprincipled for the recheck to allow a
_bt_readpage to continue unless the scan's arrays will advance/unless
the page might actually contain relevant tuples.
In practice it is highly unlikely that things will line up like this
(the untruncated prefix of attribute values from the next page's high
key is seldom an exact match for their corresponding array's current
element following array advancement on the original/previous page).
That gives us all the more reason to keep things simple and consistent.
This was arguably an oversight in commit
9a2e2a285a, which improved
nbtree array primitive scan scheduling.
Author: Peter Geoghegan <pg@bowt.ie>
Discussion: https://postgr.es/m/CAH2-WzkXzJajgyW-pCQ7vaDPhaT3huU+Zw_j448rpCBEsu2YOQ@mail.gmail.com
Nathan Bossart [Wed, 7 May 2025 18:36:51 +0000 (13:36 -0500)]
pg_dumpall: Add --sequence-data.
I recently added this option to pg_dump, but I forgot to add it to
pg_dumpall, too. There's probably little use for it at the moment,
but we will need it if/when we teach pg_upgrade to use pg_dumpall
to dump the database schemas.
Oversight in commit
9c49f0e8cd.
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/aBE8rHFo922xQUwh%40nathan
Alexander Korotkov [Wed, 7 May 2025 08:10:16 +0000 (11:10 +0300)]
Refactor ChangeVarNodesExtended() using the custom callback
fc069a3a6319 implemented Self-Join Elimination (SJE) and put related logic
to ChangeVarNodes_walker(). This commit provides refactoring to remove the
SJE-related logic from ChangeVarNodes_walker() but adds a custom callback to
ChangeVarNodesExtended(), which has a chance to process a node before
ChangeVarNodes_walker(). Passing this callback to ChangeVarNodesExtended()
allows SJE-related node handling to be kept within the analyzejoins.c.
Reported-by: Richard Guo <guofenglinux@gmail.com>
Discussion: https://postgr.es/m/CAMbWs49PE3CvnV8vrQ0Dr%3DHqgZZmX0tdNbzVNJxqc8yg-8kDQQ%40mail.gmail.com
Author: Andrei Lepikhov <lepihov@gmail.com>
Author: Alexander Korotkov <aekorotkov@gmail.com>
Peter Eisentraut [Sun, 4 May 2025 18:38:42 +0000 (20:38 +0200)]
doc: Put some psql documentation pieces back into alphabetical order
Peter Eisentraut [Sun, 4 May 2025 11:04:46 +0000 (13:04 +0200)]
Remove some tabs in C string literals
Peter Eisentraut [Sun, 4 May 2025 10:43:10 +0000 (12:43 +0200)]
doc: Add link to table
Formal tables should generally have an xref in the text that points to
them. Add them here.
Peter Eisentraut [Sun, 4 May 2025 10:39:21 +0000 (12:39 +0200)]
doc: Fix up spacing around verbatim DocBook elements
Michael Paquier [Wed, 7 May 2025 05:55:57 +0000 (14:55 +0900)]
Fix some comments related to IO workers
IO workers are treated as auxiliary processes. The comments fixed in
this commit stated that there could be only one auxiliary process of
each BackendType at the same time. This is not true for IO workers, as
up to MAX_IO_WORKERS of them can co-exist at the same time.
Author: Cédric Villemain <Cedric.Villemain@data-bene.io>
Co-authored-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/
e4a3ac45-abce-4b58-a043-
b4a31cd11113@Data-Bene.io
Peter Eisentraut [Wed, 7 May 2025 05:01:03 +0000 (07:01 +0200)]
Fix whitespace
Bruce Momjian [Wed, 7 May 2025 01:15:44 +0000 (21:15 -0400)]
doc PG 18 relnotes: adjust partition planning item
Reported-by: David Rowley
Discussion: https://postgr.es/m/CAApHDvqgK7uqPZAwxsfBiFhvBHHB0txaUxhUrdwG4d5Mik_RnA@mail.gmail.com
Bruce Momjian [Tue, 6 May 2025 21:17:46 +0000 (17:17 -0400)]
doc PG 18 relnotes: small adjustments regarding options
Reported-by: jian he
Discussion: https://postgr.es/m/CACJufxH1jo=hv77AK0HUJYBBMuPmr6+JT+8g-yovuJmHUPGOZQ@mail.gmail.com
Bruce Momjian [Tue, 6 May 2025 20:03:56 +0000 (16:03 -0400)]
doc PG 18 relnotes: move partition locking item to General Perf
Reported-by: Amit Langote
Discussion: https://postgr.es/m/CA+HiwqE+8Pui_NCCC7zgacnet0Cf3tc_vU+P=nhLDES-8xuCUw@mail.gmail.com
Bruce Momjian [Tue, 6 May 2025 19:45:03 +0000 (15:45 -0400)]
doc PG 18 relnotes: adjust partition items
Reported-by: David Rowley
Discussion: https://postgr.es/m/CAApHDvo+BrVTXMBPjNXBTnAovJWN9+-dYc0kN7rSDqdNvpggZQ@mail.gmail.com