dbTalk Databases Forums  

potential bugs?

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


Discuss potential bugs? in the mailing.database.mysql-plusplus forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Rongjun Mu
 
Posts: n/a

Default potential bugs? - 02-23-2005 , 07:28 AM






I am very new to mysql++. These may be or may be not bug, just my points
of views.

1. the return value of 'mysql_init' is not checked. Maybe a "out of
memory" exception?

2. when some operation fails because of lock(), throw BadQuery(error())
may throw a null string because this is not a real MySQL error.
Code:
if (lock()) { if (throw_excptns) throw BadQuery(error()); else ... }

3. where is Query::lock() ?

4. return ResUse(mysql_use_result(&mysql), this); in Connection::use.
If mysql_use_result(&mysql) fails, successive call ResUse::fetch_row
will throw a "Results not fetched" but actually it was fetched, but failed.

Thank you.




--
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
  #2  
Old   
Warren Young
 
Posts: n/a

Default Re: potential bugs? - 02-28-2005 , 11:33 PM






Rongjun Mu wrote:
Quote:
These may be or may be not bug, just my points of views.
Thanks for your comments. I'll reply to each one inline below.

Quote:
1. the return value of 'mysql_init' is not checked. Maybe a "out of
memory" exception?
You'd have to check the C API source to be sure, but from the docs, it
looks like you only get OOM when you ask the C API to allocate the MYSQL
object. We don't do that in the Connection class; we provide the MYSQL
object.

Quote:
2. when some operation fails because of lock(), throw BadQuery(error())
may throw a null string because this is not a real MySQL error.
I guess you're saying that this:

Quote:
throw BadQuery(error());
should be something like this: throw BadQuery("lock failed")

?

Quote:
3. where is Query::lock() ?
What do you think it should do? Maybe you should send a patch instead
of describing it.

Quote:
4. return ResUse(mysql_use_result(&mysql), this); in Connection::use.
If mysql_use_result(&mysql) fails, successive call ResUse::fetch_row
will throw a "Results not fetched" but actually it was fetched, but failed.
I'm not sure what you mean here. It would be clearer if you just
provided a patch.

--
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
  #3  
Old   
Rongjun Mu
 
Posts: n/a

Default Re: potential bugs? - 03-04-2005 , 10:09 PM



Sorry, I've mailed back to your personal email address by mistake.
It's my fault. You know, it's not what I intended.

Warren Young wrote:
Quote:
1. the return value of 'mysql_init' is not checked. Maybe a "out of
memory" exception?

You'd have to check the C API source to be sure, but from the docs, it
looks like you only get OOM when you ask the C API to allocate the MYSQL
object. We don't do that in the Connection class; we provide the MYSQL
object.

Yes, you are right.

Quote:
2. when some operation fails because of lock(), throw BadQuery(error())
may throw a null string because this is not a real MySQL error.

I guess you're saying that this:

throw BadQuery(error());

should be something like this: throw BadQuery("lock failed")
Yes. throw BadQuery("lock failed") would be nice.

Quote:
3. where is Query::lock() ?


What do you think it should do? Maybe you should send a patch instead
of describing it.

4. return ResUse(mysql_use_result(&mysql), this); in Connection::use.
If mysql_use_result(&mysql) fails, successive call ResUse::fetch_row
will throw a "Results not fetched" but actually it was fetched, but
failed.


I'm not sure what you mean here. It would be clearer if you just
provided a patch.

as for #3 and #4, my patch attached.

diff -u mysql++-1.7.30/lib/connection.cpp mysqlpp/lib/connection.cpp
--- mysql++-1.7.30/lib/connection.cpp 2005-03-01 13:55:16.000000000 +0800
+++ mysqlpp/lib/connection.cpp 2005-03-03 20:53:08.000000000 +0800
@@ -221,6 +221,8 @@
MYSQL_RES *res = mysql_store_result(&mysql);
if (res)
return Result(res);
+ else if (throw_excptns)
+ throw BadQuery(error());
else
return Result();
}
@@ -239,7 +241,13 @@
throw BadQuery(error());
else
return ResUse();
- return ResUse(mysql_use_result(&mysql), this);
+ MYSQL_RES *res = mysql_use_result(&mysql);
+ if (res)
+ return ResUse(res, this);
+ else if (throw_excptns)
+ throw BadQuery(error());
+ else
+ return ResUse(res, this); /* FIXME : return ResUse(NULL, this); ? */
}

Query Connection::query()
diff -u mysql++-1.7.30/lib/query.cpp mysqlpp/lib/query.cpp
--- mysql++-1.7.30/lib/query.cpp 2004-12-18 08:28:42.000000000 +0800
+++ mysqlpp/lib/query.cpp 2005-03-03 20:38:58.000000000 +0800
@@ -82,6 +82,11 @@
}
}

+bool Query::lock()
+{
+ return mysql->lock();
+}
+
void Query::unlock()
{
mysql->unlock();

--
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
  #4  
Old   
Warren Young
 
Posts: n/a

Default Re: potential bugs? - 03-05-2005 , 01:20 AM



Rongjun Mu wrote:

Quote:
Yes. throw BadQuery("lock failed") would be nice.
Done.

I found some additional lock-handling problems. I added simple fixes
for them, but the right thing to do is to create a lock class that you
can instantiate on the stack on entry to the function so that it is
always destroyed correctly on function exit. I've added this to the
Wishlist.

Quote:
as for #3 and #4, my patch attached.
Accepted, with minor changes. Thanks!

--
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.