Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fJQBQ-0005IN-Mz for pgsql-hackers@arkaria.postgresql.org; Thu, 17 May 2018 21:11:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fJQBP-0004Wk-7P for pgsql-hackers@arkaria.postgresql.org; Thu, 17 May 2018 21:11:31 +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.89) (envelope-from ) id 1fJQBO-0004Wa-Tf for pgsql-hackers@lists.postgresql.org; Thu, 17 May 2018 21:11:31 +0000 Received: from mail-qt0-x242.google.com ([2607:f8b0:400d:c0d::242]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fJQBL-0004Ih-Kf for pgsql-hackers@lists.postgresql.org; Thu, 17 May 2018 21:11:29 +0000 Received: by mail-qt0-x242.google.com with SMTP id c2-v6so7706451qtn.9 for ; Thu, 17 May 2018 14:11:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=TFZSlbvi2uJqr9OiysXdphT2T6wUTjjAdn7DWW7LlA8=; b=Ow384s73CRPO02vxa8bM86AAy0jDx4w5JPiy1pPUeZG//cl1Z7rFAn5rR7D0Y9W7uC ZGpxc2X2N9iHpfNXhqNOac7MPb1CQI9kx65lib7qE6lQ3e2U2h0OBUUQeZ8leucoC6h5 iR13X1vwc2OiaLubtirmc1ECNVGnkZZCFX0WXz+ZFwH1lhx2JV18D0jcIkpIdPP2IaQJ Zp1k+ofEJstGyLgE/wFq5Y8NbcHWpSxd89l35YHkSWYLe1BcrKTZx2HlARiR4gNgwGNa iuPlXuMTwcQCfCE/nLGqYX7bZqO2klxAcafyTyhRpNpPfVVUJ+1GyiyxhmmYgFr9SpDq 5nCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=TFZSlbvi2uJqr9OiysXdphT2T6wUTjjAdn7DWW7LlA8=; b=N0AXRrnsnpBaGzaufoCRvg6vF1MAHrMmnYZufx1gQ5KtSHbj2O5lgxz8N8w3SAx4ln YhIvhjguoEH8GWG2GVRJRU+wtYIHNw4b1/uDEFbODHUetQtixiDtBG59cteFmZYS5Ik1 UhIlRChn0aAbGM6H5zID2NlFyh3utFSfp2iT/J0w3OB5ECZUsXqZ7VIBhSNiL+3JV8xj SRqqwZUFdimWUlLiGdKr7U+2mFK0g0VuL6Mr/BugslVGP9QawPMeqw/KDXh7ojLAhmkh Ny0exKrFVQFGeKqEqiPlombMe5T6c7RRsd8sx2HqrquJ67PMASX3RbIeQbZBohaLZaCz XiUg== X-Gm-Message-State: ALKqPweJh+PlH/ZHR7mIdP3ND/9+nMurFrsds3Xu59UElKRnnetv1xlU ch6LA2jDzw97dyVruoMh4vFeWQ== X-Google-Smtp-Source: AB8JxZp9kscIxXwPS0wZxVajtiHANUWndIDGZoAXqN4DMlSxlz8P0R5fAbW1trQ4WhdLYNRjhJryXQ== X-Received: by 2002:ac8:35f0:: with SMTP id l45-v6mr6884997qtb.317.1526591486553; Thu, 17 May 2018 14:11:26 -0700 (PDT) Received: from alvin.alvh.no-ip.org ([179.57.112.31]) by smtp.gmail.com with ESMTPSA id a130-v6sm4353556qkg.43.2018.05.17.14.11.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 May 2018 14:11:25 -0700 (PDT) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id EF1DB863; Thu, 17 May 2018 17:11:23 -0400 (-04) Date: Thu, 17 May 2018 17:11:23 -0400 From: Alvaro Herrera To: Dagfinn Ilmari =?iso-8859-1?Q?Manns=E5ker?= Cc: Peter Eisentraut , Tom Lane , Pavel Stehule , Nikita Glukhov , PostgreSQL Hackers Subject: Re: Transform for pl/perl Message-ID: <20180517211123.wrml3yvrl3b2rmrq@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20170306-137-4415bd-dirty (1.8.0) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hello This is still listed as an open item, though the patch proposed by Peter upthread has been committed. If I understand correctly, ilmari was going to propose another patch. Or is the right course of action to set the open item as resolved? On 2018-May-02, Dagfinn Ilmari Mannsåker wrote: > Peter Eisentraut writes: > > > These two items are now outstanding: > > > > On 4/10/18 07:33, Dagfinn Ilmari Mannsåker wrote: > >> 2) jsonb scalar values are passed to the plperl function wrapped in not > >> one, but _two_ layers of references > > > > I don't understand this one, or why it's a problem, or what to do about it. > > It means that if you call a jsonb-transforming pl/perl function like > > select somefunc(jsonb '42'); > > it receives not the scalar 42, but reference to a reference to the > scalar (**int instead of an int, in C terms). This is not caught by the > current round-trip tests because the output transform automatically > dereferences any number of references on the way out again. > > The fix is to reshuffle the newRV() calls in Jsonb_to_SV() and > jsonb_to_plperl(). I am working on a patch (and improved tests) for > this, but have not have had time to finish it yet. I hope be able to in > the next week or so. > > >> 3) jsonb numeric values are passed as perl's NV (floating point) type, > >> losing precision if they're integers that would fit in an IV or UV. > > > > This seems fixable, but perhaps we need to think through whether this > > will result in other strange behaviors. > > Nubers > 2⁵³ are not "interoperable" in the sense of the JSON spec, > because JavaScript only has doubles, but it seems desirable to preserve > whatever precision one reasonably can, and I can't think of any > downsides. We already support the full numeric range when processing > JSONB in SQL, it's just in the PL/Perl transform (and possibly > PL/Python, I didn't look) we're losing precision. > > Perl can also be configured to use long double or __float128 (via > libquadmath) for its NV type, but I think preserving 64bit integers when > building against a Perl with a 64bit integer type would be sufficient. > > - ilmari > -- > "The surreality of the universe tends towards a maximum" -- Skud's Law > "Never formulate a law or axiom that you're not prepared to live with > the consequences of." -- Skud's Meta-Law > -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services