DBI and Safe compartment problems with errstr methods
From: Simon Huggins (huggie_at_earth.li)
Date: 10/19/04
- Next message: Lincoln A Baxter: "RE: Slow connection to Oracle 9i"
- Previous message: Ron Reidy: "RE: Slow connection to Oracle 9i"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 19 Oct 2004 15:44:43 +0100 To: dbi-users@perl.org
Hi,
We run user's CGI inside a Safe compartment and provide database access
with DBI which works fine. I'm using Postgres as it happens.
It's mostly working fine apart from errstr.
I can't get either $DBI::errstr or $sth->errstr working nicely in the
Safe compartment.
DBI is required outside of the compartment and we do the connect outside
as well. Then various variables and functions are shared with the
compartment.
e.g.
$cpt->share(qw($DBI::errstr
&DBI::st::TIEHASH
&DBI::st::FETCH
&DBI::st::execute
&DBI::st::fetch
&DBI::st::fetchrow
&DBI::st::fetchrow_array
&DBI::st::fetchrow_hashref
&DBI::st::fetchrow_arrayref
&DBI::st::rows
&DBI::st::state
&DBI::st::finish
&DBI::st::bind_columns
&DBI::st::errstr
@DBD::Pg::st_mem::ISA
&DBD::st::errstr
@DBD::Pg::st::ISA
&DBD::Pg::st::execute
&DBD::Pg::st::fetchrow
&DBD::Pg::st::rows
&DBD::Pg::st::finish
&DBD::Pg::st::FETCH
$DBD::Pg::st::imp_data_size
@DBD::_::st::ISA
&DBD::_::st::fetch
&DBD::_::st::fetchrow
&DBD::_::st::fetchrow_array
&DBD::_::st::fetchrow_arrayref
&DBD::_::st::fetchrow_hashref
&DBD::_::st::fetch_all
&DBD::_::st::fetchall_arrayref
&DBD::_::st::bind_columns
&DBD::_::db::quote
));
and then:
$cpt->reval('*Root::DBD::Pg::st::imp_data_size = \$DBD::Pg::st::imp_data_size');
It's code I've inherited so it's not entirely to me why the last bit is
needed.
In any case when I give it an erroring statement and try to do:
$sth->execute;
if ($sth->errstr) {
print "<p>Errored with ".$sth->errstr;
I get:
Can't locate DBI object method "errstr" via package "Root::DBD::Pg::st"
If I share(&DBD::Pg::st::errstr) as well then I get:
Undefined subroutine &DBD::Pg::st::errstr called
Likewise if I try sharing DBD::_::st::errstr.
What do I need in order to expose all the various errstr methods to my
Safe compartment?
Any help about how $sth->errstr gets resolved to the driver's copy would
be appreciated.
--
Simon Huggins \ "That's why we like you, Mulder; your ideas are weirder
\ than ours." - Byers
http://www.earth.li/~huggie/ htag.pl 0.0.22
- Next message: Lincoln A Baxter: "RE: Slow connection to Oracle 9i"
- Previous message: Ron Reidy: "RE: Slow connection to Oracle 9i"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]