Re: Determine server version from psql script - Mailing list pgsql-general

From Igor Korot
Subject Re: Determine server version from psql script
Date
Msg-id CA+FnnTy2Lk+K8t2uKwc1cAnCm6+RTb72eVRxt9+Y8y+C=sUeyA@mail.gmail.com
Whole thread Raw
In response to Re: Determine server version from psql script  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: Determine server version from psql script
List pgsql-general
Hi, David,

On Sat, Mar 22, 2025, 8:58 PM David G. Johnston <david.g.johnston@gmail.com> wrote:
On Saturday, March 22, 2025, Igor Korot <ikorot01@gmail.com> wrote:


Is it actually running in psql?

Yes, i run "psql - d draft -a -f <filename>

Then read the psql docs.  Your version has \if and you’ll find server version listed as the available client variables.

I was hoping for something like

If server_version >= X:
     CREATE OR REPLACE TRIGGER...
else:
     CREATE TRIGGER...

Python-like syntax here as I'm not sure how to do it properly...

Thank you.


David J.

pgsql-general by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: Determine server version from psql script
Next
From: Tom Lane
Date:
Subject: Re: Determine server version from psql script