>>>>> "Mark" == Mark Mikulec <mark@xxxxxxxxxxxx> writes: Mark> To be honest this whole affair with COPY FROM program seems like Mark> a bug to me though. Perhaps you're misunderstanding what COPY FROM PROGRAM is actually for. Its purpose is to do exactly what COPY does, that is to say, take as input a file in either PG's tab-delimited format or in CSV format, break it into records and fields, and insert the data into a table. Note that JSON is not a supported input format for COPY, though of course JSON _values_ can appear as data within a field inside either the tab-delimited or CSV formats. COPY FROM PROGRAM simply does COPY but with the input (whether in tab or CSV format) taken from the output of the program rather than a file. In tab-delimited format, the delimiter can be changed to something other than a tab, but the escape character is fixed as \ and the characters NL, CR, \, and the delimiter character are required to be escaped. Thus, any literal \ in the data MUST be escaped as \\ before passing the data to COPY in this mode. In CSV mode, CSV quoting and escaping rules are followed. It's not COPY's job to read a single datum, whether in JSON format or anything else. -- Andrew (irc:RhodiumToad)