pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Anthony Bykov <a.bykov@postgrespro.ru>
To: pgsql-hackers@postgresql.org
Subject: Re: Transform for pl/perl
Date: Tue, 24 Oct 2017 15:27:09 +0300
Message-ID: <20171024152709.641251ae@anthony-24-g082ur> (raw)
In-Reply-To: <20171024140129.6bd01f68@anthony-24-g082ur>
References: <20171024140129.6bd01f68@anthony-24-g082ur>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

There are some moments I should mention:
1. {"1":1}::jsonb is transformed into HV {"1"=>"1"}, while
["1","2"]::jsonb is transformed into AV ["1", "2"]

2. If there is a numeric value appear in jsonb, it will be transformed
to SVnv through string (Numeric->String->SV->SVnv). Not the best
solution, but as far as I understand this is usual practise in
postgresql to serialize Numerics and de-serialize them.

3. SVnv is transformed into jsonb through string
(SVnv->String->Numeric).

An example may also be helpful to understand extension. So, as an
example, function "test" transforms incoming jsonb into perl,
transforms it back into jsonb and returns it.

create extension jsonb_plperl cascade;

create or replace function test(val jsonb)
returns jsonb
transform for type jsonb
language plperl
as $$
return $_[0];
$$;

select test('{"1":1,"example": null}'::jsonb);


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (62+ messages)  latest in thread

Message-ID: <20171024152709.641251ae@anthony-24-g082ur>
Permalink:  ../20171024152709.641251ae@anthony-24-g082ur/
Also on:    postgresql.org/message-id/20171024152709.641251ae@anthony-24-g082ur

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: a.bykov@postgrespro.ru
  Subject: Re: Transform for pl/perl
  In-Reply-To: <20171024152709.641251ae@anthony-24-g082ur>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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