Re: SQL/MED - file_fdw - Mailing list pgsql-hackers

From Itagaki Takahiro
Subject Re: SQL/MED - file_fdw
Date
Msg-id AANLkTinv=qAg32vAPvFNygm+mYOBKQoj3Od_XD9fiSYX@mail.gmail.com
Whole thread Raw
In response to Re: SQL/MED - file_fdw  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: SQL/MED - file_fdw  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
On Sun, Dec 19, 2010 at 12:18, Robert Haas <robertmhaas@gmail.com> wrote:
> I'm sort of suspicious of the fact that BeginCopyTo() is a shell
> around BeginCopy() while BeginCopyFrom() does a whole bunch of other
> stuff.  I haven't grokked what the code is doing here well enough to
> have a concrete proposal though...

I added Begin/EndCopyTo() just because the internal code looks
symmetric. The proposal doesn't change behaviors of COPY commands
at all. It just exports a part of COPY FROM codes as "File Reader"
so that the file_fdw external module can reuse the code. I believe
we have the conclusion that we should avoid code duplication
to read files in the prior discussion.

We could arrange COPY TO codes as like as the COPY FROM APIs, but
I've not and I won't do that at this time because it is not required
by SQL/MED at all. If we do, it would be "File Writer" APIs, like:

cstate = BeginCopyTO(...);
while (tuple = ReadTupleFromSomewhere()) { /* write the tuple into a TSV/CSV file */ NextCopyTo(cstate, tuple);
}
EndCopyTo(cstate);

--
Itagaki Takahiro


pgsql-hackers by date:

Previous
From: "David E. Wheeler"
Date:
Subject: Re: Extensions, patch v20 (bitrot fixes) (was: Extensions, patch v19 (encoding brainfart fix))
Next
From: Robert Haas
Date:
Subject: Re: SQL/MED - file_fdw