Skip to content

Commit

Permalink
add ib_drop_database function
Browse files Browse the repository at this point in the history
  • Loading branch information
real-dam committed Oct 25, 2011
1 parent 75b6373 commit 3c188e9
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Firebird.pm
Expand Up @@ -1152,6 +1152,15 @@ Retrieve query plan from a prepared SQL statement.
my $sth = $dbh->prepare('SELECT * FROM foo');
print $sth->func('ib_plan'); # PLAN (FOO NATURAL)
=item C<ib_drop_database>
$result = $dbh->func('ib_drop_database');
Drops the database, associated with the connection. The database handle is no
longer valid after calling this function.
Caution is advised as the drop is irrevocable.
=back
Expand Down
37 changes: 37 additions & 0 deletions Firebird.xs
Expand Up @@ -1170,6 +1170,43 @@ ib_database_info(dbh, ...)
#undef DB_INFOBUF
#undef DB_RESBUF_CASEHDR

int
ib_drop_database(dbh)
SV *dbh
PREINIT:
ISC_STATUS status[ISC_STATUS_LENGTH];
CODE:
{
D_imp_dbh(dbh);

/* set the database handle to inactive */
DBIc_ACTIVE_off(imp_dbh);

/* rollback */
if (imp_dbh->tr)
{
isc_rollback_transaction(status, &(imp_dbh->tr));
if (ib_error_check(dbh, status))
XSRETURN(FALSE);

imp_dbh->tr = 0L;
}

FREE_SETNULL(imp_dbh->ib_charset);
FREE_SETNULL(imp_dbh->tpb_buffer);
FREE_SETNULL(imp_dbh->dateformat);
FREE_SETNULL(imp_dbh->timeformat);
FREE_SETNULL(imp_dbh->timestampformat);

/* drop */
isc_drop_database(status, &(imp_dbh->db));

if (ib_error_check(dbh, status)) RETVAL = 0;
else RETVAL = 1;
}
OUTPUT:
RETVAL

#*******************************************************************************

IB_EVENT *
Expand Down

0 comments on commit 3c188e9

Please sign in to comment.