Subject: Determine server version from psql script

From: Igor Korot <[email-masked]>
Date: Sat, 22 Mar 2025 19:31:45 -0500

Hi, All,
I have a big script that populated the DB for me.

I made it based on the latest available version.

However,  i have version 13 installed on my Linux box and so trying to
execute "CREATE OR REPLACE TRIGGER..." will fail.

Is there a way to determine the server version from such a script?

Thank you.

---

From: Adrian Klaver <[email-masked]>
Date: Sat, 22 Mar 2025 17:42:43 -0700

> I have a big script that populated the DB for me.

The language used for the script?

Is it actually running in psql?

> Is there a way to determine the server version from such a script?

 From here:

https://www.postgresql.org/docs/13/runtime-config-preset.html#GUC-SERVER-VERSION-NUM

show server_version_num;

Though how you use that is going to depend on the answers to the first 
two questions.

-- 
Adrian Klaver
[email-masked]

---

From: Tom Lane <[email-masked]>
Date: Sat, 22 Mar 2025 20:59:11 -0400

> show server_version_num;

psql already populates its SERVER_VERSION_NUM variable from that
for you.

			regards, tom lane