Re: raw output from copy - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: raw output from copy
Date
Msg-id CAFj8pRC+AjdqF9qFojRp1z=744ZPj7RF13HCDV49n93uQVmdOA@mail.gmail.com
Whole thread Raw
In response to Re: raw output from copy  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers


2016-04-12 22:48 GMT+02:00 Tom Lane <tgl@sss.pgh.pa.us>:
Pavel Stehule <pavel.stehule@gmail.com> writes:
> I had a idea about additional options of COPY RAW statements. One can be
> CAST function. These CAST functions can be used to any for any format.

Uh, what?  CAST() is not about external representations of values, and
overloading it for that purpose doesn't seem like a particularly good
idea: you'd have to figure out what the conversions meant inside SQL as
well as externally.  Also, maybe I missed something, but a different
representation of individual data values within a COPY wasn't what we
were after here.

I didn't think about this idea to deep - so there can be more than one problem. More - I though about it before you designed RAW_TEXT mode - that can coverage this use case too.

Originally I had only RAW mode, what can be difficult for JSONB, so my solution was

COPY target(jsonbcol) FROM jsondata OPTIONS(RAW, CAST(json_to_jsonb)).

Now this idea is obsolete, because anybody can do

COPY target(jsonbcol) FROM jsondata OPTIONS(RAW_TEXT)

What is much more simple.

Using explicit casts in COPY statement was motivated by possible requirement do some manipulations with data before their storing to table. It is idea, and probably wrong idea.

I don't want to increase complexity of COPY statement too much. My goal is enhance COPY to import single objects simply. And if you need some more complex, then you can write some simple application where can be used classic COPY or COPY RAW again (because it doesn't require escaping).

Regards

Pavel

 

                        regards, tom lane

pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Re: [COMMITTERS] pgsql: Avoid extra locks in GetSnapshotData if old_snapshot_threshold <
Next
From: Robert Haas
Date:
Subject: Re: Performance degradation in commit 6150a1b0