postgresql/src/include/libpq
Fujii Masao 06a5c3cdef Set notice receiver before libpq connection startup completes
Commit 112faf1378 added custom notice receivers for replication,
postgres_fdw, and dblink so that remote NOTICE, WARNING, and similar
messages are reported via ereport(). However, those notice receivers were
installed only after libpqsrv_connect() and libpqsrv_connect_params()
returned, by which point libpq connection startup had already completed.
As a result, messages emitted during connection establishment could be
missed.

This commit fixes the issue by splitting libpqsrv_connect() and
libpqsrv_connect_params() into separate start and complete phases:
libpqsrv_connect_start(), libpqsrv_connect_params_start(), and
libpqsrv_connect_complete(). This allows callers to perform
per-connection setup, such as installing a notice receiver, after the
connection has been started but before startup completes.

Note that callers of libpqsrv_connect_start() and
libpqsrv_connect_params_start() must still call
libpqsrv_connect_complete(), even if the start function returns NULL, so
that any external FDs reserved during startup are released properly.

Author: Chao Li <lic@highgo.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Vignesh C <vignesh21@gmail.com>
Reviewed-by: Rafia Sabih <rafia.pghackers@gmail.com>
Discussion: https://postgr.es/m/A2B8B7DE-C119-492F-A9FA-14CF86849777@gmail.com
2026-05-23 00:25:48 +09:00
..
auth.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
be-fsstubs.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
be-gssapi-common.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
crypt.h Add password expiration warnings. 2026-02-11 10:36:15 -06:00
hba.h Declare load_hosts() as returning HostsFileLoadResult. 2026-05-04 18:33:06 -04:00
ifaddr.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
libpq-be-fe-helpers.h Set notice receiver before libpq connection startup completes 2026-05-23 00:25:48 +09:00
libpq-be-fe.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
libpq-be.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
libpq-fs.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
libpq.h Declare load_hosts() as returning HostsFileLoadResult. 2026-05-04 18:33:06 -04:00
oauth.h oauth: Allow validators to register custom HBA options 2026-04-07 08:15:19 -07:00
pg-gssapi.h Pre-beta mechanical code beautification, step 1: run pgindent. 2026-05-13 10:34:17 -04:00
pqcomm.h libpq: Prepare for protocol grease during 19beta 2026-02-06 10:31:45 -08:00
pqformat.h Revert "Replace pg_restrict by standard restrict" 2026-01-14 15:12:25 +01:00
pqmq.h Don't include proc.h in shm_mq.h 2026-02-27 10:53:47 +01:00
pqsignal.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
protocol.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
sasl.h sasl: Allow backend mechanisms to "abandon" exchanges 2026-03-31 11:47:31 -07:00
scram.h Update copyright for 2026 2026-01-01 13:24:10 -05:00