2016-04-12 22:48 GMT+02:00 Tom Lane <t...@sss.pgh.pa.us>:
> Pavel Stehule <pavel.steh...@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
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, tom lane