Re: BUG #12320: json parsing with embedded double quotes

From: Francisco Olarte <folarte(at)peoplecall(dot)com>
To: postgres(at)bt-r(dot)com
Cc: "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #12320: json parsing with embedded double quotes
Date: 2014-12-23 18:17:05
Message-ID: CA+bJJbz0-KdKeBZ9JzyzJDcVkZ5bHimH-TfSsz4hjGQNpm65Fw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Hi Aaron:
....

>
> user:\"root\""}}}}},"from":0,"size":20,"timeout":10000,"sort":{"timestamp":{"order":"

.....

Copy from does it's own round of backslash scaping, if you look at

http://www.postgresql.org/docs/9.4/static/sql-copy.html

The third paragraph under File formats / text format reads:

Backslash characters (\) can be used in the COPY data to quote data
characters that might otherwise be taken as row or column delimiters. In
particular, the following characters must be preceded by a backslash if
they appear as part of a column value: backslash itself, newline, carriage
return, and the current delimiter character.

As you want the backslash as part of the data you need to double it in the
file, otherwise you'll fall into the later case:
.....Any other backslashed character that is not mentioned in the above
table will be taken to represent itself

And the backslash will get eaten and the json parser will fail. It's the
same problem that you get when you try to put windows paths or perl type
regular expresions inside doube quoted C/Java/perl/shell/and_many_more
Strings.

If your table is always a single column and you cannot edit the file, you
can always try to change the scape character.

Regards.
Francisco Olarte.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message ramul87 2014-12-24 03:08:01 BUG #12322: Help Connections
Previous Message pawelkokoszkiewicz 2014-12-23 16:14:54 BUG #12321: problem with installation

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2014-12-23 18:30:54 Re: [COMMITTERS] pgsql: Use a bitmask to represent role attributes
Previous Message David G Johnston 2014-12-23 18:10:15 Re: [COMMITTERS] pgsql: Use a bitmask to represent role attributes