Odd Shortcut behaviour in PG14

From: Zahir Lalani <ZahirLalani(at)oliver(dot)agency>
To: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Odd Shortcut behaviour in PG14
Date: 2023-11-23 16:55:56
Message-ID: DB9P251MB0546E102DB0B567C40205976A7B9A@DB9P251MB0546.EURP251.PROD.OUTLOOK.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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 server 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)

This code has worked up till now and works on the dev server. The expectation being that if ekey=0 the lateral join will be ignored. However on the new QA server this is hit and miss. It fails many times as it seems to ignore the shortcut even though ekey is 0. We can make it work by doing this:

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 - but it solves the issue 100%. Any guidance on why this would be the case?

Zahir Lalani
Director of Enterprise Systems
[signature_2000159722]
151 Rosebery Avenue
London EC1R 4AB

t: +44 (0)7956 455 168
e: zahirlalani(at)oliver(dot)agency<mailto:zahirlalani(at)oliver(dot)agency>

Thank you for your email. For a faster response please take note of the below:

1. If your query is regarding a hosting issue/new request, please direct your request to Devops(dot)support(at)oliver(dot)agency<mailto:Devops(dot)support(at)oliver(dot)agency>
2. If your request is regarding the data warehouse or zoho, please direct your request to mi_reporting(at)oliver(dot)agency<mailto:mi_reporting(at)oliver(dot)agency>
3. If your request is regarding OMG issues/configuration, please direct your request to omgsupport(at)oliver(dot)agency<mailto:omgsupport(at)oliver(dot)agency>

For all other requests I will try and respond as soon as I can. Please note our response SLA's

* Critical (P1) - systems down or unresponsive = within 1 hour
* High (P2) - Issues with data accuracy/access/functional = within 4 business hours
* Medium (P3) - new requests / amendments to current setups etc = within 2 business days
* Low - general requests regarding any system = best endeavour

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2023-11-23 17:11:44 Re: Odd Shortcut behaviour in PG14
Previous Message Ron Johnson 2023-11-23 16:32:54 Re: pg_restore enhancements