Re: Questions about parsing boolean and casting to anyelement

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Questions about parsing boolean and casting to anyelement
Дата
Msg-id 17184.1234799324@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Questions about parsing boolean and casting to anyelement  (ITAGAKI Takahiro <itagaki.takahiro@oss.ntt.co.jp>)
Ответы Re: Questions about parsing boolean and casting to anyelement
Список 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 по дате отправления:

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: SE-PostgreSQL and row level security
Следующее
От: Tom Lane
Дата:
Сообщение: Re: SE-PostgreSQL and row level security