public inbox for [email protected]  
help / color / mirror / Atom feed
From: Edwin UY <[email protected]>
To: Pgsql-admin <[email protected]>
Subject: How to check if a Procedure or FUNCTION EXIST
Date: Wed, 28 May 2025 03:01:17 +1200
Message-ID: <CA+wokJ_fJphYtOFxd2nHV7P6B9YdhN3=cOcevGHXPd50iUvreQ@mail.gmail.com> (raw)

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-postg...

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


reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: How to check if a Procedure or FUNCTION EXIST
  In-Reply-To: <CA+wokJ_fJphYtOFxd2nHV7P6B9YdhN3=cOcevGHXPd50iUvreQ@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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