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.94.2) (envelope-from ) id 1thmMp-006lKa-Je for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Feb 2025 09:15:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1thmMm-0093KJ-Ad for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Feb 2025 09:15:40 +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.94.2) (envelope-from ) id 1thmMm-0093K8-0u for pgsql-hackers@lists.postgresql.org; Tue, 11 Feb 2025 09:15:40 +0000 Received: from mail-yb1-xb2c.google.com ([2607:f8b0:4864:20::b2c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1thmMj-000CB3-1X for pgsql-hackers@postgresql.org; Tue, 11 Feb 2025 09:15:39 +0000 Received: by mail-yb1-xb2c.google.com with SMTP id 3f1490d57ef6-e5ad75ca787so4531014276.0 for ; Tue, 11 Feb 2025 01:15:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739265336; x=1739870136; 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=LFScWkxwuLxaSVsCm2yNStbRI9qXyi62fMp6EXxG17E=; b=Q5dgX87PY/iexp0mprxp0d+OHXVrCPPxrVp1NYwqsi1ItjDkXXmphiofyOk4TYdIeZ 3zzIlzpjw/7On58BX0qHoIEEWt+iLhJfq8zuNmdl4oa1G1Gl3ygSxSVlbO3soz6/MJsU ib/3DNqcnrs5d6nVkCKOGgzSuLEV3wDWWZux8MrSuYkcZd4PEf9aTWGU2nyD8oaPAM0R wlUDj+sZ6grvoyl+Ae1834Enz9wy/ZCu20iSieyNgm/qDmwgiDaqZ/iNRKIFiu3p1c6n 3Iqs3/0u6Cvq8oDbcJ2NVqp/bPPa6oEC15dRIcerxesYd95t0bFaHhdwqr46011LVxuS jjsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739265336; x=1739870136; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LFScWkxwuLxaSVsCm2yNStbRI9qXyi62fMp6EXxG17E=; b=k1LFXwjlb0qBxmexEbACgt3qfbjzlydob27UvexVirKa3MkrxJyANZW0GERw/e93zs FlXMJoDnC9IdR90gDiRz1gpMbZt2WdMnApuHp6y8MDxdo/gt9sd07ZxQvsQ+RZo5GZlp n0NC8T0SF7x+YCK2DUmuSg6GtOKcMp0e1WoahAzEP0l5thp3yDEJd6zerQSfGzhdLYLP uQtuD9VMxize8nCq+Jc/vBsEBDUD9oDavlmp0UMQyP+OdgbNyaS9zvNUTdgQtZKtOmt5 5UERvsuDwYwex5ycRwKywEVnGhLFR0bkUPoD7sIXIQ3KxbsbGfCp6Z8aKJZJHHCWOoZv LUqQ== X-Forwarded-Encrypted: i=1; AJvYcCV9aOfUQHlbThJFxCPTmXAlXS09DFXA89GUxwa0cZRg7JH2ERKx2Wj0lFMfQehNejRQt8Dg8C/pyBYMfq/w@postgresql.org X-Gm-Message-State: AOJu0Yysn4np6MeYo5MDYkv14EcCxKHYET0IYQFxFOS2iRFutcVHxf2Y dQGzz+icyuZD8XdKAsst0PdV2M4bRmECzXR/b0Y1871748DGNT7R+TDHtKIq0UIrgm+oXb7I8/v GkitVMw7YWu2liGPJqlsWL9fSjQHGGrlz X-Gm-Gg: ASbGncs7l5tKC3+RjzGjhcuV92G+WVWO2ZcbV+ZDfb75RDlYt4D3ye8xRD9hpTuQ9Xv USTXwYxTAM1Sj6qaR+dZ9LntIE2dWV4d/g4sJlWvN6xdOuPRSIBITA1GFDjzfu6eqFvrzQ5y6 X-Google-Smtp-Source: AGHT+IGJGUtTWSIczsUbS+tvPQlSEOWwZRICg/rmnb2SeaHlTiXj852BhqNX6+BzRAVApM20DSBdCyhbmms5TbQ2dZ4= X-Received: by 2002:a05:6902:a84:b0:e5b:5fdb:9af8 with SMTP id 3f1490d57ef6-e5d94547eb8mr2943784276.20.1739265336019; Tue, 11 Feb 2025 01:15:36 -0800 (PST) MIME-Version: 1.0 References: <09800cb1-43aa-4239-8918-46b71ede4900@eisentraut.org> <536b281b-2cb3-4477-971f-c64838bc6263@eisentraut.org> <51875199-d5f5-41ed-92dc-3e7b1b996991@eisentraut.org> <84adfb1b-826c-42b2-a907-b327d3760c7e@eisentraut.org> <831d7f99-0618-48e5-8557-f3d57137f339@eisentraut.org> <64c2468c-3b69-44d7-863a-165931a70c1d@eisentraut.org> <8be3512a-a23f-4088-a9ec-bf68650a2997@eisentraut.org> <75eb1a6f-d59f-42e6-8a78-124ee808cda7@gmail.com> <8d6a3d4c-f630-4cf9-aced-6cead95776e5@Spark> <12d5cce9-917f-4a99-86d3-715bb3b363bb@Spark> In-Reply-To: From: Richard Guo Date: Tue, 11 Feb 2025 17:15:24 +0800 X-Gm-Features: AWEUYZnyyEim5k253a9S-o1tpB7LobNwcLRg3xj5CCVoFKiYk7xMJLaELj7Np_o Message-ID: Subject: Re: Virtual generated columns To: Zhang Mingli Cc: jian he , Peter Eisentraut , Dean Rasheed , Alexander Lakhin , pgsql-hackers 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 Tue, Feb 11, 2025 at 10:34=E2=80=AFAM Richard Guo wrote: > Yeah, I also feel that the virtual generated columns should adhere to > outer join semantics, rather than being unconditionally replaced by > the generation expressions. But maybe I'm wrong. > > If that's the case, this incorrect-result issue isn't limited to > constant expressions; it could also occur with non-strict ones. It seems that outer-join removal does not work well with virtual generated columns. create table t (a int, b int); create table vt (a int primary key, b int generated always as (a * 2)); explain (costs off) select t.a from t left join vt on t.a =3D vt.a where coalesce(vt.b, 1) =3D = 1; QUERY PLAN --------------- Seq Scan on t (1 row) This plan does not seem correct to me. The inner-rel attribute 'vt.b' is used above the join, which means the join should not be removed. explain (costs off) select t.a from t left join vt on t.a =3D vt.a where coalesce(vt.b, 1) =3D 1 or t.a is null; server closed the connection unexpectedly For this query, an Assert in remove_rel_from_query() is hit. I haven't looked into the details yet, but I suspect that both of these issues are caused by our failure to mark the correct nullingrel bits for the virtual generated columns. Thanks Richard