Re: Pg + perl + apache

From: "Michael L(dot) Artz" <dragon(at)october29(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Pg + perl + apache
Date: 2004-02-16 05:40:52
Message-ID: 403057E4.9030709@october29.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks, that did help to debug the application. I found that my errors
weren't so random after all ... if I went to a page with a bad query,
then I would start getting the error.

So, basically, if I grab a DB connection and issue a bad query, then
every other query issued via that DB connection will not work because
they are in the same transaction? So the following perl snippet:

----------------------------
my $dbh = DBI->connect(@database);

# invalid SQL
my $sql = "SELECT crap;";
my $sth = $dbh->prepare($sql);
$sth->execute();

$sql = "SELECT 1;";
my ($should_be_one) = $dbh->selectrow_array($sql);

$dbh->disconnect();
-----------------------------

should throw an error for *both* queries? So I guess I need to issue a
commit after I do my queries, or else turn autocommit on.

And yes, always using strict and warnings in my scripts, and using
Apache::DBI's connection pooling to cache my DB connections.

Thanks
-Mike

Martijn van Oosterhout wrote:

>On Sat, Feb 14, 2004 at 04:35:58PM -0500, Michael L. Artz wrote:
>
>
>>I'm having some odd issues, but I'm not sure exactly the cause of them,
>>but postgres is the component in the system that is throwing the errors,
>>so I thought I'd start here.
>>
>>
>
><snip>
>
>
>>with the corresponding postgresql.log entry being
>>
>>LOG: statement: SELECT session_key FROM session WHERE user_id = 101
>>ERROR: current transaction is aborted, queries ignored until end of
>>transaction block
>>
>>
>
>This happens when, within a transaction gets an error, you don't notice and
>keep blindly sending queries.
>
>Scroll up to find the actual error.
>
>If it's the first transaction in a session, that means someone forgot to
>clear their transaction. I guess you could fix it then by sending "abort"
>as the first query.
>
>Hope this helps,
>
>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ben 2004-02-16 07:28:55 Re: making tsearch2 dictionaries
Previous Message Louis P. Boudville 2004-02-16 01:30:54 Support.