[Announce] libzdb 2.0
Jan-Henrik Haukeland
hauk at tildeslash.com
Mon Feb 12 23:51:43 CET 2007
Version 2.0 of Zild Database Library is available:
Download: http://www.tildeslash.com/libzdb/dist/libzdb-2.0.tar.gz
MD5 checksum: dd68ec3ea782da704ea7d33c28b04107 libzdb-2.0.tar.gz
Change log: http://www.tildeslash.com/libzdb/dist/CHANGES.txt
This is a feature and bug fix release which has been tested on the
following platforms:
Darwin 8.8.1 [ppc/x86]
Linux FC [x86]
Changes in this release:
Version 2.0
-----------
* Exceptions handling added to the library. This change how
clients should use the library. Methods in the library that
can throw an SQL Exception should now be called from inside
a try-catch block.
Bug fixes:
* Fixed a PostgreSQL prepared statement bug. If parts of a
statement was defined after its last parameter, preparation
failed.
About exceptions handling:
Exceptions handling
-------------------
The library implements an elegant solution for providing
thread-safe exceptions handling to clients. Use of exceptions
are recommend since it provides better error reporting and frees
programmers from the tedious return-code idiom for dealing with
errors. The API documents every method that can throw an exception.
Methods in the library that can throw an exception should be called
from inside a try-catch block.
The implementation is concise and does not add much overhead to
the library. However, handling of errors will be slower compared
to just testing return values. A raised exception must do a jump up
the stack frame to its nearest installed exception handler. The
difference in time should be negligible though and in microseconds
if not nano.
Exception handling is included by default when building the library,
but may optionally be turned off at configure time. To disable this
feature use the configure switch --disable-exceptions
What does this means in form of code changes?
For example, instead of writing:
if (!PreparedStatement_setString(p, 1, x)) {
[handle error]
}
if (!PreparedStatement_setString(p, 2, y)) {
[handle error]
}
if (!PreparedStatement_setInt(p, 3, z)) {
[handle error]
}
You should now write:
TRY
PreparedStatement_setString(p, 1, x);
PreparedStatement_setString(p, 2, y);
PreparedStatement_setInt(p, 3, z);
PreparedStatement_execute(p);
CATCH(SQLException)
log("SQL error: %s\n", Connection_getLastError(con);
END_TRY;
See also http://www.tildeslash.com/libzdb/api-docs/Exception_8h.html
for details.
We hope this is a welcome feature and that it will make it even
easier to program against the library. If you absolutely do not want
this feature, remember that it is possible to disable it at configure
time.
More information about the libzdb-general
mailing list