New COPY commands in libpq
От | reina_ga@hotmail.com (Tony Reina) |
---|---|
Тема | New COPY commands in libpq |
Дата | |
Msg-id | 272e4be7.0404300512.49592ecb@posting.google.com обсуждение исходный текст |
Ответы |
Re: New COPY commands in libpq
Re: New COPY commands in libpq |
Список | pgsql-hackers |
I read in the manual that the libpq functions PQputline(conn, cmd) and PQendcopy(conn) have been deprecated and that PQputCopyData(conn, cmd, sizeof(cmd)) and PQputCopyEnd(conn, msg) are the replacements. I'm trying to convert a program that works just fine with the old functions. I assume I'm missing a step here: old C++ code: CString cmd; res = PQexec(conn, "COPY segmentvalues FROM STDIN;");if (PQresultStatus (res) != PGRES_COPY_IN){ PQclear (res); return ns_DATABASEERROR;}else PQclear(res); cmd.Format("1\t\2\t{3,4,5}\n");PQputline(conn, cmd);cmd.Format("\\.\n");PQputline(conn, cmd); PQendcopy(conn); New C++ code: CString cmd, msg; res = PQexec(conn, "COPY segmentvalues FROM STDIN;");if (PQresultStatus (res) != PGRES_COPY_IN){ PQclear (res); return ns_DATABASEERROR;}else PQclear(res); cmd.Format("1\t\2\t{3,4,5}\n"); * PQputCopyData(conn, cmd, sizeof(cmd)); cmd.Format("\\.\n"); * PQputCopyData(conn, cmd, sizeof(cmd)); * PQputCopyEnd(conn, msg); Old C++ code works, new stuff doesn't. Only line that have changed are *'d. The serverlog gives me the error: "ERROR: Copy from STDIN failed: CONTEXT: COPY segmentvalues, line 1: "1 " ERROR: current transaction is aborted, commands ignored until the end of transaction block." Can anyone point me in the right direction? There aren't any examples of how to use the new code in the manual. I thought I was following the written instructions correctly (but apparently am not). Thanks. -Tony p.s. Running PostgreSQL 7.4.2 server on Fedora Linux. Client is a Windows XP MS Visual C++ .NET using libpq.
В списке pgsql-hackers по дате отправления: