Re: need a function to extract list items from pg_node_tree

Lists: pgsql-hackers
From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Subject: need a function to extract list items from pg_node_tree
Date: 2012-12-21 12:20:00
Message-ID: 1356092400.25658.6.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

In order to implement the PARAMETER_DEFAULT column in the information
schema I need a way to get the expressions out of the proargdefaults
column. pg_get_expr(proargdefaults, 0) gives me all expressions
comma-separated, but I need them individually. I think a function like
pg_get_list_nth (to keep consistent with the internal list API) could
work. Alternatively, a list-to-array function might do the trick. Are
there are any other potential uses cases that should be considered here?
AFAICT, indexprs is the only other system catalog column that contains
an expression list.


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: need a function to extract list items from pg_node_tree
Date: 2012-12-21 12:26:32
Message-ID: 20121221122632.GA4213@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2012-12-21 07:20:00 -0500, Peter Eisentraut wrote:
> In order to implement the PARAMETER_DEFAULT column in the information
> schema I need a way to get the expressions out of the proargdefaults
> column. pg_get_expr(proargdefaults, 0) gives me all expressions
> comma-separated, but I need them individually. I think a function like
> pg_get_list_nth (to keep consistent with the internal list API) could
> work. Alternatively, a list-to-array function might do the trick. Are
> there are any other potential uses cases that should be considered here?
> AFAICT, indexprs is the only other system catalog column that contains
> an expression list.

Hm. Wouldn't it be better to create a pg_node_tree[] and use that in
pg_attribute? Its already in the variable length part of pg_proc
anyway...

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: need a function to extract list items from pg_node_tree
Date: 2012-12-21 14:01:42
Message-ID: 50D46BC6.1030008@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 12/21/12 7:26 AM, Andres Freund wrote:
> On 2012-12-21 07:20:00 -0500, Peter Eisentraut wrote:
>> In order to implement the PARAMETER_DEFAULT column in the information
>> schema I need a way to get the expressions out of the proargdefaults
>> column. pg_get_expr(proargdefaults, 0) gives me all expressions
>> comma-separated, but I need them individually. I think a function like
>> pg_get_list_nth (to keep consistent with the internal list API) could
>> work. Alternatively, a list-to-array function might do the trick. Are
>> there are any other potential uses cases that should be considered here?
>> AFAICT, indexprs is the only other system catalog column that contains
>> an expression list.
>
> Hm. Wouldn't it be better to create a pg_node_tree[] and use that in
> pg_attribute? Its already in the variable length part of pg_proc
> anyway...

That sounds like a good idea. I don't know why they are currently
stored as a list.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: need a function to extract list items from pg_node_tree
Date: 2012-12-21 15:53:26
Message-ID: 15686.1356105206@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> On 12/21/12 7:26 AM, Andres Freund wrote:
>> Hm. Wouldn't it be better to create a pg_node_tree[] and use that in
>> pg_attribute? Its already in the variable length part of pg_proc
>> anyway...

> That sounds like a good idea. I don't know why they are currently
> stored as a list.

They're stored as a list because that's what's convenient for use by the
parser/planner. I believe that a change like this would be quite
inconvenient on that end, and that that is not where we want to put the
inconvenience. I'm also concerned about possibly breaking any
third-party code that's already coping with the current representation.

regards, tom lane