pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedPG14: "is of" vs pg_typeof
6+ messages / 2 participants
[nested] [flat]
* PG14: "is of" vs pg_typeof
@ 2022-04-23 20:14 Karsten Hilbert <Karsten.Hilbert@gmx.net>
2022-04-23 20:36 ` Re: PG14: "is of" vs pg_typeof Karsten Hilbert <Karsten.Hilbert@gmx.net>
2022-04-23 20:36 ` Re: PG14: "is of" vs pg_typeof Adrian Klaver <adrian.klaver@aklaver.com>
2022-04-23 20:43 ` Re: PG14: "is of" vs pg_typeof Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 3 replies; 6+ messages in thread
From: Karsten Hilbert @ 2022-04-23 20:14 UTC (permalink / raw)
To: pgsql-general
PostgreSQL 14.2-1
Dear readers,
it used to be possible to say (inside plpgsql):
if _value is of (text, char, varchar, name) then
val_type := ''string'';
elsif _value is of (smallint, integer, bigint, numeric, boolean) then
val_type := ''numeric'';
elsif _value is of (bytea) then
val_type := ''data'';
elsif _value is of (text[]) then
val_type := ''str_array'';
else
raise exception ''cfg.set_option(text, any, text, text, text): invalid type of value'';
end if;
where _value is some typed value.
As of now (not sure when that started) PG 14 is giving me
gnumed_v23=> select 'a'::text is of (text, integer);
ERROR: syntax error at or near "of"
(same thing inside plpgsql)
where the log says
2022-04-23 19:58:33 GMT ERROR: 42601: syntax error at or near "of" at character 21
2022-04-23 19:58:33 GMT LOCATION: scanner_yyerror, scan.l:1176
2022-04-23 19:58:33 GMT STATEMENT: select 'a'::text is of (text, integer);
I can't find anything in the changelog saying that "is of"
was removed. For what it's worth, nothing in the docs ever
said it existed either (though it did, as per real life).
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 ?
Thanks,
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: PG14: "is of" vs pg_typeof
2022-04-23 20:14 PG14: "is of" vs pg_typeof Karsten Hilbert <Karsten.Hilbert@gmx.net>
@ 2022-04-23 20:36 ` Karsten Hilbert <Karsten.Hilbert@gmx.net>
2022-04-23 20:39 ` Re: PG14: "is of" vs pg_typeof Adrian Klaver <adrian.klaver@aklaver.com>
2 siblings, 1 reply; 6+ messages in thread
From: Karsten Hilbert @ 2022-04-23 20:36 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Am Sat, Apr 23, 2022 at 10:14:03PM +0200 schrieb Karsten Hilbert:
> I can't find anything in the changelog saying that "is of"
> was removed. For what it's worth, nothing in the docs ever
> said it existed either (though it did, as per real life).
Oh, wait,
https://www.postgresql.org/message-id/1129826.1605805700@sss.pgh.pa.us
is that it ? It is gone ?
Alright, alright,
https://www.postgresql.org/message-id/1052846.1605802012@sss.pgh.pa.us
I am rewriting my code already. Interesting how one discovers
the proper search strategy only eventually, *after* asking for
help.
Anyway, so there, "IS OF" (the old PG one, at any rate) is
gone.
Thanks,
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: PG14: "is of" vs pg_typeof
2022-04-23 20:14 PG14: "is of" vs pg_typeof Karsten Hilbert <Karsten.Hilbert@gmx.net>
2022-04-23 20:36 ` Re: PG14: "is of" vs pg_typeof Karsten Hilbert <Karsten.Hilbert@gmx.net>
@ 2022-04-23 20:39 ` Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 0 replies; 6+ messages in thread
From: Adrian Klaver @ 2022-04-23 20:39 UTC (permalink / raw)
To: Karsten Hilbert <Karsten.Hilbert@gmx.net>; pgsql-general@lists.postgresql.org
On 4/23/22 13:36, Karsten Hilbert wrote:
> Am Sat, Apr 23, 2022 at 10:14:03PM +0200 schrieb Karsten Hilbert:
>
>> I can't find anything in the changelog saying that "is of"
>> was removed. For what it's worth, nothing in the docs ever
>> said it existed either (though it did, as per real life).
>
> Oh, wait,
>
> https://www.postgresql.org/message-id/1129826.1605805700@sss.pgh.pa.us
>
> is that it ? It is gone ?
>
> Alright, alright,
>
> https://www.postgresql.org/message-id/1052846.1605802012@sss.pgh.pa.us
>
> I am rewriting my code already. Interesting how one discovers
> the proper search strategy only eventually, *after* asking for
> help.
Also the actual commit:
https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=926fa801ac9eb54c5275472271ec63a059904...
>
> Anyway, so there, "IS OF" (the old PG one, at any rate) is
> gone.
>
> Thanks,
> Karsten
> --
> GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: PG14: "is of" vs pg_typeof
2022-04-23 20:14 PG14: "is of" vs pg_typeof Karsten Hilbert <Karsten.Hilbert@gmx.net>
@ 2022-04-23 20:36 ` Adrian Klaver <adrian.klaver@aklaver.com>
2 siblings, 0 replies; 6+ messages in thread
From: Adrian Klaver @ 2022-04-23 20:36 UTC (permalink / raw)
To: pgsql-general
On 4/23/22 13:14, Karsten Hilbert wrote:
> PostgreSQL 14.2-1
>
> Dear readers,
>
> I can't find anything in the changelog saying that "is of"
> was removed. For what it's worth, nothing in the docs ever
> said it existed either (though it did, as per real life).
It works through version 13. I also am not seeing, yet, where it was
removed in 14.
> Is there anything obvious I am missing for easily
> resurrecting the above "is of" use ?
>
> Thanks,
> Karsten
> --
> GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: PG14: "is of" vs pg_typeof
2022-04-23 20:14 PG14: "is of" vs pg_typeof Karsten Hilbert <Karsten.Hilbert@gmx.net>
@ 2022-04-23 20:43 ` Adrian Klaver <adrian.klaver@aklaver.com>
2022-04-23 20:47 ` Re: PG14: "is of" vs pg_typeof Karsten Hilbert <Karsten.Hilbert@gmx.net>
2 siblings, 1 reply; 6+ messages in thread
From: Adrian Klaver @ 2022-04-23 20:43 UTC (permalink / raw)
To: 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
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: PG14: "is of" vs pg_typeof
2022-04-23 20:14 PG14: "is of" vs pg_typeof Karsten Hilbert <Karsten.Hilbert@gmx.net>
2022-04-23 20:43 ` Re: PG14: "is of" vs pg_typeof Adrian Klaver <adrian.klaver@aklaver.com>
@ 2022-04-23 20:47 ` Karsten Hilbert <Karsten.Hilbert@gmx.net>
0 siblings, 0 replies; 6+ messages in thread
From: Karsten Hilbert @ 2022-04-23 20:47 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Am Sat, Apr 23, 2022 at 01:43:52PM -0700 schrieb Adrian Klaver:
> > 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);
Found that, but thanks anyway.
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2022-04-23 20:47 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-04-23 20:14 PG14: "is of" vs pg_typeof Karsten Hilbert <Karsten.Hilbert@gmx.net>
2022-04-23 20:36 ` Karsten Hilbert <Karsten.Hilbert@gmx.net>
2022-04-23 20:39 ` Adrian Klaver <adrian.klaver@aklaver.com>
2022-04-23 20:36 ` Adrian Klaver <adrian.klaver@aklaver.com>
2022-04-23 20:43 ` Adrian Klaver <adrian.klaver@aklaver.com>
2022-04-23 20:47 ` Karsten Hilbert <Karsten.Hilbert@gmx.net>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox