Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Y9Jwv-0003vQ-Bz for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Jan 2015 20:44:57 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Y9Jwu-00044w-Pu for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Jan 2015 20:44:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Y9Jws-00042V-Ov for pgsql-hackers@postgresql.org; Thu, 08 Jan 2015 20:44:54 +0000 Received: from relay3-d.mail.gandi.net ([2001:4b98:c:538::195]) by magus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1Y9Jwp-0004DD-Hz for pgsql-hackers@postgresql.org; Thu, 08 Jan 2015 20:44:53 +0000 Received: from mfilter21-d.gandi.net (mfilter21-d.gandi.net [217.70.178.149]) by relay3-d.mail.gandi.net (Postfix) with ESMTP id 0248BA80B6; Thu, 8 Jan 2015 21:44:48 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mfilter21-d.gandi.net Received: from relay3-d.mail.gandi.net ([217.70.183.195]) by mfilter21-d.gandi.net (mfilter21-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id saX17lFsZjBH; Thu, 8 Jan 2015 21:44:46 +0100 (CET) X-Originating-IP: 98.27.58.255 Received: from [192.168.10.146] (cpe-098-027-058-255.nc.res.rr.com [98.27.58.255]) (Authenticated sender: adsend@dunslane.net) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id D18ECA80B8; Thu, 8 Jan 2015 21:44:45 +0100 (CET) Message-ID: <54AEEC3C.10907@dunslane.net> Date: Thu, 08 Jan 2015 15:44:44 -0500 From: Andrew Dunstan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Aaron Botsis , pgsql-hackers@postgresql.org CC: Francisco Olarte Subject: Re: Patch: [BUGS] BUG #12320: json parsing with embedded double quotes References: <87B56448-146A-4ECD-96D3-8B09B89D4EEA@bt-r.com> <54AD8CEF.3080904@dunslane.net> In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 01/08/2015 03:05 PM, Aaron Botsis wrote: > > >> It's also unnecessary. CSV format, while not designed for this, is=20 >> nevertheless sufficiently flexible to allow successful import of json=20 >> data meeting certain criteria (essentially no newlines), like this: >> >> copy the_table(jsonfield) >> from '/path/to/jsondata' >> csv quote e'\x01' delimiter e'\x02=E2=80=99; > > While perhaps unnecessary, given the size and simplicity of the patch,=20 > IMO it=E2=80=99s a no brainer to merge (it actually makes the code smalle= r by=20 > 3 lines). It also enables non-json use cases anytime one might want to=20 > preserve embedded escapes, or use different ones entirely. Do you see=20 > other reasons not to commit it? Well, for one thing it's seriously incomplete. You need to be able to=20 change the delimiter as well. Otherwise, any embedded tab in the json=20 will cause you major grief. Currently the delimiter and the escape MUST be a single byte non-nul=20 character, and there is a check for this in csv mode. Your patch would=20 allow any arbitrary string (including one of zero length) for the escape=20 in text mode, and would then silently ignore all but the first byte.=20 That's not the way we like to do things. And, frankly, I would need to spend quite a lot more time thinking about=20 other implications than I have given it so far. This is an area where I=20 tend to be VERY cautious about making changes. This is a fairly fragile=20 ecosystem. cheers andrew --=20 Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers