On Wed, 2007-01-24 at 17:56 +0300, Королев Илья wrote:
> I've compile and install svn version and have got some troubles:
>
> i've code like this
>
> Query q;
> q << "...";
> cerr << q.preview() << endl;
> q.execute();
>
> On 2.1.1 it was ok, but now it (sometimes) lead to error
> "ERROR - You have an error in your SQL syntax; check the manual that
> corresponds to your MySQL server version for the right syntax to use near ''
> at line 1"
>
> q.preview() shows normal query. But if I comment "cerr" line, query works
> fine.
Hmm, I wonder if this has anything to do with the bug I reported:
> > On Mon, 2007-01-08 at 10:43 -0700, Robert Mecklenburg wrote:
> > [Query::str() is inserting a null byte in the result]
>
> The problem appears slightly different than described above. It appears
> that every time str() is called a new null byte is appended as shown by
> the following code:
>
> #include <mysql++.h>
> int
> main()
> {
> mysqlpp::Connection c("s5db", "192.168.1.126", "root", "99TeraT@gz");
> mysqlpp::Query q = c.query();
>
> for (int i = 0; i < 10; ++i)
> std::cout << "preview length = " << q.preview().length()
> << std::endl;
>
> return 0;
> }
>
> When run produces:
>
> preview length = 1
> preview length = 2
> preview length = 3
> preview length = 4
> preview length = 5
> preview length = 6
> preview length = 7
> preview length = 8
> preview length = 9
> preview length = 10
The bug is that preview is inserting a null byte into the query string
on every call. Two calls, two null bytes; three calls, three null
bytes. One ever responded to by bug report. Changes in the new
release were made to allow null bytes in query strings, so possibly
the old code masked the error and the new code reveals it.
Just a thought,
--
Robert