Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f3dVU-00027m-Bk for pgsql-committers@arkaria.postgresql.org; Wed, 04 Apr 2018 08:11:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f3dVS-00082j-9M for pgsql-committers@arkaria.postgresql.org; Wed, 04 Apr 2018 08:10:58 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f3dVS-00082a-0h for pgsql-committers@lists.postgresql.org; Wed, 04 Apr 2018 08:10:58 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f3dVO-0007Ui-DI for pgsql-committers@lists.postgresql.org; Wed, 04 Apr 2018 08:10:57 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id EF3B821C1F3B; Wed, 4 Apr 2018 11:10:52 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from anthony-24-g082ur (unknown [31.173.148.242]) (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 B117021C1EA8; Wed, 4 Apr 2018 11:10:52 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1522829452; bh=ZS4V05C2VYxHRfQxjCOIS1BSE868atpSQwuiMC5SDOg=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=T995L1RQUxvVDFwfvJghUF3lk7Tcn7SA4sfQb6mYNbHk6wNJ6M2oka5UQL7p7b50u /t9oKmsOps0q1QMh7UJXy9e+HmX71pgPQxA/zfj2PJVekJ9hEM+Z3zlFgkfNARa7zm dkhlBUnzef1fPBofJA973/b3OiNTvCStAtT5SeyU= Date: Wed, 4 Apr 2018 11:10:51 +0300 From: Anthony Bykov To: Tom Lane Cc: Peter Eisentraut , pgsql-committers@lists.postgresql.org Subject: Re: pgsql: Transforms for jsonb to PL/Perl Message-ID: <20180404111051.28c7912d@anthony-24-g082ur> In-Reply-To: <15089.1522791424@sss.pgh.pa.us> References: <13723.1522768121@sss.pgh.pa.us> <3001.1522769607@sss.pgh.pa.us> <15089.1522791424@sss.pgh.pa.us> 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 Tue, 03 Apr 2018 17:37:04 -0400 Tom Lane wrote: > I wrote: > > Hm, it fails on my own machine too (RHEL6, perl 5.10.1), with the > > same "cannot transform this Perl type to jsonb" symptoms. A bit > > of tracing shows that SvTYPE(in) is returning SVt_PVIV in some > > of the failing cases, and SVt_PVNV in others. > > I tried to fix this by reducing the amount of knowledge that function > embeds about the possible SvTYPEs. After the special cases for AV, > HV, and NULL, the attached just tests SvIOK, SvNOK, and SvPOK, and > does the right thing for each case. > > This results in one change in the module's test results: the example > that thinks it's returning a regexp match result no longer fails, > but just returns the scalar result (0). I'm inclined to think that > this is correct/desirable and the existing behavior is an accidental > artifact of not coping with Perl's various augmented representations > of scalar values. > > Thoughts? > > regards, tom lane > Hello, I don't think that user expect having 0 in jsonb when they have regexp: it should have a possibility to convert resulting jsonb back to perl with exact same type and data. -- Anthony Bykov Postgres Professional: http://www.postgrespro.com The Russian Postgres Company