mirror of
https://github.com/DBD-SQLite/DBD-SQLite
synced 2025-06-07 22:28:47 -04:00
table_column_metadata on inactive dbh
This commit is contained in:
parent
081566e6c2
commit
b64f69f992
2 changed files with 13 additions and 1 deletions
7
dbdimp.c
7
dbdimp.c
|
@ -1436,6 +1436,13 @@ sqlite_db_table_column_metadata(pTHX_ SV *dbh, SV *dbname, SV *tablename, SV *co
|
||||||
int rc;
|
int rc;
|
||||||
HV *metadata = (HV*)sv_2mortal((SV*)newHV());
|
HV *metadata = (HV*)sv_2mortal((SV*)newHV());
|
||||||
|
|
||||||
|
if (!DBIc_ACTIVE(imp_dbh)) {
|
||||||
|
sqlite_error(dbh, -2, "attempt to fetch table column metadata on inactive database handle");
|
||||||
|
return metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
croak_if_db_is_null();
|
||||||
|
|
||||||
/* dbname may be NULL but (table|column)name may not be NULL */
|
/* dbname may be NULL but (table|column)name may not be NULL */
|
||||||
if (!tablename || !SvPOK(tablename)) {
|
if (!tablename || !SvPOK(tablename)) {
|
||||||
sqlite_error(dbh, -2, "table_column_metadata requires a table name");
|
sqlite_error(dbh, -2, "table_column_metadata requires a table name");
|
||||||
|
|
|
@ -10,7 +10,7 @@ use t::lib::Test qw/connect_ok @CALL_FUNCS/;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
use Test::NoWarnings;
|
use Test::NoWarnings;
|
||||||
|
|
||||||
plan tests => 15 * @CALL_FUNCS + 1;
|
plan tests => 16 * @CALL_FUNCS + 1;
|
||||||
for my $call_func (@CALL_FUNCS) {
|
for my $call_func (@CALL_FUNCS) {
|
||||||
my $dbh = connect_ok(RaiseError => 1);
|
my $dbh = connect_ok(RaiseError => 1);
|
||||||
$dbh->do('create table foo (id integer primary key autoincrement, "name space", unique_col integer unique)');
|
$dbh->do('create table foo (id integer primary key autoincrement, "name space", unique_col integer unique)');
|
||||||
|
@ -47,5 +47,10 @@ for my $call_func (@CALL_FUNCS) {
|
||||||
|
|
||||||
eval { $dbh->$call_func(undef, 'foo', '', 'table_column_metadata') };
|
eval { $dbh->$call_func(undef, 'foo', '', 'table_column_metadata') };
|
||||||
ok !$@, "not died when columnname is an empty string";
|
ok !$@, "not died when columnname is an empty string";
|
||||||
|
|
||||||
|
$dbh->disconnect;
|
||||||
|
|
||||||
|
eval { $dbh->$call_func(undef, 'foo', 'name space', 'table_column_metadata') };
|
||||||
|
ok $@, "successfully died when dbh is inactive";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue