On Tue, Apr 01, 2014 at 01:53:13PM -0400, Robert Haas wrote:
> > One of the things you mentioned is "I often find it necessary to refer to
> > existing examples of code when trying to figure out how to do things
> > correctly". I couldn't agree more. Haven't seen one yet, but found plenty
> > of discussion that tap danced around one or more of the components of the
> > copy, put, end paradigm. Maybe I should have just asked for a sample code
> > snippet but didn't after a day or so of frustration and trying to piece
> > together other people's incomplete samples.
>
> FWIW, I've generally found that the best examples are what's in the
> core distribution. I'd go and look at a tool like psql or pg_restore
> and find the code that handles this, and then copy it and cut it down
> to what you need.
To move the conversation along:
https://github.com/postgres/postgres/blob/master/src/bin/psql/copy.c#L664
Seems possibly even more robust than most people will code, but it's
had a lot of real world testing.
Have a nice day,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/
> He who writes carelessly confesses thereby at the very outset that he does
> not attach much importance to his own thoughts. -- Arthur Schopenhauer