pgsql: common/jsonapi: support libpq as a client

2024-09-11 Thread Peter Eisentraut
common/jsonapi: support libpq as a client Based on a patch by Michael Paquier. For libpq, use PQExpBuffer instead of StringInfo. This requires us to track allocation failures so that we can return JSON_OUT_OF_MEMORY as needed rather than exit()ing. Author: Jacob Champion Co-authored-by: Michael

pgsql: Remove obsolete unconstify()

2024-09-11 Thread Peter Eisentraut
Remove obsolete unconstify() This is no longer needed as of OpenSSL 1.1.0 (the current minimum version). LibreSSL made the same change around the same time as well. Reviewed-by: Daniel Gustafsson Discussion: https://www.postgresql.org/message-id/20463f79-a7b0-4bba-a178-d805f99c02f9%40eisentrau

pgsql: Update .gitignore

2024-09-11 Thread Peter Eisentraut
Update .gitignore for commit 0785d1b8b2 Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/6b25c57a2dd61a44bdb60d5424d4aaa7e0f14334 Modified Files -- src/test/modules/test_json_parser/.gitignore | 1 + 1 file changed, 1 insertion(+)

pgsql: Fix unique key checks in JSON object constructors

2024-09-11 Thread Tomas Vondra
Fix unique key checks in JSON object constructors When building a JSON object, the code builds a hash table of keys, to allow checking if the keys are unique. The uniqueness check and adding the new key happens in json_unique_check_key(), but this assumes the pointer to the key remains valid. Unf

pgsql: Fix unique key checks in JSON object constructors

2024-09-11 Thread Tomas Vondra
Fix unique key checks in JSON object constructors When building a JSON object, the code builds a hash table of keys, to allow checking if the keys are unique. The uniqueness check and adding the new key happens in json_unique_check_key(), but this assumes the pointer to the key remains valid. Unf

pgsql: Fix unique key checks in JSON object constructors

2024-09-11 Thread Tomas Vondra
Fix unique key checks in JSON object constructors When building a JSON object, the code builds a hash table of keys, to allow checking if the keys are unique. The uniqueness check and adding the new key happens in json_unique_check_key(), but this assumes the pointer to the key remains valid. Unf

pgsql: Replace gratuitous memmove() with memcpy()

2024-09-11 Thread Peter Eisentraut
Replace gratuitous memmove() with memcpy() The index access methods all had similar code that copied the passed-in scan keys to local storage. They all used memmove() for that, which is not wrong, but it seems confusing not to use memcpy() when that would work. Presumably, this was all once copi

pgsql: pg_createsubscriber: minor documentation fixes

2024-09-11 Thread Magnus Hagander
pg_createsubscriber: minor documentation fixes Branch -- REL_17_STABLE Details --- https://git.postgresql.org/pg/commitdiff/7748c847c332c2231846d913aa81d7e20b4b0241 Modified Files -- doc/src/sgml/ref/pg_createsubscriber.sgml | 6 +++--- 1 file changed, 3 insertions(+), 3 delet

pgsql: pg_createsubscriber: minor documentation fixes

2024-09-11 Thread Magnus Hagander
pg_createsubscriber: minor documentation fixes Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/280423300b361eb9deff5ea40d4b0e6fab00211b Modified Files -- doc/src/sgml/ref/pg_createsubscriber.sgml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)

pgsql: Remove incorrect Assert.

2024-09-11 Thread Tom Lane
Remove incorrect Assert. check_agglevels_and_constraints() asserted that if we find an aggregate function in an EXPR_KIND_FROM_SUBSELECT expression, the expression must be in a LATERAL subquery. Alexander Lakhin found a case where that's not so: because of the odd scoping rules for NEW/OLD within

pgsql: Remove incorrect Assert.

2024-09-11 Thread Tom Lane
Remove incorrect Assert. check_agglevels_and_constraints() asserted that if we find an aggregate function in an EXPR_KIND_FROM_SUBSELECT expression, the expression must be in a LATERAL subquery. Alexander Lakhin found a case where that's not so: because of the odd scoping rules for NEW/OLD within

pgsql: Remove incorrect Assert.

2024-09-11 Thread Tom Lane
Remove incorrect Assert. check_agglevels_and_constraints() asserted that if we find an aggregate function in an EXPR_KIND_FROM_SUBSELECT expression, the expression must be in a LATERAL subquery. Alexander Lakhin found a case where that's not so: because of the odd scoping rules for NEW/OLD within

pgsql: Remove incorrect Assert.

2024-09-11 Thread Tom Lane
Remove incorrect Assert. check_agglevels_and_constraints() asserted that if we find an aggregate function in an EXPR_KIND_FROM_SUBSELECT expression, the expression must be in a LATERAL subquery. Alexander Lakhin found a case where that's not so: because of the odd scoping rules for NEW/OLD within

pgsql: Remove incorrect Assert.

2024-09-11 Thread Tom Lane
Remove incorrect Assert. check_agglevels_and_constraints() asserted that if we find an aggregate function in an EXPR_KIND_FROM_SUBSELECT expression, the expression must be in a LATERAL subquery. Alexander Lakhin found a case where that's not so: because of the odd scoping rules for NEW/OLD within

pgsql: Remove incorrect Assert.

2024-09-11 Thread Tom Lane
Remove incorrect Assert. check_agglevels_and_constraints() asserted that if we find an aggregate function in an EXPR_KIND_FROM_SUBSELECT expression, the expression must be in a LATERAL subquery. Alexander Lakhin found a case where that's not so: because of the odd scoping rules for NEW/OLD within

pgsql: Remove incorrect Assert.

2024-09-11 Thread Tom Lane
Remove incorrect Assert. check_agglevels_and_constraints() asserted that if we find an aggregate function in an EXPR_KIND_FROM_SUBSELECT expression, the expression must be in a LATERAL subquery. Alexander Lakhin found a case where that's not so: because of the odd scoping rules for NEW/OLD within

pgsql: SQL/JSON: Fix JSON_QUERY(... WITH CONDITIONAL WRAPPER)

2024-09-11 Thread Amit Langote
SQL/JSON: Fix JSON_QUERY(... WITH CONDITIONAL WRAPPER) Currently, when WITH CONDITIONAL WRAPPER is specified, array wrappers are applied even to a single SQL/JSON item if it is a scalar JSON value, but this behavior does not comply with the standard. To fix, apply wrappers only when there are mul

pgsql: SQL/JSON: Fix JSON_QUERY(... WITH CONDITIONAL WRAPPER)

2024-09-11 Thread Amit Langote
SQL/JSON: Fix JSON_QUERY(... WITH CONDITIONAL WRAPPER) Currently, when WITH CONDITIONAL WRAPPER is specified, array wrappers are applied even to a single SQL/JSON item if it is a scalar JSON value, but this behavior does not comply with the standard. To fix, apply wrappers only when there are mul

pgsql: Adjust tuplestore stats API

2024-09-11 Thread David Rowley
Adjust tuplestore stats API 1eff8279d added an API to tuplestore.c to allow callers to obtain storage telemetry data. That API wasn't quite good enough for callers that perform tuplestore_clear() as the telemetry functions only accounted for the current state of the tuplestore, not the maximums b

pgsql: Move logic related to WAL replay of Heap/Heap2 into its own file

2024-09-11 Thread Michael Paquier
Move logic related to WAL replay of Heap/Heap2 into its own file This brings more clarity to heapam.c, by cleanly separating all the logic related to WAL replay and the rest of Heap and Heap2, similarly to other RMGRs like hash, btree, etc. The header reorganization is also nice in heapam.c, cutt