Commit Graph

58587 Commits

Author SHA1 Message Date
Peter Eisentraut 2e810bdb7f Make formatting in nls.mk files more consistent
Some of the nls.mk files used different indentation or line breaks
than the majority, which makes editing these files unnecessarily
confusing.
2024-05-14 09:21:17 +02:00
Bruce Momjian e87e732455 doc PG 17 relnotes: add item about libpq large data transfers
Reported-by: Jelte Fennema-Nio

Discussion: https://postgr.es/m/CAGECzQTz5aUqLEL6daLd2Hu2FXS_LOSh4keDndJ1fwThsb_b5w@mail.gmail.com

Reviewed-by: Joe Conway

Backpatch-through: master
2024-05-13 20:55:33 -04:00
David Rowley ec1a405adc Revert "Temporarily install debugging in partition_prune test"
1db689715 added debugging output to the partition_prune regression test
to help us figure out why buildfarm member Parula was occasionally
failing.

We've not seen any failures in around 4 weeks and the best guess as to
what the problem was is a compiler bug.  Since there are no recent
failures, there's now no need to keep this debugging code, so revert it.

Discussion: https://postgr.es/m/CAApHDvqyLF881EvDtXT=ossa0i4ioJBtW2c0Wbouzt5d3HDb5Q@mail.gmail.com
2024-05-14 12:39:30 +12:00
Bruce Momjian 6961753381 doc PG 17 relnotes: add psql connection control-C item
Reported-by: Jelte Fennema-Nio

Discussion: https://postgr.es/m/CAGECzQTz5aUqLEL6daLd2Hu2FXS_LOSh4keDndJ1fwThsb_b5w@mail.gmail.com

Reviewed-by: Tom Lane

Backpatch-through: master
2024-05-13 20:01:51 -04:00
Nathan Bossart 3cb2f13ac5 Fix pg_sequence_last_value() for unlogged sequences on standbys.
Presently, when this function is called for an unlogged sequence on
a standby server, it will error out with a message like

	ERROR:  could not open file "base/5/16388": No such file or directory

Since the pg_sequences system view uses pg_sequence_last_value(),
it can error similarly.  To fix, modify the function to return NULL
for unlogged sequences on standby servers.  Since this bug is
present on all versions since v15, this approach is preferable to
making the ERROR nicer because we need to repair the pg_sequences
view without modifying its definition on released versions.  For
consistency, this commit also modifies the function to return NULL
for other sessions' temporary sequences.  The pg_sequences view
already appropriately filters out such sequences, so there's no bug
there, but we might as well offer some defense in case someone
invokes this function directly.

Unlogged sequences were first introduced in v15, but temporary
sequences are much older, so while the fix for unlogged sequences
is only back-patched to v15, the temporary sequence portion is
back-patched to all supported versions.

We could also remove the privilege check in the pg_sequences view
definition in v18 if we modify this function to return NULL for
sequences for which the current user lacks privileges, but that is
left as a future exercise for when v18 development begins.

Reviewed-by: Tom Lane, Michael Paquier
Discussion: https://postgr.es/m/20240501005730.GA594666%40nathanxps13
Backpatch-through: 12
2024-05-13 15:53:50 -05:00
Tom Lane 1f7452fa59 Remove COMMAND_TAG_NEXTTAG from enum CommandTag.
COMMAND_TAG_NEXTTAG isn't really a valid command tag.  Declaring it
as if it were one prompts complaints from Coverity and perhaps other
static analyzers.  Our only use of it is in an entirely-unnecessary
array sizing declaration, so let's just drop it.

Ranier Vilela

Discussion: https://postgr.es/m/CAEudQAoY0xrKuTAX7W10zsjjUpKBPFRtdCyScb3Z0FB2v6HNmQ@mail.gmail.com
2024-05-13 13:52:17 -04:00
Alvaro Herrera 11c1984ccc
Fix typo 2024-05-13 13:13:25 +02:00
Alexander Korotkov 2a679ae94e Fix regression tests conflict in 3ca43dbbb6
3ca43dbbb6 adds regression tests with permission checks.  The conflict has
been observed at buildfarm member piculet.

This commit fixes the conflict in the following way.
1. partition_split.sql now uses role names regress_partition_split_alice and
   regress_partition_split_bob (it mistakenly used
   regress_partition_merge_alice and regress_partition_merge_bob before).
2. Permissions on schemas partitions_merge_schema and partition_split_schema
   are granted to corresponding roles.  Before, the lack of permissions led to
   the creation of objects in the public schema and potential conflict.

Reported-by: Daniel Gustafsson
Discussion: https://postgr.es/m/03A07EF6-98D2-419B-A3AA-A111C64CC207%40yesql.se
2024-05-13 13:26:34 +03:00
Alvaro Herrera 6f8bb7c1e9
Revert structural changes to not-null constraints
There are some problems with the new way to handle these constraints
that were detected at the last minute, and require fixes that appear too
invasive to be doing this late in the cycle.  Revert this (again) for
now, we'll try again with these problems fixed.

The following commits are reverted:

    b0e96f3119  Catalog not-null constraints
    9b581c5341  Disallow changing NO INHERIT status of a not-null constraint
    d0ec2ddbe0  Fix not-null constraint test
    ac22a9545c  Move privilege check to the right place
    b0f7dd915b  Check stack depth in new recursive functions
    3af7217942  Update information_schema definition for not-null constraints
    c3709100be  Fix propagating attnotnull in multiple inheritance
    d9f686a72e  Fix restore of not-null constraints with inheritance
    d72d32f52d  Don't try to assign smart names to constraints
    0cd711271d  Better handle indirect constraint drops
    13daa33fa5  Disallow NO INHERIT not-null constraints on partitioned tables
    d45597f72f  Disallow direct change of NO INHERIT of not-null constraints
    21ac38f498  Fix inconsistencies in error messages

Discussion: https://postgr.es/m/202405110940.joxlqcx4dogd@alvherre.pgsql
2024-05-13 11:31:09 +02:00
Alvaro Herrera e89f4c6618
Fix test case to do what it intends to
This test case intended to fail because setting a column as generated to
the partitioned table while leaving the partition alone is not allowed;
but instead failed because of a discrepancy of not-null constraint.  Fix
this by adding the not-null constraint first, then set the column as
generated in a separate ALTER TABLE command, which gets the expected
error.  Also, because the next test also wants to set the column as
not-null, add a BEGIN/ROLLBACK block so that the added not-null is
removed.

Oversight in 6995863157.
2024-05-13 10:32:33 +02:00
Alexander Korotkov 3ca43dbbb6 Add permission check for MERGE/SPLIT partition operations
Currently, we check only owner permission for the parent table before
MERGE/SPLIT partition operations.  This leads to a security hole when users
can get access to the data of partitions without permission.  This commit
fixes this problem by requiring owner permission on all the partitions
involved.

Reported-by: Alexander Lakhin
Discussion: https://postgr.es/m/0520c72e-8d97-245e-53f9-173beca2ab2e%40gmail.com
Author: Dmitry Koval, Alexander Korotkov
2024-05-13 00:00:21 +03:00
Thomas Munro cff4e5a36b Skip citext_utf8 test on Windows.
On other Windows build farm animals it is already skipped because they
don't use UTF-8 encoding.  On "hamerkop", UTF-8 is used, and then the
test fails.

It is not clear to me (a non-Windows person looking only at buildfarm
evidence) whether Windows is less sophisticated than other OSes and
doesn't know how to downcase Turkish İ with the standard Unicode
database, or if it is more sophisticated than other systems and uses
locale-specific behavior like ICU does.

Whichever the reason, the result is the same: we need to skip the test
on Windows, just as we already do for ICU, at least until a
Windows-savvy developer comes up with a better idea.  The technique for
detecting the OS is borrowed from collate.windows.win1252.sql.

This was anticipated by commit c2e8bd27, but the problem only surfaced
when Windows build farm animals started using Meson.

Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CA%2BhUKGJ1LeC3aE2qQYTK95rFVON3ZVoTQpTKJqxkHdtEyawH4A%40mail.gmail.com
2024-05-13 07:55:58 +12:00
Michael Paquier 267d41dc4f injection_points: Store runtime conditions in private area
This commit fixes a race condition between injection point run and
detach, where a point detached by a backend and concurrently running in
a second backend could cause the second backend to do an incorrect
condition check.  This issue happens because the second backend
retrieves the callback information in a first step in the shmem hash
table for injection points, and the condition in a second step within
the callback.  If the point is detached between these two steps, the
condition would be removed, causing the point to run while it should
not.  Storing the condition in the new private_data area introduced in
33181b48fd ensures that the condition retrieved is consistent with its
callback.

This commit leads to a lot of simplifications in the module
injection_points, as there is no need to handle the runtime conditions
inside it anymore.  Runtime conditions have no more a maximum number.

Per discussion with Noah Misch.

Reviewed-by: Noah Misch
Discussion: https://postgr.es/m/20240509031553.47@rfd.leadboat.com
2024-05-12 19:42:26 +09:00
Michael Paquier 33181b48fd Introduce private data area for injection points
This commit extends the backend-side infrastructure of injection points
so as it becomes possible to register some input data when attaching a
point.  This private data can be registered with the function name and
the library name of the callback when attaching a point, then it is
given as input argument to the callback.  This gives the possibility for
modules to pass down custom data at runtime when attaching a point
without managing that internally, in a manner consistent with the
callback entry retrieved from the hash shmem table storing the injection
point data.

InjectionPointAttach() gains two arguments, to be able to define the
private data contents and its size.

A follow-up commit will rely on this infrastructure to close a race
condition with the injection point detach in the module
injection_points.

While on it, this changes InjectionPointDetach() to return a boolean,
returning false if a point cannot be detached.  This has been mentioned
by Noah as useful when it comes to implement more complex tests with
concurrent point detach, solid with the automatic detach done for local
points in the test module.

Documentation is adjusted in consequence.

Per discussion with Noah Misch.

Reviewed-by: Noah Misch
Discussion: https://postgr.es/m/20240509031553.47@rfd.leadboat.com
2024-05-12 18:53:06 +09:00
Heikki Linnakangas 407e0b023c Change ALPN protocol ID to IANA-approved "postgresql"
"TBD-pgsql" was a placeholder until the IANA registration was
approved.

Discussion: https://www.postgresql.org/message-id/87jzk2hj2n.fsf%40wibble.ilmari.org
Discussion: https://mailarchive.ietf.org/arch/msg/tls-reg-review/9LWPzQfOpbc8dTT7vc9ahNeNaiw/
2024-05-11 18:48:19 +03:00
Bruce Momjian 31e8f4e619 doc PG 17 relnotes: move FETCH_COUNT item, and clarify
Backpatch-through: master
2024-05-10 17:34:33 -04:00
Bruce Momjian e7b2593bd6 doc PG 17 relnotes: add FETCH_COUNT item
Reported-by: Daniel Verite

Discussion: https://postgr.es/m/82569de4-9b2a-4311-beb2-81d5418491ec@manitou-mail.org

Backpatch-through: master
2024-05-10 15:47:08 -04:00
Peter Eisentraut 144c2ce0cc Fix ON CONFLICT DO NOTHING/UPDATE for temporal indexes
A PRIMARY KEY or UNIQUE constraint with WITHOUT OVERLAPS will be a
GiST index, not a B-Tree, but it will still have indisunique set.  The
code for ON CONFLICT fails if it sees a non-btree index that has
indisunique.  This commit fixes that and adds some tests.  But now
that we can't just test indisunique, we also need some extra checks to
prevent DO UPDATE from running against a WITHOUT OVERLAPS constraint
(because the conflict could happen against more than one row, and we'd
only update one).

Author: Paul A. Jungwirth <pj@illuminatedcomputing.com>
Discussion: https://www.postgresql.org/message-id/1426589a-83cb-4a89-bf40-713970c07e63@illuminatedcomputing.com
2024-05-10 14:55:31 +02:00
Tom Lane 5caa057496 Doc: update the "Using EXPLAIN" examples to match current code.
A lot of the examples in this section are quite ancient and no
longer match the system's current behavior.  I ran through them
and updated the sample output to match what I get today.

Notably, it seems that the tenk1 table got a few pages smaller back
around v12, so that a lot of the cost estimates for queries on that
table are a little different now.  (This also caused some examples
to surprisingly not match others, depending on when they were made.)

One mergejoin-based example no longer produces the same plan at all,
so I had to work around that, including switching to a different
example of using an enable_xxx setting.

I also changed a couple of examples that were relying on nonexistent
tables or indexes.  IMO the premise of this section is that the
examples should be more-or-less reproducible against the regression
database, so that these examples were unhelpful as given.  It's not
that hard to find a corresponding example with the tables we do have.

Some of the EXPLAIN ANALYZE examples were out of date in that we show
more numbers than we did at the time.

Possibly chapter 68 could use similar review, but I'm out of
energy for today.
2024-05-09 18:56:46 -04:00
Bruce Momjian 6a126d91cd doc PG 17 relnotes: fix author of LLVM item
Discussion: https://postgr.es/m/CA+hUKG+yU4+YqsCuQuzdCeETPdU+FjebXgV5Fkp6xrtr7EKC3w@mail.gmail.com

Backpatch-through: master
2024-05-09 16:37:51 -04:00
Bruce Momjian c3db1f30cb doc: clarify PERIOD and WITHOUT OVERLAPS in CREATE TABLE
Discussion: https://postgr.es/m/04938501-fc8f-46f3-97a4-9a81a3f24530@illuminatedcomputing.com

Author: Paul Jungwirth

Backpatch-through: master
2024-05-09 16:34:09 -04:00
Tom Lane d727c54317 Fix recursive RECORD-returning plpython functions.
If we recursed to a new call of the same function, with a different
coldeflist (AS clause), it would fail because the inner call would
overwrite the outer call's idea of what to return.  This is vaguely
like 1d2fe56e4 and c5bec5426, but it's not due to any API decisions:
it's just that we computed the actual output rowtype at the start of
the call, and saved it in the per-procedure data structure.  We can
fix it at basically zero cost by doing the computation at the end
of each call instead of the start.

It's not clear that there's any real-world use-case for such a
function, but given that it doesn't cost anything to fix,
it'd be silly not to.

Per report from Andreas Karlsson.  Back-patch to all supported
branches.

Discussion: https://postgr.es/m/1651a46d-3c15-4028-a8c1-d74937b54e19@proxel.se
2024-05-09 13:16:34 -04:00
Bruce Momjian b538e69249 doc PG 17 relnotes: Visual Studio clarification
Reported-by: Andrew Dunstan

Backpatch-through: master
2024-05-09 12:35:04 -04:00
Tom Lane 9effc4608e Repair ALTER EXTENSION ... SET SCHEMA.
It turns out that we broke this in commit e5bc9454e, because
the code was assuming that no dependent types would appear
among the extension's direct dependencies, and now they do.

This isn't terribly hard to fix: just skip dependent types,
expecting that we will recurse to them when we process the parent
object (which should also be among the direct dependencies).
But a little bit of refactoring is needed so that we can avoid
duplicating logic about what is a dependent type.

Although there is some testing of ALTER EXTENSION SET SCHEMA,
it failed to cover interesting cases, so add more tests.

Discussion: https://postgr.es/m/930191.1715205151@sss.pgh.pa.us
2024-05-09 12:19:52 -04:00
Bruce Momjian d82ab9fc31 doc PG 17 relnotes: Fixes from jian he
Backpatch-through: master
2024-05-09 11:43:03 -04:00
Bruce Momjian 45ea5b0a27 doc PG 17 relnotes: various fixes
Fixes suggested by David Rowley, Bertrand Drouvot, Masahiko
Sawada, Richard Guo, jian he, Dagfinn Ilmari Mannsåker

Backpatch-through: master
2024-05-09 11:19:56 -04:00
Tom Lane c7be3c015b Make left-join removal safe under -DREALLOCATE_BITMAPSETS.
The initial building of RestrictInfos and SpecialJoinInfos tends to
create structures that share relid sets (such as syn_lefthand and
outer_relids).  There's nothing wrong with that in itself, but when
we modify those relid sets during join removal, we have to be sure
not to corrupt the values that other structures are pointing at.
remove_rel_from_query() was careless about this.  It accidentally
worked anyway because (1) we'd never be reducing the sets to empty,
so they wouldn't get pfree'd; and (2) the in-place modification is the
same one that we did or will apply to the other struct's relid set,
so that there wasn't visible corruption at the end of the process.

While there's no live bug in a standard build, of course this is way
too fragile to accept going forward.  (Maybe we should back-patch
this change too for safety, but I've refrained for now.)

This bug was exposed by the recent invention of REALLOCATE_BITMAPSETS.
Commit e0477837c had installed a fix, but that went away with the
reversion of SJE, so now we need to fix it again.

David Rowley and Tom Lane

Discussion: https://postgr.es/m/CACJufxFVQmr4=JWHAOSLuKA5Zy9H26nY6tVrRFBOekHoALyCkQ@mail.gmail.com
2024-05-09 11:01:50 -04:00
Peter Eisentraut e2d5508c50 psql: Add missing punctuation in help output 2024-05-09 16:36:51 +02:00
Peter Eisentraut 1c4429e703 doc: Use better placeholder in COPY synopsis 2024-05-09 16:36:51 +02:00
Alvaro Herrera 21ac38f498
Fix inconsistencies in error messages
Reported by Kyotaro Horiguchi

Also some comments mentioning wrong version numbers, spotted by Justin
Pryzby.

Discussion: https://postgr.es/m/20240507.171724.750916195320223609.horikyota.ntt@gmail.com
Discussion: https://postgr.es/m/Zh0aAH7tbZb-9HbC@pryzbyj2023
2024-05-09 13:31:22 +02:00
Bruce Momjian e305f71565 doc: first draft of Postgres 17 release notes
Backpatch-through: master
2024-05-08 23:54:30 -04:00
Michael Paquier 855517307d Fix overread in JSON parsing errors for incomplete byte sequences
json_lex_string() relies on pg_encoding_mblen_bounded() to point to the
end of a JSON string when generating an error message, and the input it
uses is not guaranteed to be null-terminated.

It was possible to walk off the end of the input buffer by a few bytes
when the last bytes consist of an incomplete multi-byte sequence, as
token_terminator would point to a location defined by
pg_encoding_mblen_bounded() rather than the end of the input.  This
commit switches token_terminator so as the error uses data up to the
end of the JSON input.

More work should be done so as this code could rely on an equivalent of
report_invalid_encoding() so as incorrect byte sequences can show in
error messages in a readable form.  This requires work for at least two
cases in the JSON parsing API: an incomplete token and an invalid escape
sequence.  A more complete solution may be too invasive for a backpatch,
so this is left as a future improvement, taking care of the overread
first.

A test is added on HEAD as test_json_parser makes this issue
straight-forward to check.

Note that pg_encoding_mblen_bounded() no longer has any callers.  This
will be removed on HEAD with a separate commit, as this is proving to
encourage unsafe coding.

Author: Jacob Champion
Discussion: https://postgr.es/m/CAOYmi+ncM7pwLS3AnKCSmoqqtpjvA8wmCdoBtKA3ZrB2hZG6zA@mail.gmail.com
Backpatch-through: 13
2024-05-09 12:45:37 +09:00
Tom Lane 2fb7560cc8 Doc: document that triggers can break referential integrity.
User-written triggers can modify or block the effects of SQL update
and delete operations.  That includes operations that are executed
to implement foreign keys' referential integrity actions (such as
ON UPDATE SET NULL or ON DELETE CASCADE).  Therefore it's possible
for a misdesigned trigger to result in a database state that violates
the foreign key constraint.

While this isn't great, the alternatives seem worse: in particular,
refusing to fire triggers for such updates would break many valuable
use-cases.  We could also try to recheck the constraint after the
action, but that'd roughly double the already-high cost of FK
constraint enforcement, for no benefit in normal cases.  So we've
always considered that it's on the trigger programmer's head to
avoid breaking RI actions.  This was never documented anywhere,
though.  Add a para to the Triggers chapter to explain it.

Laurenz Albe, David Johnston, Tom Lane

Discussion: https://postgr.es/m/b81fe38fcc25a81be6e2e5b3fc1ff624130762fa.camel@cybertec.at
2024-05-08 11:13:40 -04:00
Peter Eisentraut 482e108cd3 Add test for REPLICA IDENTITY with a temporal key
You can only use REPLICA IDENTITY USING INDEX with a unique B-tree
index.  This commit just adds a test showing that you cannot use it
with a WITHOUT OVERLAPS index (which is GiST).

Author: Paul A. Jungwirth <pj@illuminatedcomputing.com>
Discussion: https://www.postgresql.org/message-id/3775839b-3f0f-4c8a-ac03-a253222e6a4b%40illuminatedcomputing.com
2024-05-08 15:24:48 +02:00
Peter Eisentraut 84f08f2215 doc: Improve order of options on pg_upgrade reference page
Put the new long-only options in a location that is consistent with
the existing long-only options and also the --help output.
2024-05-08 10:17:51 +02:00
Etsuro Fujita 4364e0126e Fix typo in src/backend/utils/resowner/README. 2024-05-08 16:15:00 +09:00
Peter Eisentraut 6d716adf85 Fix incorrect format placeholder 2024-05-08 08:37:46 +02:00
Tom Lane c1aea206e3 Ensure that "pg_restore -l" reports dependent TOC entries correctly.
If -l was specified together with selective-restore options such as -n
or -N, dependent TOC entries such as comments would be omitted from
the listing, even when an actual restore would have selected them.
This happened because PrintTOCSummary neglected to update the te->reqs
marking of the entry they depended on.

Per report from Justin Pryzby.  This has been wrong since 0d4e6ed30
taught _tocEntryRequired to sometimes look at the "reqs" marking of
other TOC entries, so back-patch to all supported branches.

Discussion: https://postgr.es/m/ZjoeirG7yxODdC4P@pryzbyj2023
2024-05-07 18:22:52 -04:00
Tom Lane c5bec5426a Don't corrupt plpython's "TD" dictionary in a recursive trigger call.
If a plpython-language trigger caused another one to be invoked,
the "TD" dictionary created for the inner one would overwrite the
outer one's "TD" dictionary.  This is more or less the same problem
that 1d2fe56e4 fixed for ordinary functions in plpython, so fix it
the same way, by saving and restoring "TD" during a recursive
invocation.

This fix makes an ABI-incompatible change in struct PLySavedArgs.
I'm not too worried about that because it seems highly unlikely that
any extension is messing with those structs.  We could imagine doing
something weird to preserve nominal ABI compatibility in the back
branches, like keeping the saved TD object in an extra element of
namedargs[].  However, that would only be very nominal compatibility:
if anything *is* touching PLySavedArgs, it would likely do the wrong
thing due to not knowing about the additional value.  So I judge it
not worth the ugliness to do something different there.

(I also changed struct PLyProcedure, but its added field fits
into formerly-padding space, so that should be safe.)

Per bug #18456 from Jacques Combrink.  This bug is very ancient,
so back-patch to all supported branches.

Discussion: https://postgr.es/m/3008982.1714853799@sss.pgh.pa.us
2024-05-07 18:15:00 -04:00
Peter Eisentraut 509199587d Fix assorted bugs related to identity column in partitioned tables
When changing the data type of a column of a partitioned table, craft
the ALTER SEQUENCE command only once.  Partitions do not have identity
sequences of their own and thus do not need a ALTER SEQUENCE command
for each partition.

Fix getIdentitySequence() to fetch the identity sequence associated
with the top-level partitioned table when a Relation of a partition is
passed to it.  While doing so, translate the attribute number of the
partition into the attribute number of the partitioned table.

Author: Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Reviewed-by: Dmitry Dolgov <9erthalion6@gmail.com>
Discussion: https://www.postgresql.org/message-id/3b8a9dc1-bbc7-0ef5-6863-c432afac7d59@gmail.com
2024-05-07 22:50:00 +02:00
Jeff Davis 832c4f657f Remove obsolete comment.
Per suggestion from Peter, the comment was not helpful, so remove it
rather than fixing it.

Reported-by: Peter Eisentraut
Discussion: https://postgr.es/m/d9421b21-e759-4b74-a039-c487b469c1f3@eisentraut.org
2024-05-07 11:44:47 -07:00
Tom Lane 6572bd55b0 Prevent RLS filters on ctid from breaking WHERE CURRENT OF <cursor>.
The executor only supports CurrentOfExpr as the sole tidqual of a
TidScan plan node.  tidpath.c failed to take any particular care about
that, but would just take the first ctid equality qual it could find
in the target relation's baserestrictinfo list.  Originally that was
fine because the grammar prevents any other WHERE conditions from
being combined with CURRENT OF <cursor>.  However, if the relation has
RLS visibility policies then those would get included in the list.
Should such a policy include a condition on ctid, we'd typically grab
the wrong qual and produce a malfunctioning plan.

To fix, introduce a simplistic priority ordering scheme for which ctid
equality qual to prefer.  Real-world cases involving more than one
such qual are so rare that it doesn't seem worth going to any great
trouble to choose one over another, so I didn't work very hard; but
this code could be extended in future if someone thinks differently.

It's extremely difficult to think of a reasonable use-case for an RLS
restriction involving ctid, and certainly we've heard no field reports
of this failure.  So this doesn't seem worthy of back-patching, but
in the name of cleanliness let's fix it going forward.

Patch by me, per report from Robert Haas.

Discussion: https://postgr.es/m/3914881.1715038270@sss.pgh.pa.us
2024-05-07 13:35:10 -04:00
Peter Eisentraut 09fe9659fd doc: Improve order of options on pgbench reference page
Both the pgbench --help output and the reference page have sections
for initialization options, benchmarking options, and common options.
But the --debug option ended up in the wrong place on the reference
page.  Fix that by making the documentation match the --help output.
2024-05-07 11:25:55 +02:00
Bruce Momjian 4712177a6c postgresql.conf: align variable comments, mostly new ones
Backpatch-through: master
2024-05-06 21:16:06 -04:00
Tom Lane 07746a8ef2 Finish incomplete revert of ec63622c0.
The code change this made might well be fine to keep, but the
comment justifying it by reference to self-join removal isn't.
Let's just go back to the status quo ante, pending a more thorough
review/redesign of SJE.

(I found this by grepping to see if any references to self-join
removal remained in the tree.)
2024-05-06 14:22:45 -04:00
Nathan Bossart 521a7156ab Fix privilege checks in pg_stats_ext and pg_stats_ext_exprs.
The catalog view pg_stats_ext fails to consider privileges for
expression statistics.  The catalog view pg_stats_ext_exprs fails
to consider privileges and row-level security policies.  To fix,
restrict the data in these views to table owners or roles that
inherit privileges of the table owner.  It may be possible to apply
less restrictive privilege checks in some cases, but that is left
as a future exercise.  Furthermore, for pg_stats_ext_exprs, do not
return data for tables with row-level security enabled, as is
already done for pg_stats_ext.

On the back-branches, a fix-CVE-2024-4317.sql script is provided
that will install into the "share" directory.  This file can be
used to apply the fix to existing clusters.

Bumps catversion on 'master' branch only.

Reported-by: Lukas Fittl
Reviewed-by: Noah Misch, Tomas Vondra, Tom Lane
Security: CVE-2024-4317
Backpatch-through: 14
2024-05-06 09:00:00 -05:00
Alexander Korotkov d1d286d83c Revert: Remove useless self-joins
This commit reverts d3d55ce571 and subsequent fixes 2b26a69455, 93c85db3b5,
b44a1708ab, b7f315c9d7, 8a8ed916f7, b5fb6736ed, 0a93f803f4, e0477837ce,
a7928a57b9, 5ef34a8fc3, 30b4955a46, 8c441c0827, 028b15405b, fe093994db,
489072ab7a, and 466979ef03.

We are quite late in the release cycle and new bugs continue to appear.  Even
though we have fixes for all known bugs, there is a risk of throwing many
bugs to end users.

The plan for self-join elimination would be to do more review and testing,
then re-commit in the early v18 cycle.

Reported-by: Tom Lane
Discussion: https://postgr.es/m/2422119.1714691974%40sss.pgh.pa.us
2024-05-06 14:36:36 +03:00
Alvaro Herrera 81b2252e60
Remove mention of nchar
This datatype is purposefully not documented.

Erik Wienhold <ewie@ewie.name>
Discussion: https://postgr.es/m/om3g7p7u3ztlrdp4tfswgulavljgn2fe6u2agk34mrr65dffuu@cpzlzuv6flko
2024-05-06 12:45:17 +02:00
Peter Eisentraut 7a31eb2aaa Translation updates
Source-Git-URL: https://git.postgresql.org/git/pgtranslation/messages.git
Source-Git-Hash: be182cc55e6f72c66215fd9b38851969e3ce5480
2024-05-06 12:06:31 +02:00
Peter Eisentraut bde2eec1b5 doc: Improve order of options on initdb reference page
Both the initdb --help output and the reference page have a section
for options and a section for less commonly used options.  But some
recently added options were sprinkled around inconsistently.  Fix that
by making the documentation match the --help output.
2024-05-06 09:56:54 +02:00