Re: parameter info?

Lists: pgsql-hackers
From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: parameter info?
Date: 2013-02-01 01:05:43
Message-ID: 510B14E7.9020907@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


What's the best way for me to find out if a given parameter of a
function is a constant? The context is that it's expensive to process,
and in most cases will in fact be a constant, so if it is in fact a
constant I'd like to process it once and stash the results.

cheers

andrew


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: parameter info?
Date: 2013-02-01 04:02:35
Message-ID: CAFj8pRBsTLbOivQ-hWiZrHSvwN84D62afCQ+dLWptAFy+g8wNw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

hello

2013/2/1 Andrew Dunstan <andrew(at)dunslane(dot)net>:
>
> What's the best way for me to find out if a given parameter of a function is
> a constant? The context is that it's expensive to process, and in most cases
> will in fact be a constant, so if it is in fact a constant I'd like to
> process it once and stash the results.
>

you can look into parser tree

see src of get_fn_expr_argtype(fcinfo->flinfo, 0);

Regards

Pavel

> cheers
>
> andrew
>
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: parameter info?
Date: 2013-02-01 04:17:07
Message-ID: 14561.1359692227@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> What's the best way for me to find out if a given parameter of a
> function is a constant? The context is that it's expensive to process,
> and in most cases will in fact be a constant, so if it is in fact a
> constant I'd like to process it once and stash the results.

I think we added get_fn_expr_arg_stable() for precisely that
purpose.

regards, tom lane


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: parameter info?
Date: 2013-02-01 13:34:21
Message-ID: 510BC45D.8070306@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 01/31/2013 11:17 PM, Tom Lane wrote:
> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
>> What's the best way for me to find out if a given parameter of a
>> function is a constant? The context is that it's expensive to process,
>> and in most cases will in fact be a constant, so if it is in fact a
>> constant I'd like to process it once and stash the results.
> I think we added get_fn_expr_arg_stable() for precisely that
> purpose.
>
>

Thanks. That's exactly what I was looking for.

cheers

andrew