1

Is it possible to find out if an argument in a function in postgres was defined as

table.column%type foo

or

sometype foo

querying e.g. pg_proc?

1 Answer 1

2

The proargtypes column in pg_proc is an array of the types of all the function's arguments. Each type can then be cross-referenced to pg_type.oid.

So if I define a function like this:

steve@steve@[local] =# create function testfunc(pg_proc.proname%type) returns boolean language 'sql' immutable strict as $$ select true $$;
NOTICE:  type reference pg_proc.proname%TYPE converted to name
CREATE FUNCTION

Well, that notice isn't too hopeful.

The pg_proc entry for that function is:

 proname  | proargtypes
----------+-------------
 testfunc | 19

and type 19 is just "name". so it looks like the answer here is "no", I'm afraid.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.