-2

PostgreSQL 11 introduces TRANSFORM FOR TYPE, from these docs by HP, PostgreSQL 11 New_Features

postgres=# CREATE EXTENSION jsonb_plperl CASCADE ;
NOTICE: installing required extension "plperl"
CREATE EXTENSION

postgres=> CREATE OR REPLACE FUNCTION fperl(val jsonb)
RETURNS jsonb
TRANSFORM FOR TYPE jsonb
LANGUAGE plperl
AS $$
 return $_[0] ;
$$ ;
CREATE FUNCTION

postgres=> SELECT fperl('{"1":1,"example": null}'::jsonb) ;
 fperl
---------------------------
{"1": 1, "example": null}
(1 row)

But it seems this would work the very same way if I remove TRANSFORM FOR TYPE jsonb

0

That's a totally useless example. I believe what TRANSFORM FOR TYPE is supposed to support is something like this,

postgres=> CREATE OR REPLACE FUNCTION fperl(val jsonb)
RETURNS jsonb
TRANSFORM FOR TYPE jsonb
LANGUAGE plperl
AS $$
 return $_[0]->{foo};
$$ ;

SELECT fperl('{"foo":"bar"}'::jsonb) ;

You can see in the above that we actually see the jsonb object as a perl hash and can access the members.

jsonb_plperl is the new stuff here. CREATE TRANSFORM dates to PostgreSQL 9.5.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.