From: | Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com> |
---|---|
To: | Luke Coldiron <lukecoldiron(at)hotmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: COPY FROM STDIN |
Date: | 2016-01-06 02:26:44 |
Message-ID: | 568C7B64.8070707@BlueTreble.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 1/4/16 12:18 PM, Luke Coldiron wrote:
> Is there a way to achieve the performance of the COPY FROM STDIN command
> within a C extension function connected to the db connection that called
> the C function? I have text that I would like to receive as input to a C
> function that contains many COPY command statements in the file that
> would be parsed similar to how psql would handle the file but I don't
> want to shell out to psql as I need to do all of this work on the db
> connection that the function was called from as there are other commands
> that I need to perform as well after before and after handling the COPY
> commands on this same connection. I would like the unit of work to be
> all or nothing and have the performance of the COPY FROM STDIN command
> and not break things out into SELECT INTO or INSERT statements for
> performance.
>
> Ideally I would like to be able to attach to the calling db connection
> via SPI_connect() and then use the libpq library to issue the copy
> commands via PQputCopyData, PQputCopyEnd.
C functions can use SPI, so I'm not sure what the issue is?
http://www.postgresql.org/docs/9.5/static/spi.html
(BTW, you'll want to scroll to the bottom of that page...)
--
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
From | Date | Subject | |
---|---|---|---|
Next Message | oleg yusim | 2016-01-06 03:17:45 | Re: Failing to known state |
Previous Message | Jim Nasby | 2016-01-06 02:22:21 | Re: to_timestamp alternatives |