Re: Implementation of query timeout

From: "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: "Radoslaw Smogura *EXTERN*" <rsmogura(at)softperience(dot)eu>, <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Implementation of query timeout
Date: 2009-10-30 07:47:02
Message-ID: D960CB61B694CF459DCFB4B0128514C203937FEC@exadv11.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Radoslaw Smogura wrote:
> I read a TODO list, and I decided to help a bit. So I've tried to implement
> queryTimeout, currently ony for non-batch statements. You can see code, at
> http://rsmogura.net/pgsql/pgsql_jdbc_querytimeout.tar.bz2
> and analyze, chceck and test it.
>
> Small description how it works.
>
> 1. When the query is executed it checks if timeout > 0.
> 2. If yes it creates TimerTask and add it to the queue, then sends the query
> to server.
> 3. On timeout and if statement hasn't ended cancelStatement is called().

Maybe I am missing something there, but wouldn't it be much easier
to send the following to the server:

SET statement_timeout=<n>

Then all statements that time out throw an exception with SQLSTATE 57014,
and there's no need for separate threads and canceling the query.

Yours,
Lauernz Albe

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Radosław Smogura 2009-10-30 17:35:25 Re: Implementation of query timeout
Previous Message Viktor Rosenfeld 2009-10-29 20:11:56 Howto retrieve a custom type via JDBC