pgsql: Tidy up claimed supported CPUs and OSes.

2022-07-10 Thread Thomas Munro
Tidy up claimed supported CPUs and OSes.

 * Remove arbitrary mention of certain endianness and bitness variants;
   it's enough to say that applicable variants are expected to work.
 * List RISC-V (known to work, being tested).
 * List SuperH and M88K (code exists, unknown status, like M68K).
 * De-list VAX and remove code (known not to work).
 * Remove stray trace of Alpha (support was removed years ago).
 * List illumos, DragonFlyBSD (known to work, being tested).
 * No need to single Windows out by listing a specific version, when we
   don't do that for other OSes; it's enough to say that we support
   current versions of the listed OSes (when 16 ships, that'll be
   Windows 10+).

Reviewed-by: Tom Lane 
Reviewed-by: Greg Stark 
Discussion: 
https://postgr.es/m/CA%2BhUKGKk7NZO1UnJM0PyixcZPpCGqjBXW_0bzFZpJBGAf84XKg%40mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/92d70b77ebb45ec43c163d7ebfe7a3c613c24621

Modified Files
--
contrib/pgcrypto/crypt-blowfish.c |  2 +-
doc/src/sgml/installation.sgml| 13 +++--
src/include/storage/s_lock.h  | 30 --
3 files changed, 8 insertions(+), 37 deletions(-)



pgsql: doc: Fix inconsistent quotes in some jsonb fields

2022-07-10 Thread Michael Paquier
doc: Fix inconsistent quotes in some jsonb fields

Single quotes are not allowed in json internals, double quotes are.

Reported-by: Eric Mutta
Discussion: 
https://postgr.es/m/[email protected]
Backpatch-through: 14

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/1cd182163061f0c8619eaf79dc077ef78a81a13b

Modified Files
--
doc/src/sgml/json.sgml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)



pgsql: doc: Fix inconsistent quotes in some jsonb fields

2022-07-10 Thread Michael Paquier
doc: Fix inconsistent quotes in some jsonb fields

Single quotes are not allowed in json internals, double quotes are.

Reported-by: Eric Mutta
Discussion: 
https://postgr.es/m/[email protected]
Backpatch-through: 14

Branch
--
REL_15_STABLE

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

Modified Files
--
doc/src/sgml/json.sgml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)



pgsql: doc: Fix inconsistent quotes in some jsonb fields

2022-07-10 Thread Michael Paquier
doc: Fix inconsistent quotes in some jsonb fields

Single quotes are not allowed in json internals, double quotes are.

Reported-by: Eric Mutta
Discussion: 
https://postgr.es/m/[email protected]
Backpatch-through: 14

Branch
--
REL_14_STABLE

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

Modified Files
--
doc/src/sgml/json.sgml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)



pgsql: Improve two comments related to a boolean DefElem's value

2022-07-10 Thread Michael Paquier
Improve two comments related to a boolean DefElem's value

The original comments mentioned a "parameter" as something not defined
in a fast-exit path to assume a true status.  This is rather confusing
as the parameter DefElem is defined, and the intention is to check if
its value is defined.  This improves both comments to mention the value
assigned to the DefElem's value instead, so as future patches are able
to catch the tweak if this code pattern gets copied around more.

Author: Peter Smith
Discussion: 
https://postgr.es/m/CAHut+Pv0yWynWTmp4o34s0d98xVubys9fy=p0yxsz5_sucn...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/8445f5a21d40b969673ca03918c74b4fbc882bf4

Modified Files
--
src/backend/commands/copy.c   | 2 +-
src/backend/commands/define.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)



pgsql: Improve error message with JSON_SERIALIZE()

2022-07-10 Thread Michael Paquier
Improve error message with JSON_SERIALIZE()

The error message introduced in 3c633f3 can share the same format string
with an existing message used for JSON(), reducing the translation
effort.

Author: Kyotaro Horiguchi
Discussion: 
https://postgr.es/m/[email protected]
Backpatch-through: 15

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/0a6be1f0ec3cc9b98453bdab2d4edcfd5a00c7fa

Modified Files
--
src/backend/parser/parse_expr.c   | 5 +++--
src/test/regress/expected/sqljson.out | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)



pgsql: Improve error message with JSON_SERIALIZE()

2022-07-10 Thread Michael Paquier
Improve error message with JSON_SERIALIZE()

The error message introduced in 3c633f3 can share the same format string
with an existing message used for JSON(), reducing the translation
effort.

Author: Kyotaro Horiguchi
Discussion: 
https://postgr.es/m/[email protected]
Backpatch-through: 15

Branch
--
REL_15_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/834fce52f941cd228beca2067dca82f6e33a4d98

Modified Files
--
src/backend/parser/parse_expr.c   | 5 +++--
src/test/regress/expected/sqljson.out | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)



pgsql: Fix two portability issues with the tests of test_oat_hooks

2022-07-10 Thread Michael Paquier
Fix two portability issues with the tests of test_oat_hooks

This addresses two issues in the tests of test_oat_hooks:
- The role regress_test_user was being left behind, preventing the test
to succeed on repeated runs.  It makes sense to leave some objects
behind to have more coverage for pg_upgrade (as does test_pg_dump), but
the role dropped here does not own any objects so there is no reason to
keep it.
- GRANT SET ON PARAMETER is issued, creating an entry in
pg_parameter_acl without cleaning up the entry created.  This causes
an overlap with unsafe_tests as both use work_mem, making the latter
fail.  This commit adds an extra REVOKE SET ON PARAMETER to clean the
contents of pg_parameter_acl, switching to maintenance_work_mem rather
than work_mem to avoid an overlap between both tests.

The tests of test_oat_hooks cannot use installcheck yet as these are
proving to be unstable with caching and the namespace search hooks, so
the issues fixed here cannot be reached yet, but they would be once the
hook issue is addressed and installcheck is allowed again in
test_oat_hooks.

Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 15

Branch
--
REL_15_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/03b87d08a4163d23d4acd83e3c022ab82b43a7ac

Modified Files
--
src/test/modules/test_oat_hooks/expected/test_oat_hooks.out | 8 ++--
src/test/modules/test_oat_hooks/sql/test_oat_hooks.sql  | 6 --
2 files changed, 10 insertions(+), 4 deletions(-)



pgsql: Fix two portability issues with the tests of test_oat_hooks

2022-07-10 Thread Michael Paquier
Fix two portability issues with the tests of test_oat_hooks

This addresses two issues in the tests of test_oat_hooks:
- The role regress_test_user was being left behind, preventing the test
to succeed on repeated runs.  It makes sense to leave some objects
behind to have more coverage for pg_upgrade (as does test_pg_dump), but
the role dropped here does not own any objects so there is no reason to
keep it.
- GRANT SET ON PARAMETER is issued, creating an entry in
pg_parameter_acl without cleaning up the entry created.  This causes
an overlap with unsafe_tests as both use work_mem, making the latter
fail.  This commit adds an extra REVOKE SET ON PARAMETER to clean the
contents of pg_parameter_acl, switching to maintenance_work_mem rather
than work_mem to avoid an overlap between both tests.

The tests of test_oat_hooks cannot use installcheck yet as these are
proving to be unstable with caching and the namespace search hooks, so
the issues fixed here cannot be reached yet, but they would be once the
hook issue is addressed and installcheck is allowed again in
test_oat_hooks.

Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 15

Branch
--
master

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

Modified Files
--
src/test/modules/test_oat_hooks/expected/test_oat_hooks.out | 8 ++--
src/test/modules/test_oat_hooks/sql/test_oat_hooks.sql  | 6 --
2 files changed, 10 insertions(+), 4 deletions(-)



Re: pgsql: Only allow returning string types or bytea from json_serialize

2022-07-10 Thread Michael Paquier
On Fri, Jul 08, 2022 at 07:20:14PM +0900, Michael Paquier wrote:
> Yeah, I think that you are right, so let's fix this.  If Andrew does
> not show up, I'll take care of it.

Okay, this one is done, then.  Thanks for the patch, Horiguchi-san.
--
Michael


signature.asc
Description: PGP signature


pgsql: Build de-escaped JSON strings in larger chunks during lexing

2022-07-10 Thread John Naylor
Build de-escaped JSON strings in larger chunks during lexing

During COPY BINARY with large JSONB blobs, it was found that half
the time was spent parsing JSON, with much of that spent in separate
appendStringInfoChar() calls for each input byte.

Add lookahead loop to json_lex_string() to allow batching multiple bytes
via appendBinaryStringInfo(). Also use this same logic when de-escaping
is not done, to avoid code duplication.

Report and proof of concept patch by Jelte Fennema, reworked by Andres
Freund and John Naylor

Discussion: 
https://www.postgresql.org/message-id/CAGECzQQuXbies_nKgSiYifZUjBk6nOf2%3DTSXqRjj2BhUh8CTeA%40mail.gmail.com
Discussion: 
https://www.postgresql.org/message-id/flat/pr3pr83mb0476f098cbcf68af7a1ca89ff7...@pr3pr83mb0476.eurprd83.prod.outlook.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/3838fa269c15706df2b85ce2d6af8aacd5611655

Modified Files
--
src/common/jsonapi.c | 58 +++-
1 file changed, 39 insertions(+), 19 deletions(-)



pgsql: Fix lock assertions in dshash.c.

2022-07-10 Thread Thomas Munro
Fix lock assertions in dshash.c.

dshash.c previously maintained flags to be able to assert that you
didn't hold any partition lock.  These flags could get out of sync with
reality in error scenarios.

Get rid of all that, and make assertions about the locks themselves
instead.  Since LWLockHeldByMe() loops internally, we don't want to put
that inside another loop over all partition locks.  Introduce a new
debugging-only interface LWLockAnyHeldByMe() to avoid that.

This problem was noted by Tom and Andres while reviewing changes to
support the new shared memory stats system, and later showed up in
reality while working on commit 389869af.

Back-patch to 11, where dshash.c arrived.

Reported-by: Tom Lane 
Reported-by: Andres Freund 
Reviewed-by: Kyotaro HORIGUCHI 
Reviewed-by: Zhihong Yu 
Reviewed-by: Andres Freund 
Discussion: 
https://postgr.es/m/[email protected]
Discussion: 
https://postgr.es/m/CA%2BhUKGJ31Wce6HJ7xnVTKWjFUWQZPBngxfJVx4q0E98pDr3kAw%40mail.gmail.com

Branch
--
master

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

Modified Files
--
src/backend/lib/dshash.c  | 44 +--
src/backend/storage/lmgr/lwlock.c | 26 +++
src/include/storage/lwlock.h  |  1 +
3 files changed, 37 insertions(+), 34 deletions(-)



pgsql: Fix lock assertions in dshash.c.

2022-07-10 Thread Thomas Munro
Fix lock assertions in dshash.c.

dshash.c previously maintained flags to be able to assert that you
didn't hold any partition lock.  These flags could get out of sync with
reality in error scenarios.

Get rid of all that, and make assertions about the locks themselves
instead.  Since LWLockHeldByMe() loops internally, we don't want to put
that inside another loop over all partition locks.  Introduce a new
debugging-only interface LWLockAnyHeldByMe() to avoid that.

This problem was noted by Tom and Andres while reviewing changes to
support the new shared memory stats system, and later showed up in
reality while working on commit 389869af.

Back-patch to 11, where dshash.c arrived.

Reported-by: Tom Lane 
Reported-by: Andres Freund 
Reviewed-by: Kyotaro HORIGUCHI 
Reviewed-by: Zhihong Yu 
Reviewed-by: Andres Freund 
Discussion: 
https://postgr.es/m/[email protected]
Discussion: 
https://postgr.es/m/CA%2BhUKGJ31Wce6HJ7xnVTKWjFUWQZPBngxfJVx4q0E98pDr3kAw%40mail.gmail.com

Branch
--
REL_15_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/53df1e28d2f7554ab23292414ce3200f732ee1c1

Modified Files
--
src/backend/lib/dshash.c  | 44 +--
src/backend/storage/lmgr/lwlock.c | 26 +++
src/include/storage/lwlock.h  |  1 +
3 files changed, 37 insertions(+), 34 deletions(-)



pgsql: Fix lock assertions in dshash.c.

2022-07-10 Thread Thomas Munro
Fix lock assertions in dshash.c.

dshash.c previously maintained flags to be able to assert that you
didn't hold any partition lock.  These flags could get out of sync with
reality in error scenarios.

Get rid of all that, and make assertions about the locks themselves
instead.  Since LWLockHeldByMe() loops internally, we don't want to put
that inside another loop over all partition locks.  Introduce a new
debugging-only interface LWLockAnyHeldByMe() to avoid that.

This problem was noted by Tom and Andres while reviewing changes to
support the new shared memory stats system, and later showed up in
reality while working on commit 389869af.

Back-patch to 11, where dshash.c arrived.

Reported-by: Tom Lane 
Reported-by: Andres Freund 
Reviewed-by: Kyotaro HORIGUCHI 
Reviewed-by: Zhihong Yu 
Reviewed-by: Andres Freund 
Discussion: 
https://postgr.es/m/[email protected]
Discussion: 
https://postgr.es/m/CA%2BhUKGJ31Wce6HJ7xnVTKWjFUWQZPBngxfJVx4q0E98pDr3kAw%40mail.gmail.com

Branch
--
REL_14_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/5e7608e81ebb2a9e2a72ab771eba3c620c0b42a6

Modified Files
--
src/backend/lib/dshash.c  | 35 +--
src/backend/storage/lmgr/lwlock.c | 26 ++
src/include/storage/lwlock.h  |  1 +
3 files changed, 36 insertions(+), 26 deletions(-)



pgsql: Fix lock assertions in dshash.c.

2022-07-10 Thread Thomas Munro
Fix lock assertions in dshash.c.

dshash.c previously maintained flags to be able to assert that you
didn't hold any partition lock.  These flags could get out of sync with
reality in error scenarios.

Get rid of all that, and make assertions about the locks themselves
instead.  Since LWLockHeldByMe() loops internally, we don't want to put
that inside another loop over all partition locks.  Introduce a new
debugging-only interface LWLockAnyHeldByMe() to avoid that.

This problem was noted by Tom and Andres while reviewing changes to
support the new shared memory stats system, and later showed up in
reality while working on commit 389869af.

Back-patch to 11, where dshash.c arrived.

Reported-by: Tom Lane 
Reported-by: Andres Freund 
Reviewed-by: Kyotaro HORIGUCHI 
Reviewed-by: Zhihong Yu 
Reviewed-by: Andres Freund 
Discussion: 
https://postgr.es/m/[email protected]
Discussion: 
https://postgr.es/m/CA%2BhUKGJ31Wce6HJ7xnVTKWjFUWQZPBngxfJVx4q0E98pDr3kAw%40mail.gmail.com

Branch
--
REL_13_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/7cdd0c2d7cdf08a4f8dfd8678a7b244c942e64e4

Modified Files
--
src/backend/lib/dshash.c  | 35 +--
src/backend/storage/lmgr/lwlock.c | 26 ++
src/include/storage/lwlock.h  |  1 +
3 files changed, 36 insertions(+), 26 deletions(-)



pgsql: Fix lock assertions in dshash.c.

2022-07-10 Thread Thomas Munro
Fix lock assertions in dshash.c.

dshash.c previously maintained flags to be able to assert that you
didn't hold any partition lock.  These flags could get out of sync with
reality in error scenarios.

Get rid of all that, and make assertions about the locks themselves
instead.  Since LWLockHeldByMe() loops internally, we don't want to put
that inside another loop over all partition locks.  Introduce a new
debugging-only interface LWLockAnyHeldByMe() to avoid that.

This problem was noted by Tom and Andres while reviewing changes to
support the new shared memory stats system, and later showed up in
reality while working on commit 389869af.

Back-patch to 11, where dshash.c arrived.

Reported-by: Tom Lane 
Reported-by: Andres Freund 
Reviewed-by: Kyotaro HORIGUCHI 
Reviewed-by: Zhihong Yu 
Reviewed-by: Andres Freund 
Discussion: 
https://postgr.es/m/[email protected]
Discussion: 
https://postgr.es/m/CA%2BhUKGJ31Wce6HJ7xnVTKWjFUWQZPBngxfJVx4q0E98pDr3kAw%40mail.gmail.com

Branch
--
REL_12_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/4f88dbac22a845a33c758554e25ca0ee7e9dedac

Modified Files
--
src/backend/lib/dshash.c  | 37 ++---
src/backend/storage/lmgr/lwlock.c | 26 ++
src/include/storage/lwlock.h  |  1 +
3 files changed, 37 insertions(+), 27 deletions(-)



pgsql: Fix lock assertions in dshash.c.

2022-07-10 Thread Thomas Munro
Fix lock assertions in dshash.c.

dshash.c previously maintained flags to be able to assert that you
didn't hold any partition lock.  These flags could get out of sync with
reality in error scenarios.

Get rid of all that, and make assertions about the locks themselves
instead.  Since LWLockHeldByMe() loops internally, we don't want to put
that inside another loop over all partition locks.  Introduce a new
debugging-only interface LWLockAnyHeldByMe() to avoid that.

This problem was noted by Tom and Andres while reviewing changes to
support the new shared memory stats system, and later showed up in
reality while working on commit 389869af.

Back-patch to 11, where dshash.c arrived.

Reported-by: Tom Lane 
Reported-by: Andres Freund 
Reviewed-by: Kyotaro HORIGUCHI 
Reviewed-by: Zhihong Yu 
Reviewed-by: Andres Freund 
Discussion: 
https://postgr.es/m/[email protected]
Discussion: 
https://postgr.es/m/CA%2BhUKGJ31Wce6HJ7xnVTKWjFUWQZPBngxfJVx4q0E98pDr3kAw%40mail.gmail.com

Branch
--
REL_11_STABLE

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

Modified Files
--
src/backend/lib/dshash.c  | 37 ++---
src/backend/storage/lmgr/lwlock.c | 26 ++
src/include/storage/lwlock.h  |  1 +
3 files changed, 37 insertions(+), 27 deletions(-)



pgsql: Convert macros to static inline functions (bufpage.h)

2022-07-10 Thread Peter Eisentraut
Convert macros to static inline functions (bufpage.h)

Remove PageIsValid() and PageSizeIsValid(), which weren't used and
seem unnecessary.

Some code using these formerly-macros needs some adjustments because
it was previously playing loose with the Page vs. PageHeader types,
which is no longer possible with the functions instead of macros.

Reviewed-by: Amul Sul 
Discussion: 
https://www.postgresql.org/message-id/flat/5b558da8-99fb-0a99-83dd-f72f05388517%40enterprisedb.com

Branch
--
master

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

Modified Files
--
contrib/pageinspect/rawpage.c   |  24 ++--
src/backend/storage/page/bufpage.c  |  18 +--
src/bin/pg_checksums/pg_checksums.c |   2 +-
src/include/storage/bufpage.h   | 257 ++--
src/include/storage/checksum_impl.h |   2 +-
5 files changed, 182 insertions(+), 121 deletions(-)



Re: pgsql: Only allow returning string types or bytea from json_serialize

2022-07-10 Thread Kyotaro Horiguchi
At Mon, 11 Jul 2022 12:49:11 +0900, Michael Paquier  wrote 
in 
> On Fri, Jul 08, 2022 at 07:20:14PM +0900, Michael Paquier wrote:
> > Yeah, I think that you are right, so let's fix this.  If Andrew does
> > not show up, I'll take care of it.
> 
> Okay, this one is done, then.  Thanks for the patch, Horiguchi-san.

Thanks!
(I came to notice that I sent the mail only to -commiters..)

regards.

-- 
Kyotaro Horiguchi
NTT Open Source Software Center