Re: Apache - DBI - Postgresql: Cancelling queries

From: Jonathan Bartlett <johnnyb(at)eskimo(dot)com>
To: Mat <psql-mail(at)freeuk(dot)com>
Cc: pgsql general list <pgsql-general(at)postgresql(dot)org>
Subject: Re: Apache - DBI - Postgresql: Cancelling queries
Date: 2003-08-01 22:55:45
Message-ID: Pine.GSU.4.44.0308011551370.10152-100000@eskimo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> The first problem was the lack of cancel query, second problem seems to
> be that the DBI database handles cannot be shared between thread - so i
> will have to pass a signal to the thread waiting for query to return to
> cancel it? anyone else tried this? any more gaping pitfalls that i
> should be aware of?!

Never fork() a process using DBI; When either the child or the parent
dies, the connection on both of them will close, even if it wasn't
actively using it.

As for #1, here's the answer from perldoc DBI:

To assist in implementing these operations, the DBI pro
vides a "cancel" method for statement handles. The "can
cel" method should abort the current operation and is
designed to be called from a signal handler.

However, it must be stressed that: a) few drivers imple
ment this at the moment (the DBI provides a default method
that just returns "undef"); and b) even if implemented,
there is still a possibility that the statement handle,
and possibly the parent database handle, will not be
usable afterwards.

If "cancel" returns true, then it has successfully invoked
the database engines own cancel function. If it returns
false, then "cancel" failed. If it returns "undef", then
the database engine does not have cancel implemented.

Jon

In response to

Browse pgsql-general by date

  From Date Subject
Next Message b b 2003-08-01 23:25:05 last inserted raw (identity)
Previous Message elein 2003-08-01 22:42:35 Re: CREATE TABLE with a column of type {table name}