Re: Patch: [BUGS] BUG #12320: json parsing with embedded double quotes

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Aaron Botsis <aaron(at)bt-r(dot)com>, pgsql-hackers(at)postgresql(dot)org
Cc: Francisco Olarte <folarte(at)peoplecall(dot)com>
Subject: Re: Patch: [BUGS] BUG #12320: json parsing with embedded double quotes
Date: 2015-01-08 20:44:44
Message-ID: 54AEEC3C.10907@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers


On 01/08/2015 03:05 PM, Aaron Botsis wrote:
>
>
>> It's also unnecessary. CSV format, while not designed for this, is
>> nevertheless sufficiently flexible to allow successful import of json
>> data meeting certain criteria (essentially no newlines), like this:
>>
>> copy the_table(jsonfield)
>> from '/path/to/jsondata'
>> csv quote e'\x01' delimiter e'\x02’;
>
> While perhaps unnecessary, given the size and simplicity of the patch,
> IMO it’s a no brainer to merge (it actually makes the code smaller by
> 3 lines). It also enables non-json use cases anytime one might want to
> preserve embedded escapes, or use different ones entirely. Do you see
> other reasons not to commit it?

Well, for one thing it's seriously incomplete. You need to be able to
change the delimiter as well. Otherwise, any embedded tab in the json
will cause you major grief.

Currently the delimiter and the escape MUST be a single byte non-nul
character, and there is a check for this in csv mode. Your patch would
allow any arbitrary string (including one of zero length) for the escape
in text mode, and would then silently ignore all but the first byte.
That's not the way we like to do things.

And, frankly, I would need to spend quite a lot more time thinking about
other implications than I have given it so far. This is an area where I
tend to be VERY cautious about making changes. This is a fairly fragile
ecosystem.

cheers

andrew

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message jeff.casavant 2015-01-08 21:24:29 BUG #12465: Materialized view dump restoration issue
Previous Message Aaron Botsis 2015-01-08 20:05:10 Re: Patch: [BUGS] BUG #12320: json parsing with embedded double quotes

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2015-01-08 20:46:35 Re: make check-world regress failed
Previous Message Peter Eisentraut 2015-01-08 20:44:22 Re: pg_rewind in contrib