dbTalk Databases Forums  

throw exceptions flag not properly copied in the copy constructor for mysqlpp::Query

mailing.database.mysql-plusplus mailing.database.mysql-plusplus


Discuss throw exceptions flag not properly copied in the copy constructor for mysqlpp::Query in the mailing.database.mysql-plusplus forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Joel Fielder
 
Posts: n/a

Default throw exceptions flag not properly copied in the copy constructor for mysqlpp::Query - 03-29-2006 , 12:12 PM






Hello,

I would like to highlight a possible bug according to the following
entry in the change log for version 2.0.0, 2005.08.16 (r1031) The
"Excess Hair Removal" release:

Quote:
The "throw exceptions" flag is passed from parent to child
in all situations now. (Or if not, please report it as
a bug.) [snip]
Regards,
Joel.

-- Recreation (pseudo-ish) Code --

class crasher
{
public:
crasher(const mysqlpp::Query& q);

mysqlpp::Query m_query;
};

crasher::crasher(const mysqlpp::Query& q)
: m_query(q)
{
std::cout << q.throw_exceptions() << std::endl;
std::cout << m_query.throw_exceptions() << std::endl;
}

main()
{
mysqlpp::Connection con("blah","blah","blah","blah");
mysqlpp::Query q = con.query();

crasher c(q);
c.m_query << "select * from `non_existent_table`";

try
{
std::vector<MY_SSQLS_STRUCT> res;
c.m_query.storein(res);
}
catch(const std::exception& e)
{
std::cout << e.what() << std::endl;
}
}

-- Expected Console Output --

1
1
Table 'non_existent_table' doesn't exist

-- Actual Console Output --

1
0
Segmentation fault

-- Solution --

I think that the copy constructor for mysqlpp::Query is copying the
wrong exceptions flag.

Therefore line 35 of query.cpp:

OptionalExceptions(q.exceptions()),

should be changed to read:

OptionalExceptions(q.throw_exceptions()),

which would match the behaviour of Query:perator=.


--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.