develooper Front page | | Postings from January 2019

Re: RaiseWarn attribute for DBI

Thread Previous | Thread Next
January 18, 2019 09:47
Re: RaiseWarn attribute for DBI
Message ID:
On Friday 18 January 2019 09:13:48 Tim Bunce wrote:
> On Thu, Jan 17, 2019 at 10:02:39AM +0100, wrote:
> > 
> > Currently DBI has only $dbh->{PrintWarn} attribute to control warnings.
> > When is set to true (by default) all warnings from DBI driver are passed
> > to perl's "warn" function.
> > 
> > So I would propose to add $dbh->{RaiseWarn} attribute (off by default)
> > to behave like $dbh->{RaiseError}, but for warnings.
> I'd like to know more about the specific use-case(s) that prompted this.

Hi! The use-case is for testing code, that its SQL part does not produce
any warning. Lot of database server supports vendor specific SQL command
to convert warnings to errors, but there is no standard way how to do it
driver/database independent. And because DBI reports warnings via Perl's
warn, it is not possible to easily distinguish between DBI warnings,
internal Perl warnings and warnings generated by other 3rd modules.

So use-case is: raise DBI errors for any warning or error from database
server and let warnings reported by 3rd modules and by Perl itself as
is. So to ensure that database server does not produce any "problems".

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About