Alexander Korotkov [Wed, 22 May 2024 23:22:40 +0000 (02:22 +0300)]
Don't copy extended statistics during MERGE/SPLIT partition operations
When MERGE/SPLIT created new partitions, it was cloning the extended
statistics of the parent table.
However, extended stats on partitioned tables don't behave like
indexes on partitioned tables (which exist only to create physical
indexes on child tables). Rather, extended stats on a parent 1) cause
extended stats to be collected and computed across the whole partition
hierarchy, and 2) do not cause extended stats to be computed for the
individual partitions.
"CREATE TABLE ... PARTITION OF" command doesn't copy extended
statistics. This commit makes createPartitionTable() behave
consistently.
Reported-by: Justin Pryzby
Discussion: https://postgr.es/m/ZiJW1g2nbQs9ekwK%40pryzbyj2023
Author: Alexander Korotkov, Justin Pryzby
Alexander Korotkov [Wed, 22 May 2024 23:21:00 +0000 (02:21 +0300)]
Fix the name collision detection in MERGE/SPLIT partition operations
Both MERGE and SPLIT partition operations support the case when the name of the
new partition matches the name of the existing partition to be merged/split.
But the name collision detection doesn't always work as intended. The SPLIT
partition operation finds the namespace to search for an existing partition
without taking into account the parent's persistence. The MERGE partition
operation checks for the name collision with simple equal() on RangeVar's
simply ignoring the search_path.
This commit fixes this behavior as follows.
1. The SPLIT partition operation now finds the namespace to search for
an existing partition according to the parent's persistence.
2. The MERGE partition operation now checks for the name collision similarly
to the SPLIT partition operation using
RangeVarGetAndCheckCreationNamespace() and get_relname_relid().
Reported-by: Alexander Lakhin
Discussion: https://postgr.es/m/
86b4f1e3-0b5d-315c-9225-
19860d64d685%40gmail.com
Author: Dmitry Koval, Alexander Korotkov
Alexander Korotkov [Wed, 22 May 2024 23:13:43 +0000 (02:13 +0300)]
amcheck: Report an error when the next page to a leaf is not a leaf
This is a very unlikely condition during checking a B-tree unique constraint,
meaning that the index structure is violated badly, and we shouldn't continue
checking to avoid endless loops, etc. So it's worth immediately throwing an
error.
Reported-by: Peter Geoghegan
Discussion: https://postgr.es/m/CAH2-Wzk%2B2116uOXdOViA27SHcr31WKPgmjsxXLBs_aTxAeThzg%40mail.gmail.com
Author: Pavel Borisov
Alexander Korotkov [Wed, 22 May 2024 23:12:45 +0000 (02:12 +0300)]
amcheck: Don't load the right sibling page into BtreeCheckState
5ae2087202 implemented a cross-page unique constraint check by loading
the right sibling to the BtreeCheckState.target variable. This is wrong,
because bt_target_page_check() shouldn't change the target page. Also,
BtreeCheckState.target shouldn't be changed alone without
BtreeCheckState.targetblock.
However, the above didn't cause any visible bugs for the following reasons.
1. We do a cross-page unique constraint check only for leaf index pages.
2. The only way target page get accessed after a cross-page unique constraint
check is loading of the lowkey.
3. The only place lowkey is used is bt_child_highkey_check(), and that applies
only to non-leafs.
The reasons above don't diminish the fact that changing BtreeCheckState.target
for a cross-page unique constraint check is wrong. This commit changes this
check to temporarily store the right sibling to the local variable.
Reported-by: Peter Geoghegan
Discussion: https://postgr.es/m/CAH2-Wzk%2B2116uOXdOViA27SHcr31WKPgmjsxXLBs_aTxAeThzg%40mail.gmail.com
Author: Pavel Borisov
Alexander Korotkov [Wed, 22 May 2024 23:11:14 +0000 (02:11 +0300)]
amcheck: Refactoring the storage of the last visible entry
This commit introduces a new data structure BtreeLastVisibleEntry comprising
information about the last visible heap entry with the current value of key.
Usage of this data structure allows us to avoid passing all this information
as individual function arguments.
Reported-by: Alexander Korotkov
Discussion: https://www.postgresql.org/message-id/CAPpHfdsVbB9ToriaB1UHuOKwjKxiZmTFQcEF%3DjuzzC_nby31uA%40mail.gmail.com
Author: Pavel Borisov, Alexander Korotkov
Bruce Momjian [Wed, 22 May 2024 22:50:33 +0000 (18:50 -0400)]
doc PG 17 relnotes: fix pg_stat_reset_shared quoting
Reported-by: torikoshia
Discussion: https://postgr.es/m/
8ab708436c369d47fcbb23a8ad775ea7@oss.nttdata.com
Backpatch-through: master
Bruce Momjian [Wed, 22 May 2024 22:48:16 +0000 (18:48 -0400)]
doc PG 17 relnotes: fix pg_stat_statements typo
Reported-by: Masahiko Sawada
Discussion: https://postgr.es/m/CAD21AoB_MR=S_Gh=oeJR4ji0GGY+d8747O-5pYcbMbhGOMtAwQ@mail.gmail.com
Author: Masahiko Sawada
Backpatch-through: master
Bruce Momjian [Wed, 22 May 2024 22:46:26 +0000 (18:46 -0400)]
doc PG 17 relnotes: adjust SQL/JSON constructor func. authors
Reported-by: Amit Langote
Discussion: https://postgr.es/m/CA+HiwqHA2_2V-UtdEEjX3wMUcO=pAwH2D=9P9cRYGVcNLJkH+w@mail.gmail.com
Author: Amit Langote
Backpatch-through: master
Bruce Momjian [Wed, 22 May 2024 22:39:19 +0000 (18:39 -0400)]
doc PG 17 relnotes: adjust builtin collation provider item
Reported-by: Jeff Davis
Discussion: https://postgr.es/m/
92e039f6fabc3567169e95e12b39a04c00f8503b.camel@j-davis.com
Backpatch-through: master
Tom Lane [Wed, 22 May 2024 22:22:50 +0000 (18:22 -0400)]
Fix input of ISO "extended" time format for types time and timetz.
Commit
3e1a373e2 missed teaching DecodeTimeOnly the same "ptype"
manipulations it added to DecodeDateTime. While likely harmless
at the time, it became a problem after
5b3c59535 added an error check
that ptype must be zero once we exit the parsing loop (that is, there
shouldn't be any unused prefixes). The consequence was that we'd
reject time or timetz input like T12:34:56 (the "extended" format
per ISO 8601-1:2019), even though that still worked in timestamp
input.
Since this is clearly under-tested code, add test cases covering all
the ISO 8601 time formats. (Note: although 8601 allows just "Thh",
we have never accepted that, and this patch doesn't change that.
I'm content to leave that as-is because it seems too likely to be
a mistake rather than intended input. If anyone wants to allow
that, it should be a separate patch anyway, and not back-patched.)
Per bug #18470 from David Perez. Back-patch to v16 where we
broke it.
Discussion: https://postgr.es/m/18470-
34fad4c829106848@postgresql.org
Bruce Momjian [Wed, 22 May 2024 21:59:00 +0000 (17:59 -0400)]
doc PG 17 relnotes: add Heikki Linnakangas to vacuum item
Reported-by: Melanie Plageman
Discussion: https://postgr.es/m/CAAKRu_YYR5MXY-xuCpr7DKKugCExTSjRy9Ax8c-z7LKa8dDfwg@mail.gmail.com
Author: Melanie Plageman
Backpatch-through: master
Tom Lane [Wed, 22 May 2024 21:54:17 +0000 (17:54 -0400)]
Fix handling of extended expression statistics in CREATE TABLE LIKE.
transformTableLikeClause believed that it could process extended
statistics immediately because "the representation of CreateStatsStmt
doesn't depend on column numbers". That was true when extended stats
were first introduced, but it was falsified by the addition of
extended stats on expressions: the parsed expression tree is fed
forward by the LIKE option, and that will contain Vars. So if the
new table doesn't have attnums identical to the old one's (typically
because there are some dropped columns in the old one), that doesn't
work. The CREATE goes through, but it emits invalid statistics
objects that will cause problems later.
Fortunately, we already have logic that can adapt expression trees
to the possibly-new column numbering. To use it, we have to delay
processing of CREATE_TABLE_LIKE_STATISTICS into expandTableLikeClause,
just as for other LIKE options that involve expressions.
Per bug #18468 from Alexander Lakhin. Back-patch to v14 where
extended statistics on expressions were added.
Discussion: https://postgr.es/m/18468-
f5add190e3fa5902@postgresql.org
Robert Haas [Tue, 21 May 2024 16:54:09 +0000 (12:54 -0400)]
Fix generate_union_paths for non-sortable types.
The previous logic would fail to set groupList when
grouping_is_sortable() returned false, which could cause queries
to return wrong answers when some columns were not sortable.
David Rowley, reviewed by Heikki Linnakangas and Álvaro Herrera.
Reported by Hubert "depesz" Lubaczewski.
Discussion: http://postgr.es/m/Zktzf926vslR35Fv@depesz.com
Discussion: http://postgr.es/m/CAApHDvra=c8_zZT0J-TftByWN2Y+OJfnjNJFg4Dfdi2s+QzmqA@mail.gmail.com
Robert Haas [Tue, 21 May 2024 16:42:27 +0000 (12:42 -0400)]
Re-allow planner to use Merge Append to efficiently implement UNION.
This reverts commit
7204f35919b7e021e8d1bc9f2d76fd6bfcdd2070,
thus restoring
66c0185a3 (Allow planner to use Merge Append to
efficiently implement UNION) as well as the follow-on commits
d5d2205c8,
3b1a7eb28,
7487044d6.
Per further discussion on pgsql-release, we wish to ship beta1 with
this feature, and patch the bug that was found just before wrap,
rather than shipping beta1 with the feature reverted.
Robert Haas [Tue, 21 May 2024 16:41:32 +0000 (12:41 -0400)]
Doc: return
66c0185a3 to the release notes.
This reverts commit
e1e83a71715f1c2f0717bb66e630ca3bda79b9c1.
Per further discussion on pgsql-release, we wish to ship beta1 with
that feature, and patch the bug, rather than shipping beta1 with
that feature reverted.
Tom Lane [Mon, 20 May 2024 21:42:50 +0000 (17:42 -0400)]
Stamp 17beta1.
Tom Lane [Mon, 20 May 2024 19:16:17 +0000 (15:16 -0400)]
Doc: remove
66c0185a3 from release notes.
Discussion: https://postgr.es/m/Zktzf926vslR35Fv@depesz.com
(also some private discussion among pgsql-release)
Tom Lane [Mon, 20 May 2024 19:08:30 +0000 (15:08 -0400)]
Revert commit
66c0185a3 and follow-on patches.
This reverts
66c0185a3 (Allow planner to use Merge Append to
efficiently implement UNION) as well as the follow-on commits
d5d2205c8,
3b1a7eb28,
7487044d6. In addition to those,
07746a8ef
had to be removed then re-applied in a different place, because
66c0185a3 moved the relevant code.
The reason for this last-minute thrashing is that depesz found a
case in which the patched code creates a completely wrong plan
that silently gives incorrect query results. It's unclear what
the cause is or how many cases are affected, but with beta1 wrap
staring us in the face, there's no time for closer investigation.
After we figure that out, we can decide whether to un-revert this
for beta2 or hold it for v18.
Discussion: https://postgr.es/m/Zktzf926vslR35Fv@depesz.com
(also some private discussion among pgsql-release)
Bruce Momjian [Mon, 20 May 2024 13:36:58 +0000 (09:36 -0400)]
doc PG 17 relnotes: adjust vacuum items
Reported-by: John Naylor
Discussion: https://postgr.es/m/CANWCAZbPEoFcSjedGsz4AV=_sbwUN4sgjrukVCu-JzrqFC5Hhw@mail.gmail.com
Author: John Naylor
Backpatch-through: master
Peter Eisentraut [Mon, 20 May 2024 10:04:11 +0000 (12:04 +0200)]
Translation updates
Source-Git-URL: https://git.postgresql.org/git/pgtranslation/messages.git
Source-Git-Hash:
647792ce18e56f51614f7559106ad15362c5d1cc
Bruce Momjian [Mon, 20 May 2024 00:12:42 +0000 (20:12 -0400)]
doc PG 17 relnotes: adjust vacuum item to use "or"
Reported-by: David Rowley
Discussion: https://postgr.es/m/CAApHDvrR1ZQ69keUwr5_BGo2iWNqhpZooZSz2g96KnOxO0_GTw@mail.gmail.com
Backpatch-through: master
Bruce Momjian [Sat, 18 May 2024 21:52:56 +0000 (17:52 -0400)]
doc PG 17 relnotes: adjust "builtin" collation provider
Reported-by: Daniel Verite
Discussion: https://postgr.es/m/
13447ff6-15fd-4137-8339-
f4fddda7eb11@manitou-mail.org
Backpatch-through: master
Bruce Momjian [Sat, 18 May 2024 21:43:16 +0000 (17:43 -0400)]
doc PG 17 relnotes: update to current
Reported-by: jian he
Discussion: https://postgr.es/m/CACJufxE7fbWckFeXdW86VTia2BV+LOcfNR-aPf1cP2fjxEB0Aw@mail.gmail.com
Backpatch-through: master
Tom Lane [Sat, 18 May 2024 18:26:05 +0000 (14:26 -0400)]
Add test case showing that commit
d0d44049d fixed a live bug.
When I committed
d0d44049d (Account for optimized MinMax aggregates
during SS_finalize_plan), I didn't have a test case showing that it
was fixing any reachable bug. Here is one, based on bug #18465 from
Hal Takahara. Without the fix, all rows of the result show the same
"min" value, because the aggregate doesn't get recalculated.
Committed despite beta1 release freeze, with the concurrence of
pgsql-release.
Discussion: https://postgr.es/m/18465-
2fae927718976b22@postgresql.org
Discussion: https://postgr.es/m/
2391880.
1689025003@sss.pgh.pa.us
Bruce Momjian [Sat, 18 May 2024 16:50:22 +0000 (12:50 -0400)]
doc PG 17 relnotes: add incremental JSON parser item
Reported-by: Andrew Dunstan
Discussion: https://postgr.es/m/
e48dbf1e-62c9-4dbb-8b42-
bb9ed898a0ab@dunslane.net
Backpatch-through: master
Bruce Momjian [Sat, 18 May 2024 16:13:59 +0000 (12:13 -0400)]
doc PG 17 relnotes: improve JSON casting item
Reported-by: jian he
Discussion: https://postgr.es/m/CACJufxE0HY19F8Oo-wb-+i4bKDamiaL_aUV8qB69_8mwoScZow@mail.gmail.com
Backpatch-through: master
Bruce Momjian [Sat, 18 May 2024 14:39:47 +0000 (10:39 -0400)]
doc PG 17 relnotes: adjust vacuum memory item
Reported-by: David Rowley
Discussion: https://postgr.es/m/CAApHDvpZnr+wRMX5Wic9Na60fZSbruEffMoECVubBjv483jV2w@mail.gmail.com
Backpatch-through: master
Tom Lane [Fri, 17 May 2024 15:41:24 +0000 (11:41 -0400)]
Sync typedefs.list with buildfarm, for real this time.
In commit
da256a4a7, I manually added some typedef names to the
buildfarm-generated list so as not to cause any formatting regressions
compared to the prior manually-updated list.
About half of the additions were injection-point-related names.
It turns out that those were missing because none of the buildfarm
animals contributing typedef lists were building with
--enable-injection-points. I rectified that on my animal sifaka,
and now those are in the list available from the buildfarm.
The other half were typedefs that didn't show up in the generated list
because our method for collecting that doesn't catch names that are
not used to declare any C variables or fields. Such a typedef name
doesn't really add a lot of value, so we decided to get rid of them,
and that's now been done in commits
110eb4aef and
be5942aee. (Note:
I'm pretty sure there are some remaining cases of that, but we've
already accepted the ensuing odd formatting of the typedef declaration
itself. The present fixes only dealt with typedefs that had been
manually added to typedefs.list during the v17 development cycle.)
Hence, we can now install a verbatim copy of the buildfarm's list
and not have it affect anything. The only change is to add
InjectionPointCallback, which I'd omitted from
da256a4a7 because
it chanced not to affect any pgindent decisions.
Discussion: https://postgr.es/m/
1919000.
1715815925@sss.pgh.pa.us
Peter Eisentraut [Fri, 17 May 2024 11:48:31 +0000 (13:48 +0200)]
A few follow-up fixes for GUC name quoting
Fixups for
17974ec259: Some messages were missed (and some were new
since the patch was originally proposed), and there was a typo
introduced.
Peter Eisentraut [Fri, 17 May 2024 09:23:08 +0000 (11:23 +0200)]
Revise GUC names quoting in messages again
After further review, we want to move in the direction of always
quoting GUC names in error messages, rather than the previous (PG16)
wildly mixed practice or the intermittent (mid-PG17) idea of doing
this depending on how possibly confusing the GUC name is.
This commit applies appropriate quotes to (almost?) all mentions of
GUC names in error messages. It partially supersedes
a243569bf65 and
8d9978a7176, which had moved things a bit in the opposite direction
but which then were abandoned in a partial state.
Author: Peter Smith <smithpb2250@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CAHut%2BPv-kSN8SkxSdoHano_wPubqcg5789ejhCDZAcLFceBR-w%40mail.gmail.com
Peter Eisentraut [Fri, 17 May 2024 05:30:19 +0000 (07:30 +0200)]
Remove unused typedefs
There were a few typedefs that were never used to define a variable or
field. This had the effect that the buildfarm's typedefs.list would
not include them, and so they would need to be re-added manually to
keep the overall pgindent result perfectly clean.
We can easily get rid of these typedefs to avoid the issue. In a few
cases, we just let the enum or struct stand on its own without a
typedef around it. In one case, an enum was abused to define flag
bits; that's better done with macro definitions.
This fixes all the remaining issues with missing entries in the
buildfarm's typedefs.list.
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/
1919000.
1715815925@sss.pgh.pa.us
Michael Paquier [Fri, 17 May 2024 03:29:57 +0000 (12:29 +0900)]
Remove enum WaitEventExtension
This enum was used to determine the first ID to use when assigning a
custom wait event for extensions, which is always 1. It was kept so
as it would be possible to add new in-core wait events in the category
"Extension". There is no such thing currently, so let's remove this
enum until a case justifying it pops up. This makes the code simpler
and easier to understand.
This has as effect to switch back autoprewarm.c to use PG_WAIT_EXTENSION
rather than WAIT_EVENT_EXTENSION, on par with v16 and older stable
branches.
Thinko in
c9af05465307.
Reported-by: Peter Eisentraut
Discussion: https://postgr.es/m/
195c6c45-abce-4331-be6a-
e87724e1d060@eisentraut.org
Noah Misch [Thu, 16 May 2024 21:11:00 +0000 (14:11 -0700)]
Fix documentation about DROP DATABASE FORCE process termination rights.
Specifically, it terminates a background worker even if the caller
couldn't terminate the background worker with pg_terminate_backend().
Commit
3a9b18b3095366cd0c4305441d426d04572d88c1 neglected to update
this. Back-patch to v13, which introduced DROP DATABASE FORCE.
Reviewed by Amit Kapila. Reported by Kirill Reshke.
Discussion: https://postgr.es/m/
20240429212756.60.nmisch@google.com
Melanie Plageman [Thu, 16 May 2024 14:37:07 +0000 (10:37 -0400)]
BitmapHeapScan: Remove incorrect assert and reset field
04e72ed617be pushed the skip fetch optimization (allowing bitmap heap
scans to operate like index-only scans if none of the underlying data is
needed) into heap AM implementations of bitmap table scan callbacks.
04e72ed617be added an assert that all tuples in blocks eligible for the
optimization had been NULL-filled and emitted by the end of the scan.
This assert is incorrect when not all tuples need be scanned to execute
the query; for example: a join in which not all inner tuples need to be
scanned before skipping to the next outer tuple.
Remove the assert and reset the field on which it previously asserted to
avoid incorrectly emitting NULL-filled tuples from a previous scan on
rescan.
Author: Melanie Plageman
Reviewed-by: Tomas Vondra, Michael Paquier, Alvaro Herrera
Reported-by: Melanie Plageman
Reproduced-by: Tomas Vondra, Richard Guo
Discussion: https://postgr.es/m/CAMbWs48orzZVXa7-vP9Nt7vQWLTE04Qy4PePaLQYsVNQgo6qRg%40mail.gmail.com
Heikki Linnakangas [Thu, 16 May 2024 14:17:37 +0000 (17:17 +0300)]
Remove option to fall back from direct to postgres SSL negotiation
There were three problems with the sslnegotiation options:
1. The sslmode=prefer and sslnegotiation=requiredirect combination was
somewhat dangerous, as you might unintentionally fall back to
plaintext authentication when connecting to a pre-v17 server.
2. There was an asymmetry between 'postgres' and 'direct'
options. 'postgres' meant "try only traditional negotiation", while
'direct' meant "try direct first, and fall back to traditional
negotiation if it fails". That was apparent only if you knew that the
'requiredirect' mode also exists.
3. The "require" word in 'requiredirect' suggests that it's somehow
more strict or more secure, similar to sslmode. However, I don't
consider direct SSL connections to be a security feature.
To address these problems:
- Only allow sslnegotiation='direct' if sslmode='require' or
stronger. And for the record, Jacob and Robert felt that we should do
that (or have sslnegotiation='direct' imply sslmode='require') anyway,
regardless of the first issue.
- Remove the 'direct' mode that falls back to traditional negotiation,
and rename what was called 'requiredirect' to 'direct' instead. In
other words, there is no "try both methods" option anymore, 'postgres'
now means the traditional negotiation and 'direct' means a direct SSL
connection.
Reviewed-by: Jelte Fennema-Nio, Robert Haas, Jacob Champion
Discussion: https://www.postgresql.org/message-id/
d3b1608a-a1b6-4eda-9ec5-
ddb3e4375808%40iki.fi
Robert Haas [Thu, 16 May 2024 12:44:27 +0000 (08:44 -0400)]
Document that increasing max_connections uses more resources.
Roberto Mello
Discussion: http://postgr.es/m/CAKz==bJBCWrvN77fmuZ2XqD3jazWEb=E80AA4Yv9C9tQ61YDdQ@mail.gmail.com
David Rowley [Thu, 16 May 2024 12:39:15 +0000 (00:39 +1200)]
Doc: use true|false rather than on|off for "failover" option
The CREATE SUBSCRIPTION documentation mentions "false" is the default
option, so let's use true|false rather than on|off in the text which
talks about this option in the ALTER SUBSCRIPTION page.
The other boolean options mentioned in create_subscription.sgml use true
and false so it makes sense to be consistent with these. The "failover"
option is new to v17.
Author: Peter Smith
Discussion: https://postgr.es/m/CAHut+Ps-RqrggaJU5w85BbeQzw9CLmmLgADVJoJ=xx_4D5CWvw@mail.gmail.com
Peter Eisentraut [Thu, 16 May 2024 09:29:41 +0000 (11:29 +0200)]
pg_amcheck: Put new options in consistent order in --help and man page
Peter Eisentraut [Thu, 16 May 2024 06:15:35 +0000 (08:15 +0200)]
Revert temporal primary keys and foreign keys
This feature set did not handle empty ranges correctly, and it's now
too late for PostgreSQL 17 to fix it.
The following commits are reverted:
6db4598fcb8 Add stratnum GiST support function
46a0cd4cefb Add temporal PRIMARY KEY and UNIQUE constraints
86232a49a43 Fix comment on gist_stratnum_btree
030e10ff1a3 Rename pg_constraint.conwithoutoverlaps to conperiod
a88c800deb6 Use daterange and YMD in without_overlaps tests instead of tsrange.
5577a71fb0c Use half-open interval notation in without_overlaps tests
34768ee3616 Add temporal FOREIGN KEY contraints
482e108cd38 Add test for REPLICA IDENTITY with a temporal key
c3db1f30cba doc: clarify PERIOD and WITHOUT OVERLAPS in CREATE TABLE
144c2ce0cc7 Fix ON CONFLICT DO NOTHING/UPDATE for temporal indexes
Discussion: https://www.postgresql.org/message-id/
d0b64a7a-dfe4-4b84-a906-
c7dedfa40a3e@eisentraut.org
Bruce Momjian [Thu, 16 May 2024 02:54:29 +0000 (22:54 -0400)]
doc PG 17 relnotes: wording adjustments
Reported-by: jian he
Discussion: https://postgr.es/m/CACJufxHTJBqDmBC4iPgte_xd4aMgONRm680Ji5m5gCA8+YEmJg@mail.gmail.com
Co-authored-by: jian he
Backpatch-through: master
Bruce Momjian [Thu, 16 May 2024 02:47:59 +0000 (22:47 -0400)]
doc PG 17 relnotes: add item about vacuum storage/limits/WAL
Reported-by: Alvaro Herrera
Discussion: https://postgr.es/m/
202405150838.sg5ddcexyyf4@alvherre.pgsql
Backpatch-through: master
Thomas Munro [Thu, 16 May 2024 01:41:03 +0000 (13:41 +1200)]
jit: Remove {llvm-config,clang}-N configure probes.
Previously we searched for llvm-config-N and clang-N as well as the
unversioned names, and maintained a list of expected values of N. There
doesn't seem to be any reason to think that the default llvm-config and
clang won't be good enough, and if they aren't, they can be overridden
with LLVM_CONFIG and CLANG, so let's stop maintaining that list.
The list had not been updated since LLVM 7 with no complaints, so commit
820b5af73dc probably should have just removed it when dropping support
for 7, instead of trying to be helpful by bringing it up to date with
recent version numbers.
The Meson build system didn't have that, so no change there.
Suggested-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://postgr.es/m/CA%2BhUKG%2BSOP-aR%3DYF_n0dtXGWeCy6x%2BCn-RMWURU5ySQdmeKW1Q%40mail.gmail.com
David Rowley [Thu, 16 May 2024 00:50:16 +0000 (12:50 +1200)]
Fix some inconsistencies in EXPLAIN output
06286709e added a SERIALIZE option to EXPLAIN which included showing the
amount of kilobytes serialized. The calculation to convert bytes into
kilobytes wasn't consistent with how that's done in the rest of EXPLAIN.
Traditionally we round up to the nearest kB, but the new code rounded to
the nearest kB.
To fix this, invent a macro that does the conversion and use that macro
everywhere that requires this conversion.
Additionally,
5de890e36 added EXPLAIN (MEMORY) but included the memory
sizes in bytes. Convert these values to kilobytes to align with the
other memory related outputs.
In passing, swap out a "long" type in show_hash_info() and use a uint64
instead. We do support platforms where sizeof(Size) == 8 and
sizeof(long) == 4, so using a long there is questionable.
Reported-by: jian he
Reviewed-by: jian he
Discussion: https://www.postgresql.org/message-id/CACJufxE4Sp7xvgOwhqtFx5hS85AxMKobPWDo-xZHZVTpK3EBjA@mail.gmail.com
Michael Paquier [Thu, 16 May 2024 00:15:01 +0000 (09:15 +0900)]
doc: Mention more variant --name=value of -c name=value for postgres
postgres --name=value and -c name=value are equivalents. This commit
expands the documentation of libpq's "option" connection parameter and
the server startup sequence for shell interactions to mention both
rather than only -c.
Extracted from a larger patch by the same authors.
Reported-by: Alexey Palazhchenko
Author: David Johnston, Aleksander Alekseev
Reviewed-by: Nathan Bossart, Peter Eisentraut, Álvaro Herrera
Discussion: https://postgr.es/m/CAJ7c6TMkuLiLfrA+EFCPYfhXoMKRxxssB5c86+ibxfaz6+=Sdg@mail.gmail.com
Tom Lane [Wed, 15 May 2024 23:01:56 +0000 (19:01 -0400)]
Doc: update src/tools/pgindent/README for current practice.
This README explains how to run pgindent, but it was written
for our former practice of running pgindent only infrequently.
Nowadays the plan is to keep the tree indent-clean all the time,
so the typical thing is to do an incremental pgindent run with
each commit. Revise to explain that as the normal case, and
the infrequent full-on process as a separate thing.
For now, pgperltidy is still a run-it-infrequently item.
Daniel Gustafsson [Wed, 15 May 2024 20:48:51 +0000 (22:48 +0200)]
Fix query result leak during binary upgrade
9a974cbcba00 moved the query in binary_upgrade_set_pg_class_oids to the
outer level, but left the PQclear and query buffer destruction in the
is_index conditional.
353708e1fb2d fixed the leak of the query buffer
but left the PGresult leak. This moves clearing the result to the outer
level ensuring that it will be called.
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/
374550C1-F4ED-4D9D-9498-
0FD029CCF674@yesql.se
Backpatch-through: v15
Peter Eisentraut [Wed, 15 May 2024 11:49:41 +0000 (13:49 +0200)]
Re-forbid underscore in positional parameters
Underscores were added to numeric literals in
faff8f8e47. This change
also affected the positional parameters (e.g., $1) rule, which uses
the same production for its digits. But this did not actually work,
because the digits for parameters are processed using atol(), which
does not handle underscores and ignores whatever it cannot parse.
The underscores notation is probably not useful for positional
parameters, so for simplicity revert that rule to its old form that
only accepts digits 0-9.
Author: Erik Wienhold <ewie@ewie.name>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://www.postgresql.org/message-id/flat/
5d216d1c-91f6-4cbe-95e2-
b4cbd930520c%40ewie.name
Peter Eisentraut [Wed, 15 May 2024 11:05:30 +0000 (13:05 +0200)]
doc: Add standard Environment section to pg_upgrade ref page
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://www.postgresql.org/message-id/flat/
8458c9c5-18f1-46d7-94c4-
1c30e4f44908%40eisentraut.org
Peter Eisentraut [Wed, 15 May 2024 11:05:30 +0000 (13:05 +0200)]
doc: Add standard Environment section to pg_amcheck ref page
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://www.postgresql.org/message-id/flat/
8458c9c5-18f1-46d7-94c4-
1c30e4f44908%40eisentraut.org
Peter Eisentraut [Wed, 15 May 2024 11:05:30 +0000 (13:05 +0200)]
doc: Remove claims that initdb and pg_ctl use libpq environment variables
Erroneously introduced by
571df93cff8.
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://www.postgresql.org/message-id/flat/
8458c9c5-18f1-46d7-94c4-
1c30e4f44908%40eisentraut.org
Peter Eisentraut [Wed, 15 May 2024 08:52:26 +0000 (10:52 +0200)]
Remove stray blank line among gram.y keywords
introduced by
de3600452b
Peter Eisentraut [Wed, 15 May 2024 07:44:05 +0000 (09:44 +0200)]
Make all Perl warnings fatal, catch-up
Apply
c5385929593 to new Perl files that had missed the note.
Michael Paquier [Wed, 15 May 2024 05:31:47 +0000 (14:31 +0900)]
Add missing newline at the end of index_including.sql
Thinko in
a63224be49b8.
David Rowley [Wed, 15 May 2024 03:01:21 +0000 (15:01 +1200)]
Fix incorrect year in some copyright notices added this year
A few patches that were written <= 2023 and committed in 2024 still
contained 2023 copyright year. Fix that.
Discussion: https://postgr.es/m/CAApHDvr5egyW3FmHbAg-Uq2p_Aizwco1Zjs6Vbq18KqN64-hRA@mail.gmail.com
Bruce Momjian [Wed, 15 May 2024 02:12:49 +0000 (22:12 -0400)]
doc PG 17 relnotes: add logical replication apply subtrans item
Reported-by: Masahiko Sawada
Discussion: https://postgr.es/m/CAD21AoD5jjB+M+BK5JTis8=W1g8KsS1961FyMqRpj=NBFXrJeA@mail.gmail.com
Backpatch-through: master
Bruce Momjian [Wed, 15 May 2024 02:03:47 +0000 (22:03 -0400)]
doc PG 17 relnotes: remove NOT NULL revert, add ALPN item
Make current as of 2024-05-14
Backpatch-through: master
Bruce Momjian [Wed, 15 May 2024 00:48:11 +0000 (20:48 -0400)]
doc PG 17 relnotes: wording fix
Reported-by: Pantelis Theodosiou
Discussion: https://postgr.es/m/CAE3TBxxvkSGJGv7S0SMLSAe0khrQJBHsTca799r=vDJTn+BDAw@mail.gmail.com
Backpatch-through: master
Bruce Momjian [Wed, 15 May 2024 00:42:55 +0000 (20:42 -0400)]
doc PG 17 relnotes: wording fixes
Reported-by: Elena Indrupskaya
Discussion: https://postgr.es/m/
22110133-bca5-4a99-889c-
aa0096423456@postgrespro.ru
Author: Elena Indrupskaya
Backpatch-through: master
Bruce Momjian [Wed, 15 May 2024 00:36:36 +0000 (20:36 -0400)]
doc PG 17 relnotes: add two optimizer items
One is about subqueries becoming joins and the other is about optimizing
LIMIT by improving startup cost.
Reported-by: Andy Fan
Discussion: https://postgr.es/m/87h6f4ncc6.fsf@163.com
Reviewed-by: David Rowley
Backpatch-through: master
Tom Lane [Wed, 15 May 2024 00:19:20 +0000 (20:19 -0400)]
Fix handling of polymorphic output arguments for procedures.
Most of the infrastructure for procedure arguments was already
okay with polymorphic output arguments, but it turns out that
CallStmtResultDesc() was a few bricks shy of a load here. It thought
all it needed to do was call build_function_result_tupdesc_t, but
that function specifically disclaims responsibility for resolving
polymorphic arguments. Failing to handle that doesn't seem to be
a problem for CALL in plpgsql, but CALL from plain SQL would get
errors like "cannot display a value of type anyelement", or even
crash outright.
In v14 and later we can simply examine the exposed types of the
CallStmt.outargs nodes to get the right type OIDs. But it's a lot
more complicated to fix in v12/v13, because those versions don't
have CallStmt.outargs, nor do they do expand_function_arguments
until ExecuteCallStmt runs. We have to duplicatively run
expand_function_arguments, and then re-determine which elements
of the args list are output arguments.
Per bug #18463 from Drew Kimball. Back-patch to all supported
versions, since it's busted in all of them.
Discussion: https://postgr.es/m/18463-
f8cd77e12564d8a2@postgresql.org
Tom Lane [Tue, 14 May 2024 20:46:38 +0000 (16:46 -0400)]
Do pre-release housekeeping on catalog data.
Run renumber_oids.pl to move high-numbered OIDs down, as per pre-beta
tasks specified by RELEASE_CHANGES. For reference, the command was
./renumber_oids.pl --first-mapped-oid 8000 --target-oid 6300
Tom Lane [Tue, 14 May 2024 20:37:22 +0000 (16:37 -0400)]
Add
da256a4a7 to .git-blame-ignore-revs.
Tom Lane [Tue, 14 May 2024 20:34:50 +0000 (16:34 -0400)]
Pre-beta mechanical code beautification.
Run pgindent, pgperltidy, and reformat-dat-files.
The pgindent part of this is pretty small, consisting mainly of
fixing up self-inflicted formatting damage from patches that
hadn't bothered to add their new typedefs to typedefs.list.
In order to keep it from making anything worse, I manually added
a dozen or so typedefs that appeared in the existing typedefs.list
but not in the buildfarm's list. Perhaps we should formalize that,
or better find a way to get those typedefs into the automatic list.
pgperltidy is as opinionated as always, and reformat-dat-files too.
Peter Eisentraut [Tue, 14 May 2024 10:57:22 +0000 (12:57 +0200)]
Add missing gettext triggers
Commit
d6607016c7 moved all the jsonapi.c error messages into
token_error(). This needs to be added to the various nls.mk files
that use this. Since that makes token_error() effectively a globally
known symbol, the name seems a bit too general, so rename to
json_token_error() for more clarity.
Peter Eisentraut [Tue, 14 May 2024 09:34:11 +0000 (11:34 +0200)]
Add missing source files to pg_combinebackup/nls.mk
Daniel Gustafsson [Tue, 14 May 2024 08:50:26 +0000 (10:50 +0200)]
Remove auth-options support from initdb
When --auth was added to initdb in commit
e7029b212755 it had support
for auth options separated by space from the auth type, like:
--auth pam <servicename>
--auth ident sameuser
Passing an option to the ident auth type was removed in
01c1a12a5bb4
which left the pam auth-options support in place.
8a02339e9ba3 broke
this by inverting a calculation in the strncmp arguments, which went
unnoticed for a long time. The ability to pass options to the auth
type was never documented.
Rather than fixing the support for an undocumented feature which has
been broken for all supported versions, and which only supports one
out of many auth types which can take options, it is removed.
Reported-by: Jingxian Li <aqktjcm@qq.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/tencent_29731C7C7E6A2F9FB807C3A1DC3D81293C06@qq.com
Daniel Gustafsson [Tue, 14 May 2024 08:41:32 +0000 (10:41 +0200)]
Fix memory leaks in error reporting with LOG level
When loglevel is set to LOG, allocated strings used in the error
message would leak. Fix by explicitly pfreeing them.
Author: Ranier Vilela <ranier.vf@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/CAEudQAqMeE0AHcOsOzZx51Z0eiFJAjhBPRFt+Bxi3ETXWen7ig@mail.gmail.com
Peter Eisentraut [Tue, 14 May 2024 08:26:27 +0000 (10:26 +0200)]
Add missing gettext triggers
Due to commit
dc212340058, which added use of
src/common/parse_manifest.c in the backend.
Peter Eisentraut [Tue, 14 May 2024 07:15:31 +0000 (09:15 +0200)]
Make formatting in nls.mk files more consistent
Some of the nls.mk files used different indentation or line breaks
than the majority, which makes editing these files unnecessarily
confusing.
Bruce Momjian [Tue, 14 May 2024 00:55:13 +0000 (20:55 -0400)]
doc PG 17 relnotes: add item about libpq large data transfers
Reported-by: Jelte Fennema-Nio
Discussion: https://postgr.es/m/CAGECzQTz5aUqLEL6daLd2Hu2FXS_LOSh4keDndJ1fwThsb_b5w@mail.gmail.com
Reviewed-by: Joe Conway
Backpatch-through: master
David Rowley [Tue, 14 May 2024 00:39:30 +0000 (12:39 +1200)]
Revert "Temporarily install debugging in partition_prune test"
1db689715 added debugging output to the partition_prune regression test
to help us figure out why buildfarm member Parula was occasionally
failing.
We've not seen any failures in around 4 weeks and the best guess as to
what the problem was is a compiler bug. Since there are no recent
failures, there's now no need to keep this debugging code, so revert it.
Discussion: https://postgr.es/m/CAApHDvqyLF881EvDtXT=ossa0i4ioJBtW2c0Wbouzt5d3HDb5Q@mail.gmail.com
Bruce Momjian [Tue, 14 May 2024 00:01:51 +0000 (20:01 -0400)]
doc PG 17 relnotes: add psql connection control-C item
Reported-by: Jelte Fennema-Nio
Discussion: https://postgr.es/m/CAGECzQTz5aUqLEL6daLd2Hu2FXS_LOSh4keDndJ1fwThsb_b5w@mail.gmail.com
Reviewed-by: Tom Lane
Backpatch-through: master
Nathan Bossart [Mon, 13 May 2024 20:53:50 +0000 (15:53 -0500)]
Fix pg_sequence_last_value() for unlogged sequences on standbys.
Presently, when this function is called for an unlogged sequence on
a standby server, it will error out with a message like
ERROR: could not open file "base/5/16388": No such file or directory
Since the pg_sequences system view uses pg_sequence_last_value(),
it can error similarly. To fix, modify the function to return NULL
for unlogged sequences on standby servers. Since this bug is
present on all versions since v15, this approach is preferable to
making the ERROR nicer because we need to repair the pg_sequences
view without modifying its definition on released versions. For
consistency, this commit also modifies the function to return NULL
for other sessions' temporary sequences. The pg_sequences view
already appropriately filters out such sequences, so there's no bug
there, but we might as well offer some defense in case someone
invokes this function directly.
Unlogged sequences were first introduced in v15, but temporary
sequences are much older, so while the fix for unlogged sequences
is only back-patched to v15, the temporary sequence portion is
back-patched to all supported versions.
We could also remove the privilege check in the pg_sequences view
definition in v18 if we modify this function to return NULL for
sequences for which the current user lacks privileges, but that is
left as a future exercise for when v18 development begins.
Reviewed-by: Tom Lane, Michael Paquier
Discussion: https://postgr.es/m/
20240501005730.GA594666%40nathanxps13
Backpatch-through: 12
Tom Lane [Mon, 13 May 2024 17:52:17 +0000 (13:52 -0400)]
Remove COMMAND_TAG_NEXTTAG from enum CommandTag.
COMMAND_TAG_NEXTTAG isn't really a valid command tag. Declaring it
as if it were one prompts complaints from Coverity and perhaps other
static analyzers. Our only use of it is in an entirely-unnecessary
array sizing declaration, so let's just drop it.
Ranier Vilela
Discussion: https://postgr.es/m/CAEudQAoY0xrKuTAX7W10zsjjUpKBPFRtdCyScb3Z0FB2v6HNmQ@mail.gmail.com
Alvaro Herrera [Mon, 13 May 2024 11:13:25 +0000 (13:13 +0200)]
Fix typo
Alexander Korotkov [Mon, 13 May 2024 10:26:34 +0000 (13:26 +0300)]
Fix regression tests conflict in
3ca43dbbb6
3ca43dbbb6 adds regression tests with permission checks. The conflict has
been observed at buildfarm member piculet.
This commit fixes the conflict in the following way.
1. partition_split.sql now uses role names regress_partition_split_alice and
regress_partition_split_bob (it mistakenly used
regress_partition_merge_alice and regress_partition_merge_bob before).
2. Permissions on schemas partitions_merge_schema and partition_split_schema
are granted to corresponding roles. Before, the lack of permissions led to
the creation of objects in the public schema and potential conflict.
Reported-by: Daniel Gustafsson
Discussion: https://postgr.es/m/
03A07EF6-98D2-419B-A3AA-
A111C64CC207%40yesql.se
Alvaro Herrera [Mon, 13 May 2024 09:31:09 +0000 (11:31 +0200)]
Revert structural changes to not-null constraints
There are some problems with the new way to handle these constraints
that were detected at the last minute, and require fixes that appear too
invasive to be doing this late in the cycle. Revert this (again) for
now, we'll try again with these problems fixed.
The following commits are reverted:
b0e96f311985 Catalog not-null constraints
9b581c534186 Disallow changing NO INHERIT status of a not-null constraint
d0ec2ddbe088 Fix not-null constraint test
ac22a9545ca9 Move privilege check to the right place
b0f7dd915bca Check stack depth in new recursive functions
3af721794272 Update information_schema definition for not-null constraints
c3709100be73 Fix propagating attnotnull in multiple inheritance
d9f686a72ee9 Fix restore of not-null constraints with inheritance
d72d32f52d26 Don't try to assign smart names to constraints
0cd711271d42 Better handle indirect constraint drops
13daa33fa5a6 Disallow NO INHERIT not-null constraints on partitioned tables
d45597f72fe5 Disallow direct change of NO INHERIT of not-null constraints
21ac38f498b3 Fix inconsistencies in error messages
Discussion: https://postgr.es/m/
202405110940.joxlqcx4dogd@alvherre.pgsql
Alvaro Herrera [Mon, 13 May 2024 08:32:33 +0000 (10:32 +0200)]
Fix test case to do what it intends to
This test case intended to fail because setting a column as generated to
the partitioned table while leaving the partition alone is not allowed;
but instead failed because of a discrepancy of not-null constraint. Fix
this by adding the not-null constraint first, then set the column as
generated in a separate ALTER TABLE command, which gets the expected
error. Also, because the next test also wants to set the column as
not-null, add a BEGIN/ROLLBACK block so that the added not-null is
removed.
Oversight in
699586315704.
Alexander Korotkov [Sun, 12 May 2024 21:00:21 +0000 (00:00 +0300)]
Add permission check for MERGE/SPLIT partition operations
Currently, we check only owner permission for the parent table before
MERGE/SPLIT partition operations. This leads to a security hole when users
can get access to the data of partitions without permission. This commit
fixes this problem by requiring owner permission on all the partitions
involved.
Reported-by: Alexander Lakhin
Discussion: https://postgr.es/m/
0520c72e-8d97-245e-53f9-
173beca2ab2e%40gmail.com
Author: Dmitry Koval, Alexander Korotkov
Thomas Munro [Sun, 12 May 2024 19:55:20 +0000 (07:55 +1200)]
Skip citext_utf8 test on Windows.
On other Windows build farm animals it is already skipped because they
don't use UTF-8 encoding. On "hamerkop", UTF-8 is used, and then the
test fails.
It is not clear to me (a non-Windows person looking only at buildfarm
evidence) whether Windows is less sophisticated than other OSes and
doesn't know how to downcase Turkish İ with the standard Unicode
database, or if it is more sophisticated than other systems and uses
locale-specific behavior like ICU does.
Whichever the reason, the result is the same: we need to skip the test
on Windows, just as we already do for ICU, at least until a
Windows-savvy developer comes up with a better idea. The technique for
detecting the OS is borrowed from collate.windows.win1252.sql.
This was anticipated by commit
c2e8bd27, but the problem only surfaced
when Windows build farm animals started using Meson.
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CA%2BhUKGJ1LeC3aE2qQYTK95rFVON3ZVoTQpTKJqxkHdtEyawH4A%40mail.gmail.com
Michael Paquier [Sun, 12 May 2024 10:42:26 +0000 (19:42 +0900)]
injection_points: Store runtime conditions in private area
This commit fixes a race condition between injection point run and
detach, where a point detached by a backend and concurrently running in
a second backend could cause the second backend to do an incorrect
condition check. This issue happens because the second backend
retrieves the callback information in a first step in the shmem hash
table for injection points, and the condition in a second step within
the callback. If the point is detached between these two steps, the
condition would be removed, causing the point to run while it should
not. Storing the condition in the new private_data area introduced in
33181b48fd0e ensures that the condition retrieved is consistent with its
callback.
This commit leads to a lot of simplifications in the module
injection_points, as there is no need to handle the runtime conditions
inside it anymore. Runtime conditions have no more a maximum number.
Per discussion with Noah Misch.
Reviewed-by: Noah Misch
Discussion: https://postgr.es/m/
20240509031553.47@rfd.leadboat.com
Michael Paquier [Sun, 12 May 2024 09:53:06 +0000 (18:53 +0900)]
Introduce private data area for injection points
This commit extends the backend-side infrastructure of injection points
so as it becomes possible to register some input data when attaching a
point. This private data can be registered with the function name and
the library name of the callback when attaching a point, then it is
given as input argument to the callback. This gives the possibility for
modules to pass down custom data at runtime when attaching a point
without managing that internally, in a manner consistent with the
callback entry retrieved from the hash shmem table storing the injection
point data.
InjectionPointAttach() gains two arguments, to be able to define the
private data contents and its size.
A follow-up commit will rely on this infrastructure to close a race
condition with the injection point detach in the module
injection_points.
While on it, this changes InjectionPointDetach() to return a boolean,
returning false if a point cannot be detached. This has been mentioned
by Noah as useful when it comes to implement more complex tests with
concurrent point detach, solid with the automatic detach done for local
points in the test module.
Documentation is adjusted in consequence.
Per discussion with Noah Misch.
Reviewed-by: Noah Misch
Discussion: https://postgr.es/m/
20240509031553.47@rfd.leadboat.com
Heikki Linnakangas [Sat, 11 May 2024 15:48:19 +0000 (18:48 +0300)]
Change ALPN protocol ID to IANA-approved "postgresql"
"TBD-pgsql" was a placeholder until the IANA registration was
approved.
Discussion: https://www.postgresql.org/message-id/87jzk2hj2n.fsf%40wibble.ilmari.org
Discussion: https://mailarchive.ietf.org/arch/msg/tls-reg-review/9LWPzQfOpbc8dTT7vc9ahNeNaiw/
Bruce Momjian [Fri, 10 May 2024 21:34:33 +0000 (17:34 -0400)]
doc PG 17 relnotes: move FETCH_COUNT item, and clarify
Backpatch-through: master
Bruce Momjian [Fri, 10 May 2024 19:47:08 +0000 (15:47 -0400)]
doc PG 17 relnotes: add FETCH_COUNT item
Reported-by: Daniel Verite
Discussion: https://postgr.es/m/
82569de4-9b2a-4311-beb2-
81d5418491ec@manitou-mail.org
Backpatch-through: master
Peter Eisentraut [Fri, 10 May 2024 12:36:49 +0000 (14:36 +0200)]
Fix ON CONFLICT DO NOTHING/UPDATE for temporal indexes
A PRIMARY KEY or UNIQUE constraint with WITHOUT OVERLAPS will be a
GiST index, not a B-Tree, but it will still have indisunique set. The
code for ON CONFLICT fails if it sees a non-btree index that has
indisunique. This commit fixes that and adds some tests. But now
that we can't just test indisunique, we also need some extra checks to
prevent DO UPDATE from running against a WITHOUT OVERLAPS constraint
(because the conflict could happen against more than one row, and we'd
only update one).
Author: Paul A. Jungwirth <pj@illuminatedcomputing.com>
Discussion: https://www.postgresql.org/message-id/
1426589a-83cb-4a89-bf40-
713970c07e63@illuminatedcomputing.com
Tom Lane [Thu, 9 May 2024 22:56:35 +0000 (18:56 -0400)]
Doc: update the "Using EXPLAIN" examples to match current code.
A lot of the examples in this section are quite ancient and no
longer match the system's current behavior. I ran through them
and updated the sample output to match what I get today.
Notably, it seems that the tenk1 table got a few pages smaller back
around v12, so that a lot of the cost estimates for queries on that
table are a little different now. (This also caused some examples
to surprisingly not match others, depending on when they were made.)
One mergejoin-based example no longer produces the same plan at all,
so I had to work around that, including switching to a different
example of using an enable_xxx setting.
I also changed a couple of examples that were relying on nonexistent
tables or indexes. IMO the premise of this section is that the
examples should be more-or-less reproducible against the regression
database, so that these examples were unhelpful as given. It's not
that hard to find a corresponding example with the tables we do have.
Some of the EXPLAIN ANALYZE examples were out of date in that we show
more numbers than we did at the time.
Possibly chapter 68 could use similar review, but I'm out of
energy for today.
Bruce Momjian [Thu, 9 May 2024 20:37:51 +0000 (16:37 -0400)]
doc PG 17 relnotes: fix author of LLVM item
Discussion: https://postgr.es/m/CA+hUKG+yU4+YqsCuQuzdCeETPdU+FjebXgV5Fkp6xrtr7EKC3w@mail.gmail.com
Backpatch-through: master
Bruce Momjian [Thu, 9 May 2024 20:34:09 +0000 (16:34 -0400)]
doc: clarify PERIOD and WITHOUT OVERLAPS in CREATE TABLE
Discussion: https://postgr.es/m/
04938501-fc8f-46f3-97a4-
9a81a3f24530@illuminatedcomputing.com
Author: Paul Jungwirth
Backpatch-through: master
Tom Lane [Thu, 9 May 2024 17:16:21 +0000 (13:16 -0400)]
Fix recursive RECORD-returning plpython functions.
If we recursed to a new call of the same function, with a different
coldeflist (AS clause), it would fail because the inner call would
overwrite the outer call's idea of what to return. This is vaguely
like
1d2fe56e4 and
c5bec5426, but it's not due to any API decisions:
it's just that we computed the actual output rowtype at the start of
the call, and saved it in the per-procedure data structure. We can
fix it at basically zero cost by doing the computation at the end
of each call instead of the start.
It's not clear that there's any real-world use-case for such a
function, but given that it doesn't cost anything to fix,
it'd be silly not to.
Per report from Andreas Karlsson. Back-patch to all supported
branches.
Discussion: https://postgr.es/m/
1651a46d-3c15-4028-a8c1-
d74937b54e19@proxel.se
Bruce Momjian [Thu, 9 May 2024 16:34:43 +0000 (12:34 -0400)]
doc PG 17 relnotes: Visual Studio clarification
Reported-by: Andrew Dunstan
Backpatch-through: master
Tom Lane [Thu, 9 May 2024 16:19:43 +0000 (12:19 -0400)]
Repair ALTER EXTENSION ... SET SCHEMA.
It turns out that we broke this in commit
e5bc9454e, because
the code was assuming that no dependent types would appear
among the extension's direct dependencies, and now they do.
This isn't terribly hard to fix: just skip dependent types,
expecting that we will recurse to them when we process the parent
object (which should also be among the direct dependencies).
But a little bit of refactoring is needed so that we can avoid
duplicating logic about what is a dependent type.
Although there is some testing of ALTER EXTENSION SET SCHEMA,
it failed to cover interesting cases, so add more tests.
Discussion: https://postgr.es/m/930191.
1715205151@sss.pgh.pa.us
Bruce Momjian [Thu, 9 May 2024 15:43:03 +0000 (11:43 -0400)]
doc PG 17 relnotes: Fixes from jian he
Backpatch-through: master
Bruce Momjian [Thu, 9 May 2024 15:19:35 +0000 (11:19 -0400)]
doc PG 17 relnotes: various fixes
Fixes suggested by David Rowley, Bertrand Drouvot, Masahiko
Sawada, Richard Guo, jian he, Dagfinn Ilmari Mannsåker
Backpatch-through: master
Tom Lane [Thu, 9 May 2024 15:01:42 +0000 (11:01 -0400)]
Make left-join removal safe under -DREALLOCATE_BITMAPSETS.
The initial building of RestrictInfos and SpecialJoinInfos tends to
create structures that share relid sets (such as syn_lefthand and
outer_relids). There's nothing wrong with that in itself, but when
we modify those relid sets during join removal, we have to be sure
not to corrupt the values that other structures are pointing at.
remove_rel_from_query() was careless about this. It accidentally
worked anyway because (1) we'd never be reducing the sets to empty,
so they wouldn't get pfree'd; and (2) the in-place modification is the
same one that we did or will apply to the other struct's relid set,
so that there wasn't visible corruption at the end of the process.
While there's no live bug in a standard build, of course this is way
too fragile to accept going forward. (Maybe we should back-patch
this change too for safety, but I've refrained for now.)
This bug was exposed by the recent invention of REALLOCATE_BITMAPSETS.
Commit
e0477837c had installed a fix, but that went away with the
reversion of SJE, so now we need to fix it again.
David Rowley and Tom Lane
Discussion: https://postgr.es/m/CACJufxFVQmr4=JWHAOSLuKA5Zy9H26nY6tVrRFBOekHoALyCkQ@mail.gmail.com
Peter Eisentraut [Thu, 9 May 2024 14:35:41 +0000 (16:35 +0200)]
psql: Add missing punctuation in help output
Peter Eisentraut [Thu, 9 May 2024 14:34:50 +0000 (16:34 +0200)]
doc: Use better placeholder in COPY synopsis
Alvaro Herrera [Thu, 9 May 2024 11:31:22 +0000 (13:31 +0200)]
Fix inconsistencies in error messages
Reported by Kyotaro Horiguchi
Also some comments mentioning wrong version numbers, spotted by Justin
Pryzby.
Discussion: https://postgr.es/m/
20240507.171724.
750916195320223609.horikyota.ntt@gmail.com
Discussion: https://postgr.es/m/Zh0aAH7tbZb-9HbC@pryzbyj2023
Bruce Momjian [Thu, 9 May 2024 03:54:30 +0000 (23:54 -0400)]
doc: first draft of Postgres 17 release notes
Backpatch-through: master
Michael Paquier [Thu, 9 May 2024 03:45:37 +0000 (12:45 +0900)]
Fix overread in JSON parsing errors for incomplete byte sequences
json_lex_string() relies on pg_encoding_mblen_bounded() to point to the
end of a JSON string when generating an error message, and the input it
uses is not guaranteed to be null-terminated.
It was possible to walk off the end of the input buffer by a few bytes
when the last bytes consist of an incomplete multi-byte sequence, as
token_terminator would point to a location defined by
pg_encoding_mblen_bounded() rather than the end of the input. This
commit switches token_terminator so as the error uses data up to the
end of the JSON input.
More work should be done so as this code could rely on an equivalent of
report_invalid_encoding() so as incorrect byte sequences can show in
error messages in a readable form. This requires work for at least two
cases in the JSON parsing API: an incomplete token and an invalid escape
sequence. A more complete solution may be too invasive for a backpatch,
so this is left as a future improvement, taking care of the overread
first.
A test is added on HEAD as test_json_parser makes this issue
straight-forward to check.
Note that pg_encoding_mblen_bounded() no longer has any callers. This
will be removed on HEAD with a separate commit, as this is proving to
encourage unsafe coding.
Author: Jacob Champion
Discussion: https://postgr.es/m/CAOYmi+ncM7pwLS3AnKCSmoqqtpjvA8wmCdoBtKA3ZrB2hZG6zA@mail.gmail.com
Backpatch-through: 13