users/c2main/postgres.git
11 months agoMake RelationFlushRelation() work without ResourceOwner during abort
Heikki Linnakangas [Thu, 6 Jun 2024 15:56:28 +0000 (18:56 +0300)]
Make RelationFlushRelation() work without ResourceOwner during abort

ReorderBufferImmediateInvalidation() executes invalidation messages in
an aborted transaction. However, RelationFlushRelation sometimes
required a valid resource owner, to temporarily increment the refcount
of the relache entry. Commit b8bff07daa worked around that in the main
subtransaction abort function, AbortSubTransaction(), but missed this
similar case in ReorderBufferImmediateInvalidation().

To fix, introduce a separate function to invalidate a relcache
entry. It does the same thing as RelationClearRelation(rebuild==true)
does when outside a transaction, but can be called without
incrementing the refcount.

Add regression test. Before this fix, it failed with:

ERROR: ResourceOwnerEnlarge called after release started

Reported-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: https://www.postgresql.org/message-id/e56be7d9-14b1-664d-0bfc-00ce9772721c@gmail.com

11 months agoRestore preprocess_groupclause()
Alexander Korotkov [Thu, 6 Jun 2024 10:44:34 +0000 (13:44 +0300)]
Restore preprocess_groupclause()

0452b461bc made optimizer explore alternative orderings of group-by pathkeys.
It eliminated preprocess_groupclause(), which was intended to match items
between GROUP BY and ORDER BY.  Instead, get_useful_group_keys_orderings()
function generates orderings of GROUP BY elements at the time of grouping
paths generation.  The get_useful_group_keys_orderings() function takes into
account 3 orderings of GROUP BY pathkeys and clauses: original order as written
in GROUP BY, matching ORDER BY clauses as much as possible, and matching the
input path as much as possible.  Given that even before 0452b461b,
preprocess_groupclause() could change the original order of GROUP BY clauses
we don't need to consider it apart from ordering matching ORDER BY clauses.

This commit restores preprocess_groupclause() to provide an ordering of
GROUP BY elements matching ORDER BY before generation of paths.  The new
version of preprocess_groupclause() takes into account an incremental sort.
The get_useful_group_keys_orderings() function now takes into 2 orderings of
GROUP BY elements: the order generated preprocess_groupclause() and the order
matching the input path as much as possible.

Discussion: https://postgr.es/m/CAPpHfdvyWLMGwvxaf%3D7KAp-z-4mxbSH8ti2f6mNOQv5metZFzg%40mail.gmail.com
Author: Alexander Korotkov
Reviewed-by: Andrei Lepikhov, Pavel Borisov
11 months agoRename PathKeyInfo to GroupByOrdering
Alexander Korotkov [Thu, 6 Jun 2024 10:43:24 +0000 (13:43 +0300)]
Rename PathKeyInfo to GroupByOrdering

0452b461bc made optimizer explore alternative orderings of group-by pathkeys.
The PathKeyInfo data structure was used to store the particular ordering of
group-by pathkeys and corresponding clauses.  It turns out that PathKeyInfo
is not the best name for that purpose.  This commit renames this data structure
to GroupByOrdering, and revises its comment.

Discussion: https://postgr.es/m/db0fc3a4-966c-4cec-a136-94024d39212d%40postgrespro.ru
Reported-by: Tom Lane
Author: Andrei Lepikhov
Reviewed-by: Alexander Korotkov, Pavel Borisov
11 months agoAdd invariants check to get_useful_group_keys_orderings()
Alexander Korotkov [Thu, 6 Jun 2024 10:42:47 +0000 (13:42 +0300)]
Add invariants check to get_useful_group_keys_orderings()

This commit introduces invariants checking of generated orderings
in get_useful_group_keys_orderings() for assert-enabled builds.

Discussion: https://postgr.es/m/a663f0f6-cbf6-49aa-af2e-234dc6768a07%40postgrespro.ru
Reported-by: Tom Lane
Author: Andrei Lepikhov
Reviewed-by: Alexander Korotkov, Pavel Borisov
11 months agoFix asymmetry in setting EquivalenceClass.ec_sortref
Alexander Korotkov [Thu, 6 Jun 2024 10:41:34 +0000 (13:41 +0300)]
Fix asymmetry in setting EquivalenceClass.ec_sortref

0452b461bc made get_eclass_for_sort_expr() always set
EquivalenceClass.ec_sortref if it's not done yet.  This leads to an asymmetric
situation when whoever first looks for the EquivalenceClass sets the
ec_sortref.  It is also counterintuitive that get_eclass_for_sort_expr()
performs modification of data structures.

This commit makes make_pathkeys_for_sortclauses_extended() responsible for
setting EquivalenceClass.ec_sortref.  Now we set the
EquivalenceClass.ec_sortref's needed to explore alternative GROUP BY ordering
specifically during building pathkeys by the list of grouping clauses.

Discussion: https://postgr.es/m/17037754-f187-4138-8285-0e2bfebd0dea%40postgrespro.ru
Reported-by: Tom Lane
Author: Andrei Lepikhov
Reviewed-by: Alexander Korotkov, Pavel Borisov
11 months agodoc PG 17 relnotes: adjust integer bin/oct funcs and psql tab
Bruce Momjian [Thu, 6 Jun 2024 00:52:54 +0000 (20:52 -0400)]
doc PG 17 relnotes:  adjust integer bin/oct funcs and psql tab

Reported-by: Dean Rasheed
Discussion: https://postgr.es/m/CAEZATCXiNyExAXxKCO1h6oBB2nbfq9PtdA1nQowRsVFW1eD_MQ@mail.gmail.com

Backpatch-through: master

11 months agoPrevent inconsistent use of stats entry for replication slots
Michael Paquier [Wed, 5 Jun 2024 23:47:40 +0000 (08:47 +0900)]
Prevent inconsistent use of stats entry for replication slots

Concurrent activity around replication slot creation and drop could
cause a replication slot to use a stats entry it should not have used
when created, triggering an assertion failure when retrieving an
inconsistent entry from the dshash table used by the stats facility.

The issue is that pgstat_drop_replslot() calls pgstat_drop_entry()
without checking the result.  If pgstat_drop_entry() cannot free the
entry related to the object dropped, pgstat_request_entry_refs_gc()
should be called.  AtEOXact_PgStat_DroppedStats() and surrounding
routines dropping stats entries already do that.

This is documented in pgstat_internal.h, but let's add a comment at the
top of pgstat_drop_entry() as that can be easy to miss.

Reported-by: Alexander Lakhin
Author: Floris Van Nee
Analyzed-by: Andres Freund
Discussion: https://postgr.es/m/17947-b9554521ad963c9c@postgresql.org
Backpatch-through: 15

11 months agoFix documentation for POSIX semaphores.
Nathan Bossart [Wed, 5 Jun 2024 20:32:47 +0000 (15:32 -0500)]
Fix documentation for POSIX semaphores.

The documentation for POSIX semaphores is missing a reference to
max_wal_senders.  This commit fixes that in the same way that
commit 4ebe51a5fb fixed the same issue in the documentation for
System V semaphores.

Discussion: https://postgr.es/m/20240517164452.GA1914161%40nathanxps13
Backpatch-through: 12

11 months agoMove new SLRU buffers GUCs to a better place in postgresql.conf.sample
Peter Eisentraut [Wed, 5 Jun 2024 18:24:41 +0000 (20:24 +0200)]
Move new SLRU buffers GUCs to a better place in postgresql.conf.sample

They were under "File Locations", which doesn't make sense.  Move them
to Resource Usage / Memory, which matches their categorization in the
source code and in the documentation.

11 months agodoc: Fix example with database regexp in HBA documentation
Michael Paquier [Wed, 5 Jun 2024 10:56:51 +0000 (19:56 +0900)]
doc: Fix example with database regexp in HBA documentation

This HBA entry was using "local" while specifying an address, which was
incorrect.  While in it, this adjusts the format of the entry to be
aligned with the surroundings.

Oversight in 8fea86830e1d.

Reported-by: Stéphane Schildknecht
Reviewed-by: David G. Johnston
Discussion: https://postgr.es/m/44662001-54c4-4bfd-be93-35e01ca25fa1@gmail.com
Backpatch-through: 16

11 months agoFix some grammatical errors in some comments
David Rowley [Wed, 5 Jun 2024 09:31:28 +0000 (21:31 +1200)]
Fix some grammatical errors in some comments

Introduced by 9f1337639.

Author: James Coleman <jtc331@gmail.com>
Discussion: https://postgr.es/m/CAAaqYe9ZQ_1+QiF_Nv7b37opicBu+35ZQK1CetQ54r5UdrF1eg@mail.gmail.com

11 months agoFix pl/tcl's handling of errors from Tcl_ListObjGetElements().
Tom Lane [Tue, 4 Jun 2024 22:02:13 +0000 (18:02 -0400)]
Fix pl/tcl's handling of errors from Tcl_ListObjGetElements().

In a procedure or function returning tuple, we use that function to
parse the Tcl script's result, which is supposed to be a Tcl list.
If it isn't, you get an error.  Commit 26abb50c4 incautiously
supposed that we could use throw_tcl_error() to report such an error.
That doesn't actually work, because low-level functions like
Tcl_ListObjGetElements() don't fill Tcl's errorInfo variable.
The result is either a null-pointer-dereference crash or emission
of misleading context information describing the previous Tcl error.

Back off to just reporting the interpreter's result string, and
improve throw_tcl_error()'s comment to explain when to use it.

Also, although the similar code in pltcl_trigger_handler() avoided
this mistake, it was using a fairly confusing wording of the
error message.  Improve that while we're here.

Per report from A. Kozhemyakin.  Back-patch to all supported
branches.

Erik Wienhold and Tom Lane

Discussion: https://postgr.es/m/6a2a1c40-2b2c-4a33-8b72-243c0766fcda@postgrespro.ru

11 months agoFix PL/pgSQL's handling of integer ranges containing underscores.
Dean Rasheed [Tue, 4 Jun 2024 10:48:01 +0000 (11:48 +0100)]
Fix PL/pgSQL's handling of integer ranges containing underscores.

Commit faff8f8e47 allowed integer literals to contain underscores, but
failed to update the lexer's "numericfail" rule. As a result, a
decimal integer literal containing underscores would fail to parse, if
used in an integer range with no whitespace after the first number,
such as "1_001..1_003" in a PL/pgSQL FOR loop.

Fix and backpatch to v16, where support for underscores in integer
literals was added.

Report and patch by Erik Wienhold.

Discussion: https://postgr.es/m/808ce947-46ec-4628-85fa-3dd600b2c154%40ewie.name

11 months agoFix another couple of outdated comments for MERGE RETURNING.
Dean Rasheed [Tue, 4 Jun 2024 08:29:42 +0000 (09:29 +0100)]
Fix another couple of outdated comments for MERGE RETURNING.

Oversights in c649fa24a4 which added RETURNING support to MERGE.

Discussion: https://postgr.es/m/CAApHDvpqp6vtUzG-_josUEiBGyqnrnVxJ-VdF+hJLXjHdHzsyQ@mail.gmail.com

11 months agoci: windows: Use the same image for VS and MinGW tasks
Andres Freund [Tue, 4 Jun 2024 02:06:50 +0000 (19:06 -0700)]
ci: windows: Use the same image for VS and MinGW tasks

The VS and MinGW Windows images have been merged, to reduce the space needed
for images. Before 98811323c8e the split helped boot performance, but now that
we are using VMs that doesn't appear to be the case anymore.

Author: Nazir Bilal Yavuz <byavuz81@gmail.com>
Discussion: https://postgr.es/m/CAN55FZ2kWYjPd7uUC5QswrB3tfVJDiURqC%2BMGM6a3oeev%3DVgOA%40mail.gmail.com
Backpatch: 15-, where CI was added

11 months agoImprove assertion in mdwritev()
Michael Paquier [Mon, 3 Jun 2024 22:15:10 +0000 (07:15 +0900)]
Improve assertion in mdwritev()

The assertion used at the beginning of mdwritev(), that is not enabled
except by defining -DCHECK_WRITE_VS_EXTEND as mdnblocks() is costly,
forgot about the total number of blocks to write at location specified
by the caller.  The calculation is fixed to count for that, and uses
casts to uint64 to ensure a proper check should the number of blocks
overflow.

Using a cast is a suggestion from Tom Lane.

Oversight in 4908c5872059.

Author: Xing Guo
Discussion: https://postgr.es/m/CACpMh+BM-VgKeO7suPG-VHTtpzJ+zsbDPwVHu42PLp-iTk0z+A@mail.gmail.com

11 months agoFix documentation for System V semaphores.
Nathan Bossart [Mon, 3 Jun 2024 17:10:43 +0000 (12:10 -0500)]
Fix documentation for System V semaphores.

The formulas for SEMMNI and SEMMNS do not include the archiver
process, which was converted to an auxiliary process in v14, and
the WAL summarizer process, which was introduced in v17.  This
commit corrects these formulas and adds a missing reference to
max_wal_senders nearby.  Since this section of the documentation
tends to be incorrect quite often, we should likely give up on
documenting the exact formulas in favor of something less fragile,
but that is left as a future exercise.

Reported-by: Sami Imseih
Reviewed-by: Sami Imseih
Discussion: https://postgr.es/m/20240517164452.GA1914161%40nathanxps13
Backpatch-through: 12

12 months agodoc PG 17 relnotes: adjust IN wording
Bruce Momjian [Tue, 28 May 2024 04:21:13 +0000 (00:21 -0400)]
doc PG 17 relnotes:  adjust IN wording

Reported-by: David Rowley
Discussion: https://postgr.es/m/CAApHDvqmW0wQRam4paRbHvLQA+w5CJOCno4BCu=NFRLRhYhtRw@mail.gmail.com

Backpatch-through: master

12 months agoFix check for memory allocation
Daniel Gustafsson [Mon, 27 May 2024 17:37:17 +0000 (19:37 +0200)]
Fix check for memory allocation

Commit 61461a300c1 accidentally checked memory allocation success
using the wrong variable.

Author: Ranier Vilela <ranier.vf@gmail.com>
Reviewed-by: Jelte Fennema-Nio <postgres@jeltef.nl>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/CAEudQAqQFTH7xCB-+K6zEKjfqbhqCxcr_w4DuJTxVT6h3vzu2w@mail.gmail.com

12 months agoFix meson uuid header check so it works with MSVC
Andrew Dunstan [Sun, 26 May 2024 21:34:45 +0000 (17:34 -0400)]
Fix meson uuid header check so it works with MSVC

The OSSP uuid.h file includes unistd.h, so to use it with MSVC we need to
include the postgres include directories so it picks up our version of
that in src/include/port/win32_msvc. Adjust the meson test accordingly.

12 months agoFix potential NULL pointer dereference in getIdentitySequence()
Michael Paquier [Sun, 26 May 2024 11:58:27 +0000 (20:58 +0900)]
Fix potential NULL pointer dereference in getIdentitySequence()

The function invokes SearchSysCacheAttNum() and SearchSysCacheAttName().
They may respectively return 0 for the attribute number or NULL for
the attribute name if the attribute does not exist, without any kind of
error handling.  The common practice is to check that the data retrieved
from the syscache is valid.  There is no risk of NULL pointer
dereferences currently, but let's stick to the practice of making sure
that this data is always valid, to catch future inconsistency mistakes.
The code is switched to use get_attnum() and get_attname(), and adds
some error handling.

Oversight in 509199587df7.

Reported-by: Ranier Vilela
Author: Ashutosh Bapat
Discussion: https://postgr.es/m/CAEudQAqh_RZqoFcYKso5d9VhF-Vd64_ZodfQ_2zSusszkEmyRg@mail.gmail.com

12 months agoamcheck: Fixes for right page check during unique constraint check
Alexander Korotkov [Sun, 26 May 2024 04:14:12 +0000 (07:14 +0300)]
amcheck: Fixes for right page check during unique constraint check

 * Don't forget to pfree() the right page when it's to be ignored.
 * Report error on unexpected non-leaf right page even if this page is not
   to be ignored.  This restores the logic which was unintendedly changed
   in 97e5b0026f.

Reported-by: Pavel Borisov
12 months agodoc PG 17 relnotes: improve btree "set/array" matching item
Bruce Momjian [Sun, 26 May 2024 03:56:06 +0000 (23:56 -0400)]
doc PG 17 relnotes:  improve btree "set/array" matching item

Reported-by: Peter Geoghegan
Discussion: https://postgr.es/m/CAH2-WznwSs5irUka2deUooSdH7Sts2oPdVv4PCOwhK51fq2ZTg@mail.gmail.com

Backpatch-through: master

12 months agodoc PG 17 relnotes: fix "pg_stat_slru_reset" wording
Bruce Momjian [Sun, 26 May 2024 03:50:20 +0000 (23:50 -0400)]
doc PG 17 relnotes:  fix "pg_stat_slru_reset" wording

Reported-by: Marcos Pegoraro
Discussion: https://postgr.es/m/CAB-JLwYXrL-8FBfVDX8tevyTJ8y1SMmot5A-5cLqXAAne7W0CQ@mail.gmail.com

Backpatch-through: master

12 months agodoc PG 17 relnote: adjust "SLRU cache sizes to be configured"
Bruce Momjian [Sun, 26 May 2024 03:48:14 +0000 (23:48 -0400)]
doc PG 17 relnote:  adjust "SLRU cache sizes to be configured"

Add Álvaro Herrera as additional item author.

Reported-by: Álvaro Herrera
Discussion: https://postgr.es/m/202405231122.zew2gncy63fo@alvherre.pgsql

Author: Álvaro Herrera

Backpatch-through: master

12 months agoProvide deterministic order for catalog queries in partition_split.sql
Alexander Korotkov [Sun, 26 May 2024 03:38:00 +0000 (06:38 +0300)]
Provide deterministic order for catalog queries in partition_split.sql

System catalog tables are subject to modification by parallel tests.  This
is the source of instability when querying them without explicit ORDER BY.
This commit adds explicit ORDER BY to system catalog queries in
partition_split.sql to stabilize the result.

Reported-by: Tom Lane
Discussion: https://postgr.es/m/695264.1716578979%40sss.pgh.pa.us

12 months agodoc PG 17 relnotes: combine items
Bruce Momjian [Sun, 26 May 2024 03:40:17 +0000 (23:40 -0400)]
doc PG 17 relnotes:  combine items

Reported-by: Andres Freund
Discussion: https://postgr.es/m/20240524182329.gmzcd3a2zrvyepgy@awork3.anarazel.de

Backpatch-through: master

12 months agoFix comment in 024_add_drop_pub.pl
Michael Paquier [Fri, 24 May 2024 04:40:36 +0000 (13:40 +0900)]
Fix comment in 024_add_drop_pub.pl

A comment of the test was referring to an incorrect table.

Thinko in 1046a69b3087.

Extracted from a larger patch by the same author.

Author: Alexander Lakhin
Discussion: https://postgr.es/m/70b340bc-244a-589d-ef8b-d8aebb707a84@gmail.com

12 months agoImprove stability of subscription/029_on_error.pl
Michael Paquier [Fri, 24 May 2024 02:21:21 +0000 (11:21 +0900)]
Improve stability of subscription/029_on_error.pl

This test was failing when using wal_debug=on and -DWAL_DEBUG because of
additional log entries that made the test grab an LSN not mapping with
the error expected in the test.

Previously the test would look for the first matching line to get the
LSN to skip up to.  This is improved by having the test scan the logs
with a regexp that checks for the expected ERROR string, ensuring that
the wanted LSN comes from the correct context.

Backpatch down to 15 where this test has been introduced.

Author: Ian Ilyasov
Discussion: https://postgr.es/m/GV1P251MB100415F17E6B2FDD7188777ECDE32@GV1P251MB1004.EURP251.PROD.OUTLOOK.COM
Backpatch-through: 15

12 months agoRemove race conditions between ECPGdebug() and ecpg_log().
Tom Lane [Thu, 23 May 2024 19:52:06 +0000 (15:52 -0400)]
Remove race conditions between ECPGdebug() and ecpg_log().

Coverity complains that ECPGdebug is accessing debugstream without
holding debug_mutex, which is a fair complaint: we should take
debug_mutex while changing the settings ecpg_log looks at.

In some branches it also complains about unlocked use of simple_debug.
I think it's intentional and safe to have a quick unlocked check of
simple_debug at the start of ecpg_log, since that early exit will
always be taken in non-debug cases.  But we should recheck
simple_debug after acquiring the mutex.  In the worst case, calling
ECPGdebug concurrently with ecpg_log in another thread could result
in a null-pointer dereference due to debugstream transiently being
NULL while simple_debug isn't 0.

This is largely hypothetical, since it's unlikely anybody uses
ECPGdebug() at all in the field, and our own regression tests
don't seem to be hitting the theoretical race conditions either.
Still, if we're going to the trouble of having mutexes here, we ought
to be using them in a way that's actually safe not just almost safe.
Hence, back-patch to all supported branches.

12 months agojsonapi: Some message style fixes
Peter Eisentraut [Thu, 23 May 2024 07:22:28 +0000 (09:22 +0200)]
jsonapi: Some message style fixes

Add missing punctuation, and un-gettext-mark an internal error.

12 months agodoc: Clean up title case use
Peter Eisentraut [Thu, 23 May 2024 06:34:05 +0000 (08:34 +0200)]
doc: Clean up title case use

12 months agoFix typo and comments related to the recent no-wait lock improvements
Michael Paquier [Thu, 23 May 2024 04:47:12 +0000 (13:47 +0900)]
Fix typo and comments related to the recent no-wait lock improvements

The argument of dontWait at the top of ProcSleep() was documented
backwards, and there was a typo in lock.c.

Thinkos in 2346df6fc373.

Author: Will Mortensen
Reviewed-by: Jingxian Li, Michael Paquier
Discussion: https://postgr.es/m/CAMpnoC5f+eiS7tdy8PUpd_LacSTVT-pYpVooKfjHRQQmkHPZ2g@mail.gmail.com

12 months agodoc: Fix column_name parameter in ALTER MATERIALIZED VIEW
Michael Paquier [Thu, 23 May 2024 04:02:57 +0000 (13:02 +0900)]
doc: Fix column_name parameter in ALTER MATERIALIZED VIEW

Parameter column_name must be an existing column because ALTER
MATERIALIZED VIEW cannot add new columns.  The old description was
likely copied from ALTER TABLE.

Author: Erik Wienhold
Discussion: https://postgr.es/m/6880ca53-7961-4eeb-86d5-6bd05fc2027e@ewie.name
Backpatch-through: 12

12 months agoFix a couple of outdated comments now that we have MERGE RETURNING
David Rowley [Thu, 23 May 2024 03:24:54 +0000 (15:24 +1200)]
Fix a couple of outdated comments now that we have MERGE RETURNING

This has been supported since c649fa24a.

Discussion: https://postgr.es/m/CAApHDvpqp6vtUzG-_josUEiBGyqnrnVxJ-VdF+hJLXjHdHzsyQ@mail.gmail.com

12 months agoDon't copy extended statistics during MERGE/SPLIT partition operations
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

12 months agoFix the name collision detection in MERGE/SPLIT partition operations
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

12 months agoamcheck: Report an error when the next page to a leaf is not a leaf
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

12 months agoamcheck: Don't load the right sibling page into BtreeCheckState
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

12 months agoamcheck: Refactoring the storage of the last visible entry
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

12 months agodoc PG 17 relnotes: fix pg_stat_reset_shared quoting
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

12 months agodoc PG 17 relnotes: fix pg_stat_statements typo
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

12 months agodoc PG 17 relnotes: adjust SQL/JSON constructor func. authors
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

12 months agodoc PG 17 relnotes: adjust builtin collation provider item
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

12 months agoFix input of ISO "extended" time format for types time and timetz.
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

12 months agodoc PG 17 relnotes: add Heikki Linnakangas to vacuum item
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

12 months agoFix handling of extended expression statistics in CREATE TABLE LIKE.
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

12 months agoFix generate_union_paths for non-sortable types.
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

12 months agoRe-allow planner to use Merge Append to efficiently implement UNION.
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
d5d2205c83b1a7eb287487044d6.

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.

12 months agoDoc: return 66c0185a3 to the release notes.
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.

12 months agoStamp 17beta1.
Tom Lane [Mon, 20 May 2024 21:42:50 +0000 (17:42 -0400)]
Stamp 17beta1.

12 months agoDoc: remove 66c0185a3 from release notes.
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)

12 months agoRevert commit 66c0185a3 and follow-on patches.
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
d5d2205c83b1a7eb287487044d6.  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)

12 months agodoc PG 17 relnotes: adjust vacuum items
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

12 months agoTranslation updates
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

12 months agodoc PG 17 relnotes: adjust vacuum item to use "or"
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

12 months agodoc PG 17 relnotes: adjust "builtin" collation provider
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

12 months agodoc PG 17 relnotes: update to current
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

12 months agoAdd test case showing that commit d0d44049d fixed a live bug.
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

12 months agodoc PG 17 relnotes: add incremental JSON parser item
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

12 months agodoc PG 17 relnotes: improve JSON casting item
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

12 months agodoc PG 17 relnotes: adjust vacuum memory item
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

12 months agoSync typedefs.list with buildfarm, for real this time.
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

12 months agoA few follow-up fixes for GUC name quoting
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.

12 months agoRevise GUC names quoting in messages again
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

12 months agoRemove unused typedefs
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

12 months agoRemove enum WaitEventExtension
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

12 months agoFix documentation about DROP DATABASE FORCE process termination rights.
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

12 months agoBitmapHeapScan: Remove incorrect assert and reset field
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

12 months agoRemove option to fall back from direct to postgres SSL negotiation
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

12 months agoDocument that increasing max_connections uses more resources.
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

12 months agoDoc: use true|false rather than on|off for "failover" option
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

12 months agopg_amcheck: Put new options in consistent order in --help and man page
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

12 months agoRevert temporal primary keys and foreign keys
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

12 months agodoc PG 17 relnotes: wording adjustments
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

12 months agodoc PG 17 relnotes: add item about vacuum storage/limits/WAL
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

12 months agojit: Remove {llvm-config,clang}-N configure probes.
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

12 months agoFix some inconsistencies in EXPLAIN output
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

12 months agodoc: Mention more variant --name=value of -c name=value for postgres
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

12 months agoDoc: update src/tools/pgindent/README for current practice.
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.

12 months agoFix query result leak during binary upgrade
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

12 months agoRe-forbid underscore in positional parameters
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

12 months agodoc: Add standard Environment section to pg_upgrade ref page
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

12 months agodoc: Add standard Environment section to pg_amcheck ref page
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

12 months agodoc: Remove claims that initdb and pg_ctl use libpq environment variables
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

12 months agoRemove stray blank line among gram.y keywords
Peter Eisentraut [Wed, 15 May 2024 08:52:26 +0000 (10:52 +0200)]
Remove stray blank line among gram.y keywords

introduced by de3600452b

12 months agoMake all Perl warnings fatal, catch-up
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.

12 months agoAdd missing newline at the end of index_including.sql
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.

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

12 months agodoc PG 17 relnotes: add logical replication apply subtrans item
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

12 months agodoc PG 17 relnotes: remove NOT NULL revert, add ALPN item
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

12 months agodoc PG 17 relnotes: wording fix
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

12 months agodoc PG 17 relnotes: wording fixes
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

12 months agodoc PG 17 relnotes: add two optimizer items
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

12 months agoFix handling of polymorphic output arguments for procedures.
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

12 months agoDo pre-release housekeeping on catalog data.
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

12 months agoAdd da256a4a7 to .git-blame-ignore-revs.
Tom Lane [Tue, 14 May 2024 20:37:22 +0000 (16:37 -0400)]
Add da256a4a7 to .git-blame-ignore-revs.

12 months agoPre-beta mechanical code beautification.
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.

12 months agoAdd missing gettext triggers
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.

12 months agoAdd missing source files to pg_combinebackup/nls.mk
Peter Eisentraut [Tue, 14 May 2024 09:34:11 +0000 (11:34 +0200)]
Add missing source files to pg_combinebackup/nls.mk