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 1r6FRC-000AbM-NB for pgsql-general@arkaria.postgresql.org; Thu, 23 Nov 2023 19:32:34 +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 1r6FRB-003pdP-6r for pgsql-general@arkaria.postgresql.org; Thu, 23 Nov 2023 19:32:33 +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.94.2) (envelope-from ) id 1r6FRA-003pdF-Ll for pgsql-general@lists.postgresql.org; Thu, 23 Nov 2023 19:32:32 +0000 Received: from mail-oi1-x230.google.com ([2607:f8b0:4864:20::230]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1r6FR3-0071Z5-T1 for pgsql-general@lists.postgresql.org; Thu, 23 Nov 2023 19:32:31 +0000 Received: by mail-oi1-x230.google.com with SMTP id 5614622812f47-3b84e328327so376933b6e.2 for ; Thu, 23 Nov 2023 11:32:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700767945; x=1701372745; darn=lists.postgresql.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=UXIDIOxfvl602Sbg/wxomgPDxvHthP0bilAhCqRfcC8=; b=hyr/Y/IFtaE3jaDOYw4ShAq0g2X8lSCaMUwginyboWjqagGUSUHuDaKMLD5ZmaYe/8 tRsnhr5TgChjyQi1O5gQumlWxf4NipbeB/3ebLkc2cOZteYwFGkXX/k2RDOeWRlPiAKY 8/AqgfCGDbcnrPP6Ov31sbb0szIT/W0ThA2bd84/38E0XArMbqdXPHvm2xWE9I5KP3pg Qn35fAom+dVfraEYw9NilYpcb3S8G5N3vFQlGZyJfzgiTdFX/id5QGx/cj3wZpNJcRij yPYv9LbIu1QYc+mzyHwfu+gQtLR9rtaoUYM1FIVt5DIakDbYEPvvMDw3taiRMABOWHF6 N9qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700767945; x=1701372745; h=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=UXIDIOxfvl602Sbg/wxomgPDxvHthP0bilAhCqRfcC8=; b=e1hW0dibURxGhLNOGmcP8mrMc9qda0KN2a6vNb9tIMCk/BseLItSc1skHJ+B/dvwqp o9JE0zC6ZyQoSHnr9OPUnlsu2pgDtrLFucy7uj4jHFG5/R4/3IRTbtmw0phGezFEekd6 MFblMhvqcK918gPbYq5lHYe70/q6z+zBg/3r8D0x8ebDgdd5mwmtMKsk9sx6l7kGCFpS n+7c4jnU3ohYhJVo4rWp/EJjVGnEwmt6NNjxJFZH9jn6HtHENenBZXPgClT1ASn5d5w5 7SV1lT9yaqONJBTf/qZi+46wOAPFkUkkRZqO3GzDACDzbTGFtRU4ol+b/qEi8HAbUaOG Cs+g== X-Gm-Message-State: AOJu0YwSU8yaPNj9nBo1M27rqkWHUC5nM/M5aAkHvknMg24hCTaXNLMa 8UvwM6v7BpIFJn3gnYPrX+MQ0cElopJuh7NYILC80agmtnM= X-Google-Smtp-Source: AGHT+IF6ucnjqWxSCDFzOUUlH/qKc+EzqXK9A6TR+1WlFf7U8PjECRzzH/0Wpm9C3uiVbzfbg4C4mz7Fe8Lit4yfYsM= X-Received: by 2002:a05:6358:7212:b0:168:e452:c163 with SMTP id h18-20020a056358721200b00168e452c163mr277792rwa.17.1700767944890; Thu, 23 Nov 2023 11:32:24 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Ron Johnson Date: Thu, 23 Nov 2023 14:32:13 -0500 Message-ID: Subject: Re: Odd Shortcut behaviour in PG14 To: "pgsql-generallists.postgresql.org" Content-Type: multipart/alternative; boundary="000000000000335e56060ad6e580" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000335e56060ad6e580 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Out of curiosity, what is the point of adding the "true" predicate no matter the position? Maybe I've created an incorrect truth table, but "true AND" (and "AND true") don't make any logical difference when added to (ekey > 0)*.* On Thu, Nov 23, 2023 at 11:56=E2=80=AFAM Zahir Lalani wrote: > Hello all > > > > Got a really weird problem with shortcut processing on one server. > > > > We have just upgraded to PG14 from PG11. The following code works as > expected on our primary Dev server, and we recently upgraded our QA serve= r > to the same level. However in this case the shortcut processing seems > broken. > > > > Here is the code in question: > > > > LEFT JOIN lateral ( > > SELECT > > CASE WHEN (ekey > 0) THEN convert_from(crypto_secretbox_open, > 'utf8')::JSON ELSE NULL END AS edata > > FROM crypto_secretbox_open( > > sc.data, > > sc.nonce, > > boxkey) > > ) *enc ON true and (ekey > 0)* > > > > [snip] > > LEFT JOIN lateral ( > > SELECT > > CASE WHEN (ekey > 0) THEN convert_from(crypto_secretbox_open, > 'utf8')::JSON ELSE NULL END AS edata > > FROM crypto_secretbox_open( > > sc.data, > > sc.nonce, > > boxkey) > > *) enc ON (ekey > 0) and true* > > > > This should theoretically be no different =E2=80=93 but it solves the iss= ue 100%. > Any guidance on why this would be the case? > > > --000000000000335e56060ad6e580 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Out of=C2=A0curiosity, what is the point of adding th= e "true" predicate no matter the position?=C2=A0 Maybe I've c= reated an incorrect truth table, but "true AND" (and "AND tr= ue") don't make any logical difference when added to=C2=A0(ekey &g= t; 0).


On Thu, N= ov 23, 2023 at 11:56=E2=80=AFAM Zahir Lalani <ZahirLalani@oliver.agency> wrote:

Hello all

=C2=A0

Got a really weird problem with shortcut processing = on one server.

=C2=A0

We have just upgraded to PG14 from PG11. The followi= ng code works as expected on our primary Dev server, and we recently upgrad= ed our QA server to the same level. However in this case the shortcut proce= ssing seems broken.

=C2=A0

Here is the code in question:

=C2=A0

LEFT JOIN lateral (

=C2=A0=C2=A0=C2=A0 SELECT

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 CASE WHEN= (ekey > 0) THEN convert_from(crypto_secretbox_open, 'utf8')::JS= ON ELSE NULL END AS edata

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 FROM cryp= to_secretbox_open(

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sc.data,

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sc.nonce,

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 boxkey)

) enc ON true and (ekey > 0)

=C2=A0

[snip]=C2=A0

LEFT JOIN lateral (

=C2=A0=C2=A0=C2=A0 SELECT

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 CASE WHEN= (ekey > 0) THEN convert_from(crypto_secretbox_open, 'utf8')::JS= ON ELSE NULL END AS edata

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 FROM cryp= to_secretbox_open(

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sc.data,

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sc.nonce,

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 boxkey)

) enc ON (ekey > 0) and true=

=C2=A0

This should theoretically be no different =E2=80=93 = but it solves the issue 100%. Any guidance on why this would be the case?

=C2=A0

--000000000000335e56060ad6e580--