pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Pavel Stehule <pavel.stehule@gmail.com>
Cc: Nikita Glukhov <n.gluhov@postgrespro.ru>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Transform for pl/perl
Date: Tue, 24 Apr 2018 14:31:24 -0400
Message-ID: <84fba634-71ba-4482-7e1b-5877bff5c6cb@2ndQuadrant.com> (raw )
In-Reply-To: <5d7b91e8-ea88-6811-e215-e7ea1013dca9@2ndquadrant.com >
References: <20171127132439.23dc26ef@anthony-24-g082ur >
<20171207125602.5326f103@anthony-24-g082ur >
<CAEepm=02=Ya7p=-X5Of=JD-+9+bmmwnpd9nr8AeVnOopB6Y+NQ@mail.gmail.com >
<20180112114739.6a9f0d4c@anthony-24-g082ur >
<20180131103621.GA19345@zakirov.localdomain >
<20180215125313.290468ae@anthony-24-g082ur >
<CAFj8pRCYBPFGZG5LHdfY1Ej+a_9sb3ugyDkUaJGD37UjpRpA8Q@mail.gmail.com >
<20180312110821.29c80420@anthony-24-g082ur >
<CAFj8pRDaTYHD30CP8u2v_wwsJfxFBfthcNEp_KgEOHVN0gUfAw@mail.gmail.com >
<505345c5-0159-077d-f64e-60afb01e5fbe@postgrespro.ru >
<CAFj8pRB1mLEvmnhRL9HheF6yeKPvuzBf2tQ=s+2QXGpnCJdbqQ@mail.gmail.com >
<26a0840a-6b09-44fc-9e4e-8200c1887882@2ndquadrant.com >
<d8jtvskjzzs.fsf@dalvik.ping.uio.no >
<d8jefjojudc.fsf@dalvik.ping.uio.no >
<15075.1523287460@sss.pgh.pa.us >
<d8ja7ubjnyp.fsf@dalvik.ping.uio.no >
<17423.1523368349@sss.pgh.pa.us >
<d8j604zjgtd.fsf@dalvik.ping.uio.no >
<d8j1sfnjfpb.fsf@dalvik.ping.uio.no >
<5d7b91e8-ea88-6811-e215-e7ea1013dca9@2ndquadrant.com >
On 04/24/2018 12:17 PM, Peter Eisentraut wrote:
> On 4/10/18 10:31, Dagfinn Ilmari Mannsåker wrote:
>> Also, it doesn't parse back in as jsonb either:
>>
>> =# select jsonbnan()::text::json;
>> ERROR: invalid input syntax for type json
>> DETAIL: Token "NaN" is invalid.
>> CONTEXT: JSON data, line 1: NaN
>>
>> And it's inconsistent with to_jsonb():
>>
>> =# select to_jsonb('nan'::numeric);
>> ┌──────────┐
>> │ to_jsonb │
>> ├──────────┤
>> │ "NaN" │
>> └──────────┘
>>
>> It would be highly weird if PL transforms (jsonb_plpython does the same
>> thing) let you create spec-violating jsonb values that don't round-trip
>> via jsonb_out/in.
> Yeah this is not good. Is there a way to do this in a centralized way?
> Is there a function to check an internal jsonb value for consistency.
> Should at least the jsonb output function check and not print invalid
> values?
>
The output function fairly reasonably assumes that the jsonb is in a
form that would be parsed in by the input function. In particular, it
assumes that anything like a NaN will be stored as text and not as a
jsonb numeric. I don't think the transform should be doing anything
different from the input function.
There is the routine IsValidJsonNumber that helps - see among others
hstore_io.c for an example use.
cheers
andrew
--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
view thread (62+ messages) latest in thread
Message-ID: <84fba634-71ba-4482-7e1b-5877bff5c6cb@2ndQuadrant.com>
Permalink: ../84fba634-71ba-4482-7e1b-5877bff5c6cb@2ndQuadrant.com/
Also on: postgresql.org/message-id/84fba634-71ba-4482-7e1b-5877bff5c6cb@2ndQuadrant.com
copy link · copy postgr.es
reply 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: andrew.dunstan@2ndquadrant.com, peter.eisentraut@2ndquadrant.com, ilmari@ilmari.org, tgl@sss.pgh.pa.us, pavel.stehule@gmail.com, n.gluhov@postgrespro.ru, pgsql-hackers@lists.postgresql.org
Subject: Re: Transform for pl/perl
In-Reply-To: <84fba634-71ba-4482-7e1b-5877bff5c6cb@2ndQuadrant.com>
* 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