Re: Consequence of changes to CTE's in 12 - Mailing list pgsql-general

From David G. Johnston
Subject Re: Consequence of changes to CTE's in 12
Date
Msg-id CAKFQuwa4QJ=LiPuSseooEfYpUoxZs=98koAAFPMfO2po7tXikg@mail.gmail.com
Whole thread Raw
In response to Consequence of changes to CTE's in 12  (Steve Baldwin <steve.baldwin@gmail.com>)
List pgsql-general
On Thu, Feb 11, 2021 at 5:07 PM Steve Baldwin <steve.baldwin@gmail.com> wrote:
My 'dilemma' is that this functionality is packaged and the database it is bundled into could be running on a pre-12 version or 12+. Is there any way I can rewrite my view to achieve the same outcome (i.e. only creating 0 or 1 advisory locks) regardless of the server version? I realise I could have two installation scripts but if it is installed into a pre-12 DB and that DB is subsequently upgraded to 12+, my behaviour is broken.

Pretty sure you will need to choose a location in which to make the installation behave version-dependently.  Within PostgreSQL itself that would be most easily done by writing a pl/pgsql function that conditionally adds the MATERIALIZED indicator on the textual representation of the query before executing it.  You can hide that function call within a view if desired.

David J.

pgsql-general by date:

Previous
From: Michael Lewis
Date:
Subject: Re: Consequence of changes to CTE's in 12
Next
From: Tom Lane
Date:
Subject: Re: Consequence of changes to CTE's in 12