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 1wVWHQ-0021Du-2e for pgsql-bugs@arkaria.postgresql.org; Fri, 05 Jun 2026 15:16:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wVWHO-00D1OP-24 for pgsql-bugs@arkaria.postgresql.org; Fri, 05 Jun 2026 15:16:14 +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 1wVWHO-00D1OH-1I for pgsql-bugs@lists.postgresql.org; Fri, 05 Jun 2026 15:16:14 +0000 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wVWHM-00000001FvZ-1DFv for pgsql-bugs@lists.postgresql.org; Fri, 05 Jun 2026 15:16:13 +0000 Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-36bdb11bf8bso1206719a91.0 for ; Fri, 05 Jun 2026 08:16:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1780672570; cv=none; d=google.com; s=arc-20240605; b=Hp83dwQpST6uvJFTtaabv91I4ch70yKMmWR/6JLvXognpG4M3yhyEKIEpmUqcDTDby 1HgE12HV07lpsjFsh2WpDbN6n5eooO9dKPodDci+glI1dDiDKmNbCDFoSbGzBOpweE8l EmN9bcpCLsIkCd1zd1OPsYuOBRxVFoFuvdgNbP6SFLfH0A+9pWFi9DwTRDStVl8QCRUP H7Ff03ST6RMi9ghvYsy+DUsMmBSCtkX6KmzKQoCjPb1NWlXF/M5OQNJqbMCrl9SaYBK9 FwKLPP9QefYkZLvxFYX2qhyBKUNv9fDcDMadQ9THkWTp54sPLh3f+o45PheiewT70pNa e3jg== 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=jf1U7Veszf3xwNSu7JE9/xfzrpjnz7kDryAfL336R3s=; fh=KZdKKFsPuuIjfuPx1/87O/F62ivrct7APARmXjqxcJk=; b=RNfd11n3ocEVd5PIMIV0GEinpUVuersh+86R3ClPZSzq4csKus2e0NaWzwqsaIQqVX 3RMApCR7j/oVteKQbYnxzzfiB6zeKM+kwStgnO6Ortc7tSwZF/CJeeyuOXiUa9HqSmyQ c6t8l2kOZJcmM2IjNL/t/Wd38dqyZKFgC/qHzu337pBZdh9dBpCIXgsafJl3sLNG3+/1 S/FyD7xgz5hmhJiSmiL04aOzJ3DtSIfHN+T4bfWSwzW2hGoAvWQ2+O9kx9zm18/gvCPM nxzul78E36ThbNPHacYO0AbC2j8csDJfuv3pWIAPt/lZ2mXMXlxUpIb5BdEY7t10ax2e Uqfg==; darn=lists.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=1780672570; x=1781277370; darn=lists.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=jf1U7Veszf3xwNSu7JE9/xfzrpjnz7kDryAfL336R3s=; b=SWQzNjFiH2isQwOgKj0GBqQ+SCsPCGcAGFHSE2loMDNsACthqBaDHqn+Mxko6yRnL7 LoEJAK1oI6rTmNpJp7iuLRcxaDoOL+GaCfeLYWGatKDX42K7+PxdkAud6oe014r22zSV BDfzFTOVLvavNO1dL4669vnUId8T+o8FaLwbzzmuPQX209DsvSEktCZsaKCjqHNSU9Vy E7q+hX/YTWdKO1GAmapiBMzMkgKulc/9P9WwhYmB6j4McKaNbDW0AynEQyZdbDQxgz3c MW3uzJfMAMm36FIR0HGa7vqqCkgWHwE73qOBz2L0kqzGFoSWqrryVU+zyrwYYsk1qKMy X3Qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780672570; x=1781277370; 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=jf1U7Veszf3xwNSu7JE9/xfzrpjnz7kDryAfL336R3s=; b=GpMdGTewMIns/iB+YmYEq95fQvwclwC3b80A27Fg8h/LUN2H6jsMtJvXBgyYLrs+Nh CeLr2IqsoEwnBHvlKzdIqjBZEMCSktI7Z4/vrqGlajxDMfOsiRIFHvHDEkOI12BCOSjq PwDMqsCoGnxUnVi1Q6Wb/9wDdGiA0AldVLhGeqdDHu+rNa0ow2bhf8wpbZIvuIRjFZN9 D0nq0LbiU7XsJGwyCeGiTpxLBtdzLOv0pyQb8E1r1np4qZa6fAdfjYEiOgpSL4v4LrET T6jlaHrUCjhXzDpSPEFPmZ45KZnrr9q+BuPAKGuNksE3YsioZoTwAk0IaKpn7QERMn87 5WIw== X-Gm-Message-State: AOJu0YykLiib4gY2KwL/bqevXZfbz0ASiDvzK2Q9Lbh6rtk2xZnwF6SZ 92VtYaO3tywHMIdfzCukozur3envRQS2RWIx68e602cZmNZ2RradLlzIXFhyj1iGy/Xo990xz7s pDyCsTHBHrAFLc304fOGWrOKuCSYL0qs= X-Gm-Gg: Acq92OEg6IcXB11eMFhDtqF2ggHuPBZ++JeS49atHB1zfZZRB3l/lI9twS407UpeRcU E3xAFnL9zCGpjfwiDqIxGXMz3KEkAVaFqCkferLOU9W8TG2tCLnXnLzqHDOKeu+WwiOwILgrmF0 o5mC37WywesXJJMddnFSHBIjPe5ixScDH4HKj8KK7DIbGI1GfdLnQNr9aMAHkgSn8IE/K44Mb5x l7EekH5Tpc+3asmzoXokyiJt6CfuussnrPqpe1yg6S/0DjI63oby6qR7soOaV9GfTFr5yQqXxHw cqb4oMHb8To2T/UKGzqmXXCzTfolE2VnRvGls+xmAyuYr6td+oXA X-Received: by 2002:a17:90b:580e:b0:36b:944b:fd81 with SMTP id 98e67ed59e1d1-370ee82e03amr4286207a91.4.1780672569578; Fri, 05 Jun 2026 08:16:09 -0700 (PDT) MIME-Version: 1.0 References: <19511-f9f251767b658232@postgresql.org> In-Reply-To: From: Fujii Masao Date: Sat, 6 Jun 2026 00:15:57 +0900 X-Gm-Features: AVVi8CfpcJxcbZ8S7Mxq7DjEIJBDHbr6Tr0ntxzkhPImzD7Vr_V-oDnJVeIAP9Y Message-ID: Subject: Re: BUG #19511: contrib/dblink: NULL dereference in dblink_get_notify() when called without a prior connection To: Amjad Shahzad Cc: pgsql-bugs@lists.postgresql.org 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, Jun 5, 2026 at 7:55=E2=80=AFPM Amjad Shahzad wrote: > > Hi Fujii, > > You are correct. I checked the libpq source and both PQconsumeInput() and= PQnotifies() have explicit NULL guards: > > /* fe-exec.c line 2003 */ > if (!conn) > return 0; > > /* fe-exec.c line 2688 */ > if (!conn) > return NULL; > > So no segmentation fault actually occurs. The function silently returns 0= rows when called without a prior connection instead of crashing. > > The real issue is a behavioral inconsistency: every other dblink function= that uses the default connection explicitly checks for NULL > and calls dblink_conn_not_avail() to give a clear error message. > > dblink_get_notify() is the only exception, it silently returns an empty r= esult set, which could mislead callers into thinking no > notifications exist when in fact no connection was established. dblink_get_notify() was introduced by commit f4095b4c4b2 in 2009, and it appears to have behaved this way ever since. So there may be existing systems that depend on the current behavior. Also, there do not seem to have been any complaints about it over the past 10+ years. Therefore, unless the current behavior can be shown to cause actual issues or risks, I'm just feeling tempted to avoid changing it... At the very least, I don't think we should change the behavior in the back branches. Thought? Regards, --=20 Fujii Masao