Skip Menu |

This queue is for tickets about the DBD-SQLite CPAN distribution.

Report information
The Basics
Id: 44871
Status: resolved
Priority: 0/
Queue: DBD-SQLite

People
Owner: Nobody in particular
Requestors: kane [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.21
Fixed in: (no value)



Subject: Using hooks like 'create_function' do not return errors when they fail
Hi, I just ran into this annoying bug; the below code should die with an informative error when the call fails. However, teh dbd::sqlite xs code does not return any errors in such situations, leaving the user to guess what could have gone wrong.... $dbh->func( 'test', # name of function to use in SQL -1, # amount of arguments that will be passed sub { 1 }, # sub routine to callback to 'create_function' # sqlite name for this hook ) or die $dbh->err;
More generally, DBD::SQLite internals don't follow the DBI best-practice for error handling. The driver shouldn't call croak() itself. All errors should be handled using the DBIh_SET_ERR_SV() or DBIh_SET_ERR_CHAR() macros. That will ensure that RaiseError, PrintError, PrintWarn, HandleError and HandleSetError work properly. The first few lines of _sqlite_error() should be replaced with a call to DBIh_SET_ERR_CHAR(). In relation to the specific issue re func(): all the XS methods called via func() must be changed to return true on success and false on error.
Resolved in 1.26_02. On Wed Apr 08 17:48:52 2009, TIMB wrote: Show quoted text
> More generally, DBD::SQLite internals don't follow the DBI best- > practice for error handling. > > The driver shouldn't call croak() itself. > > All errors should be handled using the DBIh_SET_ERR_SV() or > DBIh_SET_ERR_CHAR() macros. > That will ensure that RaiseError, PrintError, PrintWarn, HandleError > and HandleSetError work > properly. > > The first few lines of _sqlite_error() should be replaced with a call > to DBIh_SET_ERR_CHAR(). > > In relation to the specific issue re func(): all the XS methods called > via func() must be changed to > return true on success and false on error.