Alvaro Herrera [Fri, 25 Aug 2023 11:31:24 +0000 (13:31 +0200)] Catalog not-null constraints
We now create contype='n' pg_constraint rows for not-null constraints.
We propagate these constraints to other tables during operations such as
adding inheritance relationships, creating and attaching partitions and
creating tables LIKE other tables. We also spawn not-null constraints
for inheritance child tables when their parents have primary keys.
These related constraints mostly follow the well-known rules of
conislocal and coninhcount that we have for CHECK constraints, with some
adaptations: for example, as opposed to CHECK constraints, we don't
match not-null ones by name when descending a hierarchy to alter it,
instead matching by column name that they apply to. This means we don't
require the constraint names to be identical across a hierarchy.
For now, we omit them for system catalogs. Maybe this is worth
reconsidering. We don't support NOT VALID nor DEFERRABLE clauses
either; these can be added as separate features later (this is
already large and complicated enough.)
psql shows these constraints in \d+.
pg_dump requires some ad-hoc hacks, particularly when dumping a primary
key. We now create one "throwaway" not-null constraint for each column
in the PK together with the CREATE TABLE command, and once the PK is
created, all those throwaway constraints are removed. This avoids
having to check each tuple for nullness when the dump restores the
primary key creation.
pg_upgrading from an older release requires a somewhat brittle procedure
to create a constraint state that matches what would be created if the
database were being created fresh in Postgres 17. I have tested all the
scenarios I could think of, and it works correctly as far as I can tell,
but I could have neglected weird cases.
This has been very long in the making. The first was
written by Bernd Helmle in 2010 to add a new pg_constraint.contype value
('n'), which I (Álvaro) then hijacked in 2011 and 2012, until that one
was killed by the realization that we ought to use contype='c' instead:
manufactured CHECK constraints. However, later SQL standard
development, as well as nonobvious emergent properties of that design
(mostly, failure to distinguish them from "normal" CHECK constraints as
well as the performance implication of having to test the CHECK
expression) led us to reconsider this choice, so now the current
implementation uses contype='n' again. During Postgres 16 this had
already been introduced by commit
e056c557aef4, but there were some
problems mainly with the pg_upgrade procedure that couldn't be fixed in
reasonable time, so it was reverted.
In 2016 Vitaly Burovoy also worked on this feature[1] but found no
consensus for his proposed approach, which was claimed to be closer to
the letter of the standard, requiring an additional pg_attribute column
to track the OID of the not-null constraint for that column.
[1] https://postgr.es/m/CAKOSWNkN6HSyatuys8xZxzRCR-KL1OkHS5-b9qd9bf1Rad3PLA@mail.gmail.com
Author: Álvaro Herrera <
[email protected]>
Author: Bernd Helmle <
[email protected]>
Reviewed-by: Justin Pryzby <[email protected]>Reviewed-by: Peter Eisentraut <[email protected]>Reviewed-by: Dean Rasheed <[email protected]>Amit Kapila [Fri, 25 Aug 2023 03:27:55 +0000 (08:57 +0530)] Reset the logical worker type while cleaning up other worker info.
Commit
2a8b40e36 introduces the worker type field for logical replication
workers, but forgot to reset the type when the worker exits. This can lead
to recognizing a stopped worker as a valid logical replication worker.
Fix it by resetting the worker type and additionally adding the safeguard
to not use LogicalRepWorker until ->in_use is verified.
Reported-by: Thomas Munro based on cfbot reports.Author: Hou Zhijie, Alvaro Herrera
Reviewed-by: Amit KapilaDiscussion: http://postgr.es/m/CA+hUKGK2RQh4LifVgBmkHsCYChP-65UwGXOmnCzYVa5aAt4GWg@mail.gmail.com
Andres Freund [Thu, 24 Aug 2023 21:17:03 +0000 (14:17 -0700)] Use "template" data directory in tests
When running all (or just many) of our tests, a significant portion of both
CPU time and IO is spent running initdb. Most of those initdb runs don't
specify any options influencing properties of the created data directory.
Avoid most of that overhead by creating a "template" data directory, alongside
the temporary installation. Instead of running initdb, pg_regress and tap
tests can copy that data directory. When a tap test specifies options to
initdb, the template data directory is not used. That could be relaxed for
some options, but it's not clear it's worth the effort.
There unfortunately is some duplication between pg_regress.c and Cluster.pm,
but there are no easy ways of sharing that code without introducing additional
complexity.
Reviewed-by: Daniel Gustafsson <[email protected]>Discussion: https://postgr.es/m/
20220120021859[email protected]Nathan Bossart [Thu, 24 Aug 2023 17:13:31 +0000 (10:13 -0700)] pg_upgrade: Bump MESSAGE_WIDTH.
Commit
7b378237aa added a status message to pg_upgrade that is 60
characters wide. Since the MESSAGE_WIDTH macro is currently set to
60, there is no space between this new status message and the "ok"
or "failed" indicator appended when the step completes. To fix
this problem, this commit increases the value of MESSAGE_WIDTH to
62.
Suggested-by: Bharath RupireddyReviewed-by: Peter EisentrautDiscussion: https://postgr.es/m/CALj2ACVVvk1cYLtWVxHv%3DZ1Ubq%3DUES9fhKbUU4c9k4W%2BfEDnbw%40mail.gmail.com
Back-through: 16
Tom Lane [Thu, 24 Aug 2023 16:02:40 +0000 (12:02 -0400)] Avoid unnecessary plancache revalidation of utility statements.
Revalidation of a plancache entry (after a cache invalidation event)
requires acquiring a snapshot. Normally that is harmless, but not
if the cached statement is one that needs to run without acquiring a
snapshot. We were already aware of that for TransactionStmts,
but for some reason hadn't extrapolated to the other statements that
PlannedStmtRequiresSnapshot() knows mustn't set a snapshot. This can
lead to unexpected failures of commands such as SET TRANSACTION
ISOLATION LEVEL. We can fix it in the same way, by excluding those
command types from revalidation.
However, we can do even better than that: there is no need to
revalidate for any statement type for which parse analysis, rewrite,
and plan steps do nothing interesting, which is nearly all utility
commands. To mechanize this, invent a parser function
stmt_requires_parse_analysis() that tells whether parse analysis does
anything beyond wrapping a CMD_UTILITY Query around the raw parse
tree. If that's what it does, then rewrite and plan will just
skip the Query, so that it is not possible for the same raw parse
tree to produce a different plan tree after cache invalidation.
stmt_requires_parse_analysis() is basically equivalent to the
existing function analyze_requires_snapshot(), except that for
obscure reasons that function omits ReturnStmt and CallStmt.
It is unclear whether those were oversights or intentional.
I have not been able to demonstrate a bug from not acquiring a
snapshot while analyzing these commands, but at best it seems mighty
fragile. It seems safer to acquire a snapshot for parse analysis of
these commands too, which allows making stmt_requires_parse_analysis
and analyze_requires_snapshot equivalent.
In passing this fixes a second bug, which is that ResetPlanCache
would exclude ReturnStmts and CallStmts from revalidation.
That's surely *not* safe, since they contain parsable expressions.
Per bug #18059 from Pavel Kulakov. Back- to all supported
branches.
Discussion: https://postgr.es/m/18059-
79c692f036b25346@postgresql.org
Alvaro Herrera [Thu, 24 Aug 2023 14:51:43 +0000 (16:51 +0200)] Add test for inherited CHECK constraint drop
This code is insufficiently covered by tests, so add a few small test
cases to immortalize its behavior before it gets rewritten completely by
the project to catalog NOT NULL constraints.
Heikki Linnakangas [Thu, 24 Aug 2023 14:03:05 +0000 (17:03 +0300)] Use FD_CLOEXEC on ListenSockets
It's good hygiene if e.g. an extension launches a subprogram when
being loaded. We went through some effort to close them in the child
process in EXEC_BACKEND mode, but it's better to not hand them down to
the child process in the first place. We still need to close them
after fork when !EXEC_BACKEND, but it's a little simpler.
In the passing, LOG a message if closing the client connection or
listen socket fails. Shouldn't happen, but if it does, would be nice
to know.
Reviewed-by: Tristan Partin, Andres Freund, Thomas MunroDiscussion: https://www.postgresql.org/message-id/
7a59b073-5b5b-151e-7ed3-
8b01ff7ce9ef@iki.fi
Peter Eisentraut [Thu, 24 Aug 2023 12:22:02 +0000 (14:22 +0200)] Fix lack of message pluralization
Peter Eisentraut [Thu, 24 Aug 2023 11:59:40 +0000 (13:59 +0200)] Update DECLARE_INDEX documentation
Update source code comment changes belonging to the changes in
6a6389a08b.
Discussion: https://www.postgresql.org/message-id/flat/
75ae5875-3abc-dafc-8aec-
73247ed41cde@eisentraut.org
Peter Eisentraut [Tue, 22 Aug 2023 12:12:45 +0000 (14:12 +0200)] Rename hook functions for debug_io_direct to match variable name.
Commit
319bae9a renamed the GUC. Rename the check and assign functions
to match, and alphabetize.
Back- to 16.
Author: Peter Eisentraut <
[email protected]>
Discussion: https://postgr.es/m/
2769341e-fa28-c2ee-3e4b-
53fdcaaf2271%40eisentraut.org
Daniel Gustafsson [Thu, 24 Aug 2023 09:53:42 +0000 (11:53 +0200)] Add proargnames to multi-argument aggregate functions
Having argument names makes it easier to understand how to use the
aggregate functions when inspecting them with \dfa or similar.
Author: Dagfinn Ilmari Mannsåker <
[email protected]>
Reviewed-by: Vik Fearing <[email protected]>Reviewed-by: Jim Jones <[email protected]>Discussion: https://postgr.es/m/
[email protected]Amit Kapila [Thu, 24 Aug 2023 09:07:29 +0000 (14:37 +0530)] Fix the error message when failing to restore the snapshot.
The SnapBuildRestoreContents() used a const value in the error message to
indicate the size in bytes it was expecting to read from the serialized
snapshot file. Fix it by reporting the size that was actually passed.
Author: Hou Zhijie
Reviewed-by: Amit Kapila
Back-through: 16
Discussion: http://postgr.es/m/OS0PR01MB5716D408364F7DF32221C08D941FA@OS0PR01MB5716.jpnprd01.prod.outlook.com
Peter Eisentraut [Thu, 24 Aug 2023 08:24:38 +0000 (10:24 +0200)] Fix translation markers
Conditionals cannot be inside gettext trigger functions, they must be
applied outside.
Peter Eisentraut [Thu, 24 Aug 2023 06:23:43 +0000 (08:23 +0200)] pg_upgrade: Improve one log message
The parenthesized plural is unnecessary here and inconsistent with
nearby similar messages.
David Rowley [Wed, 23 Aug 2023 22:33:53 +0000 (10:33 +1200)] Meson: check for pg_config_paths.h left over from make
The meson build scripts attempt to find files left over from configure
and fail, mentioning that "make maintainer-clean" should be run to remove
these. This seems to have been done for files generated from configure.
pg_config_paths.h is generated during the actual make build, so seems to
have been missed. This would result in compilation using the wrong
pg_config_paths.h file.
Here we just add this file to generated_sources_ac so that meson errors
out if pg_config_paths.h exists.
Likely this wasn't noticed before because make maintainer-clean will
remove pg_config_paths.h, however, people using the MSVC build scripts
are more likely to run into issues and they have to manually remove
these files and pg_config_paths.h wasn't listed as a conflicting file to
remove in the meson log.
Back-through: 16, where meson support was added
Discussion: https://postgr.es/m/CAApHDvqjYOxZfmLKAOWKFEE7LOr9_E6UA6YNmx9r8nxStcS3gg@mail.gmail.com
Andres Freund [Wed, 23 Aug 2023 22:15:28 +0000 (15:15 -0700)] ci: Make compute resources for CI configurable
See prior commit for an explanation for the goal of the change and why it had
to be split into two commits.
Reviewed-by: Daniel Gustafsson <[email protected]>Reviewed-by: Nazir Bilal Yavuz <[email protected]>Discussion: https://postgr.es/m/
20230808021541[email protected]Back: 15-, where CI support was added
Andres Freund [Wed, 23 Aug 2023 22:15:28 +0000 (15:15 -0700)] ci: Prepare to make compute resources for CI configurable
cirrus-ci will soon restrict the amount of free resources every user gets (as
have many other CI providers). For most users of CI that should not be an
issue. But e.g. for cfbot it will be an issue.
To allow configuring different resources on a per-repository basis, introduce
infrastructure for overriding the task execution environment. Unfortunately
this is not entirely trivial, as yaml anchors have to be defined before their
use, and cirrus-ci only allows injecting additional contents at the end of
.cirrus.yml.
To deal with that, move the definition of the CI tasks to
.cirrus.tasks.yml. The main .cirrus.yml is loaded first, then, if defined, the
file referenced by the REPO_CI_CONFIG_GIT_URL variable, will be added,
followed by the contents of .cirrus.tasks.yml. That allows
REPO_CI_CONFIG_GIT_URL to override the yaml anchors defined in .cirrus.yml.
Unfortunately git's default merge / rebase strategy does not handle copied
files, just renamed ones. To avoid painful rebasing over this change, this
commit just renames .cirrus.yml to .cirrus.tasks.yml, without adding a new
.cirrus.yml. That's done in the followup commit, which moves the relevant
portion of .cirrus.tasks.yml to .cirrus.yml. Until that is done,
REPO_CI_CONFIG_GIT_URL does not fully work.
The subsequent commit adds documentation for how to configure custom compute
resources to src/tools/ci/README
Reviewed-by: Daniel Gustafsson <[email protected]>Reviewed-by: Nazir Bilal Yavuz <[email protected]>Discussion: https://postgr.es/m/
20230808021541[email protected]Back: 15-, where CI support was added
Nathan Bossart [Wed, 23 Aug 2023 21:19:58 +0000 (14:19 -0700)] Bump catversion for to_bin() and to_oct().
Missed in
260a1f18da.
Andres Freund [Wed, 23 Aug 2023 19:25:56 +0000 (12:25 -0700)] ci: Use VMs for SanityCheck and CompilerWarnings
The main reason for this change is to reduce different ways of executing
tasks, making it easier to use custom compute resources for cfbot. A secondary
benefit is that the tasks seem slightly faster this way, apparently the
increased startup overhead is outweighed by reduced runtime overhead.
Reviewed-by: Daniel Gustafsson <[email protected]>Discussion: https://postgr.es/m/
20230808021541[email protected]Back: 15-, where CI support was added
Andres Freund [Wed, 23 Aug 2023 19:25:56 +0000 (12:25 -0700)] ci: Move execution method of tasks into yaml templates
This is done in preparation for making the compute resources for CI
configurable. It also looks cleaner.
Reviewed-by: Daniel Gustafsson <[email protected]>Discussion: https://postgr.es/m/
20230808021541[email protected]Back: 15-, where CI support was added
Andres Freund [Wed, 23 Aug 2023 19:25:56 +0000 (12:25 -0700)] ci: Don't specify amount of memory
The number of CPUs is the cost-determining factor. Most instance types that
run tests have more memory/core than what we specified, there's no real
benefit in wasting that.
Reviewed-by: Daniel Gustafsson <[email protected]>Discussion: https://postgr.es/m/
20230808021541[email protected]Back: 15-, where CI support was added
Peter Eisentraut [Wed, 23 Aug 2023 18:48:48 +0000 (20:48 +0200)] Avoid use of Perl getprotobyname
getprotobyname returns undefined on some CI machines. It's not clear
why. The code overall still works, but it raises a warning.
In PostgreSQL C code, we always call socket() with 0 for the protocol
argument, so we should be able to do the same in Perl (since the Perl
documentation says that the arguments of the socket function are the
same as in C). So do that, to avoid the issue.
Reviewed-by: Andrew Dunstan <[email protected]>Discussion: https://www.postgresql.org/message-id/flat/
06f899fd-1826-05ab-42d6-
adeb1fd5e200%40eisentraut.org
Heikki Linnakangas [Wed, 23 Aug 2023 15:08:40 +0000 (18:08 +0300)] Fix _bt_allequalimage() call within critical section.
_bt_allequalimage() does complicated things, so it's not OK to call it
in a critical section. Per buildfarm failure on 'prion', which uses
-DRELCACHE_FORCE_RELEASE -DCATCACHE_FORCE_RELEASE options.
Discussion: https://www.postgresql.org/message-id/
6e5bbc08-cdfc-b2b3-9e23-
1a914b9850a9@iki.fi
Back-through: 16, like commit
ccadf73163 that introduced this
Nathan Bossart [Wed, 23 Aug 2023 14:49:03 +0000 (07:49 -0700)] Add to_bin() and to_oct().
This commit introduces functions for converting numbers to their
equivalent binary and octal representations. Also, the base
conversion code for these functions and to_hex() has been moved to
a common helper function.
Co-authored-by: Eric Radman
Reviewed-by: Ian Barwick, Dag Lem, Vignesh C, Tom Lane, Peter Eisentraut, Kirk Wolak, Vik Fearing, John Naylor, Dean Rasheed
Discussion: https://postgr.es/m/Y6IyTQQ/TsD5wnsH%40vm3.eradman.com
Heikki Linnakangas [Wed, 23 Aug 2023 14:21:31 +0000 (17:21 +0300)] Use the buffer cache when initializing an unlogged index.
Some of the ambuildempty functions used smgrwrite() directly, followed
by smgrimmedsync(). A few small problems with that:
Firstly, one is supposed to use smgrextend() when extending a
relation, not smgrwrite(). It doesn't make much difference in
production builds. smgrextend() updates the relation size cache, so
you miss that, but that's harmless because we never use the cached
relation size of an init fork. But if you compile with
CHECK_WRITE_VS_EXTEND, you get an assertion failure.
Secondly, the smgrwrite() calls were performed before WAL-logging, so
the page image written to disk had 0/0 as the LSN, not the LSN of the
WAL record. That's also harmless in practice, but seems sloppy.
Thirdly, it's better to use the buffer cache, because then you don't
need to smgrimmedsync() the relation to disk, which adds latency.
Bypassing the cache makes sense for bulk operations like index
creation, but not when you're just initializing an empty index.
Creation of unlogged tables is hardly performance bottleneck in any
real world applications, but nevertheless.
Back to v16, but no further. These issues should be harmless in
practice, so better to not rock the boat in older branches.
Reviewed-by: Robert HaasDiscussion: https://www.postgresql.org/message-id/
6e5bbc08-cdfc-b2b3-9e23-
1a914b9850a9@iki.fi
Daniel Gustafsson [Wed, 23 Aug 2023 12:13:07 +0000 (14:13 +0200)] doc: Replace list of drivers and PLs with wiki link
The list of external language drivers and procedural languages was
never complete or exhaustive, and rather than attempting to manage
it the content has migrated to the wiki. This replaces the tables
altogether with links to the wiki as we regularly get requests for
adding various projects, which we reject without any clear policy
for why or how the content should be managed.
The threads linked to below are the most recent discussions about
this, the archives contain many more.
Back to all supported branches since the list on the wiki
applies to all branches.
Author: Jonathan Katz <
[email protected]>
Discussion: https://postgr.es/m/
169165415312.635.
10247434927885764880@wrigleys.postgresql.org
Discussion: https://postgr.es/m/
169177958824.635.
11087800083040275266@wrigleys.postgresql.org
Back-through: v11
Peter Eisentraut [Wed, 23 Aug 2023 09:23:42 +0000 (11:23 +0200)] doc: Add more ICU rules examples
In particular, add an example EBCDIC collation.
Author: Daniel Verite <
[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/
35cc1684-e516-4a01-a256-
351632d47066@manitou-mail.org
Daniel Gustafsson [Wed, 23 Aug 2023 08:22:55 +0000 (10:22 +0200)] Fix wording in comment
The comment for the DSM_OP_CREATE paramater read "the a new handle"
which is confusing. Fix by rewording to indicate what the parameter
means for DSM_OP_CREATE.
Reported-by: Junwang Zhao <[email protected]>Discussion: https://postgr.es/m/CAEG8a3J2bc197ym-M_ykOXb9ox2eNn-QNKNeoSAoHYSw2NCOnw@mail.gmail.com
Daniel Gustafsson [Wed, 23 Aug 2023 07:41:22 +0000 (09:41 +0200)] pg_upgrade: Avoid shadowing global var in function
The new_cluster parameter in check_for_new_tablespace_dir was
shadowing the globally defined new_cluster variable, causing
compiler warnings when running with -Wshadow. The function is
only applicable to the new cluster, so remove the parameter
rather than rename to match check_new_cluster_is_empty which
also only applies to the new cluster.
Author: Peter Smith <
[email protected]>
Discussion: https://postgr.es/m/CAHut+PvS_PHLntWy1yTgXv0O1tWm4iVcKBQFzpoQRDsm2Ce_Fg@mail.gmail.com
Peter Eisentraut [Wed, 23 Aug 2023 06:25:56 +0000 (08:25 +0200)] doc: Improve ICU external link
It previously pointed to the collation API documentation, which our
users don't need, but the containing chapter seems useful.
Peter Eisentraut [Wed, 23 Aug 2023 06:12:50 +0000 (08:12 +0200)] Improve vertical spacing of documentation markup
Peter Eisentraut [Wed, 23 Aug 2023 04:14:11 +0000 (06:14 +0200)] Some vertical reformatting
Remove some line breaks that have become unnecessary after some
variable renaming.
Discussion: https://www.postgresql.org/message-id/flat/
5ed89c69-f4e6-5dab-4003-
63bde7460e5e%40eisentraut.org
Peter Eisentraut [Wed, 23 Aug 2023 04:14:11 +0000 (06:14 +0200)] Rename some function arguments for better clarity
Especially make sure that array arguments have plural names.
Discussion: https://www.postgresql.org/message-id/flat/
5ed89c69-f4e6-5dab-4003-
63bde7460e5e%40eisentraut.org
Peter Eisentraut [Wed, 23 Aug 2023 04:14:11 +0000 (06:14 +0200)] Add const decorations
in index.c and indexcmds.c and some adjacent places. This especially
makes it easier to understand for some complicated function signatures
which are the input and the output arguments.
Discussion: https://www.postgresql.org/message-id/flat/
5ed89c69-f4e6-5dab-4003-
63bde7460e5e%40eisentraut.org
Nathan Bossart [Wed, 23 Aug 2023 02:16:12 +0000 (19:16 -0700)] Introduce macros for protocol characters.
This commit introduces descriptively-named macros for the
identifiers used in wire protocol messages. These new macros are
placed in a new header file so that they can be easily used by
third-party code.
Author: Dave Cramer
Reviewed-by: Alvaro Herrera, Tatsuo Ishii, Peter Smith, Robert Haas, Tom Lane, Peter Eisentraut, Michael Paquier
Discussion: https://postgr.es/m/CADK3HHKbBmK-PKf1bPNFoMC%2BoBt%2BpD9PH8h5nvmBQskEHm-Ehw%40mail.gmail.com
Thomas Munro [Wed, 23 Aug 2023 00:10:18 +0000 (12:10 +1200)] ExtendBufferedWhat -> BufferManagerRelation.
Commit
31966b15 invented a way for functions dealing with relation
extension to accept a Relation in online code and an SMgrRelation in
recovery code. It seems highly likely that future bufmgr.c interfaces
will face the same problem, and need to do something similar.
Generalize the names so that each interface doesn't have to re-invent
the wheel.
Back- to 16. Since extension AM authors might start using the
constructor macros once 16 ships, we agreed to do the rename in 16
rather than waiting for 17.
Reviewed-by: Peter Geoghegan <[email protected]>Reviewed-by: Andres Freund <[email protected]>Discussion: https://postgr.es/m/CA%2BhUKG%2B6tLD2BhpRWycEoti6LVLyQq457UL4ticP5xd8LqHySA%40mail.gmail.com
Jeff Davis [Tue, 22 Aug 2023 18:21:36 +0000 (11:21 -0700)] Fix pg_dump assertion failure when dumping pg_catalog.
Commit
396d348b04 did not account for the default collation.
Also, use pg_log_warning() instead of Assert().
Discussion: https://postgr.es/m/
ce071503fee88334aa70f360e6e4ea14d48305ee.camel%40j-davis.com
Reviewed-by: Michael PaquierBack-through: 15
Andrew Dunstan [Tue, 22 Aug 2023 15:57:08 +0000 (11:57 -0400)] Cache by-reference missing values in a long lived context
Attribute missing values might be needed past the lifetime of the tuple
descriptors from which they are extracted. To avoid possibly using
pointers for by-reference values which might thus be left dangling, we
cache a datumCopy'd version of the datum in the TopMemoryContext. Since
we first search for the value this only needs to be done once per
session for any such value.
Original complaint from Tom Lane, idea for mitigation by Andrew Dunstan,
tweaked by Tom Lane.
Back to version 11 where missing values were introduced.
Discussion: https://postgr.es/m/
1306569.
1687978174@sss.pgh.pa.us
Alvaro Herrera [Tue, 22 Aug 2023 10:22:03 +0000 (12:22 +0200)] Add comment missing in
a4a232b1e702Noticed while studying nearby code
Amit Kapila [Tue, 22 Aug 2023 03:14:09 +0000 (08:44 +0530)] Simplify the logical worker type checks by using the switch on worker type.
The current code uses if/else statements at various places to take worker
specific actions. Change those to use the switch on worker type added by
commit
2a8b40e368. This makes code easier to read and understand.
Author: Peter Smith
Reviewed-by: Amit Kapila, Hou ZhijieDiscussion: http://postgr.es/m/CAHut+PttPSuP0yoZ=9zLDXKqTJ=d0bhxwKaEaNcaym1XqcvDEg@mail.gmail.com
Michael Paquier [Mon, 21 Aug 2023 04:32:14 +0000 (13:32 +0900)] Fix pg_stat_reset_single_table_counters() for shared relations
This commit fixes the function of $subject for shared relations. This
feature has been added by
e042678. Unfortunately, this new behavior got
removed by
5891c7a when moving statistics to shared memory.
Reported-by: Mitsuru HinataAuthor: Masahiro Ikeda
Reviewed-by: Kyotaro Horiguchi, Masahiko SawadaDiscussion: https://postgr.es/m/
7cc69f863d9b1bc677544e3accd0e4b4@oss.nttdata.com
Back-through: 15
Michael Paquier [Sun, 20 Aug 2023 06:44:48 +0000 (15:44 +0900)] Bump catalog version for pg_wait_events
Missed in
1e68e43, because I cannot correctly merge a branch.
Michael Paquier [Sun, 20 Aug 2023 06:35:02 +0000 (15:35 +0900)] Add system view pg_wait_events
This new view, wrapped around a SRF, shows some information known about
wait events, as of:
- Name.
- Type (Activity, I/O, Extension, etc.).
- Description.
All the information retrieved comes from wait_event_names.txt, and the
description is the same as the documentation with filters applied to
remove any XML markups. This view is useful when joined with
pg_stat_activity to get the description of a wait event reported.
Custom wait events for extensions are included in the view.
Original idea by Yves Colin.
Author: Bertrand Drouvot
Reviewed-by: Kyotaro Horiguchi, Masahiro Ikeda, Tom Lane, MichaelPaquier
Discussion: https://postgr.es/m/
0e2ae164-dc89-03c3-cf7f-
de86378053ac@gmail.com
Andres Freund [Sat, 19 Aug 2023 19:40:45 +0000 (12:40 -0700)] ci: macos: use cached macports install
A significant chunk of the time on the macos CI task is spent installing
packages using homebrew. The downloads of the packages are cached, but the
installation needs to happen every time. We can't cache the whole homebrew
installation, because it is too large due to pre-installed packages.
Speed this up by installing packages using macports and caching the
installation as .dmg. That's a lot faster than unpacking a tarball.
In addition, don't install llvm - it wasn't enabled when building, so it's
just a waste of time/space.
This substantially speeds up the mac CI time, both in the cold cache and in
the warm cache case (the latter from ~1m20s to ~5s).
It doesn't seem great to have diverging sources of packages for CI between
branches, so back to 15 (where CI was added).
Discussion: https://postgr.es/m/
20230805202539[email protected]Back: 15-, where CI was added
Peter Eisentraut [Fri, 18 Aug 2023 05:41:14 +0000 (07:41 +0200)] Remove dubious warning message from SQL/JSON functions
There was a warning that FORMAT JSON has no effect on json/jsonb
types, which is true, but it's not clear why we should issue a warning
about it. The SQL standard does not say anything about this, which
should generally govern the behavior here. So remove it.
Discussion: https://www.postgresql.org/message-id/flat/
dfec2cae-d17e-c508-6d16-
c2dba82db486%40eisentraut.org
Michael Paquier [Fri, 18 Aug 2023 00:39:55 +0000 (09:39 +0900)] pg_upgrade: Improve style of a few verbose messages
Author: Peter Smith
Reviewed-by: Daniel Gustafsson
Discussion: https://postgr.es/m/CAHut+PuOB4bUwkYAjA_NkTrYaocKy6W3ZYK5Pin305R7mNSLgA@mail.gmail.com
Michael Paquier [Thu, 17 Aug 2023 23:11:10 +0000 (08:11 +0900)] Fix format if entry in wait_event_names.txt
The entry LockManager had two successive whitespaces between two words.
This is not an actual bug, but let's be clean. Thinko in
fa88928.
Reported-by: Masahiro IkedaAuthor: Bertrand Drouvot
Discussion: https://postgr.es/m/
dd836027-2e9e-4df9-9fd9-
7527cd1757e1@gmail.com
Nathan Bossart [Thu, 17 Aug 2023 14:25:18 +0000 (07:25 -0700)] Add a few recent commits to .git-blame-ignore-revs.
Reviewed-by: Peter GeogheganDiscussion: https://postgr.es/m/
20230815203109.GA2596919%40nathanxps13
Thomas Munro [Thu, 17 Aug 2023 04:16:43 +0000 (16:16 +1200)] Remove traces of Sun -lposix4.
This was a library on ancient Solaris systems, which was eventually
replaced by -lrt, itself now redundant on that OS.
Reviewed-by: Peter Eisentraut <[email protected]>Reviewed-by: Tristan Partin <[email protected]>Discussion: https://postgr.es/m/CA%2BhUKGLLVx4drdvXats9PxH3eeB%2BE2NkJReJ%2BRGmaOpU%3D9rgEA%40mail.gmail.com
Thomas Munro [Thu, 17 Aug 2023 04:11:41 +0000 (16:11 +1200)] Don't probe extra libraries for fdatasync.
Commit
d2e15083 got rid of the main configure probe and HAVE_FDATASYNC
macro, but we still searched -lrt and -lposix4 for old Solaris systems.
It's in the C library on modern Solaris, as on other supported systems.
Reviewed-by: Peter Eisentraut <[email protected]>Reviewed-by: Tristan Partin <[email protected]>Discussion: https://postgr.es/m/CA%2BhUKGLLVx4drdvXats9PxH3eeB%2BE2NkJReJ%2BRGmaOpU%3D9rgEA%40mail.gmail.com
Thomas Munro [Thu, 17 Aug 2023 03:45:13 +0000 (15:45 +1200)] Invalidate smgr_targblock in smgrrelease().
In rare circumstances involving relfilenode reuse, it might have been
possible for smgr_targblock to finish up pointing past the end.
Oversight in
b74e94dc. Back- to 15.
Reviewed-by: Heikki Linnakangas <[email protected]>Discussion: https://postgr.es/m/CA%2BhUKGJ8NTvqLHz6dqbQnt2c8XCki4r2QvXjBQcXpVwxTY_pvA%40mail.gmail.com
Michael Paquier [Thu, 17 Aug 2023 01:51:26 +0000 (10:51 +0900)] sepgsql: Adjust regression expected output
Oversight in
352ea3a, where support for these subcommands has been
added.
Per buildfarm member rhinoceros.
Michael Paquier [Wed, 16 Aug 2023 23:54:17 +0000 (08:54 +0900)] Add OAT hook calls for more subcommands of ALTER TABLE
The OAT hooks are added in ALTER TABLE for the following subcommands:
- { ENABLE | DISABLE | [NO] FORCE } ROW LEVEL SECURITY
- { ENABLE | DISABLE } TRIGGER
- { ENABLE | DISABLE } RULE. Note that there was hook for pg_rewrite,
but not for relation ALTER'ed in pg_class.
Tests are added to test_oat_hook for all the subcommand patterns gaining
hooks here. Based on an ask from Legs Mansion.
Discussion: https://postgr.es/m/
[email protected]Peter Eisentraut [Wed, 16 Aug 2023 14:17:00 +0000 (16:17 +0200)] Unify some error messages
We had essentially the same error in several different wordings.
Unify that.
Peter Eisentraut [Wed, 16 Aug 2023 13:09:50 +0000 (15:09 +0200)] Improved CREATE SUBSCRIPTION message for clarity
Discussion: https://www.postgresql.org/message-id/CAHut+PtfzQ7JRkb0-Y_UejAxaLQ17-bGMvV4MJJHcPoP3ML2bg@mail.gmail.com
Peter Eisentraut [Wed, 16 Aug 2023 11:46:26 +0000 (13:46 +0200)] Remove incorrect field from information schema
The source code comment already said that the presence of the field
element_types.domain_default might be a bug in the standard, since it
never made sense there. Indeed, the field is gone in newer versions
of the standard. So just remove it.
John Naylor [Wed, 16 Aug 2023 10:15:07 +0000 (17:15 +0700)] Split out tiebreaker comparisons from comparetup_* functions
Previously, if a specialized comparator found equal datum1 keys,
the "comparetup" function would repeat the comparison on the
datum before proceeding with the unabbreviated first key
and/or additional sort keys.
Move comparing additional sort keys into "tiebreak" functions so
that specialized comparators can call these directly if needed,
avoiding duplicate work.
Reviewed by David Rowley
Discussion: https://postgr.es/m/CAFBsxsGaVfUrjTghpf%3DkDBYY%3DjWx1PN-fuusVe7Vw5s0XqGdGw%40mail.gmail.com
Etsuro Fujita [Tue, 15 Aug 2023 08:45:00 +0000 (17:45 +0900)] Fix code indentation vioaltion introduced in commit
9e9931d2b.
Per buildfarm member koel
Etsuro Fujita [Tue, 15 Aug 2023 07:45:00 +0000 (16:45 +0900)] Re-allow FDWs and custom scan providers to replace joins with pseudoconstant quals.
This was disabled in commit
6f80a8d9c due to the lack of support for
handling of pseudoconstant quals assigned to replaced joins in
createplan.c. To re-allow it, this adds the support by 1)
modifying the ForeignPath and CustomPath structs so that if they
represent foreign and custom scans replacing a join with a scan, they
store the list of RestrictInfo nodes to apply to the join, as in
JoinPaths, and by 2) modifying create_scan_plan() in createplan.c so
that it uses that list in that case, instead of the baserestrictinfo
list, to get pseudoconstant quals assigned to the join, as mentioned in
the commit message for that commit.
Important item for the release notes: this is non-backwards-compatible
since it modifies the ForeignPath and CustomPath structs, as mentioned
above, and changes the argument lists for FDW helper functions
create_foreignscan_path(), create_foreign_join_path(), and
create_foreign_upper_path().
Richard Guo, with some additional changes by me, reviewed by Nishant
Sharma, Suraj Kharage, and Richard Guo.
Discussion: https://postgr.es/m/CADrsxdbcN1vejBaf8a%2BQhrZY5PXL-04mCd4GDu6qm6FigDZd6Q%40mail.gmail.com
Thomas Munro [Mon, 14 Aug 2023 22:20:11 +0000 (10:20 +1200)] De-pessimize ConditionVariableCancelSleep().
Commit
b91dd9de was concerned with a theoretical problem with our
non-atomic condition variable operations. If you stop sleeping, and
then cancel the sleep in a separate step, you might be signaled in
between, and that could be lost. That doesn't matter for callers of
ConditionVariableBroadcast(), but callers of ConditionVariableSignal()
might be upset if a signal went missing like this.
Commit
bc971f4025c interacted badly with that logic, because it doesn't
use ConditionVariableSleep(), which would normally put us back in the
wait list. ConditionVariableCancelSleep() would be confused and think
we'd received an extra signal, and try to forward it to another backend,
resulting in wakeup storms.
New idea: ConditionVariableCancelSleep() can just return true if we've
been signaled. Hypothetical users of ConditionVariableSignal() would
then still have a way to deal with rare lost signals if they are
concerned about that problem.
Back- to 16, where
bc971f4025c arrived.
Reported-by: Tomas Vondra <[email protected]>Reviewed-by: Andres Freund <[email protected]>Discussion: https://postgr.es/m/
2840876b-4cfe-240f-0a7e-
29ffd66711e7%40enterprisedb.com
Andres Freund [Mon, 14 Aug 2023 16:54:03 +0000 (09:54 -0700)] hio: Take number of prior relation extensions into account
The new relation extension logic, introduced in
00d1e02be24, could lead to
slowdowns in some scenarios. E.g., when loading narrow rows into a table using
COPY, the caller of RelationGetBufferForTuple() will only request a small
number of pages. Without concurrency, we just extended using pwritev() in that
case. However, if there is *some* concurrency, we switched between extending
by a small number of pages and a larger number of pages, depending on the
number of waiters for the relation extension logic. However, some
filesystems, XFS in particular, do not perform well when switching between
extending files using fallocate() and pwritev().
To avoid that issue, remember the number of prior relation extensions in
BulkInsertState and extend more aggressively if there were prior relation
extensions. That not just avoids the aforementioned slowdown, but also leads
to noticeable performance gains in other situations, primarily due to
extending more aggressively when there is no concurrency. I should have done
it this way from the get go.
Reported-by: Masahiko Sawada <[email protected]>Author: Andres Freund <
[email protected]>
Discussion: https://postgr.es/m/CAD21AoDvDmUQeJtZrau1ovnT_smN940=Kp6mszNGK3bq9yRN6g@mail.gmail.com
Back: 16-, where the new relation extension code was added
Bruce Momjian [Mon, 14 Aug 2023 18:03:29 +0000 (14:03 -0400)] pgtest: fix spacing
Back-through: master
Bruce Momjian [Mon, 14 Aug 2023 17:45:29 +0000 (13:45 -0400)] pgtest: update shell script to use more modern syntax
script is src/tools/pgtest
Back-through: master
Michael Paquier [Mon, 14 Aug 2023 05:47:27 +0000 (14:47 +0900)] Change custom wait events to use dynamic shared hash tables
Currently, the names of the custom wait event must be registered for
each backend, requiring all these to link to the shared memory area of
an extension, even if these are not loaded with
shared_preload_libraries.
This relaxes the constraints related to this infrastructure by
storing the wait events and their names in two dynamic hash tables in
shared memory. This has the advantage to simplify the registration of
custom wait events to a single routine call that returns an event ID
ready for consumption:
uint32 WaitEventExtensionNew(const char *wait_event_name);
The caller of this routine can then cache locally the ID returned, to be
used for pgstat_report_wait_start(), WaitLatch() or a similar routine.
The implementation uses two hash tables: one with a key based on the
event name to avoid duplicates and a second using the event ID as key
for event lookups, like on pg_stat_activity. These tables can hold a
minimum of 16 entries, and a maximum of 128 entries, which should be plenty
enough.
The code changes done in worker_spi show how things are simplified (most
of the code removed in this commit comes from there):
- worker_spi_init() is gone.
- No more shared memory hooks required (size requested and
initialization).
- The custom wait event ID is cached in the process that needs to set
it, with one single call to WaitEventExtensionNew() to retrieve it.
Per suggestion from Andres Freund.
Author: Masahiro Ikeda, with a few tweaks from me.
Discussion: https://postgr.es/m/
20230801032349[email protected]Amit Kapila [Mon, 14 Aug 2023 03:08:03 +0000 (08:38 +0530)] Simplify determining logical replication worker types.
We deduce a LogicalRepWorker's type from the values of several different
fields ('relid' and 'leader_pid') whenever logic needs to know it.
In fact, the logical replication worker type is already known at the time
of launching the LogicalRepWorker and it never changes for the lifetime of
that process. Instead of deducing the type, it is simpler to just store it
one time, and access it directly thereafter.
Author: Peter Smith
Reviewed-by: Amit Kapila, Bharath Rupireddy
Discussion: http://postgr.es/m/CAHut+PttPSuP0yoZ=9zLDXKqTJ=d0bhxwKaEaNcaym1XqcvDEg@mail.gmail.com
Andres Freund [Sat, 12 Aug 2023 20:09:45 +0000 (13:09 -0700)] ci: macos: Remove use of -Dsegsize_blocks=6
The option causes a measurable slowdown. Macos is, by far, the most expensive
platform for CI, therefore it doesn't make sense to run such a test there.
d3b111e3205 used a small segment size for two tasks, one with autoconf, one
with meson. In hindsight that is a bit overkill, it's unlikely that the option
would silently break. Thus don't move the -Dsegsize_blocks=6, just remove
it. I did however change the autoconf test to use 6 instead of 8 blocks, as
long as we allow it, a non-power-of-two test seems like a good idea.
While at it, add a comment explaining why we use a small segment size for CI.
Author: Andres Freund <
[email protected]>
Reviewed-by: Heikki Linnakangas <[email protected]>Discussion: https://postgr.es/m/
20230808021541[email protected]Back: 16-, where
d3b111e3205 introduced the use of -Dsegsize_blocks=6
Andres Freund [Sat, 12 Aug 2023 20:06:04 +0000 (13:06 -0700)] ci: macos: Remove use of -DRANDOMIZE_ALLOCATED_MEMORY
RANDOMIZE_ALLOCATED_MEMORY causes a measurable slowdown. Macos is, by far, the
most expensive platform for CI, therefore it doesn't make sense to run such a
test there.
Ubsan and asan on linux should detect most of the the cases of uninitialized
memory, so it doesn't really seem worth using -DRANDOMIZE_ALLOCATED_MEMORY in
another instance type.
Author: Andres Freund <
[email protected]>
Reviewed-by: Heikki Linnakangas <[email protected]>Discussion: https://postgr.es/m/
20230808021541[email protected]Back: 16-, where
89d16b635 added the use of -DRANDOMIZE_ALLOCATED_MEMORY
Noah Misch [Sat, 12 Aug 2023 21:37:05 +0000 (14:37 -0700)] Fix off-by-one in XLogRecordMaxSize check.
pg_logical_emit_message(false, '_', repeat('x',
1069547465)) failed with
self-contradictory message "WAL record would be
1069547520 bytes (of
maximum
1069547520 bytes)". There's no particular benefit from allowing
or denying one byte in either direction; XLogRecordMaxSize could rise a
few megabytes without trouble. Hence, this is just for cleanliness.
Back- to v16, where this check first appeared.
Michael Paquier [Sat, 12 Aug 2023 01:44:15 +0000 (10:44 +0900)] Show GIDs of two-phase commit commands as constants in pg_stat_statements
This relies on the "location" field added to TransactionStmt in
31de7e6,
now applied to the "gid" field used by 2PC commands. These commands are
now reported like:
COMMIT PREPARED $1
PREPARE TRANSACTION $1
ROLLBACK PREPARED $1
Applying constants for these commands is a huge advantage for workloads
that rely a lot on 2PC commands with different GIDs. Some tests are
added to track the new behavior.
Reviewed-by: Julien RouhaudDiscussion: https://postgr.es/m/
[email protected]Michael Paquier [Fri, 11 Aug 2023 11:43:34 +0000 (20:43 +0900)] Fix code indentation violations introduced by recent commit
The two culprit commits are
5765cfe and
5e0c761.
Per buildfarm member koel for the first commit, while I have noticed the
second one in passing.
Jeff Davis [Thu, 10 Aug 2023 19:43:53 +0000 (12:43 -0700)] Transform proconfig for faster execution.
Store function config settings in lists to avoid the need to parse and
allocate for each function execution.
Speedup is modest but significant. Additionally, this change also
seems cleaner and supports some other performance improvements under
discussion.
Discussion: https://postgr.es/m/
04c8592dbd694e4114a3ed87139a7a04e4363030[email protected]Reviewed-by: Nathan BossartJeff Davis [Thu, 10 Aug 2023 17:16:59 +0000 (10:16 -0700)] Remove test from commit
fa2e874946.
The fix itself is fine, but the test revealed other problems related
to parallel query that are not easily fixable. Remove the test for
now to fix the buildfarm.
Discussion: https://postgr.es/m/88825.
1691665432@sss.pgh.pa.us
Back-through: 11
Peter Eisentraut [Thu, 10 Aug 2023 14:55:07 +0000 (16:55 +0200)] Fix erroneous -Werror=missing-braces on old GCC
The buildfarm reports that this is an error on gcc (Debian 4.7.2-5)
4.7.2, 32-bit. The bug seems to be GCC bug 53119, which has obviously
been fixed for years.
Author: Tristan Partin <
[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/CT6HJ3U8068R.3A8SJMV02D9BC@gonk
John Naylor [Thu, 10 Aug 2023 11:37:46 +0000 (18:37 +0700)] Update Solution.pm for new LoongArch CRC symbol
Oversight in
4d14ccd6a, per report from Amit Kapila
and Michael Paquier.
Discussion: https://postgr.es/m/CAA4eK1LsV3KuyUt8tzZDjPcUds1XfVVeW3Wpeju_59DtRV0%3DxQ%40mail.gmail.com
Alvaro Herrera [Thu, 10 Aug 2023 10:04:07 +0000 (12:04 +0200)] Document RelationGetIndexAttrBitmap better
Commit
19d8e2308bc5 changed the list of set-of-columns that can be
returned by RelationGetIndexAttrBitmap, but didn't update its
"documentation". That was pretty hard to read already, so rewrite to
make it more comprehensible, adding the missing values while at it.
Back to 16, like that commit.
Discussion: https://postgr.es/m/
20230809091155[email protected]Reviewed-by: Tomas Vondra <[email protected]>John Naylor [Thu, 10 Aug 2023 04:36:15 +0000 (11:36 +0700)] Use native CRC instructions on 64-bit LoongArch
As with the Intel and Arm CRC instructions, compiler intrinsics for
them must be supported by the compiler. In contrast, no runtime check
is needed. Aligned memory access is faster, so use the Arm coding as
a model.
YANG Xudong
Discussion: https://postgr.es/m/
b522a0c5-e3b2-99cc-6387-
58134fb88cbe%40ymatrix.cn
Jeff Davis [Mon, 7 Aug 2023 22:13:24 +0000 (15:13 -0700)] Recalculate search_path after ALTER ROLE.
Renaming a role can affect the meaning of the special string $user, so
must cause search_path to be recalculated.
Discussion: https://postgr.es/m/
186761d32c0255debbdf50b6310b581b9c973e6c[email protected]Reviewed-by: Nathan Bossart, Michael PaquierBack-through: 11
Alvaro Herrera [Wed, 9 Aug 2023 09:30:59 +0000 (11:30 +0200)] struct PQcommMethods: use C99 designated initializers
As in
98afa68d9352,
2c860777656a, et al.
Peter Eisentraut [Wed, 9 Aug 2023 08:00:50 +0000 (10:00 +0200)] Fix last remaining uninitialized memory warnings
gcc (version 13) fails to properly analyze the code due to the loop
stop condition including `l != NULL`. Let's just help it out.
Author: Tristan Partin <
[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/CT6HJ3U8068R.3A8SJMV02D9BC@gonk
Michael Paquier [Tue, 8 Aug 2023 23:56:05 +0000 (08:56 +0900)] Fix pg_dumpall with in-place tablespaces
In-place tablespaces would be dumped with the path produced by
pg_tablespace_location(), which is in this case a relative path built as
pg_tblspc/OID, but this would fail to restore as such tablespaces need
to use an empty string as location. In order to detect if an in-place
tablespace is used, this commit checks if the path returned is relative
and adapts the dump contents in consequence.
Like the other changes related to in-place tablespaces, no back is
done as these are only intended for development purposes. Rui Zhao has
fixed the code, while the test is from me.
Author: Rui Zhao, Michael Paquier
Discussion: https://postgr.es/m/
80c80b4a-b87b-456f-bd46-
1ae326601d79[email protected]Michael Paquier [Mon, 7 Aug 2023 23:17:53 +0000 (08:17 +0900)] doc: Fix incorrect entries generated from wait_event_names.txt
fa88928 has introduced wait_event_names.txt, and some of its entries had
some documentation fields with more information than necessary.
This commit brings back the description of all the wait events to be
consistent with the older stable branches. Five descriptions were
incorrect.
Author: Bertrand Drouvot
Discussion: https://postgr.es/m/
e378989e-1899-643a-dec1-
10f691a0a105@gmail.com
Noah Misch [Mon, 7 Aug 2023 13:05:56 +0000 (06:05 -0700)] Reject substituting extension schemas or owners matching ["$'\].
Substituting such values in extension scripts facilitated SQL injection
when @extowner@, @extschema@, or @extschema:...@ appeared inside a
quoting construct (dollar quoting, '', or ""). No bundled extension was
vulnerable. Vulnerable uses do appear in a documentation example and in
non-bundled extensions. Hence, the attack prerequisite was an
administrator having installed files of a vulnerable, trusted,
non-bundled extension. Subject to that prerequisite, this enabled an
attacker having database-level CREATE privilege to execute arbitrary
code as the bootstrap superuser. By blocking this attack in the core
server, there's no need to modify individual extensions. Back- to
v11 (all supported versions).
Reported by Micah Gate, Valerie Woolard, Tim Carey-Smith, and Christoph
Berg.
Security: CVE-2023-39417
Peter Eisentraut [Mon, 7 Aug 2023 10:06:49 +0000 (12:06 +0200)] Translation updates
Source-Git-URL: https://git.postgresql.org/git/pgtranslation/messages.git
Source-Git-Hash:
97398d714ace69f0c919984e160f429b6fd2300eDavid Rowley [Mon, 7 Aug 2023 10:14:21 +0000 (22:14 +1200)] Don't Memoize lateral joins with volatile join conditions
The use of Memoize was already disabled in normal joins when the join
conditions had volatile functions per the code in
match_opclause_to_indexcol(). Ordinarily, the parameterization for the
inner side of a nested loop will be an Index Scan or at least eventually
lead to an index scan (perhaps nested several joins deep). However, for
lateral joins, that's not the case and seq scans can be parameterized
too, so we can't rely on match_opclause_to_indexcol().
Here we explicitly check the parameterization for volatile functions and
don't consider the generation of a Memoize path when such functions
are present.
Author: Richard Guo
Discussion: https://postgr.es/m/CAMbWs49nHFnHbpepLsv_yF3qkpCS4BdB-v8HoJVv8_=Oat0u_w@mail.gmail.com
Back-through: 14, where Memoize was introduced
Dean Rasheed [Mon, 7 Aug 2023 08:28:47 +0000 (09:28 +0100)] Fix RLS policy usage in MERGE.
If MERGE executes an UPDATE action on a table with row-level security,
the code incorrectly applied the WITH CHECK clauses from the target
table's INSERT policies to new rows, instead of the clauses from the
table's UPDATE policies. In addition, it failed to check new rows
against the target table's SELECT policies, if SELECT permissions were
required (likely to always be the case).
In addition, if MERGE executes a DO NOTHING action for matched rows,
the code incorrectly applied the USING clauses from the target table's
DELETE policies to existing target tuples. These policies were applied
as checks that would throw an error, if they did not pass.
Fix this, so that a MERGE UPDATE action applies the same RLS policies
as a plain UPDATE query with a WHERE clause, and a DO NOTHING action
does not apply any RLS checks (other than adding clauses from SELECT
policies to the join).
Back- to v15, where MERGE was introduced.
Dean Rasheed, reviewed by Stephen Frost.
Security: CVE-2023-39418
Peter Eisentraut [Mon, 7 Aug 2023 07:06:52 +0000 (09:06 +0200)] Remove configure check for z_streamp
This is surely obsolete. zlib version 1.0.4, which includes
z_streamp, was released 1996-07-24. When this check was put in in
2001 (
19c97b8579), the commit was already labeling that release as
ancient.
Reviewed-by: Tristan Partin <[email protected]>Discussion: https://www.postgresql.org/message-id/flat/
33462926-bb1e-7cc9-8d92-
d86318e8ed1d%40eisentraut.org
Peter Eisentraut [Mon, 7 Aug 2023 07:06:52 +0000 (09:06 +0200)] Improve const use in zlib-using code
If we define ZLIB_CONST before including zlib.h, zlib augments some
interfaces with const decorations. By doing that we can keep our own
interfaces cleaner and can remove some unconstify calls.
ZLIB_CONST was introduced in zlib 1.2.5.2 (17 Dec 2011). When
compiling with older zlib releases, you might now get compiler
warnings about discarding qualifiers.
CentOS 6 has zlib 1.2.3, but in
8e278b6576, we removed support for the
OpenSSL release in CentOS 6, so it seems ok to de-support the zlib
release in CentOS 6 as well.
Reviewed-by: Tristan Partin <[email protected]>Discussion: https://www.postgresql.org/message-id/flat/
33462926-bb1e-7cc9-8d92-
d86318e8ed1d%40eisentraut.org
David Rowley [Mon, 7 Aug 2023 06:16:46 +0000 (18:16 +1200)] Fix misleading comment in paraminfo_get_equal_hashops
The comment mistakenly claimed the code was checking PlaceHolderVars for
volatile functions when the code was actually checking lateral vars.
Update the comment to reflect the reality of the code.
Author: Richard Guo
Discussion: https://postgr.es/m/CAMbWs48HZGZOV85g0fx8z1qDx6NNKHexJPT2FCnKnZhxBWkd-A@mail.gmail.com
David Rowley [Sun, 6 Aug 2023 09:51:54 +0000 (21:51 +1200)] Tidy up join_search_one_level code
The code in join_search_one_level was a bit convoluted. With a casual
glance, you might think that other_rels_list was being set to something
other than joinrels[1] when level == 2, however, joinrels[level - 1] is
joinrels[1] when level == 2, so nothing special needs to happen to set
other_rels_list. Let's clean that up to avoid confusing anyone.
In passing, we may as well modernize the loop in
make_rels_by_clause_joins() and instead of passing in the ListCell to
start looping from, let's just pass in the index where to start from and
make use of for_each_from(). Ever since
1cff1b95a, Lists are arrays
under the hood. lnext() and list_head() both seem a little too linked-list
like.
Author: Alex Hsieh, David Rowley, Richard Guo
Reviewed-by: Julien RouhaudDiscussion: https://postgr.es/m/CANWNU8x9P9aCXGF%3DaT-A_8mLTAT0LkcZ_ySYrGbcuHzMQw2-1g%40mail.gmail.com
Amit Kapila [Fri, 4 Aug 2023 02:45:07 +0000 (08:15 +0530)] Simplify some of the logical replication worker-type checks.
Author: Peter Smith
Reviewed-by: Hou Zhijie
Discussion: http://postgr.es/m/CAHut+Pv-xkEpuPzbEJ=ZSi7Hp2RoGJf=VA-uDRxLi1KHSneFjg@mail.gmail.com
David Rowley [Fri, 4 Aug 2023 01:27:19 +0000 (13:27 +1200)] Attempt to stabilize new window agg regression test
This test was recently added in
3900a02c9. It appears to be unstable in
regards to the join order presumably due to the relations at either side
of the join being equal in side. Here we add a qual to make one of them
smaller so the planner is more likely to choose to hash the smaller of the
two.
Reported-by: Nathan Bossart, Tom LaneDiscussion: https://www.postgr.es/m/
20230803235403.GC1238296@nathanxps13
David Rowley [Thu, 3 Aug 2023 22:47:54 +0000 (10:47 +1200)] Minor adjustments to WindowAgg startup cost code
This is a follow-on of
3900a02c9 containing some changes which I forgot
to commit locally before forming a with git format-.
Discussion: https://postgr.es/m/CAApHDvrB0S5BMv+0-wTTqWFE-BJ0noWqTnDu9QQfjZ2VSpLv_g@mail.gmail.com
David Rowley [Thu, 3 Aug 2023 21:27:38 +0000 (09:27 +1200)] Account for startup rows when costing WindowAggs
Here we adjust the costs for WindowAggs so that they properly take into
account how much of their subnode they must read before outputting the
first row. Without this, we always assumed that the startup cost for the
WindowAgg was not much more expensive than the startup cost of its
subnode, however, that's going to be completely wrong in many cases. The
WindowAgg may have to read *all* of its subnode to output a single row
with certain window bound options.
Here we estimate how many rows we'll need to read from the WindowAgg's
subnode and proportionally add more of the subnode's run costs onto the
WindowAgg's startup costs according to how much of it we expect to have to
read in order to produce the first WindowAgg row.
The reason this is more important than we might have initially thought is
that we may end up making use of a path from the lower planner that works
well as a cheap startup plan when the query has a LIMIT clause, however,
the WindowAgg might mean we need to read far more rows than what the LIMIT
specifies.
No back on this so as not to cause plan changes in released
versions.
Bug: #17862
Reported-by: Tim PalmerAuthor: David Rowley
Reviewed-by: Andy FanDiscussion: https://postgr.es/m/17862-
1ab8f74b0f7b0611@postgresql.org
Discussion: https://postgr.es/m/CAApHDvrB0S5BMv+0-wTTqWFE-BJ0noWqTnDu9QQfjZ2VSpLv_g@mail.gmail.com
Etsuro Fujita [Thu, 3 Aug 2023 08:45:00 +0000 (17:45 +0900)] Doc: update documentation for creating custom scan paths.
Commit
f49842d1e added a new callback for custom scan paths, but missed
updating the documentation.
Back- to all supported branches.
Discussion: https://postgr.es/m/CAPmGK15ODkN%2B%3DhkBCufj1HBW0x5OTb65Xuy7ryXchMdiCMpx_g%40mail.gmail.com
Etsuro Fujita [Thu, 3 Aug 2023 08:15:00 +0000 (17:15 +0900)] Update comments on CustomPath struct.
Commit
e7cb7ee14 allowed custom scan providers to create CustomPath
paths for join relations as well, but missed updating the comments.
Back- to all supported branches.
Discussion: https://postgr.es/m/CAPmGK15ODkN%2B%3DhkBCufj1HBW0x5OTb65Xuy7ryXchMdiCMpx_g%40mail.gmail.com
Amit Kapila [Thu, 3 Aug 2023 03:29:50 +0000 (08:59 +0530)] Refactor to split Apply and Tablesync Workers code.
Both apply and tablesync workers were using ApplyWorkerMain() as entry
point. As the name implies, ApplyWorkerMain() should be considered as
the main function for apply workers. Tablesync worker's path was hidden
and does not have enough in common to share the same main function with
apply worker.
Also, most of the code shared by both worker types is already combined
in LogicalRepApplyLoop(). There is no need to combine the rest in
ApplyWorkerMain() anymore.
This introduces TablesyncWorkerMain() as a new entry point for
tablesync workers. This aims to increase code readability and would help
with future improvements like the reuse of tablesync workers in the
initial synchronization.
Author: Melih Mutlu based on suggestions by Melanie Plageman
Reviewed-by: Peter Smith, Kuroda Hayato, Amit Kapila
Discussion: http://postgr.es/m/CAGPVpCTq=rUDd4JUdaRc1XUWf4BrH2gdSNf3rtOMUGj9rPpfzQ@mail.gmail.com
Masahiko Sawada [Wed, 2 Aug 2023 06:01:13 +0000 (15:01 +0900)] Fix ReorderBufferCheckMemoryLimit() comment.
Commit
7259736a6 updated the comment but it was not correct since
ReorderBufferLargestStreamableTopTXN() returns only top-level
transactions.
Reviewed-by: Amit KapilaDiscussion: https://postgr.es/m/CAD21AoA9XB7OR86BqvrCe2dMYX%2BZv3-BvVmjF%3DGY2z6jN-kqjg%40mail.gmail.com
Back-through: 14
David Rowley [Wed, 2 Aug 2023 00:05:41 +0000 (12:05 +1200)] Fix performance regression in pg_strtointNN_safe functions
Between
6fcda9aba and
1b6f632a3, the pg_strtoint functions became quite
a bit slower in v16, despite efforts in
6b423ec67 to speed these up.
Since the majority of cases for these functions will only contain
base-10 digits, perhaps prefixed by a '-', it makes sense to have a
special case for this and just fall back on the more complex version
which processes hex, octal, binary and underscores if the fast path
version fails to parse the string.
While we're here, update the header comments for these functions to
mention that hex, octal and binary formats along with underscore
separators are now supported.
Author: Andres Freund, David Rowley
Reported-by: Masahiko SawadaReviewed-by: Dean Rasheed, John NaylorDiscussion: https://postgr.es/m/CAD21AoDvDmUQeJtZrau1ovnT_smN940%3DKp6mszNGK3bq9yRN6g%40mail.gmail.com
Back-through: 16, where
6fcda9aba and
1b6f632a3 were added
Andres Freund [Tue, 1 Aug 2023 18:22:03 +0000 (11:22 -0700)] Fix pg_stat_io buffer reuse test instability
The stats regression test attempts to ensure that Buffer Access Strategy
"reuses" are being counted in pg_stat_io by vacuuming a table which is larger
than the size of the strategy ring. However, when shared buffers are in
sufficiently high demand, another backend could evict one of the blocks in the
strategy ring before the first backend has a chance to reuse the buffer. The
backend using the strategy would then evict another shared buffer and add that
buffer to the strategy ring. This counts as an eviction and not a reuse in
pg_stat_io. Count both evictions and reuses in the test to ensure it does not
fail incorrectly.
Reported-by: Jeff Davis <[email protected]>,Author: Melanie Plageman <
[email protected]>
Reviewed-by: Alexander Lakhin <[email protected]>Reviewed-by: Masahiko Sawada <[email protected]>Discussion: https://postgr.es/m/CAAKRu_bNG27AxG9TdPtwsL6wg8AWbVckjmTL2t1HF=miDQuNtw@mail.gmail.com
Robert Haas [Tue, 1 Aug 2023 17:50:42 +0000 (13:50 -0400)] Add and use symbolic constants for tar header offsets and file types.
Because symbolic constants in a header file are better than magic
constants embedded in the code.
by me, reviewed by Tom Lane, Dagfinn Ilmari Mannsåker, and
Tristan Partin.
Discussion: http://postgr.es/m/CA+TgmoZNbLwhmCrNtkJAvi8FLkwFdMeVU3myV2HQQpA5bvbRZg@mail.gmail.com