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 1w0U63-001wbJ-0x for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Mar 2026 00:40:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w0U60-00CfbG-2e for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Mar 2026 00:40:13 +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 1w0U60-00Cfb8-1K for pgsql-hackers@lists.postgresql.org; Thu, 12 Mar 2026 00:40:13 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w0U5y-00000001h2p-0Weg for pgsql-hackers@postgresql.org; Thu, 12 Mar 2026 00:40:11 +0000 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-2ad9a9be502so3391745ad.0 for ; Wed, 11 Mar 2026 17:40:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1773276009; cv=none; d=google.com; s=arc-20240605; b=Iqys3aZUU4bNERIhm1gdOP7O8LyG3pjds2EBEYsAHSDFt/zQjCNJrnD6gCPYJs7CDP acpRMaKd90x4tYxke3V6cDdZ3LptLugjW/IauV5FQPuYsE2WK+HUbvhJEsBEz9W6EMBZ YcOa8LH9JYyArqgPw5KCaRE849HegZPgSJjAMaDmMwQOwavyH/gUkPgbJ4xiOHciyd7H 7MGbbK5310ly7pSD0k7CQ2QyJlW0tW7doiGu5gesaepHrDTXPuOQ70WqU82wnXuKcPGX ZN9m2+/ZoZOrFXxvLPEoz8WJP58uQCYpivyo8dCXMLOUXV56kj1I6UU4PwY/S1xrEp2w 471g== 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:reply-to:in-reply-to:references :mime-version:dkim-signature; bh=2a0YkbViEQUmmUH6hhvH0LQvEGy8TnMImn8H0ZS0h0w=; fh=whb+FzeSZYPL4KhpDtsk1oNLBO1lrwSYgJRSw3acass=; b=JWfkVp6CMCTuPDPgRf5KHDlinlqqHV23Eqlelyru0UTBSLIjRMgr56dE1DMGr/6Eo8 Q+0+5elKRBEnr/P9gxmWKsOnW/axLgBFeLHpZGdjK/k8Aqzr+aY/bgDOqLPl/BsrjWJJ 7DTSV8lAMomRXOgl6TzM1C6yjboS50Ekv3PNFRDV69XIP7eN23F58hPg/kUo8+xsmWeM szIp3wcyL/wUh8mrjrg5sSW3unZ0xTB2jSOHLPGMu6Q6woux5w5jA+zMJlmZAvPbfzFP ftSytY2vAeHThzNnhgOZismF5GjEsd3d1/nS7uCBUltFm8hypjO81jCvbpTnOUK6gyJM 14HA==; 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=20230601; t=1773276009; x=1773880809; darn=postgresql.org; h=cc:to:subject:message-id:date:from:reply-to:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=2a0YkbViEQUmmUH6hhvH0LQvEGy8TnMImn8H0ZS0h0w=; b=dZIsDGjXDbgqMQFjI82xrO/8rn0ARZx3S5j+KYOFrL+RaLut1pjrlYH42ryR9Fz2nK MZGwz5khufxiV/FcwJysIBWZKm1jHTdk3wfmUnc7qz4EEHZ5FjkGhYrm9fHbxlDljWFW tifyb23cumozmloamNCBBuxBCAC7Ab7xU/B7vD8S3wQX1vkAR6vht+ds/L3yRlhkLMYu EA0ZDoivZKaE+tRFGI5wvOm4qvk2GQ36PP7xky2R6OYZ007Ve7BRcY/PBRi2/Pe2nzbK k18W4eWCUUzZLA6o8OfADnwyPCiBBi8xuixp7j1m5gmdy6oNqxenj3FvCdhfUJyNdKQJ 8ynQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773276009; x=1773880809; h=cc:to:subject:message-id:date:from:reply-to:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=2a0YkbViEQUmmUH6hhvH0LQvEGy8TnMImn8H0ZS0h0w=; b=mkdIa3JJidVzIwL9T3tovPpNjI9pwtiL15lXskqWM+r1R1dqd6C0vqmm/CGM6WApR7 KPmO0WRi3AMs+n+R04/+0h3dZBjj5YsGgUy14P2X/DL3JrUOxqluHv0nVNMK1BXHXUTh al2GDMfwBdo/P5FSiOHC2J+Ngx2RYZbeOeTYB4VpYpcodA/IW6IKasKGCkspnm00OiGf PquIPDH3BBvkjxSSmlhYaZe3zTwF61yaNi2VDqyRX6eiYwuv9KhThuJ8VN472xopdtzh SLgkeE/eqPTJjT2Kp/zSQ2cBLOnyVzDGgG23xNRkmrO6dx2aNtv4C0I7FJG0q1z/FXVa CQrQ== X-Forwarded-Encrypted: i=1; AJvYcCVOONo7J3UlNDhQGeHS2Hbb83RQ8HPL+QQYSoG17hhx+NYlNgv4TwjDE3RZ75P8A1Pv8xbDM4t010KMvHV1@postgresql.org X-Gm-Message-State: AOJu0YzuNXLGMlSi7yML77HPJTGrJU49l2Ep7zajl6Vq8wdZ+E49JBHm qXNY0f2LzEzq4pq2ZP6ySnm8HDaQtEYM9u22Am5naK8p7539Sliow/A7Rb2qJ/PlSH9G3yNS75M qDzg9xn1C55/klnkIA0povAaMkZUNqvs= X-Gm-Gg: ATEYQzwHAYhOoTsn9gB3hgvyH2Al+zqT+4+wgi7y3hMige4WLqnKMLQcpQsaFGuIK3V JblZIraFuCL0z5k9Aub6IdY8EUtG3U1idKkbF2zDVFtxTHFNOQ7TWYvHWgq2Ka3Cj2xFhjMAca6 QZBz6OUf+SLIjADw2H604sTcGr4aV3mC+UBSjjtvO7u0I7BqV9nps06RqaD/JnrxCapaTdIH2JL +XLXE8eB0B0zyjbsfepz70qnREpdi8EuAUirKDm+V9Xi/3MCSO9v+VJPWR4itFTWHwTFpHzS1uk wSmVlQWe3rlZH+dA9MajNdKnHRUvRCdjDYchABx6+X6Bvv454Q== X-Received: by 2002:a17:903:2451:b0:2ae:4fdb:d596 with SMTP id d9443c01a7336-2aeae769ac1mr48994985ad.11.1773276009238; Wed, 11 Mar 2026 17:40:09 -0700 (PDT) MIME-Version: 1.0 References: <20260302.141823.129040280886273031.ishii@postgresql.org> <20260312.092125.2016894123875469735.ishii@postgresql.org> In-Reply-To: <20260312.092125.2016894123875469735.ishii@postgresql.org> Reply-To: assam258@gmail.com From: Henson Choi Date: Thu, 12 Mar 2026 09:39:57 +0900 X-Gm-Features: AaiRm53ZhEu08TLOmXXTU85s3GCr-ggETaRnZ2cyRXPfE9BANfByCZzYOQFh3MU Message-ID: Subject: Re: Row pattern recognition To: Tatsuo Ishii Cc: zsolt.parragi@percona.com, vik@postgresfriends.org, er@xs4all.nl, jacob.champion@enterprisedb.com, david.g.johnston@gmail.com, peter@eisentraut.org, pgsql-hackers@postgresql.org Content-Type: multipart/alternative; boundary="0000000000009e922e064cc8fe6e" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000009e922e064cc8fe6e Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 2026=EB=85=84 3=EC=9B=94 12=EC=9D=BC (=EB=AA=A9) AM 9:21, Tatsuo Ishii =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > Hi Zsolt, > > Thanks for the report and the test case! > > > Good catch, Zsolt. You're right =E2=80=95 the return value of > > coerce_to_boolean() must be assigned back to te->expr, otherwise > > any implicit cast (e.g., a user-defined type with an assignment > > cast to boolean) is silently discarded. > > > > The fix is straightforward: > > > > foreach_ptr(TargetEntry, te, defineClause) > > te->expr =3D (Expr *) coerce_to_boolean(pstate, (Node *) te->ex= pr, > > "DEFINE"); > > > > I've confirmed that your example query produces incorrect results > > without the fix (the truthyint value is evaluated as-is without > > the cast) and correct results with it. > > > > Patch 13 is attached with the fix and a regression test case based > > on your example. > > Yeah, current patch needs to be fixed. Question is, the output of the > expression of DEFINE clause must be a strict boolean or, it is allowed > to accept an expression coercive to boolean? > > If we prefer the former, we should use exprType() instead. > > Best regards, > -- > Tatsuo Ishii > SRA OSS K.K. > English: http://www.sraoss.co.jp/index_en/ > Japanese:http://www.sraoss.co.jp > --0000000000009e922e064cc8fe6e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


2026=EB=85=84 3=EC=9B=94 12=EC= =9D=BC (=EB=AA=A9) AM 9:21, Tatsuo Ishii <ishii@postgresql.org>=EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1= :
Hi Zsolt,

Thanks for the report and the test case!

> Good catch, Zsolt. You're right =E2=80=95 the return value of
> coerce_to_boolean() must be assigned back to te->expr, otherwise > any implicit cast (e.g., a user-defined type with an assignment
> cast to boolean) is silently discarded.
>
> The fix is straightforward:
>
>=C2=A0 =C2=A0 =C2=A0foreach_ptr(TargetEntry, te, defineClause)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0te->expr =3D (Expr *) coerce_to_bo= olean(pstate, (Node *) te->expr,
> "DEFINE");
>
> I've confirmed that your example query produces incorrect results<= br> > without the fix (the truthyint value is evaluated as-is without
> the cast) and correct results with it.
>
> Patch 13 is attached with the fix and a regression test case based
> on your example.

Yeah, current patch needs to be fixed. Question is, the output of the
expression of DEFINE clause must be a strict boolean or, it is allowed
to accept an expression coercive to boolean?

If we prefer the former, we should use exprType() instead.

Best regards,
--
Tatsuo Ishii
SRA OSS K.K.
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp
--0000000000009e922e064cc8fe6e--