DBD-SQLAnywhere
view release on metacpan or search on metacpan
Safefree( sacapi );
sacapi = NULL;
}
return( sacapi );
}
SACAPI *
SACAPI_AddRef( SACAPI *sacapi )
/*****************************/
{
LOCK_DOLLARZERO_MUTEX;
++sacapi->refcount;
UNLOCK_DOLLARZERO_MUTEX;
return( sacapi );
}
void
SACAPI_Release( SACAPI *sacapi )
/******************************/
{
LOCK_DOLLARZERO_MUTEX;
if( sacapi->refcount ) {
if( --sacapi->refcount == 0 ) {
if( sacapi->api.initialized ) {
if( IS_SACAPI_V2() ) {
sacapi->api.sqlany_fini_ex( sacapi->context );
sacapi->context = NULL;
} else {
sacapi->api.sqlany_fini();
}
sqlany_finalize_interface( &sacapi->api );
}
memset( sacapi, 0, sizeof(SACAPI) );
Safefree( sacapi );
if( sacapi == StaticAPI_V1 ) {
StaticAPI_V1 = NULL;
}
}
} else {
croak( "SACAPI refcount is already zero" );
}
UNLOCK_DOLLARZERO_MUTEX;
}
void
dbd_init( dbistate_t *dbistate )
/******************************/
// Called at boot (library load) time
// *CAN* be called concurrently by two threads loading the driver
// at the same time!
{
dTHX;
DBISTATE_INIT;
//DBIS->debug = 3;
//DBILOGFP = PerlIO_stdout();
}
int
dbd_dr_init( SV *drh )
/********************/
// Called once when each driver object is created and locked so there
// is no concurrent access.
{
dTHX;
D_imp_drh( drh );
imp_drh->sacapi = SACAPI_Alloc();
if( imp_drh->sacapi == NULL ) {
return( FALSE );
}
DBIc_IMPSET_on( imp_drh ); // imp_drh set up now
return( TRUE );
}
int
dbd_dr_destroy( SV *drh )
/***********************/
// Called once when each driver object is created and locked so there
// is no concurrent access.
{
dTHX;
D_imp_drh( drh );
if( DBIc_IMPSET( imp_drh ) ) {
if( imp_drh->sacapi != NULL ) {
SACAPI_Release( imp_drh->sacapi );
}
DBIc_IMPSET_off( imp_drh );
}
return( TRUE );
}
int
dbd_discon_all( SV *drh, imp_drh_t *imp_drh )
/*******************************************/
{
dTHR;
dTHX;
/* The disconnect_all concept is flawed and needs more work */
if( !PL_dirty && !SvTRUE(perl_get_sv("DBI::PERL_ENDING",0)) ) {
sv_setiv( DBIc_ERR(imp_drh), (IV)1 );
sv_setpv( DBIc_ERRSTR(imp_drh),
(char *)"disconnect_all not implemented");
DBIh_EVENT2( drh, ERROR_event,
DBIc_ERR(imp_drh), DBIc_ERRSTR(imp_drh) );
return( FALSE );
}
if( PL_perl_destruct_level ) {
PL_perl_destruct_level = 0;
}
return( FALSE );
}
/* Database specific error handling.
This will be split up into specific routines
for dbh and sth level.
Also split into helper routine to set number & string.
Err, many changes needed, ramble ...
*/
void
ssa_error( pTHX_ SV *h, a_sqlany_connection *conn, int sqlcode, char *what )
/**************************************************************************/
{
D_imp_xxh(h);
SV *errstr = DBIc_ERRSTR(imp_xxh);
SV *state = DBIc_STATE(imp_xxh);
D_imp_drh( h ); // not yet a driver handle!
while( DBIc_TYPE( imp_drh ) != DBIt_DR ) {
imp_drh = (imp_drh_t *)(DBIc_PARENT_COM( imp_drh ));
}
if( conn ) { /* is SQLAnywhere error (allow for non-SQLAnywhere errors) */
char msg[256];
size_t len;
char sqlstate[6];
( run in 0.904 second using v1.01-cache-2.11-cpan-e1769b4cff6 )