Re: New "raw" COPY format - Mailing list pgsql-hackers

From Daniel Verite
Subject Re: New "raw" COPY format
Date
Msg-id d3313604-fbdd-483f-9c29-aceaf491f949@manitou-mail.org
Whole thread Raw
In response to Re: New "raw" COPY format  ("Joel Jacobson" <joel@compiler.org>)
Responses Re: New "raw" COPY format
List pgsql-hackers
    Joel Jacobson wrote:

> However, I thinking rejecting such column data seems like the
> better alternative, to ensure data exported with COPY TO
> can always be imported back using COPY FROM,
> for the same format.

On the other hand, that might prevent cases where we
want to export, for instance, a valid json array:

  copy (select json_agg(col) from table ) to 'file' RAW

This is a variant of the discussion in [1] where the OP does:

 copy (select json_agg(row_to_json(t)) from <query> t) TO 'file'

and he complains that both text and csv "break the JSON".
That discussion morphed into a proposed patch adding JSON
format to COPY,  but RAW would work directly as the OP
expected.

That is, unless <query> happens to include JSON fields with LF/CRLF
in them, and the RAW format says this is an error condition.
In that case it's quite annoying to make it an error, rather than
simply let it pass.


[1]
https://postgr.es/m/CALvfUkBxTYy5uWPFVwpk_7ii2zgT07t3d-yR_cy4sfrrLU=kcg@mail.gmail.com


Best regards,
--
Daniel Vérité
https://postgresql.verite.pro/
Twitter: @DanielVerite



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: ECPG cleanup and fix for clang compile-time problem
Next
From: Tom Lane
Date:
Subject: Re: Misleading error "permission denied for table"