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 1wEcpb-004DdH-0e for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Apr 2026 00:49:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wEcpa-00H1Zi-0o for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Apr 2026 00:49:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wEcpZ-00H1Za-35 for pgsql-hackers@lists.postgresql.org; Mon, 20 Apr 2026 00:49:41 +0000 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wEcpX-000000023DY-3jjL for pgsql-hackers@lists.postgresql.org; Mon, 20 Apr 2026 00:49:41 +0000 Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-b941762394aso325086666b.1 for ; Sun, 19 Apr 2026 17:49:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1776646178; cv=none; d=google.com; s=arc-20240605; b=G4yxEmrRLPAey2yf0fShE1SMLF3EHYkUAcyprDu4vwD0Nlq82GnmevmSZIJq02xOvV 7wHQPKIg2br57WYi5bBOllP5Hmh9gDuxqAwl2WCe4tNY9kFzvtblBmo2XAgwwMqpC9Bp ssYb5LcVoh3pqqUiGfb6b2L8/ZcmDyukPlRVoE/Uk9uW/6hubAyxVQfUlORwl4/gfA1H 7wjOn1LisUd5BIsDtoQZpuREppfmaMAvF2pYT1bG2SKBkkJS4EKZj56igJyeOSt+9ODZ LlloZ09I1wYR5ut9yyUOFdlQtCqI6i0cTp6Uhk1/P0W3X+PCkMoQUv+MVNN0pYDNKVrJ vGLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=qbYewF0CsoEi4wfVbvUkj1A8FEhO8gkJK4e7j1KtJFc=; fh=NOo30AAV3JZ2gV+RE/nn4WjuTPJNrVMgF4c+LPp6+pw=; b=HVnlXjsR2YaM5RLD4k4p/dXtfuAcnVvE+rHK+4winnmCwAdEBpbkLtLra41+kujvrQ vfj/9kZfmo+5RaKp06Dh1+G82uX+s+7h27pyNe/Z4l3UoqsmL2XKhJJG6gJNLwI4TSd3 OV/PbOv2R4uUHgAR3X9VFo8wiPJvnOjOZH29nXaNq/4NBPVThf1I8ININHf2H5Hqvaxo 5uDuW9Pd0qMeh9w/CPPh/NUIbSarELCniUz1L6aD+bf6+tQpShk9YDspCBzDpsQgvgJ6 7wmY3mgU1SkW7k39vaIqxEzA/DA/Ww3hY+1gxSy15CC4nU0DC9iRvdyZ8tN7e7/RO49h mnZw==; 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=1776646178; x=1777250978; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=qbYewF0CsoEi4wfVbvUkj1A8FEhO8gkJK4e7j1KtJFc=; b=oAIW6xFqVduuNjGOcMFAmtEhWRzkaNNk2YbBvLbCt/hZZI7gg/KEG+fKFwVa5f5q5Z XvwZNh2OW9SApgxlQ3zSOwx6PxFW70s5dha/b/zS7gfEGfnGlarwKabd2Sw2P4hS7/d6 1GLZo/oThiB7pi6ugxK5MqmovnBb/+ycbaNVG45EeV1/BHQrbtBtWClSFI64jTwLKDNz pFa+jaR5nlQ+17F44ywE/vdrjuzEBCyTIjysYNF7lw5CMjVfWEt9V4M0yBBWTkw6Y892 6tkhvYZwogAeLASDyF5E59Bp6rkkPsWFnD44MiixmcSFv4NYD/VhjcnCZe2dUqwGGiuJ hexA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776646178; x=1777250978; h=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=qbYewF0CsoEi4wfVbvUkj1A8FEhO8gkJK4e7j1KtJFc=; b=a5HyXFV1sye1TX11+EWlx9QfiXcRcRYN4Qdxrcu0rbbMp3XR8z95Hn+N0Q7iLI3vUr fYXnJsPfRSnj166RGvCneHisifoLLFScFL+TyZWg5DzHSbDbouOYUD8E6DEE6SCe+hZ5 FhBXwdwnOGJJ0BI5zleSKjc/0zO1EO1SxF0UMX1QzeXaaNHDsIr5MALnPr9ME3826YH7 RoNSeDn08QnYiB7vdAhdsJnhZsB+yOJE6glTsk8di0+d/fQZyQcH9fJpJW749he4Vgw/ RVg/TXcgE9j1LeE9eEYMAQ+voDnCey7yXsB+E+iu+F8TKmZxySwy0AEsYtpkYwgUNC3l UecQ== X-Gm-Message-State: AOJu0YzrFB/4kvU9GummvAzQRAbdoVkOTyeCnAsQrXqu7Fa/5L+jZgnj nTGB2TgRgEAHAIsg84m7dFRH3uuZ03V9HUz7xozqjJvZE3PrPR0WOuWWjPm5cVH1+hPiuV6VcPt Xop5lyXmeygbRRbgMow+Z+Cz3kqg8OF0= X-Gm-Gg: AeBDieugjCYVjxiauHUr8jyX0+hzIwpi9O93eHH39KJEvu1U3LogzsgD04KGjKcOjHo OpLpw7CCTLeRNi6tROrV3RFhxMgeMBnmV5OGviN/N9RQBAsnzY3lbvJEyFfckOUy7plzoYYXd45 95SLrj1Il0mLLu2cIvOvMthCkBvgyV9X1nKRSe95/XFN/uC3in1TSMmK8vc8aCemLP1SMvQbyVe ZfDkL8fBbhirAntEeR1ZzwQvp2zzMOzyLdw3/Q8J2Y/VBuZ+j0p8EZvYEseflosGoGFVgfz6c1q jV189U01x7osc1DlbdnvTo9qZtyATy64/o0KzkQnkKEcw8oy X-Received: by 2002:a17:907:86a1:b0:b8f:848b:4456 with SMTP id a640c23a62f3a-ba418e86492mr538122866b.13.1776646177259; Sun, 19 Apr 2026 17:49:37 -0700 (PDT) MIME-Version: 1.0 References: <7f6439c7-e5a7-4d0c-82c9-4087794cd9d0@gmail.com> In-Reply-To: From: wenhui qiu Date: Mon, 20 Apr 2026 08:49:25 +0800 X-Gm-Features: AQROBzCTdghS19HL3I6FcydQzkngOsuTePgDK88pzqYpGUUUAPhTCf14Ieno9mI Message-ID: Subject: Re: Clean up remove_rel_from_query() after self-join elimination commit To: Richard Guo Cc: Pg Hackers Content-Type: multipart/alternative; boundary="000000000000498544064fd9ac04" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000498544064fd9ac04 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Richard > Assert(!is_outer_join || joinrelids !=3D NULL); > Worth asserting. If a caller sets sjinfo but passes NULL for > joinrelids, this would silently over-delete PHVs. > Assert(!is_self_join || joinrelids =3D=3D NULL); LGTM with the added assertion. Thanks again for all the heavy lifting you're doing on the Postgres optimizer > I prefer to not add this one. It's not defending any invariant. Thank you for your explanation , Thanks On Sat, Apr 18, 2026 at 6:17=E2=80=AFPM Richard Guo wrote: > On Tue, Apr 7, 2026 at 6:57=E2=80=AFPM wenhui qiu = wrote: > > Assert(!is_outer_join || joinrelids !=3D NULL); > > Worth asserting. If a caller sets sjinfo but passes NULL for > joinrelids, this would silently over-delete PHVs. > > > Assert(!is_self_join || joinrelids =3D=3D NULL); > > I prefer to not add this one. It's not defending any invariant. > > - Richard > --000000000000498544064fd9ac04 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi=C2=A0Richard
> Assert(!is_outer_join || joinreli= ds !=3D NULL);

> Worth asserting.=C2=A0 If a caller sets sjinfo b= ut passes NULL for
> joinrelids, this would silently over-delete PHVs= .
> Assert(!is_self_join || joinrelids =3D=3D NULL);
=

LGTM with the added assertion. Thanks again for all the heavy lift= ing you're doing on the Postgres optimizer

> I pre= fer to not add this one.=C2=A0 It's not defending any invariant.
Thank you for your explanation ,=C2=A0

Thanks

On Sat, Apr 18, 2026 at 6:17= =E2=80=AFPM Richard Guo <guofe= nglinux@gmail.com> wrote:
On Tue, Apr 7, 2026 at 6:57=E2=80=AFPM wenhui qiu <qiuwenhuifx@gmail.co= m> wrote:
> Assert(!is_outer_join || joinrelids !=3D NULL);

Worth asserting.=C2=A0 If a caller sets sjinfo but passes NULL for
joinrelids, this would silently over-delete PHVs.

> Assert(!is_self_join || joinrelids =3D=3D NULL);

I prefer to not add this one.=C2=A0 It's not defending any invariant.
- Richard
--000000000000498544064fd9ac04--