Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1twB4g-00BSkB-Jd for pgsql-general@arkaria.postgresql.org; Sun, 23 Mar 2025 02:28:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1twB4e-007X6i-DZ for pgsql-general@arkaria.postgresql.org; Sun, 23 Mar 2025 02:28:28 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1twB4e-007X6Z-19 for pgsql-general@lists.postgresql.org; Sun, 23 Mar 2025 02:28:28 +0000 Received: from mail-yw1-x1135.google.com ([2607:f8b0:4864:20::1135]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1twB4c-000bNY-1L for pgsql-general@lists.postgresql.org; Sun, 23 Mar 2025 02:28:27 +0000 Received: by mail-yw1-x1135.google.com with SMTP id 00721157ae682-6f6c90b51c3so35613747b3.2 for ; Sat, 22 Mar 2025 19:28:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742696905; x=1743301705; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=/0PeveAvX/wrIxRAZiKAG+HxMRNJ7YxRap7rnDF3/xA=; b=lUULBhK9W6B9GokuHaGYAUpaEA8mWiqj1osrqxvu4cEL7dLb1H5ah15LN+7H5wRrG7 g52NnvIZSpga6uZxlms09hwGbXDCWXCSUzJsS8OdkLVWwf3lShXRDrt1KLoBLua3Pxud YbAg5Gs1k4cmvSrhTnUmqD4D8gaUPTyNLwUTPlucbCjN4rqqvyf2BHQqVeijNn/xHLkw FazZXi1T/nJlhNh4VPZLcFSivjPx1FBAZSmyy+4sYu6hzBxSUlosprfknQVOdu14EsiL tgTn3+NbULIV1TR6rCrvB4+BbT8OxIWBhd6CE92aDIHKuQ15IV9qlX68Hj4g+ubygQLk cU1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742696905; x=1743301705; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/0PeveAvX/wrIxRAZiKAG+HxMRNJ7YxRap7rnDF3/xA=; b=H0ATPy6iLfABNEUGX+uj1k73bqzbv+Mf0vojkYCcQ0fz0d4pAESgCHWy2h57NhM1w7 kSeIQvkN3CCe0HaWfcu/jasQyBGTjedB2Emcu2KhWI582OiSZCd92ClGft6DtSwRN+1X OyYC2ruXshmJheuI3JNUADnQGoq39vGJzX3EbvQYxnbkt84sk/oOgOxtuhyihWASdqBE +AY3xxLo9wmfHuO6a8ZLCc34phyr9YuXQBwadJzTln749nG8I7AtQXUzvkmFo+2wb1X+ DW2FE/qvqIDga/Jh7nckjSEQqY+fVnFpj58VrRXJfTgmruFsBPLlOuNhHfdjoF0MwF7N bYvw== X-Forwarded-Encrypted: i=1; AJvYcCWci2cwP342vn3D5IYtv95QgoRj2hxThL/cwnw22N/juFqFWI/F0guCrbfDqPno42Ad2ME7/m2LtuypMaRW@lists.postgresql.org X-Gm-Message-State: AOJu0YyL9FpH2dDxbNTbZsEkB5LpDMRt4ncxOhcsr+ATf5j9AEZ356Qh 1d6mdBRKfGrcrBlKW77Jufrr2uuHZ27x2vI/1/uA1RJ6W8O8ARZbHF4LwtuD1hcJ8ln0yjyR5dh nr/XlkZy08KkSwKnIX4H1tiVJNjU= X-Gm-Gg: ASbGncsg9tgVNdoelriymQ7ZcN6bw3A0B+Q9IkLudZgoyjslMWe3oQA8N5Z07Qe/Rco 5YSX9hDyQYg62rbCc7Pa/q2guC+SaYAWjfVSX46qzKwERJAXyKKxj2F15VWsY8EWEZoA/UPw2Pb SN0VJyAbXYGmWnd2KlUIaKxv3eRngxPSIr+PvrgJRpDuWoi7sqeVWDb9Bbp07n X-Google-Smtp-Source: AGHT+IESVvmjEwYgn99h6XMZXe6Go+CMjdbcQJQtUpt/G/iMTJ/M8YKEMEo6Ou7KO8+cr/junS54QDTvDd7Gi7ud8y0= X-Received: by 2002:a05:690c:a8e:b0:6fd:42c8:3c6a with SMTP id 00721157ae682-700bad245a5mr104078677b3.34.1742696905478; Sat, 22 Mar 2025 19:28:25 -0700 (PDT) MIME-Version: 1.0 References: <90741d5f-5cda-4c4a-84f4-c470129732f4@aklaver.com> In-Reply-To: From: Igor Korot Date: Sat, 22 Mar 2025 21:28:14 -0500 X-Gm-Features: AQ5f1JrymEEeEaZEOKxLFvoKWjhayF2J3HIjKw6gPhakEq0bkyREYtwqwxEvuNY Message-ID: Subject: Re: Determine server version from psql script To: "David G. Johnston" Cc: Adrian Klaver , "pgsql-generallists.postgresql.org" Content-Type: multipart/alternative; boundary="0000000000000098c40630f93e92" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000000098c40630f93e92 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, David, On Sat, Mar 22, 2025, 8:58=E2=80=AFPM David G. Johnston wrote: > On Saturday, March 22, 2025, Igor Korot wrote: > >> >> >>> Is it actually running in psql? >>> >> >> Yes, i run "psql - d draft -a -f >> > > Then read the psql docs. Your version has \if and you=E2=80=99ll find se= rver > version listed as the available client variables. > I was hoping for something like If server_version >=3D 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. > > --0000000000000098c40630f93e92 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi, David,

On Sat, Mar 22, 2025, = 8:58=E2=80=AFPM 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 <fi= lename>

Then read the psql d= ocs.=C2=A0 Your version has \if and you=E2=80=99ll find server version list= ed as the available client variables.

I was hoping for something like

If server_version >=3D X:=
=C2=A0 =C2=A0 =C2=A0CREATE OR REPLACE TRIGGER...
else:
=C2=A0 =C2=A0 =C2=A0CREAT= E TRIGGER...

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

Thank you.


David J.

--0000000000000098c40630f93e92--