pgsql: doc: first draft of Postgres 17 release notes

2024-05-08 Thread Bruce Momjian
doc:  first draft of Postgres 17 release notes

Backpatch-through: master

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/e305f71565e203e08e47d7094082188f5737317f

Modified Files
--
doc/src/sgml/release-17.sgml | 2825 +-
1 file changed, 2814 insertions(+), 11 deletions(-)



pgsql: Fix overread in JSON parsing errors for incomplete byte sequence

2024-05-08 Thread Michael Paquier
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+ncm7pwls3ankcsmoqqtpjva8wmcdobtka3zrb2hzg...@mail.gmail.com
Backpatch-through: 13

Branch
--
REL_13_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/377c25d32275a65043f9dcf3d4668a56c37319e2

Modified Files
--
src/common/jsonapi.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)



pgsql: Fix overread in JSON parsing errors for incomplete byte sequence

2024-05-08 Thread Michael Paquier
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+ncm7pwls3ankcsmoqqtpjva8wmcdobtka3zrb2hzg...@mail.gmail.com
Backpatch-through: 13

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/855517307db8efd397d49163d65a4fd3bdcc41bc

Modified Files
--
src/common/jsonapi.c  | 4 ++--
src/test/modules/test_json_parser/t/002_inline.pl | 8 
2 files changed, 10 insertions(+), 2 deletions(-)



pgsql: Fix overread in JSON parsing errors for incomplete byte sequence

2024-05-08 Thread Michael Paquier
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+ncm7pwls3ankcsmoqqtpjva8wmcdobtka3zrb2hzg...@mail.gmail.com
Backpatch-through: 13

Branch
--
REL_16_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/5396a2987cc679a3ab5db26b54c8b76149489e29

Modified Files
--
src/common/jsonapi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)



pgsql: Fix overread in JSON parsing errors for incomplete byte sequence

2024-05-08 Thread Michael Paquier
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+ncm7pwls3ankcsmoqqtpjva8wmcdobtka3zrb2hzg...@mail.gmail.com
Backpatch-through: 13

Branch
--
REL_14_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/41adf9d960c0105ada615574126d5568d552f4db

Modified Files
--
src/common/jsonapi.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)



pgsql: Fix overread in JSON parsing errors for incomplete byte sequence

2024-05-08 Thread Michael Paquier
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+ncm7pwls3ankcsmoqqtpjva8wmcdobtka3zrb2hzg...@mail.gmail.com
Backpatch-through: 13

Branch
--
REL_15_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/8c3f30e675e972e3c2750ea82781f2c4ba77a9f8

Modified Files
--
src/common/jsonapi.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)



Re: pgsql: Add allow_alter_system GUC.

2024-05-08 Thread Bruce Momjian
On Fri, Mar 29, 2024 at 08:47:18AM -0400, Robert Haas wrote:
> Oh no! Jelte, I'm so sorry ... I spelled your name wrong in this
> commit message. :-(
> 
> Please accept my apologies.

I have corrected his name in the release notes for this item.

-- 
  Bruce Momjian  https://momjian.us
  EDB  https://enterprisedb.com

  Only you can decide what is important to you.




pgsql: Doc: document that triggers can break referential integrity.

2024-05-08 Thread Tom Lane
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.ca...@cybertec.at

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/2fb7560cc8f8ba72fab840e7ae2b2b8c36e68c53

Modified Files
--
doc/src/sgml/trigger.sgml | 11 +++
1 file changed, 11 insertions(+)



pgsql: Add test for REPLICA IDENTITY with a temporal key

2024-05-08 Thread Peter Eisentraut
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 
Discussion: 
https://www.postgresql.org/message-id/3775839b-3f0f-4c8a-ac03-a253222e6a4b%40illuminatedcomputing.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/482e108cd38db5366c52a6b1f4180f34c1796155

Modified Files
--
src/test/regress/expected/without_overlaps.out | 4 
src/test/regress/sql/without_overlaps.sql  | 4 
2 files changed, 8 insertions(+)



pgsql: doc: Improve order of options on pg_upgrade reference page

2024-05-08 Thread Peter Eisentraut
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.

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/84f08f2215754cd03feaa82bbdf10fc114458b26

Modified Files
--
doc/src/sgml/ref/pgupgrade.sgml | 46 -
1 file changed, 23 insertions(+), 23 deletions(-)



pgsql: Fix typo in src/backend/utils/resowner/README.

2024-05-08 Thread Etsuro Fujita
Fix typo in src/backend/utils/resowner/README.

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/4364e0126ec7663363cf2dff86a0f6da949fc002

Modified Files
--
src/backend/utils/resowner/README | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



pgsql: Fix incorrect format placeholder

2024-05-08 Thread Peter Eisentraut
Fix incorrect format placeholder

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/6d716adf8569b734eb8849094e9b3edab084c7f8

Modified Files
--
src/backend/replication/logical/slotsync.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)