public inbox for [email protected]  
help / color / mirror / Atom feed
Determine server version from psql script
3+ messages / 3 participants
[nested] [flat]

* Determine server version from psql script
@ 2025-03-23 00:31  Igor Korot <[email protected]>
  0 siblings, 1 reply; 3+ messages in thread

From: Igor Korot @ 2025-03-23 00:31 UTC (permalink / raw)
  To: pgsql-generallists.postgresql.org <[email protected]>

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.


^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Determine server version from psql script
@ 2025-03-23 00:42  Adrian Klaver <[email protected]>
  parent: Igor Korot <[email protected]>
  0 siblings, 1 reply; 3+ messages in thread

From: Adrian Klaver @ 2025-03-23 00:42 UTC (permalink / raw)
  To: Igor Korot <[email protected]>; pgsql-generallists.postgresql.org <[email protected]>

On 3/22/25 17:31, Igor Korot wrote:
> Hi, All,
> I have a big script that populated the DB for me.

The language used for the script?

Is it actually running in psql?

> 
> 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?

 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.

> 
> Thank you.
> 

-- 
Adrian Klaver
[email protected]







^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Determine server version from psql script
@ 2025-03-23 00:59  Tom Lane <[email protected]>
  parent: Adrian Klaver <[email protected]>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2025-03-23 00:59 UTC (permalink / raw)
  To: Adrian Klaver <[email protected]>; +Cc: Igor Korot <[email protected]>; pgsql-generallists.postgresql.org <[email protected]>

Adrian Klaver <[email protected]> writes:
> On 3/22/25 17:31, Igor Korot wrote:
>> Is there a way to determine the server version from such a script?

> show server_version_num;

psql already populates its SERVER_VERSION_NUM variable from that
for you.

			regards, tom lane






^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2025-03-23 00:59 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-03-23 00:31 Determine server version from psql script Igor Korot <[email protected]>
2025-03-23 00:42 ` Adrian Klaver <[email protected]>
2025-03-23 00:59   ` Tom Lane <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox