Re: Questions about parsing boolean and casting to anyelement - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Questions about parsing boolean and casting to anyelement
Date
Msg-id 17184.1234799324@sss.pgh.pa.us
Whole thread Raw
In response to Questions about parsing boolean and casting to anyelement  (ITAGAKI Takahiro <itagaki.takahiro@oss.ntt.co.jp>)
Responses Re: Questions about parsing boolean and casting to anyelement  (ITAGAKI Takahiro <itagaki.takahiro@oss.ntt.co.jp>)
List pgsql-hackers
ITAGAKI Takahiro <itagaki.takahiro@oss.ntt.co.jp> writes:
>   - Are there any limitations in casting to anyelement?

It's a no-op ... probably we shouldn't even let you do it, if the
lack of an error leaves room for such misinterpretation as this.
anyelement and friends are placeholders for use in function
declarations, not real types that it makes sense to cast to.

>     CREATE FUNCTION array_find(text[], text, anyelement)
>     RETURNS anyelement AS
>     $$
>         SELECT substring(i from E'\\W*=(.*)')::anyelement
>           FROM unnest($1) AS t(i) WHERE i LIKE $2 || '=%'
>          UNION ALL SELECT $3 LIMIT 1
>     $$
>     LANGUAGE sql IMMUTABLE STRICT;

The substring() necessarily produces type text, so I dunno why you
think $3 needs to be anything but text.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: SE-PostgreSQL and row level security
Next
From: Tom Lane
Date:
Subject: Re: SE-PostgreSQL and row level security