Re: Questions about parsing boolean and casting to anyelement

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: ITAGAKI Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Questions about parsing boolean and casting to anyelement
Date: 2009-02-16 15:48:44
Message-ID: 17184.1234799324@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

ITAGAKI Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-02-16 15:59:38 Re: SE-PostgreSQL and row level security
Previous Message Robert Haas 2009-02-16 15:43:00 Re: SE-PostgreSQL and row level security