From: | "Jeroen T(dot) Vermeulen" <jtv(at)xs4all(dot)nl> |
---|---|
To: | Tony Reina <reina_ga(at)hotmail(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: New COPY commands in libpq |
Date: | 2004-04-30 14:58:56 |
Message-ID: | 20040430145855.GD6945@xs4all.nl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2004-04-30 15:21:52 | Re: Current CVS tip segfaulting |
Previous Message | Andrew Dunstan | 2004-04-30 14:55:52 | Re: Call for 7.5 feature completion |