Re: table functions

From: Eric B(dot)Ridge <ebr(at)tcdi(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: table functions
Date: 2002-12-09 06:32:02
Message-ID: ED619C3E-0B3F-11D7-A9FB-0003930C70D8@tcdi.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Monday, December 9, 2002, at 01:01 AM, Joe Conway wrote:

> Eric B.Ridge wrote:
>> Let's say I've defined a table function named: myTableFunc() (written
>> in C), and that I do this:
>> select a, b, c
>> from myTableFunc() as foo (a integer, b varchar(255), c text)
>> where a = 2;
>> Is it possible for me to get the FROM, WHERE, and AS ... clauses from
>> within my table function code? I'd like to do this so my table
>> function can be a little smarter about what it does and what it
>> returns.
>
> You can get the information related to the "as foo (a integer, b
> varchar(255), c text)" aka column definition clause. It is passed in
> to the function. See contrib/tablefunc/tablefunc.c:connectby_text().
> The ReturnSetInfo structure handed to the function includes a copy of
> the tupdesc formed by the parser (expectedDesc).

great! I was snooping through tablefunc.c, but didn't really know what
I was looking for. Thanks!

<snip>

> As far as the FROM and WHERE clauses, I don't think there is any
> information available to the function. Not sure it would be practical
> or even possible to change that -- maybe someone else will comment on
> this.

hmm.

eric

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Hadley Willan 2002-12-09 07:25:31 Readline error building 7.3-2 RPM
Previous Message suresh s 2002-12-09 06:07:52 Mr Thomas problem starting postgresql