users/rhaas/postgres.git
2 weeks agofix some line break logic advice2
Robert Haas [Fri, 18 Jul 2025 19:14:47 +0000 (15:14 -0400)]
fix some line break logic

2 weeks agoRemove pgpa_fix_scan_or_clump_member.
Robert Haas [Wed, 16 Jul 2025 20:27:26 +0000 (16:27 -0400)]
Remove pgpa_fix_scan_or_clump_member.

2 weeks agoaddress XXX by addingg comments
Robert Haas [Wed, 16 Jul 2025 20:19:13 +0000 (16:19 -0400)]
address XXX by addingg comments

2 weeks agoremove obsolete XXX
Robert Haas [Wed, 16 Jul 2025 18:54:10 +0000 (14:54 -0400)]
remove obsolete XXX

2 weeks agoAppend nodes bearing non-relation RTIs are ordinary
Robert Haas [Wed, 16 Jul 2025 18:46:58 +0000 (14:46 -0400)]
Append nodes bearing non-relation RTIs are ordinary

this isn't really a correct fix

2 weeks agorework for scans
Robert Haas [Wed, 16 Jul 2025 17:01:53 +0000 (13:01 -0400)]
rework for scans

This seems to actually kind of work, but there are definitely some things
that are broken.

In particular, PARTITIONWISE() advice is being emitted for plans where
Append nodes are induced by setops rather than by table inheritance;
and what looks like extra PARTITIONWISE() advice is also being emitted
for non-obvious reasons in some table inheritance cases.

Also, INDEX_SCAN(), INDEX_ONLY_SCAN(), and BITMAP_HEAP_SCAN() output
needs revising, and ORDINARY_SCAN() output needs suppressing.

2 weeks agoreindent
Robert Haas [Wed, 16 Jul 2025 13:54:35 +0000 (09:54 -0400)]
reindent

2 weeks agorenaming, phase 2
Robert Haas [Wed, 16 Jul 2025 13:52:02 +0000 (09:52 -0400)]
renaming, phase 2

2 weeks agorenaming, phase 1
Robert Haas [Wed, 16 Jul 2025 13:47:42 +0000 (09:47 -0400)]
renaming, phase 1

2 weeks agoreclassify clumped joins as scans
Robert Haas [Wed, 16 Jul 2025 13:24:46 +0000 (09:24 -0400)]
reclassify clumped joins as scans

2 weeks agoupgrades
Robert Haas [Wed, 16 Jul 2025 12:43:40 +0000 (08:43 -0400)]
upgrades

2 weeks agocontext->walker
Robert Haas [Tue, 15 Jul 2025 17:17:49 +0000 (13:17 -0400)]
context->walker

2 weeks agoPGPAQF_SEMIJOIN_(NON_)UNIQUE
Robert Haas [Tue, 15 Jul 2025 17:13:53 +0000 (13:13 -0400)]
PGPAQF_SEMIJOIN_(NON_)UNIQUE

2 weeks agoadd query features earlier before considering elided nodes
Robert Haas [Tue, 15 Jul 2025 16:40:31 +0000 (12:40 -0400)]
add query features earlier before considering elided nodes

2 weeks agoRemove pgpa_gathered_join -- query features make it is obsolete.
Robert Haas [Tue, 15 Jul 2025 16:24:49 +0000 (12:24 -0400)]
Remove pgpa_gathered_join -- query features make it is obsolete.

2 weeks agoFirst stab at SJ_UNIQUE.
Robert Haas [Tue, 15 Jul 2025 16:10:31 +0000 (12:10 -0400)]
First stab at SJ_UNIQUE.

2 weeks agoadd query_feature thing -- this implies removing gathered_join, not done
Robert Haas [Mon, 14 Jul 2025 18:29:32 +0000 (14:29 -0400)]
add query_feature thing -- this implies removing gathered_join, not done

3 weeks agostuff
Robert Haas [Mon, 7 Jul 2025 19:41:28 +0000 (15:41 -0400)]
stuff

4 weeks agoadd "clear" functions
Robert Haas [Thu, 3 Jul 2025 19:30:58 +0000 (15:30 -0400)]
add "clear" functions

4 weeks agoremove old file
Robert Haas [Thu, 3 Jul 2025 19:00:55 +0000 (15:00 -0400)]
remove old file

4 weeks agotrim shared advice
Robert Haas [Thu, 3 Jul 2025 19:00:08 +0000 (15:00 -0400)]
trim shared advice

4 weeks agoEXPLAIN (PLAN_ADVICE)
Robert Haas [Thu, 3 Jul 2025 17:54:17 +0000 (13:54 -0400)]
EXPLAIN (PLAN_ADVICE)

4 weeks agoadd missing dsa_pin call
Robert Haas [Thu, 3 Jul 2025 16:57:41 +0000 (12:57 -0400)]
add missing dsa_pin call

4 weeks agopgindent
Robert Haas [Thu, 3 Jul 2025 16:21:41 +0000 (12:21 -0400)]
pgindent

4 weeks agopg_get_collected_shared_advice
Robert Haas [Thu, 3 Jul 2025 16:21:01 +0000 (12:21 -0400)]
pg_get_collected_shared_advice

4 weeks agoadd ability to store in the shared collector
Robert Haas [Thu, 3 Jul 2025 16:05:49 +0000 (12:05 -0400)]
add ability to store in the shared collector

4 weeks agopgindent
Robert Haas [Thu, 3 Jul 2025 14:12:12 +0000 (10:12 -0400)]
pgindent

4 weeks agocomments, skip storage of empty advice
Robert Haas [Wed, 2 Jul 2025 17:50:23 +0000 (13:50 -0400)]
comments, skip storage of empty advice

4 weeks agosomewhat-working local collection
Robert Haas [Wed, 2 Jul 2025 17:39:52 +0000 (13:39 -0400)]
somewhat-working local collection

4 weeks agostart some advice storage ideas in motion
Robert Haas [Tue, 1 Jul 2025 20:10:36 +0000 (16:10 -0400)]
start some advice storage ideas in motion

4 weeks agoadd stuff
Robert Haas [Tue, 1 Jul 2025 17:09:48 +0000 (13:09 -0400)]
add stuff

5 weeks agoMore work on output stuff.
Robert Haas [Fri, 27 Jun 2025 19:15:04 +0000 (15:15 -0400)]
More work on output stuff.

There is doubtless a lot of stuff still wrong here, but it's way
closer to what I actually want.

5 weeks agofix duplicate clumped-join creation
Robert Haas [Fri, 27 Jun 2025 17:52:17 +0000 (13:52 -0400)]
fix duplicate clumped-join creation

5 weeks agooutput restructuring and miscellaneous cleanup
Robert Haas [Fri, 27 Jun 2025 17:16:12 +0000 (13:16 -0400)]
output restructuring and miscellaneous cleanup

5 weeks agodebug_out -> output
Robert Haas [Fri, 27 Jun 2025 14:51:14 +0000 (10:51 -0400)]
debug_out -> output

5 weeks agoadd constants for enum length
Robert Haas [Fri, 27 Jun 2025 14:50:02 +0000 (10:50 -0400)]
add constants for enum length

5 weeks agoMove wrap_column into pgpa_output_context
Robert Haas [Fri, 27 Jun 2025 14:39:40 +0000 (10:39 -0400)]
Move wrap_column into pgpa_output_context

5 weeks agopgindent
Robert Haas [Fri, 27 Jun 2025 14:24:19 +0000 (10:24 -0400)]
pgindent

5 weeks agoIntroduce output context object.
Robert Haas [Fri, 27 Jun 2025 14:24:03 +0000 (10:24 -0400)]
Introduce output context object.

5 weeks agoadd some line wrapping logic
Robert Haas [Fri, 27 Jun 2025 14:00:34 +0000 (10:00 -0400)]
add some line wrapping logic

5 weeks agomove more code to pgpa_output.c
Robert Haas [Thu, 26 Jun 2025 17:59:40 +0000 (13:59 -0400)]
move more code to pgpa_output.c

5 weeks agomove debug output routines to a new file
Robert Haas [Thu, 26 Jun 2025 16:18:31 +0000 (12:18 -0400)]
move debug output routines to a new file

5 weeks agofilter join RTIs out of clumped joins to avoid failures
Robert Haas [Wed, 25 Jun 2025 20:08:20 +0000 (16:08 -0400)]
filter join RTIs out of clumped joins to avoid failures

5 weeks agoreintroduce range table identifiers
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

5 weeks agomore comments
Robert Haas [Tue, 24 Jun 2025 16:24:29 +0000 (12:24 -0400)]
more comments

5 weeks agomore comments
Robert Haas [Tue, 24 Jun 2025 16:22:16 +0000 (12:22 -0400)]
more comments

5 weeks agopgindent
Robert Haas [Tue, 24 Jun 2025 16:08:47 +0000 (12:08 -0400)]
pgindent

5 weeks agoRefactoring.
Robert Haas [Tue, 24 Jun 2025 16:08:21 +0000 (12:08 -0400)]
Refactoring.

5 weeks agoremove more code not required by the regression tests
Robert Haas [Tue, 24 Jun 2025 15:41:14 +0000 (11:41 -0400)]
remove more code not required by the regression tests

5 weeks agoremove apparently-unnecessary Result node traversal
Robert Haas [Tue, 24 Jun 2025 15:31:59 +0000 (11:31 -0400)]
remove apparently-unnecessary Result node traversal

add some comments

5 weeks agouse pgpa_descend_node more
Robert Haas [Tue, 24 Jun 2025 15:08:23 +0000 (11:08 -0400)]
use pgpa_descend_node more

5 weeks agocleanup, incidental bug fix
Robert Haas [Tue, 24 Jun 2025 14:51:45 +0000 (10:51 -0400)]
cleanup, incidental bug fix

5 weeks agofix various things so regression tests pass
Robert Haas [Tue, 24 Jun 2025 14:39:28 +0000 (10:39 -0400)]
fix various things so regression tests pass

7 weeks agofix subplan walking because i never get this right
Robert Haas [Thu, 12 Jun 2025 20:12:49 +0000 (16:12 -0400)]
fix subplan walking because i never get this right

7 weeks agoCouple of bug fixes and tweaks.
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.

7 weeks agotemporary debugging hack
Robert Haas [Thu, 12 Jun 2025 15:35:24 +0000 (11:35 -0400)]
temporary debugging hack

7 weeks agoupdate makefile
Robert Haas [Thu, 12 Jun 2025 15:20:13 +0000 (11:20 -0400)]
update makefile

7 weeks agoremove XXX
Robert Haas [Mon, 9 Jun 2025 19:16:12 +0000 (15:16 -0400)]
remove XXX

7 weeks agooutput something for GATHER and GATHER_MERGE
Robert Haas [Mon, 9 Jun 2025 19:10:52 +0000 (15:10 -0400)]
output something for GATHER and GATHER_MERGE

8 weeks agotidy up some cosmetics
Robert Haas [Fri, 6 Jun 2025 19:26:05 +0000 (15:26 -0400)]
tidy up some cosmetics

8 weeks agoLook through Gather and Gather Merge nodes.
Robert Haas [Fri, 6 Jun 2025 19:22:13 +0000 (15:22 -0400)]
Look through Gather and Gather Merge nodes.

8 weeks agoInsist that a purported scan node must have an RTI.
Robert Haas [Fri, 6 Jun 2025 19:02:27 +0000 (15:02 -0400)]
Insist that a purported scan node must have an RTI.

8 weeks agoattempt to fix handling of multiple elided nodes
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

8 weeks agofirst elided node -> last elided node
Robert Haas [Fri, 6 Jun 2025 16:31:55 +0000 (12:31 -0400)]
first elided node -> last elided node

8 weeks agoadd a comment
Robert Haas [Thu, 5 Jun 2025 19:21:51 +0000 (15:21 -0400)]
add a comment

2 months agohackity hack elided nodes
Robert Haas [Fri, 30 May 2025 15:28:21 +0000 (11:28 -0400)]
hackity hack elided nodes

2 months agohackity, hack
Robert Haas [Thu, 29 May 2025 17:49:03 +0000 (13:49 -0400)]
hackity, hack

2 months agohackity hack
Robert Haas [Wed, 28 May 2025 20:06:48 +0000 (16:06 -0400)]
hackity hack

2 months agofix a few bugs
Robert Haas [Thu, 22 May 2025 19:33:53 +0000 (15:33 -0400)]
fix a few bugs

2 months agodebugging code that shows it doesn't work
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

2 months agoRemove unused field.
Robert Haas [Wed, 21 May 2025 19:46:14 +0000 (15:46 -0400)]
Remove unused field.

2 months agopgpa_join_strategy renaming
Robert Haas [Wed, 21 May 2025 18:47:51 +0000 (14:47 -0400)]
pgpa_join_strategy renaming

2 months agofix some stuff
Robert Haas [Wed, 21 May 2025 18:32:16 +0000 (14:32 -0400)]
fix some stuff

2 months agoStart trying to get a proper treewalk oraganized.
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.

2 months agoremove junk
Robert Haas [Thu, 24 Apr 2025 18:38:45 +0000 (14:38 -0400)]
remove junk

2 months agopgpa_join.c
Robert Haas [Thu, 24 Apr 2025 18:37:56 +0000 (14:37 -0400)]
pgpa_join.c

2 months agopgpa_join.h
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.

2 months agoPort pg_plan_advice over from the subplanname branch.
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

2 months agoStore information about elided nodes in the final plan.
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.

2 months agoStore information about range-table flattening in the final plan.
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.

2 months agoGive subplans names that are known while planning that subplan.
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.

2 months agoAssert that RTIs of joined rels are discoverable from join plans.
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).

2 months agoConsider a Result node's relids in ExplainPreScanNode.
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.

2 months agoKeep track of what RTIs a Result node is scanning.
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.

2 months agoDon't retreat slot's confirmed_flush LSN.
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

2 months agoDoc: add pre-branch task to run src/tools/copyright.pl.
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

2 months agoFix incorrect year in some copyright notices
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

2 months agoecpg: Add missing newline in meson.build
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

2 months agoFix tuple_fraction calculation in generate_orderedappend_paths()
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>
2 months agoMake our usage of memset_s() conform strictly to the C11 standard.
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

2 months agoFix function name reference in comment
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

2 months agoAlign organization wording in copyright statement
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

2 months agoFix Assert failure in XMLTABLE parser
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

2 months agoAdd explicit initialization for all PlannerGlobal fields
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

2 months agoFix order of parameters in POD documentation
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

2 months agoFix the race condition in the test added by 7c99dc587.
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

2 months agoAdd tab-complete for ALTER DOMAIN ADD [CONSTRAINT]
Á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

2 months agoFix comment of tsquerysend()
Á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

2 months agorelcache: Avoid memory leak on tables with no CHECK constraints
Á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

2 months agoSort includes in alphabetical order
Á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.