Re: Pg + perl + apache - Mailing list pgsql-general

From Michael L. Artz
Subject Re: Pg + perl + apache
Date
Msg-id 403057E4.9030709@october29.net
Whole thread Raw
In response to Re: Pg + perl + apache  (Martijn van Oosterhout <kleptog@svana.org>)
Responses Re: Pg + perl + apache  (Lincoln Yeoh <lyeoh@pop.jaring.my>)
List 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,
>
>
>


pgsql-general by date:

Previous
From: "Chris Fossenier"
Date:
Subject: Re: PostgreSQL Indexing versus MySQL
Next
From: Ron St-Pierre
Date:
Subject: Re: String manipulation