pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedECPG and COPY TO STDOUT
2+ messages / 2 participants
[nested] [flat]
* ECPG and COPY TO STDOUT
@ 2004-04-01 19:22 Edmund Bacon <ebacon@onesystem.com>
2004-04-03 16:27 ` Re: ECPG and COPY TO STDOUT Michael Meskes <meskes@postgresql.org>
0 siblings, 1 reply; 2+ messages in thread
From: Edmund Bacon @ 2004-04-01 19:22 UTC (permalink / raw)
To: pgsql-interfaces
If I use COPY TO STDOUT in an ECPG program, where does the output go?
If I use COPY TO '/tmp/foo', I get the file created, with the data in
it, but trying COPY TO STDOUT produces no output.
What I'm trying to do is to dump a table's data, and have the resulting
file owned by the application user rather than the dba user.
I would rather to not have to create the file in /tmp, copy contents, rm
/tmp file, if I don't have to.
This is the program I'm using:
#include <stdio.h>
EXEC SQL INCLUDE sqlca;
EXEC SQL WHENEVER SQLERROR sqlprint;
int main()
{
EXEC SQL BEGIN DECLARE SECTION;
char *fname = "/tmp/foo";
EXEC SQL END DECLARE SECTION;
EXEC SQL CONNECT TO test;
/* produces expected file "/tmp/foo" */
EXEC SQL COPY foo TO :fname WITH DELIMITER ',';
printf("copy to /tmp/foo : sqlca.sqlcode = %ld", sqlca.sqlcode);
/* goes nowhere (?) */
EXEC SQL COPY foo TO STDOUT WITH DELIMITER ',';
printf("copy to STDOUT : sqlca.sqlcode = %ld\n", sqlca.sqlcode);
EXEC SQL DISCONNECT;
return 0;
}
--
Edmund Bacon <ebacon@onesystem.com>
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: ECPG and COPY TO STDOUT
2004-04-01 19:22 ECPG and COPY TO STDOUT Edmund Bacon <ebacon@onesystem.com>
@ 2004-04-03 16:27 ` Michael Meskes <meskes@postgresql.org>
0 siblings, 0 replies; 2+ messages in thread
From: Michael Meskes @ 2004-04-03 16:27 UTC (permalink / raw)
To: Edmund Bacon <ebacon@onesystem.com>; +Cc: pgsql-interfaces
On Thu, Apr 01, 2004 at 12:22:44PM -0700, Edmund Bacon wrote:
> If I use COPY TO STDOUT in an ECPG program, where does the output go?
Nowhere, it's discarded.
> What I'm trying to do is to dump a table's data, and have the resulting
> file owned by the application user rather than the dba user.
ecpg gets PGRES_COPY_OUT as a result from the execution and just calls
PQendcopy() without reading the data. The same happens btw with
PGRES_COPY_IN. It's working like this since the get-go in the sources I
inherited from Linux Tolke. I guess we could add this to the todo list
as a feature request.
Patches are welcome of course. :-)
Michael
--
Michael Meskes
Email: Michael at Fam-Meskes dot De
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes@jabber.org
Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2004-04-03 16:27 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-04-01 19:22 ECPG and COPY TO STDOUT Edmund Bacon <ebacon@onesystem.com>
2004-04-03 16:27 ` Michael Meskes <meskes@postgresql.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox