Re: [HACKERS] Transform for pl/perl

Поиск
Список
Период
Сортировка
От Anthony Bykov
Тема Re: [HACKERS] Transform for pl/perl
Дата
Msg-id 20171024152709.641251ae@anthony-24-g082ur
обсуждение исходный текст
Ответ на [HACKERS] Transform for pl/perl  (anthony <a.bykov@postgrespro.ru>)
Ответы Re: [HACKERS] Transform for pl/perl  (Pavel Stehule <pavel.stehule@gmail.com>)
Список pgsql-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

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Greg Stark
Дата:
Сообщение: Re: [HACKERS] Current int & float overflow checking is slow.
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [HACKERS] Remove secondary checkpoint