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 1uJvoZ-009bYd-L1 for pgsql-admin@arkaria.postgresql.org; Tue, 27 May 2025 15:02:03 +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 1uJvoY-008k5W-9p for pgsql-admin@arkaria.postgresql.org; Tue, 27 May 2025 15:02:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uJvoX-008k5N-V5 for pgsql-admin@lists.postgresql.org; Tue, 27 May 2025 15:02:01 +0000 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uJvoU-000O45-2J for pgsql-admin@lists.postgresql.org; Tue, 27 May 2025 15:02:01 +0000 Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-309fac646adso3578592a91.1 for ; Tue, 27 May 2025 08:01:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1748358117; x=1748962917; darn=lists.postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=jUP+lh6+T0BPqsRdpwegvEN97gPC0KZ4c4uVAI+erMo=; b=CGce0SmOPSas0mEJXpAoIsGMs0ky3G5CDGXWBTNRPUENanc8v+c2VHs3j33PZaHIOF 8bvsqjRIIjq77VOaF3YwbS5up33s1K7fHiEXkf1B/Tno17jkATKXCOFmgHA4mcE4oKT+ Zg76ydFEwnnjWY9Dnj6gEXyEyeQjuzemcyFexAxrWMolvEopwF5warBC+omnYr2lVQNG yJH/0VjcoD4D0pc1UOtpN4TETd1N8G3/d1gTxI7n6zHnqW384vHe2xs/ZqEHRmg7fzqO LOIgMUIu/Re17lcVeyLi7THTqww+KqXFCrrf/brtrJW8nY3d6pwkAa/2JaItADfAUOeS x4Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748358117; x=1748962917; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=jUP+lh6+T0BPqsRdpwegvEN97gPC0KZ4c4uVAI+erMo=; b=CFw93aLfN/Yj0Oiz5I0VThOZDp3UGJnlbGNLQfrAHOjGQr7RFTtzHvZx6yt4nwVYnw vWnD5YmDUa7odBBx68/EvfsROD+bTQoyV3ZDkeHrgao1ZPZ1zZtXI0gFhxve9aDpA5/1 1YP8iqcEKKd4aON7EL6CDHxb0QeU3lmlONunxjZCFlrVEhrEwg1eMjOA3ce/drz9zLVS bUkBBvgIm4IQMl85CiHRNFhV+oe/DpVLRTmK3zb74kaNkguy/iTybeKOq6MK9A/d/RFY RiSa7sjZf24G43NmfEaHy6kEO6iSIeA8KU63mq9fOHqqfA3zCwruvwblT3+nlhE5TEG8 u0eg== X-Gm-Message-State: AOJu0Yyphh+n0Den/EkstiUZshak5ZjDQ49mryP2sk7b+BBNKSvKU9JC DfyphsYgsMNZMUUehs0vghUfddOWUIPSYtN1XpgiBRskCcUmoBhtICdUDF9JsfFm4a7BwoFHS5H mnqPaJjCpTGcT76fQq7Zo1D+1dTQcfS4rD7dA X-Gm-Gg: ASbGncvkmoZu3VZkYQJcGarnGFNAQw85sv4XGXezDfM2YNsl+Af+vXoNc5m5Hx2Md/G PaBUKl0pcGSE6aAgkihcRiYJOc1SaZXEF59B1nGoUyDAA3Dfzs6pd0stFDAqwxxGgydiAEkiqda Fm+pRiqKjKc6iqAXEUEfSGTx5lcLDNPfsX X-Google-Smtp-Source: AGHT+IFLGwlSKXpxKW0LWmOUo8VfLW5XyHjA5FpIDen2AkC5QipcJQKabNsdgwExExaXwTdmhDH1tN60Ffbl6nUiB6M= X-Received: by 2002:a17:90b:2887:b0:30a:9feb:1e15 with SMTP id 98e67ed59e1d1-311cce81fcemr1392376a91.8.1748358115834; Tue, 27 May 2025 08:01:55 -0700 (PDT) MIME-Version: 1.0 From: Edwin UY Date: Wed, 28 May 2025 03:01:17 +1200 X-Gm-Features: AX0GCFuYAqxVoVju-BGfFbsujZl1lgH-jLVIFlWqTY1hNQF-s7BoJxlVFZToL4Y Message-ID: Subject: How to check if a Procedure or FUNCTION EXIST To: Pgsql-admin Content-Type: multipart/alternative; boundary="0000000000006f408906361f5802" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000006f408906361f5802 Content-Type: text/plain; charset="UTF-8" Hi, Probably a dumb question of sorts. I want to check for function and procedure if they exist or not including those created by the users as well as system functions Reading thru the following link https://stackoverflow.com/questions/34305186/how-to-check-whether-a-stored-procedure-exists-on-postgresql SELECT EXISTS ( SELECT * FROM pg_catalog.pg_proc JOIN pg_namespace ON pg_catalog.pg_proc.pronamespace = pg_namespace.oid WHERE proname = 'proc_name' AND pg_namespace.nspname = 'schema_name' ) https://www.postgresql.org/docs/current/catalog-pg-proc.html Will querying pg_catalog.pg_proc be enough? Using prokind to check if it is function or procedure and proowner whether it is a system function or user-defined? Regards, Ed --0000000000006f408906361f5802 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

Probably a dumb question of sorts.=C2=A0
I want to check for funct= ion and procedure if they exist or not including those created by the users= as well as system functions

Readin= g thru the following link


SELECT EXISTS (
=C2=A0 =C2=A0 =C2=A0= =C2=A0 SELECT *
=C2=A0 =C2=A0 =C2=A0 =C2=A0 FROM pg_catalog.pg_proc
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 JOIN pg_namespace ON pg_catalog.pg_proc.proname= space =3D pg_namespace.oid
=C2=A0 =C2=A0 =C2=A0 =C2=A0 WHERE proname =3D= 'proc_name'
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 AND pg_na= mespace.nspname =3D 'schema_name'
=C2=A0 =C2=A0 =C2=A0 =C2=A0 )<= /span>

https://www.postgresql.org/docs/curre= nt/catalog-pg-proc.html

Will qu= erying pg_catalog.pg_proc be enough? Using prokind to check if it is functi= on or procedure and proowner whether it is a system function or user-define= d?

=
Regards,
Ed

--0000000000006f408906361f5802--