Re: table functions
От | Joe Conway |
---|---|
Тема | Re: table functions |
Дата | |
Msg-id | 3DF431B8.8060408@joeconway.com обсуждение исходный текст |
Ответ на | table functions (Eric B.Ridge <ebr@tcdi.com>) |
Ответы |
Re: table functions
Re: table functions |
Список | pgsql-general |
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). This capability was added so late in the 7.3 developemnt cycle that I don't think it is documented anywhere other than the source code and some posts Tom Lane made to the list (although I'll have to look -- he may have snuck it in somewhere). 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. Joe
В списке pgsql-general по дате отправления: