Re: PG14: "is of" vs pg_typeof

Поиск
Список
Период
Сортировка
От Adrian Klaver
Тема Re: PG14: "is of" vs pg_typeof
Дата
Msg-id 8064cab0-31b1-7ac3-ebdb-c1522f4cee6b@aklaver.com
обсуждение исходный текст
Ответ на PG14: "is of" vs pg_typeof  (Karsten Hilbert <Karsten.Hilbert@gmx.net>)
Ответы Re: PG14: "is of" vs pg_typeof  (Karsten Hilbert <Karsten.Hilbert@gmx.net>)
Список pgsql-general
On 4/23/22 13:14, Karsten Hilbert wrote:
> PostgreSQL 14.2-1
> 
> Dear readers,

> Now, pg_typeof is an alternative but that only goes so far:
> it requires laboriously constructing an array on the right
> hand side for the above use case, along the lines of:
> 
>     select pg_typeof('a'::text) = any(ARRAY[pg_typeof(''::text), pg_typeof(''::name)]);
> 
> Is there anything obvious I am missing for easily
> resurrecting the above "is of" use ?

Actually it can be done as:

select pg_typeof('test'::text) in ('text'::regtype, 'varchar'::regtype);
  ?column?
----------
  t

select pg_typeof(1::int) in ('text'::regtype, 'varchar'::regtype);
  ?column?
----------
  f

> 
> Thanks,
> Karsten
> --
> GPG  40BE 5B0E C98E 1713 AFA6  5BC0 3BEA AC80 7D4F C89B
> 
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com



В списке pgsql-general по дате отправления:

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: PG14: "is of" vs pg_typeof
Следующее
От: Karsten Hilbert
Дата:
Сообщение: Re: PG14: "is of" vs pg_typeof