List:MySQL++« Previous MessageNext Message »
From:Earl Miles Date:October 26 2004 11:44pm
Subject:Strange interaction problem with mysql++ and net-snmp
View as plain text  
I have a program that is to use both MySQL++ and Net-SNMP. While using 
them both alone, everything seems to run perfectly well, but when I put 
them together I get some odd interaction problems.

If I open an SQL connection before I initialize SNMP, any query I run
on that connection will throw an exception but there is no error message
or mysql errno. This only occurs if I create the Connection object with
the new operator; if I create it on the stack, this doesn't happen and
everything works fine. So far. My actual program has been modified to
make the Connection be created on the stack, but I don't particularly
like it, given the way that code is structured.

If I initialize SNMP first, and then open the connection object, I get
coredumps in the net-snmp library when it tries to malloc().

I've managed to isolate this into a small test program. I rewrote the
test program to use just mysql without the C++ API to see if I could
duplicate the problem, and I cannot, which is why I'm checking with this
list first to see if anybody has either a) run into this before, or b)
understands the mysql++ library well enough to have any idea where to
even look next for what this problem might be.

This one's got me stumped. This would be easier to trace if I could 
understand the nature of the problem a little better. With MySQL not
returning any kind of error message, I don't have any insight as to
what exactly is going wrong. This is where I'm really hoping someone
will have some ideas.

I'm running on a pretty stock RedHat 9.0 server with 1.7.19 MySQL++,
mysql-3.23.58-1.9 from RPM, and net-snmp-5.1.1 from tar. Oh, and 

I've attached the testfile that can make this fail (which includes
an #ifdef as kind of a comment; the top one, using the new operator
fails, the bottom one doesn't). The query included is arbitrary, I
have yet to find a query to run that doesn't fail, so when compiling
anyone can just fill in values from a database that happens to be
handy. Here's the quick and dirty line I'm using to compile it:

g++ -g -O2 -o testprog test.cpp `net-snmp-config --libs` 
-L/usr/lib/mysql -lmysqlclient -lmysqlpp  -I/usr/include/mysql++ 
-I/usr/include/mysql -I/usr/local/include -Wno-deprecated

#include <mysql++.hh>
#include <iostream>

extern "C" {
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>

int main(int argc, char* argv[])

#ifndef THISWAY
	Connection* confull = new Connection(use_exceptions);
	Connection& con = *confull;
	Connection con(use_exceptions);
	con.connect("testdb", "localhost", "testuser", "testpass"); 
	std::cout << "MySQL info: " << con.host_info() 	<< std::endl;


	std::cout << "Ping result: " << << std::endl;
	std::cout << "Sizeof con: " << sizeof con << std::endl;

		std::string query = "select id from interface where interfacename = 'lo0'";
		std::cout << "Query: " << query << std::endl; 		
		Result res =;

		Row row = res[0];
		std::cout << "Num Rows: " << res.size() << std::endl;
	catch (BadQuery &er) 
	{ // handle any connection or
							  // query errors that may come up
		std::cout << "Error: " << er.error << std::endl;
		std::cout << "MySQL errnum: " << con.errnum() << std::endl;
		return 0;
	catch (...)
		std::cout << "Unhandled exception" << std::endl;

Strange interaction problem with mysql++ and net-snmpEarl Miles27 Oct
  • Re: Strange interaction problem with mysql++ and net-snmpChris Frey29 Oct
  • Re: Strange interaction problem with mysql++ and net-snmpEarl Miles17 Nov
    • Re: Strange interaction problem with mysql++ and net-snmpWarren Young18 Nov