pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Query function arg data types ONLY (no arg names)
4+ messages / 3 participants
[nested] [flat]

* Query function arg data types ONLY (no arg names)
@ 2018-04-28 16:52  Jeremy Finzel <finzelj@gmail.com>
  0 siblings, 2 replies; 4+ messages in thread

From: Jeremy Finzel @ 2018-04-28 16:52 UTC (permalink / raw)
  To: pgsql-general

It appears that neither pg_get_function_arguments
nor pg_get_function_identity_arguments could be used for this.  I want to
get function argument data types from the catalog by ordinal position,
without the argument name.

For example, I want the same information for these 2 functions:

foo(p_1 int, p_2 text)

- {int, text}

foo(int, text)

- {int, text}

Any suggestions as to how to use the catalogs or built-in postgres
functions to query this?

Thank you!
Jeremy

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

* Re: Query function arg data types ONLY (no arg names)
@ 2018-04-28 17:00  Pavel Stehule <pavel.stehule@gmail.com>
  parent: Jeremy Finzel <finzelj@gmail.com>
  1 sibling, 1 reply; 4+ messages in thread

From: Pavel Stehule @ 2018-04-28 17:00 UTC (permalink / raw)
  To: Jeremy Finzel <finzelj@gmail.com>; +Cc: pgsql-general

Hi

2018-04-28 18:52 GMT+02:00 Jeremy Finzel <finzelj@gmail.com>:

> It appears that neither pg_get_function_arguments
> nor pg_get_function_identity_arguments could be used for this.  I want to
> get function argument data types from the catalog by ordinal position,
> without the argument name.
>
> For example, I want the same information for these 2 functions:
>
> foo(p_1 int, p_2 text)
>
> - {int, text}
>
> foo(int, text)
>
> - {int, text}
>
> Any suggestions as to how to use the catalogs or built-in postgres
> functions to query this?
>

 CREATE OR REPLACE FUNCTION public.foo(a integer, b integer, c text)
 RETURNS text
 LANGUAGE sql
AS $function$ select 'hi'; $function$

postgres=# select (proargtypes::regtype[])[0:] from pg_proc where proname =
'foo';
┌─[ RECORD 1 ]┬────────────────────────┐
│ proargtypes │ {integer,integer,text} │
└─────────────┴────────────────────────┘

Regards

Pavel


> Thank you!
> Jeremy
>


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

* Re: Query function arg data types ONLY (no arg names)
@ 2018-04-28 17:03  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Jeremy Finzel <finzelj@gmail.com>
  1 sibling, 0 replies; 4+ messages in thread

From: Tom Lane @ 2018-04-28 17:03 UTC (permalink / raw)
  To: Jeremy Finzel <finzelj@gmail.com>; +Cc: pgsql-general

Jeremy Finzel <finzelj@gmail.com> writes:
> It appears that neither pg_get_function_arguments
> nor pg_get_function_identity_arguments could be used for this.  I want to
> get function argument data types from the catalog by ordinal position,
> without the argument name.

Something involving pg_proc.proargtypes::regtype[] might be useful.

			regards, tom lane




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

* Re: Query function arg data types ONLY (no arg names)
@ 2018-04-29 03:59  Jeremy Finzel <finzelj@gmail.com>
  parent: Pavel Stehule <pavel.stehule@gmail.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Jeremy Finzel @ 2018-04-29 03:59 UTC (permalink / raw)
  To: Pavel Stehule <pavel.stehule@gmail.com>; +Cc: pgsql-general

On Sat, Apr 28, 2018 at 12:01 PM Pavel Stehule <pavel.stehule@gmail.com>
wrote:

> Hi
>
> 2018-04-28 18:52 GMT+02:00 Jeremy Finzel <finzelj@gmail.com>:
>
>> It appears that neither pg_get_function_arguments
>> nor pg_get_function_identity_arguments could be used for this.  I want to
>> get function argument data types from the catalog by ordinal position,
>> without the argument name.
>>
>> For example, I want the same information for these 2 functions:
>>
>> foo(p_1 int, p_2 text)
>>
>> - {int, text}
>>
>> foo(int, text)
>>
>> - {int, text}
>>
>> Any suggestions as to how to use the catalogs or built-in postgres
>> functions to query this?
>>
>
>  CREATE OR REPLACE FUNCTION public.foo(a integer, b integer, c text)
>  RETURNS text
>  LANGUAGE sql
> AS $function$ select 'hi'; $function$
>
> postgres=# select (proargtypes::regtype[])[0:] from pg_proc where proname
> = 'foo';
> ┌─[ RECORD 1 ]┬────────────────────────┐
> │ proargtypes │ {integer,integer,text} │
> └─────────────┴────────────────────────┘
>
> Regards
>
> Pavel
>
>
>> Thank you!
>> Jeremy
>>
>
This is perfect - thank you!

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


end of thread, other threads:[~2018-04-29 03:59 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-04-28 16:52 Query function arg data types ONLY (no arg names) Jeremy Finzel <finzelj@gmail.com>
2018-04-28 17:00 ` Pavel Stehule <pavel.stehule@gmail.com>
2018-04-29 03:59   ` Jeremy Finzel <finzelj@gmail.com>
2018-04-28 17:03 ` Tom Lane <tgl@sss.pgh.pa.us>

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