Re: The mysterious pg_proc.protrftypes
Pavel Stehule <pavel.stehule@gmail.com>
From: Pavel Stehule <pavel.stehule@gmail.com>
To: Joel Jacobson <joel@compiler.org>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2021-01-25T07:14:37Z
Lists: pgsql-hackers
po 25. 1. 2021 v 8:05 odesílatel Joel Jacobson <joel@compiler.org> napsal:
> Hi,
>
> I'm trying to understand how pg_proc.protrftypes works.
>
> The documentation says "Data type OIDs for which to apply transforms.".
> For this column, there is no reference to any catalog table?
> I would guess it should be "(references pg_type.oid)", right?
>
> I tried to generate a value for this column to verify my hypothesis,
> but I struggle to find an example that produces a not null value here.
>
> I grepped the sources and found the "CREATE TRANSFORM FOR type_name"
> command,
> and found an extension using it named "bool_plperl" which I installed.
>
> I assumed this would cause a value, but no.
>
> Both of bool_plperl's two functions get null pg_proc.protrftypes values.
>
> I've tried running the full regression "make installcheck",
> but protrftypes doesn't seem to be covered:
>
> $ cd postgresql
> $ make installcheck
> ...
> =======================
> All 203 tests passed.
> =======================
> $ psql regression
> regression=# SELECT COUNT(*) FROM pg_proc WHERE protrftypes IS NOT NULL;
> count
> -------
> 0
> (1 row)
>
> Can someone please show me how to generate a function with a not null
> pg_proc.protrftypes value?
>
you should to use TRANSFORM clause in CREATE FUNCTION statement
https://www.postgresql.org/docs/current/sql-createfunction.html
CREATE EXTENSION hstore_plperl CASCADE;
CREATE FUNCTION test2() RETURNS hstore
LANGUAGE plperl
TRANSFORM FOR TYPE hstore
AS $$
$val = {a => 1, b => 'boo', c => undef};
return $val;
$$;
Regards
Pavel
> Many thanks.
>
> /Joel
>
>
>
>
>
>
>
Commits
-
Fix broken ruleutils support for function TRANSFORM clauses.
- 07d46fceb425 14.0 landed
- 57a7d6f49569 9.6.21 landed
- 41309f716ef5 9.5.25 landed
- d09e8789fe5e 10.16 landed
- a7cdd3f7124d 11.11 landed
- a26194f22bf0 13.2 landed
- 4641b2a30f0a 12.6 landed
-
Doc: improve documentation of pg_proc.protrftypes.
- 951862eda57e 14.0 landed
- 652f7818bf97 13.2 landed