Re: COPY FROM STDIN

From: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>
To: Luke Coldiron <lukecoldiron(at)hotmail(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: COPY FROM STDIN
Date: 2016-01-10 21:28:32
Message-ID: 5692CD00.4040302@BlueTreble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 1/8/16 10:37 AM, Luke Coldiron wrote:
>> On 1/6/16 9:45 PM, Luke Coldiron wrote:
>>> In the example above I'm not sure if I can use some sub struct of the
>>> SPIPlanPtr and hand it off to the DoCopy function as the CopyStmt or
>>> if I need to go about this entirely different. Any advice on the
>>> matter would be much appreciated.
>>
>> I don't know off-hand. I suggest you look at what psql does to implement
> \copy (note the \).
>> --
>> Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX Experts in
> Analytics, Data Architecture and PostgreSQL Data in Trouble? Get it in
> Treble! http://BlueTreble.com
>
> I took a look at the \copy but as far as I can tell this is using the
> frontend (client side) of postgresql and I need to be able to do this on the

Oops.

> backend (server side). I don't see a way with this either to attach to the
> connection that called the c function and execute the copy statement. The
> DoCopy in commands/copy.h appears to me to be the server side copy command.
> And I think I can get it to work if I can figure out how to attach to the
> connection of the calling function and pass in the CopyStmt variable.

That sounds... bad.

I think the way to handle this is to add a new type to CopyDest and
modify CopyGetData() and CopySendEndOfRow() accordingly.

It might be tempting to use CopyState->filename as the pointer to a
StringInfoData (StringInfo), but I'm not sure that's a great idea. I
think it'd be better to add a new field to CopyStateData.
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jim Nasby 2016-01-10 21:38:05 Re: Execute commands in single-user mode
Previous Message Gavin Flower 2016-01-10 21:21:27 Re: Code of Conduct: Is it time?