This queue is for tickets about the DBD-Pg CPAN distribution.

Report information
The Basics

greg [...]
greg [...]

(no value)
Broken in:
(no value)
Fixed in:
(no value)

Subject: 'RAISE NOTICE' does not set $sth->err
From the mailing list via Lamprecht <>: Hello, I came across the following issue: $sth->err is documented to return 6 in case of a PGRES_NONFATAL_ERROR (PG notice or warning). Here it returns undef instead: Cheers, Christoph LAmprecht use strict; use warnings; use DBI; use DBD::Pg; use Test::More 'no_plan'; my $dh = DBI->connect( "DBI:Pg:dbname=testdb", ) or die $DBI::errstr; $dh->do( q|CREATE OR REPLACE FUNCTION test_error_handler(character varying) RETURNS boolean AS $BODY$ DECLARE level ALIAS FOR $1; BEGIN IF level ~* 'notice' THEN RAISE NOTICE 'RAISE NOTICE FROM test_error_handler'; ELSIF level ~* 'warning' THEN RAISE WARNING 'RAISE WARNING FROM test_error_handler'; ELSIF level ~* 'exception' THEN RAISE EXCEPTION 'RAISE EXCEPTION FROM test_error_handler'; END IF; RETURN TRUE ; END; $BODY$ LANGUAGE 'plpgsql' VOLATILE |) or die $dh->errstr; my $sth = $dh->prepare('SELECT * FROM test_error_handler( ? )'); die $sth->errstr if $sth->err; for my $level (qw/notice warning/){ $sth->execute($level); is( $sth->err, 6, "level $level sets err to 6"); } for my $level (qw/exception/){ $sth->execute($level); is( $sth->err, 7, "level $level sets err to 7"); } $sth->finish; $dh->do('DROP FUNCTION test_error_handler(character varying)') or die $dh->errstr; ####### output: NOTICE: RAISE NOTICE FROM test_error_handler not ok 1 - level notice sets err to 6 # Failed test 'level notice sets err to 6' # at line 47. # got: undef # expected: '6' WARNING: RAISE WARNING FROM test_error_handler not ok 2 - level warning sets err to 6 # Failed test 'level warning sets err to 6' # at line 47. # got: undef # expected: '6' DBD::Pg::st execute failed: ERROR: RAISE EXCEPTION FROM test_error_handler at t line 50. ok 3 - level exception sets err to 7 1..3 # Looks like you failed 2 tests of 3.
Tricky. Wondering if we shouldn't just change the docs. I can get the *database* attribute changed to 6 easy enough, but that breaks things eight ways to Sunday, as every call that raises a notice ends up failing. Ideally, we'd have just the statement handle affected. But I cannot see a way to do that as pg_warn is called by Postgres itself, so we cannot get at the statement handle inside of there. A quick glance at the DBI code shows that there may be a way to mark things as "informational" rather than a true warning, but I've no time at the moment to dog into that. Maybe someone else wants to take a swing?

This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with to