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:
>> 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.
>> 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.
>
>> 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();