diff options
author | Michael Meskes <meskes@postgresql.org> | 2006-07-28 09:08:01 +0000 |
---|---|---|
committer | Michael Meskes <meskes@postgresql.org> | 2006-07-28 09:08:01 +0000 |
commit | 72ba3cb50f60151a0c6816a2cb3990de237442d4 (patch) | |
tree | 58d1abd29dfe91cf576d3729c449d19c9a142611 /src/interfaces/ecpg/ecpglib/execute.c | |
parent | 67cdc613693acddb7d696e999072e0a1b9a7b949 (diff) | |
download | postgresql-72ba3cb50f60151a0c6816a2cb3990de237442d4.tar.gz postgresql-72ba3cb50f60151a0c6816a2cb3990de237442d4.zip |
Added more SoC changes by Joachim Wieland <joe@mcknight.de>:
- SHOW statement puts result into a variable
- COPY TO STDOUT works
Diffstat (limited to 'src/interfaces/ecpg/ecpglib/execute.c')
-rw-r--r-- | src/interfaces/ecpg/ecpglib/execute.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c index e2bd5a68f33..c6ce668e502 100644 --- a/src/interfaces/ecpg/ecpglib/execute.c +++ b/src/interfaces/ecpg/ecpglib/execute.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.52 2006/07/14 05:28:28 tgl Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.53 2006/07/28 09:08:01 meskes Exp $ */ /* * The aim is to get a simpler inteface to the database routines. @@ -1421,9 +1421,29 @@ ECPGexecute(struct statement * stmt) status = false; break; case PGRES_COPY_OUT: - ECPGlog("ECPGexecute line %d: Got PGRES_COPY_OUT ... tossing.\n", stmt->lineno); - PQendcopy(stmt->connection->connection); - break; + { + char *buffer; + int res; + ECPGlog("ECPGexecute line %d: Got PGRES_COPY_OUT\n", stmt->lineno); + while ((res = PQgetCopyData(stmt->connection->connection, + &buffer, 0)) > 0) + { + printf("%s", buffer); + PQfreemem(buffer); + } + if (res == -1) + { + /* COPY done */ + PQclear(results); + results = PQgetResult(stmt->connection->connection); + if (PQresultStatus(results) == PGRES_COMMAND_OK) + ECPGlog("ECPGexecute line %d: Got PGRES_COMMAND_OK after PGRES_COPY_OUT\n", stmt->lineno); + else + ECPGlog("ECPGexecute line %d: Got error after PGRES_COPY_OUT: %s", PQresultErrorMessage(results)); + } + //PQendcopy(stmt->connection->connection); + break; + } case PGRES_COPY_IN: ECPGlog("ECPGexecute line %d: Got PGRES_COPY_IN ... tossing.\n", stmt->lineno); PQendcopy(stmt->connection->connection); |