[Dbdpg-general] "DBD::Pg ping test" coming back for unrelated queries from DBI

Toby Corkindale tjc at wintrmute.net
Wed Jan 4 19:45:13 GMT 2006

On Wed, Jan 04, 2006 at 06:27:18PM +0000, Toby Corkindale wrote:
> I'm getting a really wierd problem here.
> Running Pg 8.1.1, DBD::Pg 1.43, modperl 2.0.1, perl 5.8.6, Class::DBI 3.0.13.
> I'm running under mod_perl, with and without Apache::DBI, but have also been
> able to duplicate the problem outside, in a test pure-perl forking server.

Have also tested against Pg 8.0.3, incase there was something bleeding-edgey
on 8.1.1 causing the issue. Problem is still there.

I'm quite confused.

My thinking presents two possibilities.
1) The mis-placed queries are actually caused by the PostgreSQL server getting
very confused and handing out the wrong info to the wrong clients.
- but I discount that, as it'd be a really serious error that would probably
  show up in non-Perl/ClassDBI environments too.

2) Class::DBI/Ima::DBI or something is getting the order of return wrong for
several queries made in the same process. This seems slightly more likely, but
also inexplicable.
I am mixing Class::DBI calls with Ima::DBI ones manually, although this
normally works for me.

An example of a case where this occurs is as follows:

# This is inside a Class::DBI package.

__PACKAGE__->set_sql(rating => qq{
    SELECT AVG(rating)
    FROM   votes
    WHERE  person = ?

sub get_rating
    my $self = shift;
    die('must be call with object method') unless ($self->isa(__PACKAGE__));

    my $sth = __PACKAGE__->sql_rating();
    $sth->execute($self->id) or die("DB Error: " . $self->db_Main->errstr);
    my ($rating) = $sth->fetchrow_array();
    warn "Rating for " . $self->id . " = " . (defined $rating ? $rating :
    'undef') . "\n";
    return (defined $rating ? int($rating) : 0);

Turning and turning in the widening gyre/The falcon cannot hear the falconer;
Things fall apart, the centre cannot hold/Mere anarchy is loosed upon the world
(gpg --keyserver www.co.uk.pgp.net --recv-key B1CCF88E)

More information about the london.pm mailing list