Hi,
I am working on a program to do analysis of data from the Wikipedia
(http://wikipedia.org) database using MySQL++.
The program reads a very large result (up to several gigabytes) from the
database and therefore uses mysqlpp::ResUse. However while analysis of
this large result set, it have to insert the results into other tables
in the database as they are found.
I discovered that you cannot send new queries on a connection while it
have an unfinished query using mysqlpp::ResUse - it gives a "Commands
out of sync; you can't run this command now"-error when you try.
To work around this, I created a second mysqlpp::Connection object to do
inserts and updates to the database while the first mysqlpp::Connection
object was occupied by the select query with the large result set.
However, after doing that my program began to misbehave (segfaults,
result data being changed in strange ways between two reads etc.).
I put Valgrind (http://valgrind.org/) on the program, and it reports
lots of invalid reads when I access data returned by
mysqlpp::ResUse::fetch_row(). Like this:
==23222== Invalid read of size 1
==23222== at 0x1B905488: strlen (mac_replace_strmem.c:189)
==23222== by 0x804B6D6: check_len(char const*, unsigned) (create.cpp:155)
==23222== by 0x804BB28: handle_link(unsigned, char const*)
(create.cpp:266)
==23222== by 0x804C19F: main (create.cpp:457)
==23222== Address 0x1BE35A98 is 24 bytes inside a block of size 37 free'd
==23222== at 0x1B906237: operator delete(void*) (vg_replace_malloc.c:156)
==23222== by 0x1B9D2DE4:
std::string::_Rep::_M_destroy(std::allocator<char> cons
t&) (in /usr/lib/libstdc++.so.6.0.3)
==23222== by 0x1B9D30CD: std::string::~string() (in
/usr/lib/libstdc++.so.6.0.3)
==23222== by 0x804CB14:
mysqlpp::ColData_Tmpl<mysqlpp::const_string>::~ColData_T
mpl() (create.cpp:426)
So my question is: Do MySQL++ have a limitation so it only works with
one actice Connection object at a time, or do I have to do something
special to make it work with several active Connection objects?
And another question: Do you think that it would be more efficient to
store inserts + updates in for example a local file, and not send these
queries to the database until after the mysqlpp::ResUse object is deleted.
Thanks for any help.
Best regards,
Byrial Jensen