Peter Geoghegan [Sat, 17 Sep 2022 23:54:16 +0000 (16:54 -0700)]
Make check_usermap() parameter names consistent.
The function has a bool argument named "case_insensitive", but that was
spelled "case_sensitive" in the declaration. Make them consistent now
to avoid confusion in the future.
Author: Peter Geoghegan <
[email protected]>
Reviewed-By: Michael Paquiër <[email protected]>
Discussion: https://postgr.es/m/CAH2-WznJt9CMM9KJTMjJh_zbL5hD9oX44qdJ4aqZtjFi-zA3Tg@mail.gmail.com
Backpatch: 10-
Andres Freund [Sat, 17 Sep 2022 16:21:59 +0000 (09:21 -0700)]
Include c.h instead of postgres.h in src/port/*p{read,write}*.c
Frontend code shouldn't include postgres.h. Some files in src/port/ need to
include postgres.h/postgres_fe.h, but these files don't.
Discussion: https://postgr.es/m/
20220915022626[email protected]
Backpatch: 12-, where
3fd2a7932ef introduced (some) of these files
Andres Freund [Fri, 16 Sep 2022 21:08:40 +0000 (14:08 -0700)]
pgstat: Create memory contexts below TopMemoryContext
So far they were created below CacheMemoryContext. However, that's not
guaranteed to exist in all situations, leading to memory contexts created as
top-level contexts. There isn't actually a good reason anymore to create them
below CacheMemoryContext, so just creating them below TopMemoryContext seems
the best approach.
Reported-by: Reid Thompson <[email protected]>
Reviewed-by: Kyotaro Horiguchi <[email protected]>
Reviewed-by: Andres Freund <[email protected]>
Author: "Drouvot, Bertrand" <
[email protected]>
Discussion: https://postgr.es/m/
b948b729-42fe-f88c-2f4a-
0e65d84c049b@amazon.com
Backpatch: 15-
Peter Eisentraut [Sat, 17 Sep 2022 06:10:59 +0000 (08:10 +0200)]
Message style improvements
Andres Freund [Fri, 16 Sep 2022 17:07:12 +0000 (10:07 -0700)]
Fix race condition in stats.sql added in
5264add7847
Very occasionally the stats test failed due to the number of sessions not
being updated yet. Likely this requires that there is contention on the
database's stats entry. Solve this by forcing pending stats to be flushed
before fetching the stats.
I verified that there are no other test failures after making
pgstat_report_stat() only flush stats when force = true.
Per message from Tom Lane and buildfarm member crake.
Discussion: https://postgr.es/m/
3428246.
1663271992@sss.pgh.pa.us
Backpatch: 15-, where
5264add7847 added the test
Tom Lane [Fri, 16 Sep 2022 17:23:01 +0000 (13:23 -0400)]
Improve plpgsql's ability to handle arguments declared as RECORD.
Treat arguments declared as RECORD as if that were a polymorphic type
(which it is, sort of), in that we substitute the actual argument type
while forming the function cache lookup key. This allows the specific
composite type to be known in some cases where it was not before,
at the cost of making a separate function cache entry for each named
composite type that's passed to the function during a session. The
particular symptom discussed in bug #17610 could be solved in other
more-efficient ways, but only at the cost of considerable development
work, and there are other cases where we'd still fail without this.
Per bug #17610 from Martin Jurča. Back-patch to v11 where we first
allowed plpgsql functions to be declared as taking type RECORD.
Discussion: https://postgr.es/m/17610-
fb1eef75bf6c2364@postgresql.org
Peter Eisentraut [Fri, 16 Sep 2022 14:37:53 +0000 (16:37 +0200)]
Message wording improvements
Peter Eisentraut [Fri, 16 Sep 2022 09:10:41 +0000 (11:10 +0200)]
Fix createdb tests for C locale
If the createdb tests run under the C locale, the database cluster
will be initialized with encoding SQL_ASCII. With the checks added in
c7db01e325a530ec38ec7ba57cd3ed32e123e33c, this will cause several
ICU-related tests to fail because SQL_ASCII is not supported by ICU.
To work around that, use initdb option -E UTF8 for those tests to get
past that check.
Peter Eisentraut [Fri, 16 Sep 2022 07:37:54 +0000 (09:37 +0200)]
Don't allow creation of database with ICU locale with unsupported encoding
Check in CREATE DATABASE and initdb that the selected encoding is
supported by ICU. Before, they would pass but users would later get
an error from the server when they tried to use the database.
Also document that initdb sets the encoding to UTF8 by default if the
ICU locale provider is chosen.
Author: Marina Polyakova <
[email protected]>
Reviewed-by: Kyotaro Horiguchi <[email protected]>
Discussion: https://www.postgresql.org/message-id/
6dd6db0984d86a51b7255ba79f111971@postgrespro.ru
Tom Lane [Thu, 15 Sep 2022 21:17:53 +0000 (17:17 -0400)]
Detect format-string mistakes in the libpq_pipeline test module.
I happened to notice that libpq_pipeline's private implementation
of pg_fatal lacked any pg_attribute_printf decoration. Indeed,
adding that turned up a mistake! We'd likely never have noticed
because the error exits in this code are unlikely to get hit,
but still, it's a bug.
We're so used to having the compiler check this stuff for us that
a printf-like function without pg_attribute_printf is a land mine.
I wonder if there is a way to detect such omissions.
Back-patch to v14 where this code came in.
Alvaro Herrera [Thu, 15 Sep 2022 16:04:00 +0000 (18:04 +0200)]
Copy-edit docs for logical replication column lists
There was a excessive structure, leading to somewhat disorganized
presentation of the information. Remove a few tags and reorder
paragraphs to make the text flow more easily. Also, reword some of it
to be more concise.
The bit about column list combination is not modified, other than to
remove an uninteresting (and IMO confusing and wrong) paragraph; I
intend to deal with it differently afterwards.
Backpatch to 15.
Discussion: https://postgr.es/m/
20220913121138[email protected]
Noah Misch [Thu, 15 Sep 2022 13:45:23 +0000 (06:45 -0700)]
Reset InstallXLogFileSegmentActive after walreceiver self-initiated exit.
After commit
cc2c7d65fc27e877c9f407587b0b92d46cd6dd16 added this flag,
failure to reset it caused assertion failures. In non-assert builds, it
made the system fail to achieve the objectives listed in that commit;
chiefly, we might emit a spurious log message. Back-patch to v15, where
that commit first appeared.
Bharath Rupireddy and Kyotaro Horiguchi. Reviewed by Dilip Kumar,
Nathan Bossart and Michael Paquier. Reported by Dilip Kumar.
Discussion: https://postgr.es/m/CAFiTN-sE3ry=ycMPVtC+Djw4Fd7gbUGVv_qqw6qfzp=JLvqT3g@mail.gmail.com
John Naylor [Thu, 15 Sep 2022 04:40:17 +0000 (11:40 +0700)]
Fix grammar in error message
While at it, make ellipses formatting consistent when describing SQL statements.
Ekaterina Kiryanova and Alexander Lakhin
Reviewed by myself and Álvaro Herrera
Discussion: https://www.postgresql.org/message-id/
eed5cec0-a542-53da-6a5e-
7789c6ed9817%40postgrespro.ru
Backpatch only the grammar fix to v15
David Rowley [Wed, 14 Sep 2022 21:41:32 +0000 (09:41 +1200)]
Fix outdated convert_saop_to_hashed_saop comment
In
29f45e299, we added support for optimizing the execution of NOT
IN(values) by using a hash table instead of a linear search over the
array. That commit neglected to update the header comment for
convert_saop_to_hashed_saop() to mention this fact. Here we fix that.
Author: James Coleman
Discussion: https://postgr.es/m/CAAaqYe99NUpAPcxgchGstgM23fmiGjqQPot8627YgkBgNt=BfA@mail.gmail.com
Backpatch-through: 15, where
29f45e299 was added.
Peter Eisentraut [Wed, 14 Sep 2022 20:30:51 +0000 (22:30 +0200)]
Small wording improvements
Alvaro Herrera [Wed, 14 Sep 2022 13:36:21 +0000 (15:36 +0200)]
Remove duplicate initialization
This appears to be a merge mistake in
96ef3237bf74. We could put it
back the way it was before JSON_TABLE and it'd be two lines shorter, but
it's likely that JSON_TABLE will be back and will prefer things this
way. It makes no other difference in practice.
Backpatch to 15.
Reported by Ranier Vilela
Discussion: https://postgr.es/m/CAEudQAr4nOcNQskC4oBEZN4S+4heJ=1ch_ZKOxU+_Ef-FQSf-g@mail.gmail.com
Etsuro Fujita [Wed, 14 Sep 2022 09:45:01 +0000 (18:45 +0900)]
postgres_fdw: Avoid 'variable not found in subplan target list' error.
The tlist of the EvalPlanQual outer plan for a ForeignScan node is
adjusted to produce a tuple whose descriptor matches the scan tuple slot
for the ForeignScan node. But in the case where the outer plan contains
an extra Sort node, if the new tlist contained columns required only for
evaluating PlaceHolderVars or columns required only for evaluating local
conditions, this would cause setrefs.c to fail with the error.
The cause of this is that when creating the outer plan by injecting the
Sort node into an alternative local join plan that could emit such extra
columns as well, we fail to arrange for the outer plan to propagate them
up through the Sort node, causing setrefs.c to fail to match up them in
the new tlist to what is available from the outer plan. Repair.
Per report from Alexander Pyhalov.
Richard Guo and Etsuro Fujita, reviewed by Alexander Pyhalov and Tom Lane.
Backpatch to all supported versions.
Discussion: http://postgr.es/m/
cfb17bf6dfdf876467bd5ef533852d18%40postgrespro.ru
Michael Paquier [Wed, 14 Sep 2022 05:52:26 +0000 (14:52 +0900)]
Fix incorrect value for "strategy" with deflateParams() in walmethods.c
The zlib documentation mentions the values supported for the compression
strategy, but this code has been using a hardcoded value of 0 rather
than Z_DEFAULT_STRATEGY. This commit adjusts the code to use
Z_DEFAULT_STRATEGY.
Backpatch down to where this code has been added to ease the backport of
any future patch touching this area.
Reported-by: Tom Lane
Discussion: https://postgr.es/m/
1400032.
1662217889@sss.pgh.pa.us
Backpatch-through: 10
Peter Eisentraut [Wed, 14 Sep 2022 04:04:24 +0000 (06:04 +0200)]
Expand palloc/pg_malloc API for more type safety
This adds additional variants of palloc, pg_malloc, etc. that
encapsulate common usage patterns and provide more type safety.
Specifically, this adds palloc_object(), palloc_array(), and
repalloc_array(), which take the type name of the object to be
allocated as its first argument and cast the return as a pointer to
that type. There are also palloc0_object() and palloc0_array()
variants for initializing with zero, and pg_malloc_*() variants of all
of the above.
Inspired by the talloc library.
This is backpatched from master so that future backpatchable code can
make use of these APIs. This patch by itself does not contain any
users of these APIs.
Reviewed-by: Tom Lane <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/
bb755632-2a43-d523-36f8-
a1e7a389a907@enterprisedb.com
Michael Paquier [Wed, 14 Sep 2022 03:17:03 +0000 (12:17 +0900)]
Simplify handling of compression level with compression specifications
PG_COMPRESSION_OPTION_LEVEL is removed from the compression
specification logic, and instead the compression level is always
assigned with each library's default if nothing is directly given. This
centralizes the checks on the compression methods supported by a given
build, and always assigns a default compression level when parsing a
compression specification. This results in complaining at an earlier
stage than previously if a build supports a compression method or not,
aka when parsing a specification in the backend or the frontend, and not
when processing it. zstd, lz4 and zlib are able to handle in their
respective routines setting up the compression level the case of a
default value, hence the backend or frontend code (pg_receivewal or
pg_basebackup) has now no need to know what the default compression
level should be if nothing is specified: the logic is now done so as the
specification parsing assigns it. It can also be enforced by passing
down a "level" set to the default value, that the backend will accept
(the replication protocol is for example able to handle a command like
BASE_BACKUP (COMPRESSION_DETAIL 'gzip:level=-1')).
This code simplification fixes an issue with pg_basebackup --gzip
introduced by
ffd5365, where the tarball of the streamed WAL segments
would be created as of pg_wal.tar.gz with uncompressed contents, while
the intention is to compress the segments with gzip at a default level.
The origin of the confusion comes from the handling of the default
compression level of gzip (-1 or Z_DEFAULT_COMPRESSION) and the value of
0 was getting assigned, which is what walmethods.c would consider
as equivalent to no compression when streaming WAL segments with its tar
methods. Assigning always the compression level removes the confusion
of some code paths considering a value of 0 set in a specification as
either no compression or a default compression level.
Note that 010_pg_basebackup.pl has to be adjusted to skip a few tests
where the shape of the compression detail string for client and
server-side compression was checked using gzip. This is a result of the
code simplification, as gzip specifications cannot be used if a build
does not support it.
Reported-by: Tom Lane
Reviewed-by: Tom Lane
Discussion: https://postgr.es/m/
1400032.
1662217889@sss.pgh.pa.us
Backpatch-through: 15
Peter Eisentraut [Tue, 13 Sep 2022 12:18:45 +0000 (14:18 +0200)]
Make locale option behavior more consistent
Locale options can be specified for initdb, createdb, and CREATE
DATABASE. In initdb, it has always been possible to specify --locale
and then some --lc-* option to override a category. CREATE DATABASE
and createdb didn't allow that, requiring either the all-categories
option or only per-category options. In
f2553d43060edb210b36c63187d52a632448e1d2, this was changed in CREATE
DATABASE (perhaps by accident?) to be more like the initdb behavior,
but createdb still had the old behavior.
Now we change createdb to match the behavior of CREATE DATABASE and
initdb, and also update the documentation of CREATE DATABASE to match
the new behavior, which was not done in the above commit.
Author: Marina Polyakova <
[email protected]>
Reviewed-by: Justin Pryzby <[email protected]>
Discussion: https://www.postgresql.org/message-id/
7c99c132dc9c0ac630e0127f032ac480@postgrespro.ru
Alvaro Herrera [Tue, 13 Sep 2022 10:02:56 +0000 (12:02 +0200)]
Improve wal_decode_buffer_size description some more
Per Thomas Munro
Discussion: https://postgr.es/m/CA+hUKGJ9wP9kpvgoxHvqA=4g1d9-y_w3LhhdhFVU=mFiqjwHww@mail.gmail.com
Michael Paquier [Tue, 13 Sep 2022 01:38:59 +0000 (10:38 +0900)]
Move any remaining files generated by pg_upgrade into an internal subdir
This change concerns a couple of .txt files (for internal state checks)
that were still written in the path where the binary is executed, and
not in the subdirectory located in the target cluster. Like the other
.txt files doing already so (like loadable_libraries.txt), these are
saved in the base output directory. Note that on failure, the logs
report the full path to the .txt file generated, so these are easy to
find.
Oversight in
38bfae3.
Author: Daniel Gustafsson
Reviewed-by: Michael Paquier, Justin Prysby
Discussion: https://postgr.es/m/
181A6DA8-3B7F-4B71-82D5-
363FF0146820@yesql.se
Backpatch-through: 15
David Rowley [Mon, 12 Sep 2022 23:04:37 +0000 (11:04 +1200)]
Don't reference out-of-bounds array elements in brin_minmax_multi.c
The primary fix here is to fix has_matching_range() so it does not
reference ranges->values[-1] when nranges == 0. Similar problems existed
in AssertCheckRanges() too. It does not look like any of these problems
could lead to a crash as the array in question is at the end of the Ranges
struct, and values[-1] is memory that belongs to other fields in the
struct. However, let's get rid of these rather unsafe coding practices.
In passing, I (David) adjusted some comments to try to make it more clear
what some of the fields are for in the Ranges struct. I had to study the
code to find out what nsorted was for as I couldn't tell from the
comments.
Author: Ranier Vilela
Discussion: https://postgr.es/m/CAEudQAqJQzPitufX-jR=YUbJafpCDAKUnwgdbX_MzSc93wuvdw@mail.gmail.com
Backpatch-through: 14, where multi-range brin was added.
Daniel Gustafsson [Mon, 12 Sep 2022 20:17:17 +0000 (22:17 +0200)]
doc: Fix link to FreeBSD documentation project
The FreeBSD site was changed with a redirect, which in turn seems to
lead to a 404. Replace with the working link.
Author: James Coleman <
[email protected]>
Discussion: https://postgr.es/m/CAAaqYe_JZRj+KPn=hACtwsg1iLRYs=jYvxG1NW4AnDeUL1GD-Q@mail.gmail.com
Peter Eisentraut [Mon, 12 Sep 2022 14:51:00 +0000 (16:51 +0200)]
Add list of acknowledgments to release notes
This contains all individuals mentioned in the commit messages during
PostgreSQL 15 development.
current through REL_15_BETA4
Daniel Gustafsson [Mon, 12 Sep 2022 10:59:06 +0000 (12:59 +0200)]
Fix NaN comparison in circle_same test
Commit
c4c340088 changed geometric operators to use float4 and float8
functions, and handle NaN's in a better way. The circle sameness test
had a typo in the code which resulted in all comparisons with the left
circle having a NaN radius considered same.
postgres=# select '<(0,0),NaN>'::circle ~= '<(0,0),1>'::circle;
?column?
----------
t
(1 row)
This fixes the sameness test to consider the radius of both the left
and right circle.
Backpatch to v12 where this was introduced.
Author: Ranier Vilela <
[email protected]>
Discussion: https://postgr.es/m/CAEudQAo8dK=yctg2ZzjJuzV4zgOPBxRU5+Kb+yatFiddtQk6Rw@mail.gmail.com
Backpatch-through: v12
Peter Eisentraut [Mon, 12 Sep 2022 07:38:07 +0000 (09:38 +0200)]
Use float8 datatype for percentiles in pg_walinspect stat functions
pg_walinspect uses datatype double (double precision floating point
number) for WAL stats percentile calculations and expose them via
float4 (single precision floating point number), which an unnecessary
loss of precision and confusing. Even though, it's harmless that way,
let's use float8 (double precision floating-point number) to be in
sync with what pg_walinspect does internally and what it exposes to
the users. This seems to be the pattern used elsewhere in the code.
Reported-by: Peter Eisentraut
Author: Bharath Rupireddy
Reviewed-by: Peter Eisentraut
Discussion: https://www.postgresql.org/message-id/
36ee692b-232f-0484-ce94-
dc39d82021ad%40enterprisedb.com
Tom Lane [Sat, 10 Sep 2022 20:42:25 +0000 (16:42 -0400)]
Doc: improve explanation of when custom GUCs appear in pg_settings.
Be more clear about when and how an extension-defined GUC comes to be
visible in pg_settings. (Move the para to the bottom of the page, too;
whoever thought this point was more important than the para about the
view being updatable had odd priorities IMNSHO.)
Back-patch to v15 where archive modules were added, since that seems
to have made this more of a sore spot than it was before.
Benoit Lobréau, Nathan Bossart
Discussion: https://postgr.es/m/CAPE8EZ7KHaXMHKwT=HOim23tDVKYA1PruRuTfeYdCrYWwPGhag@mail.gmail.com
Tom Lane [Fri, 9 Sep 2022 19:34:04 +0000 (15:34 -0400)]
Fix possible omission of variable storage markers in ECPG.
The ECPG preprocessor converted code such as
static varchar str1[10], str2[20], str3[30];
into
static struct varchar_1 { int len; char arr[ 10 ]; } str1 ;
struct varchar_2 { int len; char arr[ 20 ]; } str2 ;
struct varchar_3 { int len; char arr[ 30 ]; } str3 ;
thus losing the storage attribute for the later variables.
Repeat the declaration for each such variable.
(Note that this occurred only for variables declared "varchar"
or "bytea", which may help explain how it escaped detection
for so long.)
Andrey Sokolov
Discussion: https://postgr.es/m/
942241662288242@mail.yandex.ru
Tom Lane [Fri, 9 Sep 2022 17:50:42 +0000 (13:50 -0400)]
Doc: improve documentation about where the psqlrc files are.
Remove no-longer-accurate claim that Windows lacks home directories.
Clarify the text by more clearly distinguishing which statements
reflect hard-wired choices versus which ones reflect overridable
defaults. Update the examples of version-specific file names,
and make them track future version changes by using "&majorversion;"
and "&version;". (BTW, in devel and beta releases this method
correctly says that you can use strings like "16devel" and "15beta4"
as minor version identifiers.)
Back-patch to v15, but not further, with the thought that in older
releases the examples with three-part version numbers still had
some historical relevance. v15 will be the first major release after
the last 9.x branch went out of support.
Robert Treat and Tom Lane, reviewed by Julien Rouhaud
Discussion: https://postgr.es/m/CAJSLCQ07F-WCYYYOY8+dWhHcVeJ1Pb01cWc-c0Hu=M3EjKT2Eg@mail.gmail.com
Tom Lane [Fri, 9 Sep 2022 16:41:36 +0000 (12:41 -0400)]
Reject bogus output from uuid_create(3).
When using the BSD UUID functions, contrib/uuid-ossp expects
uuid_create() to produce a version-1 UUID. FreeBSD still does so,
but in recent NetBSD releases that function produces a version-4
(random) UUID instead. That's not acceptable for our purposes:
if the user wanted v4 she would have asked for v4, not v1.
Hence, check the version digit and complain if it's not '1'.
Also drop the documentation's claim that the NetBSD implementation
is usable. It might be, depending on which OS version you're using,
but we're not going to get into that kind of detail.
(Maybe someday we should ditch all these external libraries
and just write our own UUID code, but today is not that day.)
Nazir Bilal Yavuz, with cosmetic adjustments and docs by me.
Backpatch to all supported versions.
Discussion: https://postgr.es/m/
3848059.
1661038772@sss.pgh.pa.us
Discussion: https://postgr.es/m/17358-
89806e7420797025@postgresql.org
Alvaro Herrera [Fri, 9 Sep 2022 11:51:45 +0000 (13:51 +0200)]
Doc fixes for MERGE statement
In commit
3d895bc846f2 I introduced a bogus semicolon mid-statement by
careless cut-n-paste; move it. This had already been reported by Justin
Pryzby.
Also, change the styling a bit by avoiding names in CamelCase. This is
more consistent with the style we use elsewhere.
Backpatch to 15.
Author: Vitaly Burovoy <
[email protected]>
Reviewed-by: Vik Fearing <[email protected]>
Discussion: https://postgr.es/m/
9afe5766-5a61-7860-598c-
136867fad065@gmail.com
Discussion: https://postgr.es/m/
20220819133016[email protected]
Alvaro Herrera [Fri, 9 Sep 2022 10:22:20 +0000 (12:22 +0200)]
Fix GetForeignKey*Triggers for self-referential FKs
Because of inadequate filtering, the check triggers were confusing the
search for action triggers in GetForeignKeyActionTriggers and vice-versa
in GetForeignKeyCheckTriggers; this confusion results in seemingly
random assertion failures, and can have real impact in non-asserting
builds depending on catalog order. Change these functions so that they
correctly ignore triggers that are not relevant to each side.
To reduce the odds of further problems, do not break out of the
searching loop in assertion builds. This break is likely to hide bugs;
without it, we would have detected this bug immediately.
This problem was introduced by
f4566345cf40, so backpatch to 15 where
that commit first appeared.
Author: Amit Langote <
[email protected]>
Discussion: https://postgr.es/m/
20220908172029[email protected]
Discussion: https://postgr.es/m/
4104619.
1662663056@sss.pgh.pa.us
Michael Paquier [Fri, 9 Sep 2022 01:01:14 +0000 (10:01 +0900)]
Add more error context to RestoreBlockImage() and consume it
On failure in restoring a block image, no details were provided, while
it is possible to see failure with an inconsistent record state, a
failure in processing decompression or a failure in decompression
because a build does not support this option.
RestoreBlockImage() is used in two code paths in the backend code,
during recovery and when checking a page consistency after applying
masking, and both places are changed to consume the error message
produced by the internal routine when it returns a false status. All
the error messages are reported under ERRCODE_INTERNAL_ERROR, that gets
used also when attempting to access a page compressed by a method
not supported by the build attempting the decompression. This is
something that can happen in core when doing physical replication with
primary and standby using inconsistent build options, for example.
This routine is available since
2c03216d and it has never provided any
context about the error happening when it failed. This change is
justified even more after
57aa5b2, that introduced compression of FPWs
in WAL.
Reported-by: Justin Prysby
Author: Michael Paquier
Discussion: https://postgr.es/m/
20220905002320[email protected]
Backpatch-through: 15
Alvaro Herrera [Thu, 8 Sep 2022 11:17:02 +0000 (13:17 +0200)]
Choose FK name correctly during partition attachment
During ALTER TABLE ATTACH PARTITION, if the name of a parent's foreign
key constraint is already used on the partition, the code tries to
choose another one before the FK attributes list has been populated,
so the resulting constraint name was "<relname>__fkey" instead of
"<relname>_<attrs>_fkey". Repair, and add a test case.
Backpatch to 12. In 11, the code to attach a partition was not smart
enough to cope with conflicting constraint names, so the problem doesn't
exist there.
Author: Jehan-Guillaume de Rorthais <
[email protected]>
Discussion: https://postgr.es/m/
20220901184156.
738ebee5@karst
Thomas Munro [Thu, 8 Sep 2022 08:25:20 +0000 (20:25 +1200)]
Fix recovery_prefetch with low maintenance_io_concurrency.
We should process completed IOs *before* trying to start more, so that
it is always possible to decode one more record when the decoded record
queue is empty, even if maintenance_io_concurrency is set so low that a
single earlier WAL record might have saturated the IO queue.
That bug was hidden because the effect of maintenance_io_concurrency was
arbitrarily clamped to be at least 2. Fix the ordering, and also remove
that clamp. We need a special case for 0, which is now treated the same
as recovery_prefetch=off, but otherwise the number is used directly.
This allows for testing with 1, which would have made the problem
obvious in simple test scenarios.
Also add an explicit error message for missing contrecords. It was a
bit strange that we didn't report an error already, and became a latent
bug with prefetching, since the internal state that tracks aborted
contrecords would not survive retrying, as revealed by
026_overwrite_contrecord.pl with this adjustment. Reporting an error
prevents that.
Back-patch to 15.
Reported-by: Justin Pryzby <[email protected]>
Reviewed-by: Kyotaro Horiguchi <[email protected]>
Discussion: https://postgr.es/m/
20220831140128.GS31833%40telsasoft.com
Alvaro Herrera [Wed, 7 Sep 2022 15:33:49 +0000 (17:33 +0200)]
Message style fixes
Amit Kapila [Wed, 7 Sep 2022 03:16:32 +0000 (08:46 +0530)]
Doc: Explain about Column List feature.
Add a new logical replication section for "Column Lists" (analogous to the
Row Filters page). This explains how the feature can be used and the
caveats in it.
Author: Peter Smith
Reviewed-by: Shi yu, Vignesh C, Erik Rijkers, Amit Kapila
Backpatch-through: 15, where it was introduced
Discussion: https://postgr.es/m/CAHut+PvOuc9=_4TbASc5=VUqh16UWtFO3GzcKQK_5m1hrW3vqg@mail.gmail.com
Tom Lane [Tue, 6 Sep 2022 22:00:32 +0000 (18:00 -0400)]
Fix new pg_publication_tables query.
The addition of published column names forgot to filter on attisdropped,
leading to cases where you could see "........pg.dropped.1........"
or the like as a reportedly-published column.
While we're here, rewrite the new subquery to get a more efficient plan
for it.
Hou Zhijie, per report from Jaime Casanova. Back-patch to v15 where
the bug was introduced. (Sadly, this means we need a post-beta4
catversion bump before beta4 has even hit the streets. I see no
good alternative though.)
Discussion: https://postgr.es/m/Yxa1SU4nH2HfN3/i@ahch-to
Tom Lane [Mon, 5 Sep 2022 21:12:45 +0000 (17:12 -0400)]
Stamp 15beta4.
Peter Eisentraut [Mon, 5 Sep 2022 12:37:22 +0000 (14:37 +0200)]
Translation updates
Source-Git-URL: https://git.postgresql.org/git/pgtranslation/messages.git
Source-Git-Hash:
f2c273bb8723eb69911a4b0b9d02ca15bbc7c60f
David Rowley [Mon, 5 Sep 2022 06:43:36 +0000 (18:43 +1200)]
Doc: clarify partitioned table limitations
Improve documentation regarding the limitations of unique and primary key
constraints on partitioned tables. The existing documentation didn't make
it clear that the constraint columns had to be present in the partition
key as bare columns. The reader could be led to believe that it was ok to
include the constraint columns as part of a function call's parameters or
as part of an expression. Additionally, the documentation didn't mention
anything about the fact that we disallow unique and primary key
constraints if the partition keys contain *any* function calls or
expressions, regardless of if the constraint columns appear as columns
elsewhere in the partition key.
The confusion here was highlighted by a report on the general mailing list
by James Vanns.
Discussion: https://postgr.es/m/CAH7vdhNF0EdYZz3GLpgE3RSJLwWLhEk7A_fiKS9dPBT3Dz_3eA@mail.gmail.com
Discussion: https://postgr.es/m/CAApHDvoU-u9iTqKjteYRFfi+UNEk7dbSAcyxEQD==vZt9B1KnA@mail.gmail.com
Reviewed-by: Erik Rijkers
Backpatch-through: 11
Tomas Vondra [Sun, 4 Sep 2022 22:06:39 +0000 (00:06 +0200)]
Reinstate tests accidentally removed by
e3fcca0d0d
Commit
e3fcca0d0d24 reverted modifications to HOT for BRIN, but it also
removed a couple unrelated tests from stats.sql. Reinstate those tests.
Reported-by: Peter Eisentraut
Tomas Vondra [Sun, 4 Sep 2022 21:37:42 +0000 (23:37 +0200)]
Force parallelism in partition_aggregate
Commit
db0d67db2 tweaked sort costing, which however resulted in a
couple plan changes in our regression tests. Most of the new plans were
fine, but partition_aggregate were meant to test parallel plans and the
new plans were serial.
Fix that by lowering parallel_setup_cost to 0, which is enough to switch
to the parallel plan again.
Report and patch by David Rowley.
Author: David Rowley
Reviewed-by: Tomas Vondra
Discussion: https://postgr.es/m/CAApHDvpVFgWzXdtUQkjyOPhNrNvumRi_=ftgS79KeAZ92tnHKQ@mail.gmail.com
Michael Paquier [Sat, 3 Sep 2022 11:57:23 +0000 (20:57 +0900)]
doc: Fix two queries related to jsonb functions
These have been updated by the revert done in
2f2b18b, but the
pre-revert state was correct. Note that the result was incorrectly
formatted in the first case.
Author: Erik Rijkers
Discussion: https://postgr.es/m/
13777e96-24b6-396b-cb16-
8ad01b6ac130@xs4all.nl
Backpatch-through: 13
Bruce Momjian [Sat, 3 Sep 2022 03:32:19 +0000 (23:32 -0400)]
doc: simplify docs about analyze and inheritance/partitions
Discussion: https://postgr.es/m/
[email protected]
Backpatch-through: 10
Bruce Momjian [Sat, 3 Sep 2022 01:57:41 +0000 (21:57 -0400)]
doc: clarify recursion internal behavior
Reported-by: Drew DeVault
Discussion: https://postgr.es/m/
20211018091720[email protected]
Backpatch-through: 10
Bruce Momjian [Sat, 3 Sep 2022 01:47:30 +0000 (21:47 -0400)]
relnotes: improve collation check and ICU items
Reported-by: Matthias van de Meent
Discussion: https://postgr.es/m/CAEze2WhrNAT2g8upDUhfqt1nWfV_JdUgXAQu7oT4rY2L68O-HQ@mail.gmail.com
Backpatch-through: 15 only
Thomas Munro [Sat, 3 Sep 2022 00:58:16 +0000 (12:58 +1200)]
Fix cache invalidation bug in recovery_prefetch.
XLogPageRead() can retry internally after a pread() system call has
succeeded, in the case of short reads, and page validation failures
while in standby mode (see commit
0668719801). Due to an oversight in
commit
3f1ce973, these cases could leave stale data in the internal
cache of xlogreader.c without marking it invalid. The main defense
against stale cached data on failure to read a page was in the error
handling path of the calling function ReadPageInternal(), but that
wasn't quite enough for errors handled internally by XLogPageRead()'s
retry loop if we then exited with XLREAD_WOULDBLOCK.
1. ReadPageInternal() now marks the cache invalid before calling the
page_read callback, by setting state->readLen to 0. It'll be set to
a non-zero value only after a successful read. It'll stay valid as
long as the caller requests data in the cached range.
2. XLogPageRead() no long performs internal retries while reading
ahead. While such retries should work, the general philosophy is
that we should give up prefetching if anything unusual happens so we
can handle it when recovery catches up, to reduce the complexity of
the system. Let's do that here too.
3. While here, a new function XLogReaderResetError() improves the
separation between xlogrecovery.c and xlogreader.c, where the former
previously clobbered the latter's internal error buffer directly.
The new function makes this more explicit, and also clears a related
flag, without which a standby would needlessly retry in the outer
function.
Thanks to Noah Misch for tracking down the conditions required for a
rare build farm failure in src/bin/pg_ctl/t/003_promote.pl, and
providing a reproducer.
Back-patch to 15.
Reported-by: Noah Misch <[email protected]>
Discussion: https://postgr.es/m/
20220807003627.GA4168930%40rfd.leadboat.com
Amit Kapila [Fri, 2 Sep 2022 11:03:18 +0000 (16:33 +0530)]
Doc: fix column list vs. replica identity rules.
It was not strictly correct to say that a column list must always include
replica identity columns because that is true for only updates and
deletes.
Author: Peter Smith
Reviwed-by: Vignesh C, Amit Kapila
Backpatch-through: 15, where it was introduced
Discussion: https://postgr.es/m/CAHut+PvOuc9=_4TbASc5=VUqh16UWtFO3GzcKQK_5m1hrW3vqg@mail.gmail.com
Etsuro Fujita [Fri, 2 Sep 2022 07:45:01 +0000 (16:45 +0900)]
Doc: Update struct Trigger definition.
Commit
487e9861d added a new field to struct Trigger, but failed to
update the documentation to match; backpatch to v13 where that came in.
Reviewed by Richard Guo.
Discussion: https://postgr.es/m/CAPmGK17NY92CyxJ%2BBG7A3JZurmng4jfRfzPiBTtNupGMF0xW1g%40mail.gmail.com
Andrew Dunstan [Thu, 1 Sep 2022 21:09:46 +0000 (17:09 -0400)]
Revert SQL/JSON features
The reverts the following and makes some associated cleanups:
commit
f79b803dc: Common SQL/JSON clauses
commit
f4fb45d15: SQL/JSON constructors
commit
5f0adec25: Make STRING an unreserved_keyword.
commit
33a377608: IS JSON predicate
commit
1a36bc9db: SQL/JSON query functions
commit
606948b05: SQL JSON functions
commit
49082c2cc: RETURNING clause for JSON() and JSON_SCALAR()
commit
4e34747c8: JSON_TABLE
commit
fadb48b00: PLAN clauses for JSON_TABLE
commit
2ef6f11b0: Reduce running time of jsonb_sqljson test
commit
14d3f24fa: Further improve jsonb_sqljson parallel test
commit
a6baa4bad: Documentation for SQL/JSON features
commit
b46bcf7a4: Improve readability of SQL/JSON documentation.
commit
112fdb352: Fix finalization for json_objectagg and friends
commit
fcdb35c32: Fix transformJsonBehavior
commit
4cd8717af: Improve a couple of sql/json error messages
commit
f7a605f63: Small cleanups in SQL/JSON code
commit
9c3d25e17: Fix JSON_OBJECTAGG uniquefying bug
commit
a79153b7a: Claim SQL standard compliance for SQL/JSON features
commit
a1e7616d6: Rework SQL/JSON documentation
commit
8d9f9634e: Fix errors in copyfuncs/equalfuncs support for JSON node types.
commit
3c633f32b: Only allow returning string types or bytea from json_serialize
commit
67b26703b: expression eval: Fix EEOP_JSON_CONSTRUCTOR and EEOP_JSONEXPR size.
The release notes are also adjusted.
Backpatch to release 15.
Discussion: https://postgr.es/m/
40d2c882-bcac-19a9-754d-
4299e1d87ac7@postgresql.org
David Rowley [Thu, 1 Sep 2022 07:21:58 +0000 (19:21 +1200)]
Fix some possibly latent bugs in slab.c
Primarily, this fixes an incorrect calculation in SlabCheck which was
looking in the wrong byte for the sentinel check. The reason that we've
never noticed this before in the form of a failing sentinel check is
because the pre-check to this always fails because all current core users
of slab contexts have a chunk size which is already MAXALIGNed, therefore
there's never any space for the sentinel byte. It is possible that an
extension needs to use a slab context and if they do with a chunk size
that's not MAXALIGNed, then they'll likely get errors about overwritten
sentinel bytes.
Additionally, this patch changes various calculations which are being done
based on the sizeof(SlabBlock). Currently, sizeof(SlabBlock) is a
multiple of 8, therefore sizeof(SlabBlock) is the same as
MAXALIGN(sizeof(SlabBlock)), however, if we were to ever have to add any
fields to that struct as part of a bug fix, then SlabAlloc could end up
returning a non-MAXALIGNed pointer. To be safe, let's ensure we always
MAXALIGN sizeof(SlabBlock) before using it in any calculations.
This patch has already been applied to master in
d5ee4db0e.
Diagnosed-by: Tomas Vondra, Tom Lane
Author: Tomas Vondra, David Rowley
Discussion: https://postgr.es/m/CAA4eK1%2B1JyW5TiL%3DyV-3Uq1CrfnTyn0Xrk5uArt31Z%3D8rgPhXQ%40mail.gmail.com
Backpatch-through: 10
Bruce Momjian [Thu, 1 Sep 2022 03:11:46 +0000 (23:11 -0400)]
doc: in create statistics docs, mention analyze for parent info
Discussion: https://postgr.es/m/
[email protected]
Backpatch-through: 10
Bruce Momjian [Thu, 1 Sep 2022 02:35:09 +0000 (22:35 -0400)]
doc: mention "bloom" as a possible index access method
Also remove USING erroneously added recently.
Reported-by: Jeff Janes
Discussion: https://postgr.es/m/CAMkU=1zhCpC7hottyMWM5Pimr9vRLprSwzLg+7PgajWhKZqRzw@mail.gmail.com
Backpatch-through: 10
Bruce Momjian [Thu, 1 Sep 2022 02:19:06 +0000 (22:19 -0400)]
doc: use FILTER in aggregate example
Reported-by: [email protected]
Discussion: https://postgr.es/m/
163499710897.684.
7420075366995883688@wrigleys.postgresql.org
Backpatch-through: 10
Bruce Momjian [Thu, 1 Sep 2022 02:04:36 +0000 (22:04 -0400)]
doc: clarify that pgcrypto's gen_random_uuid calls core func.
Previously it was just marked as a duplicate of the core function.
Reported-by: Andreas Dijkman
Discussion: https://postgr.es/m/17349-
24d61e214429e8c1@postgresql.org
Backpatch-through: 13
Bruce Momjian [Thu, 1 Sep 2022 01:46:14 +0000 (21:46 -0400)]
doc: split out the NATURAL/CROSS JOIN in SELECT syntax
This allows the syntax to be more accurate about what clauses are
supported. Also switch an example query to use the ANSI join syntax.
Reported-by: Joel Jacobson
Discussion: https://postgr.es/m/
67b71d3e-0c22-44df-a223-
351f14418319@www.fastmail.com
Backpatch-through: 11
Bruce Momjian [Thu, 1 Sep 2022 01:10:37 +0000 (21:10 -0400)]
doc: warn of SECURITY DEFINER schemas for non-sql_body functions
Non-sql_body functions are evaluated at runtime.
Reported-by: Erki Eessaar
Discussion: https://postgr.es/m/AM9PR01MB8268BF5E74E119828251FD34FE409@AM9PR01MB8268.eurprd01.prod.exchangelabs.com
Backpatch-through: 10
Bruce Momjian [Thu, 1 Sep 2022 00:27:27 +0000 (20:27 -0400)]
doc: mention that SET TIME ZONE often needs to be quoted
Also mention that time zone abbreviations are not supported.
Reported-by: [email protected]
Discussion: https://postgr.es/m/
163888728952.1269.
5167822676466793158@wrigleys.postgresql.org
Backpatch-through: 10
Bruce Momjian [Wed, 31 Aug 2022 23:43:06 +0000 (19:43 -0400)]
doc: document the maximum char/varchar length value
Reported-by: Japin Li
Discussion: https://postgr.es/m/MEYP282MB1669B13E98AE531617CB1386B6979@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM
Backpatch-through: 10
Bruce Momjian [Wed, 31 Aug 2022 23:28:42 +0000 (19:28 -0400)]
doc: show direction is optional in FETCH/MOVE's FROM/IN syntax
It used to show direction was required for FROM/IN.
Reported-by: Rob <[email protected]>
Discussion: https://postgr.es/m/
20211015165248.isqjceyilelhnu3k@localhost
Author: Rob <
[email protected]>
Backpatch-through: 10
Bruce Momjian [Wed, 31 Aug 2022 21:08:44 +0000 (17:08 -0400)]
doc: simplify WITH clause syntax in CREATE DATABASE
Reported-by: Rob <[email protected]>
Discussion: https://postgr.es/m/
20211016171149.yaouvlw5kvux6dvk@localhost
Author: Rob <
[email protected]>
Backpatch-through: 10
Tom Lane [Wed, 31 Aug 2022 20:23:20 +0000 (16:23 -0400)]
Prevent long-term memory leakage in autovacuum launcher.
get_database_list() failed to restore the caller's memory context,
instead leaving current context set to TopMemoryContext which is
how CommitTransactionCommand() leaves it. The callers both think
they are using short-lived contexts, for the express purpose of
not having to worry about cleaning up individual allocations.
The net effect therefore is that supposedly short-lived allocations
could accumulate indefinitely in the launcher's TopMemoryContext.
Although this has been broken for a long time, it seems we didn't
have any obvious memory leak here until v15's rearrangement of the
stats logic. I (tgl) am not entirely convinced that there's no
other leak at all, though, and we're surely at risk of adding one
in future back-patched fixes. So back-patch to all supported
branches, even though this may be only a latent bug in pre-v15.
Reid Thompson
Discussion: https://postgr.es/m/
972a4e12b68b0f96db514777a150ceef7dcd2e0f[email protected]
Tom Lane [Wed, 31 Aug 2022 14:42:05 +0000 (10:42 -0400)]
In the Snowball dictionary, don't try to stem excessively-long words.
If the input word exceeds 1000 bytes, don't pass it to the stemmer;
just return it as-is after case folding. Such an input is surely
not a word in any human language, so whatever the stemmer might
do to it would be pretty dubious in the first place. Adding this
restriction protects us against a known recursion-to-stack-overflow
problem in the Turkish stemmer, and it seems like good insurance
against any other safety or performance issues that may exist in
the Snowball stemmers. (I note, for example, that they contain no
CHECK_FOR_INTERRUPTS calls, so we really don't want them running
for a long time.) The threshold of 1000 bytes is arbitrary.
An alternative definition could have been to treat such words as
stopwords, but that seems like a bigger break from the old behavior.
Per report from Egor Chindyaskin and Alexander Lakhin.
Thanks to Olly Betts for the recommendation to fix it this way.
Discussion: https://postgr.es/m/
1661334672.
728714027@f473.i.mail.ru
Peter Eisentraut [Wed, 31 Aug 2022 05:42:01 +0000 (07:42 +0200)]
plpython: Don't create pgxsdir subdirectory in installdir target
As of
db23464715f4792298c639153dda7bfd9ad9d602, we don't install
anything there anymore from plpython, so we don't need to create the
installation directory anymore.
Tom Lane [Tue, 30 Aug 2022 21:28:32 +0000 (17:28 -0400)]
On NetBSD, force dynamic symbol resolution at postmaster start.
The default of lazy symbol resolution means that when the postmaster
first reaches the select() call in ServerLoop, it'll need to resolve
the link to that libc entry point. NetBSD's dynamic loader takes
an internal lock while doing that, and if a signal interrupts the
operation then there is a risk of self-deadlock should the signal
handler do anything that requires that lock, as several of the
postmaster signal handlers do. The window for this is pretty narrow,
and timing considerations make it unlikely that a signal would arrive
right then anyway. But it's semi-repeatable on slow single-CPU
machines, and in principle the race could happen with any hardware.
The least messy solution to this is to force binding of dynamic
symbols at postmaster start, using the "-z now" linker option.
While we're at it, also use "-z relro" so as to provide a small
security gain.
It's not entirely clear whether any other platforms share this
issue, but for now we'll assume it's NetBSD-specific. (We might
later try to use "-z now" on more platforms for performance
reasons, but that would not likely be something to back-patch.)
Report and patch by me; the idea to fix it this way is from
Andres Freund.
Discussion: https://postgr.es/m/
3384826.
1661802235@sss.pgh.pa.us
Robert Haas [Mon, 29 Aug 2022 14:47:12 +0000 (10:47 -0400)]
Prevent WAL corruption after a standby promotion.
When a PostgreSQL instance performing archive recovery but not using
standby mode is promoted, and the last WAL segment that it attempted
to read ended in a partial record, the previous code would create
invalid WAL on the new timeline. The WAL from the previously timeline
would be copied to the new timeline up until the end of the last valid
record, but instead of beginning to write WAL at immediately
afterwards, the promoted server would write an overwrite contrecord at
the beginning of the next segment. The end of the previous segment
would be left as all-zeroes, resulting in failures if anything tried
to read WAL from that file.
The root of the issue is that ReadRecord() decides whether to set
abortedRecPtr and missingContrecPtr based on the value of StandbyMode,
but ReadRecord() switches to a new timeline based on the value of
ArchiveRecoveryRequested. We shouldn't try to write an overwrite
contrecord if we're switching to a new timeline, so change the test in
ReadRecod() to check ArchiveRecoveryRequested instead.
Code fix by Dilip Kumar. Comments by me incorporating suggested
language from Álvaro Herrera. Further review from Kyotaro Horiguchi
and Sami Imseih.
Discussion: http://postgr.es/m/CAFiTN-t7umki=PK8dT1tcPV=mOUe2vNhHML6b3T7W7qqvvajjg@mail.gmail.com
Discussion: http://postgr.es/m/
FB0DEA0B-E14E-43A0-811F-
C1AE93D00FF3%40amazon.com
Tom Lane [Sun, 28 Aug 2022 14:44:52 +0000 (10:44 -0400)]
Doc: fix example of recursive query.
Compute total number of sub-parts correctly, per
[email protected]
Simon Riggs
Discussion: https://postgr.es/m/
166161184718.
1235920.
6304070286124217754@wrigleys.postgresql.org
John Naylor [Tue, 23 Aug 2022 02:55:05 +0000 (09:55 +0700)]
Switch format specifier for replication origins to %d
Using %u with uint16 causes warnings with -Wformat-signedness. There are many
other warnings, but for now change only these since
c920fe4818 already changed
the message string for most of them.
Per report from Peter Eisentraut
Discussion: https://www.postgresql.org/message-id/
31e63649-0355-7088-831e-
b07d5f908a8c%40enterprisedb.com
Michael Paquier [Sat, 27 Aug 2022 06:22:07 +0000 (15:22 +0900)]
Use correct connection for cancellation in frontend's parallel slots
While waiting for slots to become available in wait_on_slots() in
parallel_slot.c, the cancellation always relied on the first connection
in the set to do the job. This could cause problems when this slot's
socket is gone as PQgetCancel() would return NULL in this case. Rather
than always using the first connection, this changes the logic to use
the first valid connection for the cancellation.
Author: Ranier Vilela
Reviewed-by: Justin Pryzby
Discussion: https://postgr.es/m/CAEudQAokk1h_pUwGXsYS4oVOuf35s1O2o3TXGHpV8=AWikvgHA@mail.gmail.com
Backpatch-through: 14
Peter Eisentraut [Fri, 26 Aug 2022 08:33:55 +0000 (10:33 +0200)]
Remove obsolete comment
The comment in basebackup.c updated by
33bd4698c11 was actually
obsolete to begin with, since the symbols it was referring to haven't
existed in that header file for quite some time. The header file is
still needed for other reasons, though, so keep the #include, just
drop the comment.
Etsuro Fujita [Fri, 26 Aug 2022 07:55:01 +0000 (16:55 +0900)]
Fix typo in comment.
Peter Eisentraut [Thu, 25 Aug 2022 18:46:58 +0000 (20:46 +0200)]
libpq code should use libpq_gettext(), not _()
Fix some wrong use and install a safeguard against future mistakes.
Jeff Davis [Thu, 25 Aug 2022 17:26:31 +0000 (10:26 -0700)]
Fix doc oversight for custom WAL resource managers.
Reported-by: Bharath Rupireddy
Backpatch-through: 15
Discussion: https://postgr.es/m/CALj2ACU+at7RqnWEzS59QsFg3ZOF4C4GSp7pt+PWiLEp0zrEKg@mail.gmail.com
Peter Eisentraut [Thu, 25 Aug 2022 13:04:38 +0000 (15:04 +0200)]
Update another comment still referring to pg_start/stop_backup()
Peter Eisentraut [Thu, 25 Aug 2022 04:35:16 +0000 (06:35 +0200)]
pg_dump: Fix new ICU tests
ICU doesn't support some server encodings, so we need to exclude them
if a non-supported encoding was set up.
Michael Paquier [Fri, 1 Jul 2022 00:37:17 +0000 (09:37 +0900)]
Fix code comments still referring to pg_start/stop_backup()
pg_start_backup() and pg_stop_backup() have been respectively renamed to
pg_backup_start() and pg_backup_stop() as of
39969e2, but a few comments
did not get the call.
Reviewed-by: Kyotaro Horiguchi, David Steele
Discussion: https://postgr.es/m/YrqGlj1+4DF3dbZ/@paquier.xyz
Peter Eisentraut [Wed, 24 Aug 2022 18:13:52 +0000 (20:13 +0200)]
pg_dump: Dump colliculocale
This was forgotten when the new column was introduced.
Author: Marina Polyakova <
[email protected]>
Reviewed-by: Julien Rouhaud <[email protected]>
Discussion: https://www.postgresql.org/message-id/
7ad26354e75259f59c4a6c6997b8ee32%40postgrespro.ru
Tom Lane [Wed, 24 Aug 2022 17:01:40 +0000 (13:01 -0400)]
Defend against stack overrun in a few more places.
SplitToVariants() in the ispell code, lseg_inside_poly() in geo_ops.c,
and regex_selectivity_sub() in selectivity estimation could recurse
until stack overflow; fix by adding check_stack_depth() calls.
So could next() in the regex compiler, but that case is better fixed by
converting its tail recursion to a loop. (We probably get better code
that way too, since next() can now be inlined into its sole caller.)
There remains a reachable stack overrun in the Turkish stemmer, but
we'll need some advice from the Snowball people about how to fix that.
Per report from Egor Chindyaskin and Alexander Lakhin. These mistakes
are old, so back-patch to all supported branches.
Richard Guo and Tom Lane
Discussion: https://postgr.es/m/
1661334672.
728714027@f473.i.mail.ru
David Rowley [Wed, 24 Aug 2022 11:46:40 +0000 (23:46 +1200)]
Doc: remove duplicate "a" from func.sgml
Author: Shinya Kato
Discussion: https://postgr.es/m/
76c01275776749a167f49379ebec57f1@oss.nttdata.com
Backpatch-through: 15, where that change was introduced
Peter Eisentraut [Wed, 24 Aug 2022 11:27:34 +0000 (13:27 +0200)]
Fix ICU locale option handling in CREATE DATABASE
The code took the LOCALE option as the default/fallback for
ICU_LOCALE, but this was neither documented nor intended, so remove
it. (It was probably left in from an earlier patch version.)
Reported-by: Marina Polyakova <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/
f385ba25e7f8be427b8c582e5cca7d79%40postgrespro.ru#
515a31c5429d6d37ad1d5c9d66962a1e
Peter Eisentraut [Tue, 23 Aug 2022 19:50:12 +0000 (21:50 +0200)]
Message style adjustment
Tom Lane [Tue, 23 Aug 2022 13:55:37 +0000 (09:55 -0400)]
Doc: document possible need to raise kernel's somaxconn limit.
On fast machines, it's possible for applications such as pgbench
to issue connection requests so quickly that the postmaster's
listen queue overflows in the kernel, resulting in unexpected
failures (with not-very-helpful error messages). Most modern OSes
allow the queue size to be increased, so document how to do that.
Per report from Kevin McKibbin.
Discussion: https://postgr.es/m/CADc_NKg2d+oZY9mg4DdQdoUcGzN2kOYXBu-3--RW_hEe0tUV=g@mail.gmail.com
Tom Lane [Tue, 23 Aug 2022 13:41:37 +0000 (09:41 -0400)]
Doc: prefer sysctl to /proc/sys in docs and comments.
sysctl is more portable than Linux's /proc/sys file tree, and
often easier to use too. That's why most of our docs refer to
sysctl when talking about how to adjust kernel parameters.
Bring the few stragglers into line.
Discussion: https://postgr.es/m/361175.
1661187463@sss.pgh.pa.us
Amit Kapila [Tue, 23 Aug 2022 04:38:43 +0000 (10:08 +0530)]
Add CHECK_FOR_INTERRUPTS while decoding changes.
While decoding changes in a loop, if we skip all the changes there is no
CFI making the loop uninterruptible.
Reported-by: Whale Song and Andrey Borodin
Bug: 17580
Author: Masahiko Sawada
Reviwed-by: Amit Kapila
Backpatch-through: 10
Discussion: https://postgr.es/m/17580-
849c1d5b6d7eb422@postgresql.org
Discussion: https://postgr.es/m/
B319ECD6-9A28-4CDF-A8F4-
3591E0BF2369@yandex-team.ru
Andres Freund [Tue, 23 Aug 2022 03:16:50 +0000 (20:16 -0700)]
pgstat: Acquire lock when reading variable-numbered stats
Somewhere during the development of the patch acquiring a lock during read
access to variable-numbered stats got lost. The missing lock acquisition won't
cause corruption, but can lead to reading torn values when accessing
stats. Add the missing lock acquisitions.
Reported-by: Greg Stark <[email protected]>
Reviewed-by: "Drouvot, Bertrand" <[email protected]>
Reviewed-by: Andres Freund <[email protected]>
Author: Kyotaro Horiguchi <
[email protected]>
Discussion: https://postgr.es/m/CAM-w4HMYkM_DkYhWtUGV+qE_rrBxKOzOF0+5faozxO3vXrc9wA@mail.gmail.com
Backpatch: 15-
Peter Eisentraut [Mon, 22 Aug 2022 13:31:50 +0000 (15:31 +0200)]
Fix assertion failure in CREATE DATABASE
An assertion would fail when creating a database with libc locale
provider from a template database with icu locale provider.
Reported-by: Marina Polyakova <[email protected]>
Reviewed-by: Julien Rouhaud <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/
f385ba25e7f8be427b8c582e5cca7d79%40postgrespro.ru#
515a31c5429d6d37ad1d5c9d66962a1e
Peter Eisentraut [Mon, 22 Aug 2022 11:26:52 +0000 (13:26 +0200)]
pg_upgrade: Fix thinko in database info acquisition routine
When checking whether the major version supports per-database locale
providers, it was always looking at the version of the old cluster
instead of the cluster that was passed in. This would lead to
failures to detect locale provider mismatches.
Reported-by: Marina Polyakova <[email protected]>
Reviewed-by: Julien Rouhaud <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/
f385ba25e7f8be427b8c582e5cca7d79%40postgrespro.ru#
515a31c5429d6d37ad1d5c9d66962a1e
Amit Kapila [Mon, 22 Aug 2022 03:21:25 +0000 (08:51 +0530)]
Use logical operator && instead of & in vacuumparallel.c.
As such the current usage of & won't produce incorrect results but it
would be better to use && to short-circuit the evaluation of second
condition when the same is not required.
Author: Ranier Vilela
Reviewed-by: Tom Lane, Bharath Rupireddy
Backpatch-through: 15, where it was introduced
Discussion: https://postgr.es/m/CAEudQApL8QcoYwQuutkWKY_h7gBY8F0Xs34YKfc7-G0i83K_pw@mail.gmail.com
David Rowley [Fri, 19 Aug 2022 23:40:59 +0000 (11:40 +1200)]
Remove shadowed local variables that are new in v15
Compiling with -Wshadow=compatible-local yields quite a few warnings about
local variables being shadowed by compatible local variables in an inner
scope. Of course, this is perfectly valid in C, but we have had bugs in
the past as a result of developers failing to notice this.
af7d270dd is a
recent example.
Here we do a cleanup of warnings we receive from -Wshadow=compatible-local
for code which is new to PostgreSQL 15. We've yet to have the discussion
about if we actually ever want to run that as a standard compilation flag.
We'll need to at least get the number of warnings down to something easier
to manage before we can realistically consider if we want this or not.
This commit is the first step towards reducing the warnings.
The changes being made here are all fairly trivial. Because of that, and
the fact that v15 is still in beta, this is being back-patched into 15.
It seems more risky not to do this as the risk of future bugs is increased
by the additional conflicts that this commit could cause for any future
bug fixes touching the same areas as this commit.
Author: Justin Pryzby
Discussion: https://postgr.es/m/
20220817145434.GC26426%40telsasoft.com
Backpatch-through: 15
Peter Geoghegan [Fri, 19 Aug 2022 16:26:06 +0000 (09:26 -0700)]
Avoid reltuples distortion in very small tables.
Consistently avoid trusting a sample of only one page at the point that
VACUUM determines a new reltuples for the target table (though only when
the table is larger than a single page). This is follow-up work to
commit
74388a1a, which added a heuristic to prevent reltuples from
becoming distorted by successive VACUUM operations that each scan only a
single heap page (which was itself more or less a bugfix for an issue in
commit
44fa8488, which simplified VACUUM's handling of scanned pages).
The original bugfix commit did not account for certain remaining cases
that where not affected by its "2% of total relpages" heuristic. This
happened with relations that are small enough that just one of its pages
exceeded the 2% threshold, yet still big enough for VACUUM to deem
skipping most of its pages via the visibility map worthwhile. reltuples
could still become distorted over time with such a table, at least in
scenarios where the VACUUM command is run repeatedly and without the
table itself ever changing.
Author: Peter Geoghegan <
[email protected]>
Discussion: https://postgr.es/m/CAH2-Wzk7d4m3oEbEWkWQKd+gz-eD_peBvdXVk1a_KBygXadFeg@mail.gmail.com
Backpatch: 15-, where the rules for scanned pages changed.
Michael Paquier [Fri, 19 Aug 2022 01:00:23 +0000 (10:00 +0900)]
doc: Improve some markups and some wording around archiving modules
This commit adds or fixes used markups in a couple of places in the docs
(for <command>, <systemitem> and <literal>). While on it, clarify some
of the documentation added recently for archiving modules with
archive_command, that would still be used as default choice if no
external module is defined (though an archive module could as well use
an archive_command).
Author: Maxim Yablokov
Discussion: https://postgr.es/m/
b47ec4e8-6f6a-2aba-038e-
d5db150b245e@postgrespro.ru
Backpatch-through: 15
Peter Geoghegan [Fri, 19 Aug 2022 00:34:12 +0000 (17:34 -0700)]
Initialize index stats during parallel VACUUM.
Initialize shared memory allocated for index stats to avoid a hard
crash. This was possible when parallel VACUUM became confused about the
current phase of index processing.
Oversight in commit
8e1fae1938, which refactored parallel VACUUM.
Author: Masahiko Sawada <
[email protected]>
Reported-By: Justin Pryzby <[email protected]>
Discussion: https://postgr.es/m/
20220818133406[email protected]
Backpatch: 15-, the first version with the refactoring commit.
Jeff Davis [Thu, 18 Aug 2022 21:23:59 +0000 (14:23 -0700)]
Use correct LSN for error reporting in pg_walinspect
Usage of ReadNextXLogRecord()'s first_record parameter for error
reporting isn't always correct. For instance, in GetWALRecordsInfo()
and GetWalStats(), we're reading multiple records, and first_record
is always passed as the LSN of the first record which is then used
for error reporting for later WAL record read failures. This isn't
correct.
The correct parameter to use for error reports in case of WAL
reading failures is xlogreader->EndRecPtr. This change fixes it.
While on it, removed an unnecessary Assert in pg_walinspect code.
Reported-by: Robert Haas
Author: Bharath Rupireddy
Reviewed-by: Robert Haas
Discussion: https://www.postgresql.org/message-id/CA%2BTgmoZAOGzPUifrcZRjFZ2vbtcw3mp-mN6UgEoEcQg6bY3OVg%40mail.gmail.com
Backpatch-through: 15
Tom Lane [Thu, 18 Aug 2022 16:11:47 +0000 (12:11 -0400)]
Fix subtly-incorrect matching of parent and child partitioned indexes.
When creating a partitioned index, DefineIndex tries to identify
any existing indexes on the partitions that match the partitioned
index, so that it can absorb those as child indexes instead of
building new ones. Part of the matching is to compare IndexInfo
structs --- but that wasn't done quite right. We're comparing
the IndexInfo built within DefineIndex itself to one made from
existing catalog contents by BuildIndexInfo. Notably, while
BuildIndexInfo will run index expressions and predicates through
expression preprocessing, that has not happened to DefineIndex's
struct. The result is failure to match and subsequent creation
of duplicate indexes.
The easiest and most bulletproof fix is to build a new IndexInfo
using BuildIndexInfo, thereby guaranteeing that the processing done
is identical.
While here, let's also extract the opfamily and collation data
from the new partitioned index, removing ad-hoc logic that
duplicated knowledge about how those are constructed.
Per report from Christophe Pettus. Back-patch to v11 where
we invented partitioned indexes.
Richard Guo and Tom Lane
Discussion: https://postgr.es/m/
8864BFAA-81FD-4BF9-8E06-
7DEB8D4164ED@thebuild.com
Robert Haas [Thu, 18 Aug 2022 15:09:39 +0000 (11:09 -0400)]
When using the WAL-logged CREATE DATABASE strategy, bulk extend.
This should improve performance, and was suggested by Andres Freund.
Back-patch to v15 to keep the code consistent across branches.
Dilip Kumar
Discussion: http://postgr.es/m/
C3458199-FEDD-4356-865A-
08DFAA5D4065@anarazel.de
Discussion: http://postgr.es/m/CAFiTN-sJ0vVpJrZ=R5M+g7Tr8=NN4wKOtrqOcDEsfFfnZgivVA@mail.gmail.com
Peter Eisentraut [Thu, 18 Aug 2022 09:33:53 +0000 (11:33 +0200)]
Simplify and clarify an error message
John Naylor [Thu, 18 Aug 2022 01:57:13 +0000 (08:57 +0700)]
Refer to replication origin roident as "ID" in user facing messages and docs
The table column that stores this is of type oid, but is actually limited
to uint16 and has a different path for creating new values. Some of
the documentation already referred to it as an ID, so let's standardize
on that.
While at it, most format strings already use %u, so for consintency
change the remaining stragglers using %d.
Per suggestions from Tom Lane and Justin Pryzby
Discussion: https://www.postgresql.org/message-id/
3437166.
1659620465%40sss.pgh.pa.us
Backpatch to v15