Re: table functions as fields in a select - Mailing list pgsql-general

From max jacob
Subject Re: table functions as fields in a select
Date
Msg-id 411B8BE6.8090309@ircam.fr
Whole thread Raw
List pgsql-general
sorry, forget this: it was my fault, now the function works also on pg8.
anyway, it is strange that i can do this with c functions and not with
plpgsql ones...
m.



max jacob wrote:

> hallo,
> i am using pg7.3.4. i have written a table function in c that
> tokenizes a text, returning a setof text. i can use this function
> either in constructs like:
>    select * from tokenize( 'some text that has to be tokenized' );
> or in costructs like:
>    select tokenize( text_field ) from some_table;
> the latter gives me the whole result of all words contained in every
> "text_field" of "some_table". i wonder if this is a forseen behaviour,
> since doing the same with a plpgsql function does not work (the
> plpgsql interpreter raises an error when it reaches the "return next"
> statement telling i'm using a "set-valued function in a context that
> can not accept a set"). but the c function works fine. now i'm trying
> the 8beta, where my "tokenize" function does not work anymore in the
> second construct. the server does not alert me, it simply returns an
> empy record set. this behaviour for sure not the right one since it
> should raise an error, but mainly i would really like it to work at
> least as it did on 7.3.4 since, as i believe my little example shows,
> this can be very useful. does anybody know what is the forseen
> behavior for using a set returning function in the field list of a
> select and, if the answer is "it should raise an error", if it is
> possible to work around it?
>
> thanks in advance,
>
> max.
>
> ps: i did not subscribe the mailing list, so please use "replay all"..
>
>
>


pgsql-general by date:

Previous
From: Graeme Hinchliffe
Date:
Subject: pl/pgsql trigger table attributes
Next
From: Giannis Vrentzos
Date:
Subject: case insensitive search with greek characters