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


Reply via email to