Re: New COPY commands in libpq
От | Jeroen T. Vermeulen |
---|---|
Тема | Re: New COPY commands in libpq |
Дата | |
Msg-id | 20040430145855.GD6945@xs4all.nl обсуждение исходный текст |
Ответ на | New COPY commands in libpq (reina_ga@hotmail.com (Tony Reina)) |
Список | pgsql-hackers |
On Fri, Apr 30, 2004 at 06:12:35AM -0700, Tony Reina wrote: > CString cmd, msg; > 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. I'm not surprised. CString is clearly a class, and cmd is an object of that class. Apparently that class has an implicit conversion operator to char * (which is a striking example of a Bad Idea--kids, don't try this at home!) but nonetheless, sizeof() should still give you the size of the object, *not* the size of the string it represents! You might try porting your code to libpqxx, which is C++-native and should make large swathes of this sort of code unnecessary. Jeroen
В списке pgsql-hackers по дате отправления: