Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wQQ8o-001XrD-0z for pgsql-hackers@arkaria.postgresql.org; Fri, 22 May 2026 13:42:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wQQ8k-00DFGN-2g for pgsql-hackers@arkaria.postgresql.org; Fri, 22 May 2026 13:42:15 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wQQ8k-00DFGE-1S for pgsql-hackers@lists.postgresql.org; Fri, 22 May 2026 13:42:15 +0000 Received: from mail-oo1-xc29.google.com ([2607:f8b0:4864:20::c29]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wQQ8j-00000000HCf-2OIK for pgsql-hackers@postgresql.org; Fri, 22 May 2026 13:42:14 +0000 Received: by mail-oo1-xc29.google.com with SMTP id 006d021491bc7-69d69fcdb44so1459555eaf.1 for ; Fri, 22 May 2026 06:42:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1779457333; cv=none; d=google.com; s=arc-20240605; b=BixrG0DtQMUcAjiBt2iuwlEB3wE0wgIln6jaPXupnHk7zk6b9vFSijnrH0aZIfU2v/ RFoPTsOQ1XEZu4YyG29BMTXI3JMGxHpwEjhNGFCrdNorII1kmsezKrojiHSJbJoekcQk eqaU/I3erdrg/jcpMajvIsdlQvoA6+ZdkSfNn6X0IARL2QrXhlu+bIzaZBK58fkb9O16 66Fc5InP4Yx6nyyn9GWU/wbIRiGSMdSHdhxTQx9eat9PBLrf6QpIy9fx8Bh/SOmKTc6F sZ0cWXOXMkZ/t4JCBO/qV2avhLGgiM34sqlYt21oGkSVoZiWMyfmcQoe6EpR06o/PXtR jx0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=hxa80NxUorZH2FqDBhffq2k8tjsv8TyztCKXlA5LXLE=; fh=CrAIMn2UkJ6y+DAZ0xc6+I2y1uM00JynRsBf/q/dYzA=; b=XzvPwKoWdfpHixQoEBOq09OPF99lN5VOBCl3LDNuApPoC7Y1+wGESncCNv+q+QCtO5 T3XTTev7OLDqB8kSx0FaEE4r0gEJS7FSqzoRdmkys4M0R8e9F8IoRBZi0iLbutgE6Nwd Gday5ZlKvAeY7CelBfUfvvjTQ4SmJk1WrWd9HZRawEYKmc2A6ozp3A3iFUTVaN4OBhIa MuaztSSbfPJ+r7HgAGEaDlJhuF7xjMPA3tj2eCjEPsUEBvJ0ilI+Rvwl4bdvS75y73lB XEbbmFq2uUdkDBq3UvdYOglekvXit9QduKVoO9drfWp5b0kKM/povSOvmLBhp+KaLC0/ UmHQ==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779457333; x=1780062133; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=hxa80NxUorZH2FqDBhffq2k8tjsv8TyztCKXlA5LXLE=; b=FrA1K6i/IG/LyL011xBUhmg/35et42hpPj+pButvFiw4Xt79+6NmThAL7R2IaEJ86V EVDdv3qnOCNjw58z2CtH1NNI9MMSJgez3Nlrtge+1DQsHa6YPKinrKK9Kvz8Qu8Fxp2T 92vI1n+OFGSemjeO0tJ76lgP9otDRjX66E5DFceDaEG7kG9lA2bhv06P37Cydp2sNZfk 6rgxkL6jRAEOUWz0xyaye2x8QVd5/yy1tsCGHMAZMI10tHQes/782xQ8YGkbqj9AU7vd wAmfBgvS3EFFN+xYdJf0RMxYk1pVtj1eaQd3kDa9gUW99o/5GSrIq/hvJZTjGELKGoMt nSrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779457333; x=1780062133; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=hxa80NxUorZH2FqDBhffq2k8tjsv8TyztCKXlA5LXLE=; b=G5gyWt/faO+uPe3ac0iq+Bo2cxd+cmX2PfQfl/ynCEWUu/o1AAQRqUYrfUCsCVMVfd Es1jtwsJlqdO5LWSaDOimNsHwJK3SfCh90ECjxwOk6JMvW1U8jkrfpV/a4YcWXVzTHFf PdleNUThmd6pVS/0+PkIinkHltVS/nwiltJ80SD5DO+rTd/OccuO1po2tGJ84qleeXSl DKPrZ4quno9si0vJgzVcoHxCpyuu5bSmOeiVR4LA66gIwgZNMZqFTE6HdYttAcxd/VvD /3pFRrp1WrvKNYUuo86DsCeOcVuQY4+wz3nwmFK+GwZ7sb5ue0wtA1+11uGnIek393pd MdTA== X-Forwarded-Encrypted: i=1; AFNElJ+gpX6g5BUtvzv3wXIACjwJOiabLCmpPEvxlsXtQ3LljktiOMFYwkoeoXxQ1dLvgxejCRJCasOqc9wgrTw9@postgresql.org X-Gm-Message-State: AOJu0YyF+GSbqQrGx48/JJqLr0C16sOWTM/rSsFQbMPOI6sGKsZbcyOF BR8WbjuvkYTuA9S7OuroSwbKgKlzUx4he/oyDzcxBNy2Pshio/DHl2nJQ5vVwb56PZNra2kApyl 79DxYFnPZ2e+Ib55OP7Jw0z1txOv1qV4= X-Gm-Gg: Acq92OF63l7irSnUqoidw0x3s6KEUL0pN6y8MpRdTRxhvGfThAEhPDL8TE//66EunV4 fvhwh2zHuTnpx1bHNMs8n0ftIlOi9YZSotL/Sabtl2mdQ6rTD6yJ/uY47jrBMP+PMsHbegSt2vT jpo4T3k5LOTw0nPlg62IW0y8/kiz0aXge7FGMIOJBTXw5fnwxXCNiNdpK9t8AHV+gLBc1rg+PwT tjbFkOPCWtHL9lFP76q6/JD3HcAKakSMSxRXZERW5IhADkkgMy29CcpPnzn2pr1mjRAvWzku2Jc 3uO2vl3n2PFPa0wcm3+qflUcN+BX3m6kmMlB9azSsA== X-Received: by 2002:a4a:edcb:0:b0:688:7dbe:5ff7 with SMTP id 006d021491bc7-69d7ed3a2bamr1876196eaf.56.1779457332739; Fri, 22 May 2026 06:42:12 -0700 (PDT) MIME-Version: 1.0 References: <978D8971-08C3-4AAD-AE8B-976D753C882A@gmail.com> <6B9A85F9-B632-4286-98AF-9EC435019055@gmail.com> In-Reply-To: From: Fujii Masao Date: Fri, 22 May 2026 22:42:00 +0900 X-Gm-Features: AVHnY4IYE2OL7YB_TSmju2lPc_ipXPWCIPKAC8XQVJtn_gRu6dyxRmbDSLrzXWg Message-ID: Subject: Re: Set notice receiver before libpq connection startup To: Rafia Sabih Cc: Chao Li , vignesh C , PostgreSQL-development Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, May 22, 2026 at 8:33=E2=80=AFPM Rafia Sabih wrote: > Here are my two cents, > we need not to check conn is null here > + conn =3D libpqsrv_connect_start(connstr); > + if (conn !=3D NULL) > + PQsetNoticeReceiver(conn, libpqsrv_notice_receiver, > + "received message via remote connection"); > because it is done so in PQsetNoticeReceiver anyway. Also, since there i= s no else here so it doesn't make sense more, because if it is null then al= so we will just continue with the next function call. Yes, but I'm fine with the current code in the patch. That code makes the intent explicit, i.e., install the notice receiver only when a connecti= on object actually exists. That said, I'm also OK with simply calling PQsetNoticeReceiver() without that check. > Another point is, in pg_connect_server I don't get the value of adding an= other PGConn variable start_conn, can't we use conn itself...? > I hope this helps. Not only connect_pg_server() but libpqsrv_connect_complete() has a PG_TRY/PG_CATCH block. So if start_conn were not used, an error thrown in libpqsrv_connect_complete() could cause the current connection (conn) to be cleaned up twice unexpectedly: once in libpqsrv_connect_complete() and again in connect_pg_server(). I guess that's why Chao introduced start_conn= . Regards, --=20 Fujii Masao