pgsql: Fix more holes with SLRU code in need of int64 for segment numbe

2024-07-26 Thread Michael Paquier
Fix more holes with SLRU code in need of int64 for segment numbers This is a continuation of 3937cadfd438, taking care of more areas I have managed to miss previously. Reported-by: Noah Misch Reviewed-by: Noah Misch Discussion: https://postgr.es/m/20240724130059.1f.nmi...@google.com Backpatch-thr

pgsql: Fix more holes with SLRU code in need of int64 for segment numbe

2024-07-26 Thread Michael Paquier
Fix more holes with SLRU code in need of int64 for segment numbers This is a continuation of 3937cadfd438, taking care of more areas I have managed to miss previously. Reported-by: Noah Misch Reviewed-by: Noah Misch Discussion: https://postgr.es/m/20240724130059.1f.nmi...@google.com Backpatch-thr

pgsql: Introduce num_os_semaphores GUC.

2024-07-26 Thread Nathan Bossart
Introduce num_os_semaphores GUC. The documentation for System V IPC parameters provides complicated formulas to determine the appropriate values for SEMMNI and SEMMNS. Furthermore, these formulas have often been wrong because folks forget to update them (e.g., when adding a new auxiliary process).

pgsql: Wait for WAL summarization to catch up before creating .partial

2024-07-26 Thread Robert Haas
Wait for WAL summarization to catch up before creating .partial file. When a standby is promoted, CleanupAfterArchiveRecovery() may decide to rename the final WAL file from the old timeline by adding ".partial" to the name. If WAL summarization is enabled and this file is renamed before its partia

pgsql: Wait for WAL summarization to catch up before creating .partial

2024-07-26 Thread Robert Haas
Wait for WAL summarization to catch up before creating .partial file. When a standby is promoted, CleanupAfterArchiveRecovery() may decide to rename the final WAL file from the old timeline by adding ".partial" to the name. If WAL summarization is enabled and this file is renamed before its partia

pgsql: postgres_fdw: Fix bug in connection status check.

2024-07-26 Thread Fujii Masao
postgres_fdw: Fix bug in connection status check. The buildfarm member "hake" reported a failure in the regression test added by commit 857df3cef7, where postgres_fdw_get_connections(true) returned unexpected results. The function postgres_fdw_get_connections(true) checks if a connection is close

pgsql: pg_upgrade: Move live_check variable to user_opts.

2024-07-26 Thread Nathan Bossart
pg_upgrade: Move live_check variable to user_opts. At the moment, pg_upgrade stores whether it is doing a "live check" (i.e., the user specified --check and the old server is still running) in a local variable scoped to main(). This live_check variable is passed to several functions. To further

pgsql: Fix macro placement in pg_config.h.in

2024-07-26 Thread Daniel Gustafsson
Fix macro placement in pg_config.h.in Commit 274bbced85383e831dde accidentally placed the pg_config.h.in for SSL_CTX_set_num_tickets on the wrong line wrt where autoheader places it. Fix by re-arranging and backpatch to the same level as the original commit. Reported-by: Marina Polyakova Discus

pgsql: Fix building with MSVC for TLS session disabling

2024-07-26 Thread Daniel Gustafsson
Fix building with MSVC for TLS session disabling Commit 274bbced85 omitted the required changes for the MSVC build system in v16 through v12. Per buildfarm animal hamerkop. Discussion: https://postgr.es/m/7919238f-723c-4113-9742-ebce7a76a...@yesql.se Branch -- REL_12_STABLE Details ---

pgsql: Fix building with MSVC for TLS session disabling

2024-07-26 Thread Daniel Gustafsson
Fix building with MSVC for TLS session disabling Commit 274bbced85 omitted the required changes for the MSVC build system in v16 through v12. Per buildfarm animal hamerkop. Discussion: https://postgr.es/m/7919238f-723c-4113-9742-ebce7a76a...@yesql.se Branch -- REL_13_STABLE Details ---

pgsql: Fix macro placement in pg_config.h.in

2024-07-26 Thread Daniel Gustafsson
Fix macro placement in pg_config.h.in Commit 274bbced85383e831dde accidentally placed the pg_config.h.in for SSL_CTX_set_num_tickets on the wrong line wrt where autoheader places it. Fix by re-arranging and backpatch to the same level as the original commit. Reported-by: Marina Polyakova Discus

pgsql: Fix macro placement in pg_config.h.in

2024-07-26 Thread Daniel Gustafsson
Fix macro placement in pg_config.h.in Commit 274bbced85383e831dde accidentally placed the pg_config.h.in for SSL_CTX_set_num_tickets on the wrong line wrt where autoheader places it. Fix by re-arranging and backpatch to the same level as the original commit. Reported-by: Marina Polyakova Discus

pgsql: Fix building with MSVC for TLS session disabling

2024-07-26 Thread Daniel Gustafsson
Fix building with MSVC for TLS session disabling Commit 274bbced85 omitted the required changes for the MSVC build system in v16 through v12. Per buildfarm animal hamerkop. Discussion: https://postgr.es/m/7919238f-723c-4113-9742-ebce7a76a...@yesql.se Branch -- REL_14_STABLE Details ---

pgsql: Fix building with MSVC for TLS session disabling

2024-07-26 Thread Daniel Gustafsson
Fix building with MSVC for TLS session disabling Commit 274bbced85 omitted the required changes for the MSVC build system in v16 through v12. Per buildfarm animal hamerkop. Discussion: https://postgr.es/m/7919238f-723c-4113-9742-ebce7a76a...@yesql.se Branch -- REL_15_STABLE Details ---

pgsql: Fix macro placement in pg_config.h.in

2024-07-26 Thread Daniel Gustafsson
Fix macro placement in pg_config.h.in Commit 274bbced85383e831dde accidentally placed the pg_config.h.in for SSL_CTX_set_num_tickets on the wrong line wrt where autoheader places it. Fix by re-arranging and backpatch to the same level as the original commit. Reported-by: Marina Polyakova Discus

pgsql: Clarify error message and documentation related to typed tables.

2024-07-26 Thread Tom Lane
Clarify error message and documentation related to typed tables. We restrict typed tables (those declared as "OF composite_type") to be based on stand-alone composite types, not composite types that are the implicitly-created rowtypes of other tables. But if you tried to do that, you got the very

pgsql: Fix indentation.

2024-07-26 Thread Robert Haas
Fix indentation. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/c883453cb29cb40c1e59c3c54d159c5e744da8a9 Modified Files -- src/backend/postmaster/walsummarizer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)

pgsql: Fix indentation.

2024-07-26 Thread Robert Haas
Fix indentation. Branch -- REL_17_STABLE Details --- https://git.postgresql.org/pg/commitdiff/f2af1f4559ea74a6133ac36df3204c12e8d12ed3 Modified Files -- src/backend/postmaster/walsummarizer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)

pgsql: Fix building with MSVC for TLS session disabling

2024-07-26 Thread Daniel Gustafsson
Fix building with MSVC for TLS session disabling Commit 274bbced85 omitted the required changes for the MSVC build system in v16 through v12. Per buildfarm animal hamerkop. Discussion: https://postgr.es/m/7919238f-723c-4113-9742-ebce7a76a...@yesql.se Branch -- REL_16_STABLE Details ---

pgsql: Fix macro placement in pg_config.h.in

2024-07-26 Thread Daniel Gustafsson
Fix macro placement in pg_config.h.in Commit 274bbced85383e831dde accidentally placed the pg_config.h.in for SSL_CTX_set_num_tickets on the wrong line wrt where autoheader places it. Fix by re-arranging and backpatch to the same level as the original commit. Reported-by: Marina Polyakova Discus

pgsql: Fix macro placement in pg_config.h.in

2024-07-26 Thread Daniel Gustafsson
Fix macro placement in pg_config.h.in Commit 274bbced85383e831dde accidentally placed the pg_config.h.in for SSL_CTX_set_num_tickets on the wrong line wrt where autoheader places it. Fix by re-arranging and backpatch to the same level as the original commit. Reported-by: Marina Polyakova Discus

pgsql: Fix macro placement in pg_config.h.in

2024-07-26 Thread Daniel Gustafsson
Fix macro placement in pg_config.h.in Commit 274bbced85383e831dde accidentally placed the pg_config.h.in for SSL_CTX_set_num_tickets on the wrong line wrt where autoheader places it. Fix by re-arranging and backpatch to the same level as the original commit. Reported-by: Marina Polyakova Discus

pgsql: Allow WAL summarization to back up when timeline changes.

2024-07-26 Thread Robert Haas
Allow WAL summarization to back up when timeline changes. The old code believed that it was not possible to switch timelines without first replaying all of the WAL from the old timeline, but that turns out to be false, as demonstrated by an example from Fujii Masao. As a result, it assumed that su

pgsql: Allow WAL summarization to back up when timeline changes.

2024-07-26 Thread Robert Haas
Allow WAL summarization to back up when timeline changes. The old code believed that it was not possible to switch timelines without first replaying all of the WAL from the old timeline, but that turns out to be false, as demonstrated by an example from Fujii Masao. As a result, it assumed that su

pgsql: postgres_fdw: Add "used_in_xact" column to postgres_fdw_get_conn

2024-07-26 Thread Fujii Masao
postgres_fdw: Add "used_in_xact" column to postgres_fdw_get_connections(). This commit extends the postgres_fdw_get_connections() function to include a new used_in_xact column, indicating whether each connection is used in the current transaction. This addition is particularly useful for the upco

pgsql: postgres_fdw: Add connection status check to postgres_fdw_get_co

2024-07-26 Thread Fujii Masao
postgres_fdw: Add connection status check to postgres_fdw_get_connections(). This commit extends the postgres_fdw_get_connections() function to check if connections are closed. This is useful for detecting closed postgres_fdw connections that could prevent successful transaction commits. Users can

pgsql: pg_createsubscriber: Message style improvements

2024-07-26 Thread Peter Eisentraut
pg_createsubscriber: Message style improvements Refactor some messages, improve quoting. Branch -- REL_17_STABLE Details --- https://git.postgresql.org/pg/commitdiff/c0c005070817352e217baa430b04161890d9af5a Modified Files -- src/bin/pg_basebackup/pg_createsubscriber.c | 20 +

pgsql: pg_createsubscriber: Message style improvements

2024-07-26 Thread Peter Eisentraut
pg_createsubscriber: Message style improvements Refactor some messages, improve quoting. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/5687f8c0dd766acb15587a0af8b5208aa3841b21 Modified Files -- src/bin/pg_basebackup/pg_createsubscriber.c | 20

pgsql: Add test for early backend startup errors

2024-07-26 Thread Heikki Linnakangas
Add test for early backend startup errors The new test tests the libpq fallback behavior on an early error, which was fixed in the previous commit. This adds an IS_INJECTION_POINT_ATTACHED() macro, to allow writing injected test code alongside the normal source code. In principle, the new test co

pgsql: Add tests for errors during SSL or GSSAPI handshake

2024-07-26 Thread Heikki Linnakangas
Add tests for errors during SSL or GSSAPI handshake These test that libpq correctly falls back to a plaintext connection on handshake error, in the "prefer" modes. Reviewed-by: Michael Paquier Discussion: https://www.postgresql.org/message-id/CAOYmi%2Bnwvu21mJ4DYKUa98HdfM_KZJi7B1MhyXtnsyOO-PB6Ww

pgsql: Fix fallback behavior when server sends an ERROR early at startu

2024-07-26 Thread Heikki Linnakangas
Fix fallback behavior when server sends an ERROR early at startup With sslmode=prefer, the desired behavior is to completely fail the connection attempt, *not* fall back to a plaintext connection, if the server responds to the SSLRequest with an error ('E') response instead of rejecting SSL with a

pgsql: Fix fallback behavior when server sends an ERROR early at startu

2024-07-26 Thread Heikki Linnakangas
Fix fallback behavior when server sends an ERROR early at startup With sslmode=prefer, the desired behavior is to completely fail the connection attempt, *not* fall back to a plaintext connection, if the server responds to the SSLRequest with an error ('E') response instead of rejecting SSL with a

pgsql: Fix using injection points at backend startup in EXEC_BACKEND mo

2024-07-26 Thread Heikki Linnakangas
Fix using injection points at backend startup in EXEC_BACKEND mode Commit 86db52a506 changed the locking of injection points to use only atomic ops and spinlocks, to make it possible to define injection points in processes that don't have a PGPROC entry (yet). However, it didn't work in EXEC_BACKE

pgsql: Fix using injection points at backend startup in EXEC_BACKEND mo

2024-07-26 Thread Heikki Linnakangas
Fix using injection points at backend startup in EXEC_BACKEND mode Commit 86db52a506 changed the locking of injection points to use only atomic ops and spinlocks, to make it possible to define injection points in processes that don't have a PGPROC entry (yet). However, it didn't work in EXEC_BACKE

pgsql: doc: Enhance documentation for postgres_fdw_get_connections() ou

2024-07-26 Thread Fujii Masao
doc: Enhance documentation for postgres_fdw_get_connections() output columns. The documentation previously described the output columns of postgres_fdw_get_connections() in text format, which was manageable for the original two columns. However, upcoming patches will add new columns, making text d

pgsql: Disable all TLS session tickets

2024-07-26 Thread Daniel Gustafsson
Disable all TLS session tickets OpenSSL supports two types of session tickets for TLSv1.3, stateless and stateful. The option we've used only turns off stateless tickets leaving stateful tickets active. Use the new API introduced in 1.1.1 to disable all types of tickets. Backpatch to all supporte

pgsql: Disable all TLS session tickets

2024-07-26 Thread Daniel Gustafsson
Disable all TLS session tickets OpenSSL supports two types of session tickets for TLSv1.3, stateless and stateful. The option we've used only turns off stateless tickets leaving stateful tickets active. Use the new API introduced in 1.1.1 to disable all types of tickets. Backpatch to all supporte

pgsql: Disable all TLS session tickets

2024-07-26 Thread Daniel Gustafsson
Disable all TLS session tickets OpenSSL supports two types of session tickets for TLSv1.3, stateless and stateful. The option we've used only turns off stateless tickets leaving stateful tickets active. Use the new API introduced in 1.1.1 to disable all types of tickets. Backpatch to all supporte

pgsql: Disable all TLS session tickets

2024-07-26 Thread Daniel Gustafsson
Disable all TLS session tickets OpenSSL supports two types of session tickets for TLSv1.3, stateless and stateful. The option we've used only turns off stateless tickets leaving stateful tickets active. Use the new API introduced in 1.1.1 to disable all types of tickets. Backpatch to all supporte

pgsql: Disable all TLS session tickets

2024-07-26 Thread Daniel Gustafsson
Disable all TLS session tickets OpenSSL supports two types of session tickets for TLSv1.3, stateless and stateful. The option we've used only turns off stateless tickets leaving stateful tickets active. Use the new API introduced in 1.1.1 to disable all types of tickets. Backpatch to all supporte

pgsql: Disable all TLS session tickets

2024-07-26 Thread Daniel Gustafsson
Disable all TLS session tickets OpenSSL supports two types of session tickets for TLSv1.3, stateless and stateful. The option we've used only turns off stateless tickets leaving stateful tickets active. Use the new API introduced in 1.1.1 to disable all types of tickets. Backpatch to all supporte

pgsql: Disable all TLS session tickets

2024-07-26 Thread Daniel Gustafsson
Disable all TLS session tickets OpenSSL supports two types of session tickets for TLSv1.3, stateless and stateful. The option we've used only turns off stateless tickets leaving stateful tickets active. Use the new API introduced in 1.1.1 to disable all types of tickets. Backpatch to all supporte

pgsql: SQL/JSON: Improve error-handling of JsonBehavior expressions

2024-07-26 Thread Amit Langote
SQL/JSON: Improve error-handling of JsonBehavior expressions Instead of returning a NULL when the JsonBehavior expression value could not be coerced to the RETURNING type, throw the error message informing the user that it is the JsonBehavior expression that caused the error with the actual coerci

pgsql: SQL/JSON: Respect OMIT QUOTES when RETURNING domains over jsonb

2024-07-26 Thread Amit Langote
SQL/JSON: Respect OMIT QUOTES when RETURNING domains over jsonb populate_domain() didn't take into account the omit_quotes flag passed down to json_populate_type() by ExecEvalJsonCoercion() and that led to incorrect behavior when the RETURNING type is a domain over jsonb. Fix that by passing the

pgsql: SQL/JSON: Remove useless code in ExecInitJsonExpr()

2024-07-26 Thread Amit Langote
SQL/JSON: Remove useless code in ExecInitJsonExpr() The code was for adding an unconditional JUMP to the next step, which is unnecessary processing. Reported-by: Jian He Discussion: https://postgr.es/m/cacjufxeo4sujkcytda0_qt9tazqqkpmf1cqhw9kbouejfqq...@mail.gmail.com Backpatch-through: 17 Bra

pgsql: SQL/JSON: Fix error-handling of some JsonBehavior expressions

2024-07-26 Thread Amit Langote
SQL/JSON: Fix error-handling of some JsonBehavior expressions To ensure that the errors of executing a JsonBehavior expression that is coerced in the parser are caught instead of being thrown directly, pass ErrorSaveContext to ExecInitExprRec() when initializing it. Also, add a EEOP_JSONEXPR_COERC

pgsql: SQL/JSON: Respect OMIT QUOTES when RETURNING domains over jsonb

2024-07-26 Thread Amit Langote
SQL/JSON: Respect OMIT QUOTES when RETURNING domains over jsonb populate_domain() didn't take into account the omit_quotes flag passed down to json_populate_type() by ExecEvalJsonCoercion() and that led to incorrect behavior when the RETURNING type is a domain over jsonb. Fix that by passing the

pgsql: SQL/JSON: Remove useless code in ExecInitJsonExpr()

2024-07-26 Thread Amit Langote
SQL/JSON: Remove useless code in ExecInitJsonExpr() The code was for adding an unconditional JUMP to the next step, which is unnecessary processing. Reported-by: Jian He Discussion: https://postgr.es/m/cacjufxeo4sujkcytda0_qt9tazqqkpmf1cqhw9kbouejfqq...@mail.gmail.com Backpatch-through: 17 Bra

pgsql: SQL/JSON: Fix error-handling of some JsonBehavior expressions

2024-07-26 Thread Amit Langote
SQL/JSON: Fix error-handling of some JsonBehavior expressions To ensure that the errors of executing a JsonBehavior expression that is coerced in the parser are caught instead of being thrown directly, pass ErrorSaveContext to ExecInitExprRec() when initializing it. Also, add a EEOP_JSONEXPR_COERC

pgsql: SQL/JSON: Improve error-handling of JsonBehavior expressions

2024-07-26 Thread Amit Langote
SQL/JSON: Improve error-handling of JsonBehavior expressions Instead of returning a NULL when the JsonBehavior expression value could not be coerced to the RETURNING type, throw the error message informing the user that it is the JsonBehavior expression that caused the error with the actual coerci