Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eOJLr-0005AQ-BD for pgsql-hackers@arkaria.postgresql.org; Mon, 11 Dec 2017 08:22:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eOJLq-0003yI-Mx for pgsql-hackers@arkaria.postgresql.org; Mon, 11 Dec 2017 08:22:14 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eOJLq-0003y9-8R for pgsql-hackers@lists.postgresql.org; Mon, 11 Dec 2017 08:22:14 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1eOJLm-0006qJ-UI for pgsql-hackers@lists.postgresql.org; Mon, 11 Dec 2017 08:22:13 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 4F5BD21C1AD9; Mon, 11 Dec 2017 11:22:08 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru Received: from anthony-24-g082ur (unknown [217.23.185.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id 09F5B21C1692; Mon, 11 Dec 2017 11:22:07 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1512980528; bh=ifOuq7e9Rm5fBT7kVY1SL7Rs7Sz5AAzUxZeJraxVI0A=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=TZYy0LlC4wdz369VRUsNMNfAxlLYkqfb5zYAG6JoCNF0OO4819qYRbDllQMSJDOr8 ibw4a8gjW+WVqfgj3gyI++grZW+hrs/HS96d1SVUePFAvBRR026qXV/Kb6CrVfgaDe Vfj5kquUwrWIH4SnZF1QP1rDlqk4FBS8PVSwk+6M= Date: Mon, 11 Dec 2017 11:22:06 +0300 From: Anthony Bykov To: Peter Eisentraut Cc: pgsql-hackers@lists.postgresql.org Subject: Re: Jsonb transform for pl/python Message-ID: <20171211112206.3b4ea92f@anthony-24-g082ur> 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> Organization: postgres pro X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sat, 9 Dec 2017 16:57:05 -0500 Peter Eisentraut 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