Re: COPY table FROM STDIN via SPI

From: Joe Conway <mail(at)joeconway(dot)com>
To: chap(at)anastigmatix(dot)net
Cc: James Sewell <james(dot)sewell(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: COPY table FROM STDIN via SPI
Date: 2023-07-12 19:09:24
Message-ID: 7c3f99c2-1b64-0e4f-c7c0-1a27e438ea18@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 7/12/23 14:43, chap(at)anastigmatix(dot)net wrote:
> On 2023-07-12 14:18, Joe Conway wrote:
>> On 7/11/23 22:52, James Sewell wrote:
>>> What about running a COPY directly from C - is that possible?
>>
>> https://www.postgresql.org/docs/current/libpq-copy.html
>
> Or is the question about a COPY kicked off from server-side
> C code (following up a question about SPI)?
>
> If the idea is to kick off a COPY that reads from the connected
> client's STDIN, the wire protocol doesn't really have a way to
> work that out with the client, as Tom pointed out.
>
> Or is the goal for some server-side code to quickly populate
> a table from some file that's readable on the server and has
> the same format that COPY FROM expects?

You can still use this in a server-side extension in the same way that
dblink works. Perhaps ugly, but I have used it in the past and it worked
*really* well for us.

--
Joe Conway
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2023-07-12 20:02:23 Re: 'ERROR: attempted to update invisible tuple' from 'ALTER INDEX ... ATTACH PARTITION' on parent index
Previous Message Tomas Vondra 2023-07-12 19:05:15 Re: logical decoding and replication of sequences, take 2