From: Anthony Bykov <a.bykov@postgrespro.ru>
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: Jsonb transform for pl/python
Date: Mon, 11 Dec 2017 11:22:06 +0300
Message-ID: <20171211112206.3b4ea92f@anthony-24-g082ur> (raw)
In-Reply-To: <881aea8c-23a4-0694-8182-72620afe84c4@2ndquadrant.com>
References: <20171025145100.3a19933f@anthony-24-g082ur>
<20171113130028.32405fee@anthony-24-g082ur>
<20171113150816.1377.17052.pgcf@coridan.postgresql.org>
<20171120123555.546c922f@anthony-24-g082ur>
<20171120134835.GA9855@e733.localdomain>
<20171206144054.5664c119@anthony-24-g082ur>
<881aea8c-23a4-0694-8182-72620afe84c4@2ndquadrant.com>
On Sat, 9 Dec 2017 16:57:05 -0500
Peter Eisentraut <peter.eisentraut@2ndquadrant.com> wrote:
> On 12/6/17 06:40, Anthony Bykov wrote:
> > Hello,
> > fixed the issues:
> > 1. Rising errors when invalid object being transformed.
> > 2. We don't rise the exception when transforming range(3) only in
> > python 2. In third one it is an error.
> >
> > Please, find the 4-th version of the patch in attachments to this
> > message.
>
> Why not make this part of the plpythonu extension? It doesn't have to
> be a separate contrib module.
>
Hello,
I thought about that, but the problem is that there will be no
possibilities to create custom transform if we create this extension by
default. For example, it is easy to check if we install this extension
and try to create new transform:
# create extension jsonb_plperl cascade;
NOTICE: installing required extension "plperl"
CREATE EXTENSION
# CREATE TRANSFORM FOR jsonb LANGUAGE plperl (
# FROM SQL WITH FUNCTION jsonb_to_plperl(internal),
# TO SQL WITH FUNCTION plperl_to_jsonb(internal)
# );
2017-12-11 10:23:07.507 MSK [19149] ERROR: transform for type jsonb
language "plperl" already exists 2017-12-11 10:23:07.507 MSK [19149]
STATEMENT: CREATE TRANSFORM FOR jsonb LANGUAGE plperl ( FROM SQL WITH
FUNCTION jsonb_to_plperl(internal), TO SQL WITH FUNCTION
plperl_to_jsonb(internal) );
ERROR: transform for type jsonb language "plperl" already exists
Other types of transforms may be interesting for people when they want
to transform the jsonb to certain structures. For example, what if the
user wants the parameter to be always array inside the function, while
this extension can return integers or strings in some cases.
--
Anthony Bykov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
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, peter.eisentraut@2ndquadrant.com, pgsql-hackers@lists.postgresql.org
Subject: Re: Jsonb transform for pl/python
In-Reply-To: <20171211112206.3b4ea92f@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